123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 |
- using System.Collections.Generic;
- using System.IO;
- using System.Threading.Tasks;
- using GxPress.Common.Tools;
- using GxPress.EnumConst;
- using GxPress.Repository.Interface;
- using GxPress.Repository.Interface.WorkFlow;
- using GxPress.Repository.Interface.WorkProcess;
- using GxPress.Request.GroupChat;
- using GxPress.Service.Interface.IM;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.AspNetCore.Mvc;
- using Newtonsoft.Json;
- using Datory;
- using GxPress.Repository.Interface.AdminVerify;
- using GxPress.Repository.Interface.AppReport;
- using GxPress.Service.Interface.ElasticSearch;
- using GxPress.Repository.Interface.Collection;
- using GxPress.Repository.Interface.Missive;
- using GxPress.Repository.Interface.Note;
- using GxPress.Repository.Interface.Topic;
- using GxPress.Repository.Interface.WaitHandle;
- using GxPress.Repository.Interface.WorkCar;
- using GxPress.Repository.Interface.WorkMeeting;
- using GxPress.Repository.Interface.Visit;
- using GxPress.Repository.Interface.Analyze;
- using GxPress.Repository.Interface.UserMiddle;
- using GxPress.Repository.Interface.ArticleLabel;
- using GxPress.Repository.Interface.VerificationCode;
- using GxPress.Repository.Interface.FlowAttachment;
- using GxPress.Repository.Interface.MeetingSummaryTodo;
- using GxPress.Repository.Interface.RecordFolder;
- namespace GxPress.Api.AdminControllers
- {
- /// <summary>
- /// Utils
- /// </summary>
- [Route("api/admin/utils")]
- [ApiController]
- public class AdminUtilsController : ControllerBase
- {
- private readonly IWebHostEnvironment _environment;
- private readonly IFlowFieldValueRepository _flowFieldValueRepository;
- private readonly IFlowRepository _flowRepository;
- private readonly IFlowMessageRepository _flowMessageRepository;
- private readonly IFlowTodoRepository _flowTodoRepository;
- private readonly IProcessFieldRepository _processFieldRepository;
- private readonly IProcessGroupRepository _processGroupRepository;
- private readonly IProcessNodeRepository _processNodeRepository;
- private readonly IProcessRepository _processRepository;
- private readonly IProcessRequestLimitRepository _processRequestLimitRepository;
- private readonly IRuleApproverCheckRepository _ruleApproverCheckRepository;
- private readonly IRuleCarbonCopyRepository _ruleCarbonCopyRepository;
- private readonly IRuleConditionRepository _ruleConditionRuleRepository;
- private readonly IMeetingLocationRepository _meetingLocationRepository;
- private readonly IMeetingOrderRepository _meetingOrderRepository;
- private readonly IMeetingRepository _meetingRepository;
- private readonly IMeetingRoomRepository _meetingRoomRepository;
- private readonly IMeetingSummaryRepository _meetingSummaryRepository;
- private readonly ICarOrderRepository _carOrderRepository;
- private readonly ICarRepository _carRepository;
- private readonly ICarTypeRepository _carTypeRepository;
- private readonly IAdminRepository _adminRepository;
- private readonly IArticleGroupRepository _articleGroupRepository;
- private readonly IArticleRepository _articleRepository;
- private readonly IDepartmentRepository _departmentRepository;
- private readonly IRoleGroupRepository _roleGroupRepository;
- private readonly IRoleRepository _roleRepository;
- private readonly ISlideRepository _slideRepository;
- private readonly IUserRepository _userRepository;
- private readonly ICommentRepository _commentRepository;
- private readonly IAppVersionRepository _appVersionRepository;
- private readonly IFeedbackRepository _feedbackRepository;
- private readonly IBlacklistArticleRepository _blacklistArticleRepository;
- private readonly IThesaurusRepository _thesaurusRepository;
- private readonly IArticleGroupUserRepository _articleGroupUserRepository;
- private readonly IAddressBookGroupRepository _addressBookGroupRepository;
- private readonly IAddressBookGroupUserRepository _addressBookGroupUserRepository;
- private readonly IGroupChatRepository _groupChatRepository;
- private readonly IGroupChatUserRepository _groupChatUserRepository;
- private readonly INoticeRepository _noticeRepository;
- private readonly INoticeAddresseeRepository _noticeAddresseeRepository;
- private readonly INoticeCcRepository _noticeCcRepository;
- private readonly INoticeFolderRepository _noticeFolderRepository;
- private readonly IBlacklistUserRepository _blacklistUserRepository;
- private readonly IFinanceRepository _financeRepository;
- private readonly IPrintRepository _printRepository;
- private readonly ISellRepository _sellRepository;
- private readonly IStorehouseRepository _storehouseRepository;
- private readonly IHumanAffairsRepository _humanAffairsRepository;
- private readonly IOftenContactRepository _oftenContactRepository;
- private readonly IChatRecordRepository _chatRecordRepository;
- private readonly ITopicRepository _topicRepository;
- private readonly ITopicAddresseeRepository _topicAddresseeRepository;
- private readonly ITopicAnalyzeRepository _topicAnalyzeRepository;
- private readonly ITopicCommentRepository _topicCommentRepository;
- private readonly IFileLibraryRepository _fileLibraryRepository;
- private readonly IIMService _imService;
- private readonly IGroupRepository _groupRepository;
- private readonly IGroupUserRepository _groupUserRepository;
- private readonly IGroupFolderRepository _groupFolderRepository;
- private readonly IMiddleRepository _middleRepository;
- private readonly IElasticSearchService _elasticSearchService;
- private readonly ICollectionRepository _collectionRepository;
- private readonly INoteRepository _noteRepository;
- private readonly IAppReportRepository _appReportRepository;
- private readonly ITopicGroupRepository _topicGroupRepository;
- private readonly ITopicGroupUserRepository _topicGroupUserRepository;
- private readonly IAdminVerifyRepository _adminVerifyRepository;
- private readonly IMissiveRepository _missiveRepository;
- private readonly IMissiveAddresseeRepository _missiveAddresseeRepository;
- private readonly IMissiveCcRepository _missiveCcRepository;
- private readonly IMissiveAnalyzeRepository _missiveAnalyzeRepository;
- private readonly IFolderUserRepository _folderUserRepository;
- private readonly IWaitHandleLabelRepository _waitHandleLabelRepository;
- private readonly IWaitHandleRepository _waitHandleRepository;
- private readonly IVisitRepository _vsitRepository;
- private readonly IAnalyzeRepository _analyzeRepository;
- private readonly IUserMiddleRepository _userMiddleRepository;
- private readonly IArticleInnerLabelRepository _articleInnerLabelRepository;
- private readonly IArticleLabelRepository _articleLabelRepository;
- private readonly IVerificationCodeRepository verificationCodeRepository;
- private readonly IFlowAttachmentRepository flowAttachmentRepository;
- private readonly IMeetingSummaryTodoRepository meetingSummaryTodoRepository;
- private readonly IRecordFolderRepository recordFolderRepository;
- public AdminUtilsController(IWebHostEnvironment environment, IFlowFieldValueRepository flowFieldValueRepository,
- IFlowRepository flowRepository, IFlowMessageRepository flowMessageRepository,
- IFlowTodoRepository flowTodoRepository, IAdminRepository adminRepository,
- IArticleGroupRepository articleGroupRepository,
- IArticleRepository articleRepository,
- IDepartmentRepository departmentRepository,
- IProcessFieldRepository processFieldRepository, IProcessGroupRepository processGroupRepository,
- IProcessNodeRepository processNodeRepository, IProcessRepository processRepository,
- IProcessRequestLimitRepository processRequestLimitRepository,
- IRuleApproverCheckRepository ruleApproverCheckRepository,
- IRuleCarbonCopyRepository ruleCarbonCopyRepository, IRuleConditionRepository ruleConditionRuleRepository,
- IMeetingLocationRepository meetingLocationRepository, IMeetingOrderRepository meetingOrderRepository,
- IMeetingRepository meetingRepository, IMeetingRoomRepository meetingRoomRepository,
- IMeetingSummaryRepository meetingSummaryRepository,
- ICarOrderRepository carOrderRepository, ICarRepository carRepository, ICarTypeRepository carTypeRepository,
- IRoleGroupRepository roleGroupRepository,
- IRoleRepository roleRepository, IUserRepository userRepository, ISlideRepository slideRepository,
- ICommentRepository commentRepository, IAppVersionRepository appVersionRepository,
- IFeedbackRepository feedbackRepository, IBlacklistArticleRepository blacklistArticleRepository,
- IThesaurusRepository thesaurusRepository, IArticleGroupUserRepository articleGroupUserRepository,
- IAddressBookGroupRepository addressBookGroupRepository,
- IAddressBookGroupUserRepository addressBookGroupUserRepository, IGroupChatRepository groupChatRepository,
- IGroupChatUserRepository groupChatUserRepository, INoticeRepository noticeRepository,
- INoticeAddresseeRepository noticeAddresseeRepository, INoticeCcRepository noticeCcRepository, INoticeFolderRepository noticeFolderRepository, IBlacklistUserRepository blacklistUserRepository,
- IFinanceRepository financeRepository, IPrintRepository printRepository, ISellRepository sellRepository,
- IStorehouseRepository storehouseRepository, IHumanAffairsRepository humanAffairsRepository,
- IOftenContactRepository oftenContactRepository, IChatRecordRepository chatRecordRepository,
- ITopicRepository topicRepository, ITopicAddresseeRepository topicAddresseeRepository,
- ITopicAnalyzeRepository topicAnalyzeRepository, ITopicCommentRepository topicCommentRepository,
- IFileLibraryRepository fileLibraryRepository, IIMService imService, IGroupRepository groupRepository,
- IGroupFolderRepository groupFolderRepository, IGroupUserRepository groupUserRepository,
- IMiddleRepository middleRepository, IElasticSearchService elasticSearchService,
- ICollectionRepository collectionRepository, INoteRepository noteRepository,
- IAppReportRepository appReportRepository, ITopicGroupRepository topicGroupRepository,
- ITopicGroupUserRepository topicGroupUserRepository, IAdminVerifyRepository adminVerifyRepository,
- IMissiveRepository missiveRepository, IMissiveAddresseeRepository missiveAddresseeRepository,
- IMissiveCcRepository missiveCcRepository, IMissiveAnalyzeRepository missiveAnalyzeRepository, IWaitHandleLabelRepository waitHandleLabelRepository,
- IWaitHandleRepository waitHandleRepository, IVisitRepository visitRepository, IAnalyzeRepository analyzeRepository, IUserMiddleRepository userMiddleRepository, IArticleInnerLabelRepository articleInnerLabelRepository, IArticleLabelRepository articleLabelRepository, IVerificationCodeRepository verificationCodeRepository, IFlowAttachmentRepository flowAttachmentRepository, IMeetingSummaryTodoRepository meetingSummaryTodoRepository, IFolderUserRepository folderUserRepository, IRecordFolderRepository recordFolderRepository)
- {
- _environment = environment;
- _flowFieldValueRepository = flowFieldValueRepository;
- _flowRepository = flowRepository;
- _flowMessageRepository = flowMessageRepository;
- _flowTodoRepository = flowTodoRepository;
- _processFieldRepository = processFieldRepository;
- _processGroupRepository = processGroupRepository;
- _processNodeRepository = processNodeRepository;
- _processRepository = processRepository;
- _processRequestLimitRepository = processRequestLimitRepository;
- _ruleApproverCheckRepository = ruleApproverCheckRepository;
- _ruleCarbonCopyRepository = ruleCarbonCopyRepository;
- _ruleConditionRuleRepository = ruleConditionRuleRepository;
- _adminRepository = adminRepository;
- _articleGroupRepository = articleGroupRepository;
- _articleRepository = articleRepository;
- _departmentRepository = departmentRepository;
- _meetingLocationRepository = meetingLocationRepository;
- _meetingOrderRepository = meetingOrderRepository;
- _meetingRepository = meetingRepository;
- _meetingRoomRepository = meetingRoomRepository;
- _meetingSummaryRepository = meetingSummaryRepository;
- _carOrderRepository = carOrderRepository;
- _carRepository = carRepository;
- _carTypeRepository = carTypeRepository;
- _roleGroupRepository = roleGroupRepository;
- _roleRepository = roleRepository;
- _userRepository = userRepository;
- _slideRepository = slideRepository;
- _commentRepository = commentRepository;
- _appVersionRepository = appVersionRepository;
- _feedbackRepository = feedbackRepository;
- _blacklistArticleRepository = blacklistArticleRepository;
- _thesaurusRepository = thesaurusRepository;
- _articleGroupUserRepository = articleGroupUserRepository;
- _addressBookGroupRepository = addressBookGroupRepository;
- _addressBookGroupUserRepository = addressBookGroupUserRepository;
- _groupChatRepository = groupChatRepository;
- _groupChatUserRepository = groupChatUserRepository;
- _noticeRepository = noticeRepository;
- _noticeAddresseeRepository = noticeAddresseeRepository;
- _noticeCcRepository = noticeCcRepository;
- _noticeFolderRepository = noticeFolderRepository;
- _blacklistUserRepository = blacklistUserRepository;
- _humanAffairsRepository = humanAffairsRepository;
- _financeRepository = financeRepository;
- _sellRepository = sellRepository;
- _storehouseRepository = storehouseRepository;
- _printRepository = printRepository;
- _oftenContactRepository = oftenContactRepository;
- _chatRecordRepository = chatRecordRepository;
- _topicAddresseeRepository = topicAddresseeRepository;
- _topicCommentRepository = topicCommentRepository;
- _topicAnalyzeRepository = topicAnalyzeRepository;
- _topicRepository = topicRepository;
- _fileLibraryRepository = fileLibraryRepository;
- _imService = imService;
- _groupFolderRepository = groupFolderRepository;
- _groupUserRepository = groupUserRepository;
- _groupRepository = groupRepository;
- _middleRepository = middleRepository;
- _elasticSearchService = elasticSearchService;
- _collectionRepository = collectionRepository;
- _noteRepository = noteRepository;
- _appReportRepository = appReportRepository;
- _topicGroupRepository = topicGroupRepository;
- _topicGroupUserRepository = topicGroupUserRepository;
- _adminVerifyRepository = adminVerifyRepository;
- _missiveRepository = missiveRepository;
- _missiveAddresseeRepository = missiveAddresseeRepository;
- _missiveCcRepository = missiveCcRepository;
- _missiveAnalyzeRepository = missiveAnalyzeRepository;
- _folderUserRepository = folderUserRepository;
- _waitHandleRepository = waitHandleRepository;
- _waitHandleLabelRepository = waitHandleLabelRepository;
- _vsitRepository = visitRepository;
- _analyzeRepository = analyzeRepository;
- _userMiddleRepository = userMiddleRepository;
- _articleInnerLabelRepository = articleInnerLabelRepository;
- _articleLabelRepository = articleLabelRepository;
- this.verificationCodeRepository = verificationCodeRepository;
- this.flowAttachmentRepository = flowAttachmentRepository;
- this.meetingSummaryTodoRepository = meetingSummaryTodoRepository;
- this.recordFolderRepository = recordFolderRepository;
- }
- [HttpGet("works")]
- public async Task<string> WorksAsync()
- {
- var retVal = await _adminRepository.Database.IsConnectionWorksAsync();
- return retVal.IsConnectionWorks ? "Database Connection Works" : retVal.ErrorMessage;
- }
- [HttpGet("sync_database")]
- public async Task<string> SyncDatabase()
- {
- var database = _adminRepository.Database;
- var repositories = new List<IRepository>
- {
- _adminRepository,
- _flowFieldValueRepository,
- _flowRepository,
- _flowMessageRepository,
- _flowTodoRepository,
- _processFieldRepository,
- _processGroupRepository,
- _processNodeRepository,
- _processRepository,
- _processRequestLimitRepository,
- _ruleApproverCheckRepository,
- _ruleCarbonCopyRepository,
- _ruleConditionRuleRepository,
- _articleGroupRepository,
- _articleRepository,
- _departmentRepository,
- _meetingLocationRepository,
- _meetingOrderRepository,
- _meetingRepository,
- _meetingRoomRepository,
- _meetingSummaryRepository,
- _carOrderRepository,
- _carRepository,
- _carTypeRepository,
- _roleGroupRepository,
- _roleRepository,
- _slideRepository,
- _userRepository,
- _commentRepository,
- _appVersionRepository,
- _feedbackRepository,
- _blacklistArticleRepository,
- _thesaurusRepository,
- _articleGroupUserRepository,
- _addressBookGroupRepository,
- _addressBookGroupUserRepository,
- _groupChatRepository,
- _groupChatUserRepository,
- _noticeRepository,
- _noticeAddresseeRepository,
- _noticeCcRepository,
- _noticeFolderRepository,
- _blacklistUserRepository,
- _humanAffairsRepository,
- _financeRepository,
- _sellRepository,
- _storehouseRepository,
- _printRepository,
- _chatRecordRepository,
- _oftenContactRepository,
- _topicAddresseeRepository,
- _topicAnalyzeRepository,
- _topicCommentRepository,
- _topicRepository,
- _fileLibraryRepository,
- _groupFolderRepository,
- _groupUserRepository,
- _groupRepository,
- _middleRepository,
- _collectionRepository,
- _noteRepository,
- _appReportRepository,
- _topicGroupRepository,
- _topicGroupUserRepository,
- _adminVerifyRepository,
- _missiveRepository,
- _missiveAddresseeRepository,
- _missiveCcRepository,
- _missiveAnalyzeRepository,
- _folderUserRepository,
- _waitHandleRepository,
- _waitHandleLabelRepository,
- _vsitRepository,
- _analyzeRepository,
- _userMiddleRepository,
- _articleInnerLabelRepository,
- _articleLabelRepository,
- verificationCodeRepository,
- flowAttachmentRepository,
- meetingSummaryTodoRepository,
- recordFolderRepository
- };
- var alterCount = 0;
- var createCount = 0;
- foreach (var repository in repositories)
- {
- if (await database.IsTableExistsAsync(repository.TableName))
- {
- await database.AlterTableAsync(repository.TableName, repository.TableColumns);
- alterCount++;
- }
- else
- {
- await database.CreateTableAsync(repository.TableName, repository.TableColumns);
- createCount++;
- }
- }
- //var database = new Database();
- //database.IsTableExistsAsync()
- return $"alter: {alterCount}, create: {createCount}";
- }
- [HttpGet("qrcoder")]
- public async Task<bool> SendQRCode()
- {
- var users = await _userRepository.FindAllUserAsync(Q.Where(nameof(Entity.User.Id), ">", 0));
- foreach (var user in users)
- {
- if (string.IsNullOrEmpty(user.QRCoder))
- {
- //生成二维码
- var qrCodeData = new { key = QRCodeTypeConst.UserInfo, value = user.Guid };
- var resultPath =
- FileHelper.SaveQRCodeFile(StringUtils.GetWebRootPath(_environment.WebRootPath),
- JsonConvert.SerializeObject(qrCodeData));
- user.QRCoder = resultPath.RelativePath;
- await _userRepository.UpdateAsync(user);
- }
- }
- var groupChats = await _groupChatRepository.GetAllGroupChatAsync();
- foreach (var groupChat in groupChats)
- {
- if (string.IsNullOrEmpty(groupChat.QRCoder))
- {
- //生成二维码
- var qrCodeData = new { key = QRCodeTypeConst.GroupChatInfo, value = groupChat.Guid };
- var resultPath =
- FileHelper.SaveQRCodeFile(StringUtils.GetWebRootPath(_environment.WebRootPath),
- JsonConvert.SerializeObject(qrCodeData));
- groupChat.QRCoder = resultPath.RelativePath;
- var request = new GroupChatUpRequest { Id = groupChat.Id, QrCode = groupChat.QRCoder };
- await _groupChatRepository.UpdateAsync(request);
- }
- }
- return true;
- }
- [HttpGet("test")]
- public async Task<bool> Test()
- {
- //return await new MinIOHelper().PutObjectAsync("test", "1234.jpeg", "C:\\Users\\zuoxi\\Desktop\\1234.jpeg", "application/octet-stream");
- //return await _imService.GetTokenImAsync();
- return await _elasticSearchService.ElasticSearchData();
- }
- [HttpGet("im-token")]
- public async Task<bool> SetImToken()
- {
- return await _imService.GetTokenImAsync();
- }
- /// <summary>
- /// 插入环信用户
- /// </summary>
- /// <returns></returns>
- [HttpGet("im-user")]
- public async Task<bool> SetImUser()
- {
- var users = await _userRepository.GetAllUserIm();
- foreach (var item in users)
- {
- await _userRepository.CreateMiUserAsync(item);
- }
- return true;
- }
- /// <summary>
- /// 设置图片
- /// </summary>
- /// <returns></returns>
- [HttpGet("set-img")]
- public async Task<bool> SetImg()
- {
- //获取文章
- var articles = await _articleRepository.GetAllAsync();
- foreach (var article in articles)
- {
- var strings = StringUtils.StringCollectionToStringList(article.ImageUrls);
- foreach (var imageUrl in strings)
- {
- var imageUrlFullName = imageUrl.Split('/')[imageUrl.Split('/').Length - 1];
- //获取文件路径
- var file = StringUtils.GetWebRootPath(_environment.WebRootPath + "\\cache");
- DirectoryInfo info = new DirectoryInfo(file);
- foreach (var item in info.GetFileSystemInfos())
- {
- //判读是否是文件夹
- if (Directory.Exists(item.FullName))
- {
- //获取文件夹下面的文件
- var infos = new DirectoryInfo(item.FullName);
- foreach (var fileIo in infos.GetFileSystemInfos())
- {
- if (fileIo.FullName.Contains(imageUrlFullName))
- {
- //压缩图片
- CompressImage.Execute(fileIo.FullName);
- //压缩图片
- CompressImage.Execute(fileIo.FullName, 100);
- }
- }
- }
- }
- }
- }
- return true;
- }
- [HttpGet("send-sms")]
- public void SendSms()
- {
- var phones = new List<string>() { "17311267313", "13699447785" };
- Common.Sms.MasSms.SendSmsTemplate(phones, "dd01d79af7ec46a289cd0fca0cb3b149");
- }
- }
- }
|