AdminUtilsController.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Threading.Tasks;
  4. using GxPress.Common.Tools;
  5. using GxPress.EnumConst;
  6. using GxPress.Repository.Interface;
  7. using GxPress.Repository.Interface.WorkFlow;
  8. using GxPress.Repository.Interface.WorkProcess;
  9. using GxPress.Request.GroupChat;
  10. using GxPress.Service.Interface.IM;
  11. using Microsoft.AspNetCore.Hosting;
  12. using Microsoft.AspNetCore.Mvc;
  13. using Newtonsoft.Json;
  14. using Datory;
  15. using GxPress.Repository.Interface.AdminVerify;
  16. using GxPress.Repository.Interface.AppReport;
  17. using GxPress.Service.Interface.ElasticSearch;
  18. using GxPress.Repository.Interface.Collection;
  19. using GxPress.Repository.Interface.Missive;
  20. using GxPress.Repository.Interface.Note;
  21. using GxPress.Repository.Interface.Topic;
  22. using GxPress.Repository.Interface.WaitHandle;
  23. using GxPress.Repository.Interface.WorkCar;
  24. using GxPress.Repository.Interface.WorkMeeting;
  25. using GxPress.Repository.Interface.Visit;
  26. using GxPress.Repository.Interface.Analyze;
  27. using GxPress.Repository.Interface.UserMiddle;
  28. using GxPress.Repository.Interface.ArticleLabel;
  29. using GxPress.Repository.Interface.VerificationCode;
  30. using GxPress.Repository.Interface.FlowAttachment;
  31. using GxPress.Repository.Interface.MeetingSummaryTodo;
  32. using GxPress.Repository.Interface.RecordFolder;
  33. using GxPress.Repository.Interface.Vip;
  34. using GxPress.Repository.Interface.Order;
  35. using GxPress.Repository.Interface.SystemRole;
  36. using GxPress.Repository.Interface.Menus;
  37. using GxPress.Repository.Interface.Navigation;
  38. using GxPress.Repository.Interface.SystemLabel;
  39. using GxPress.Repository.Interface.Category;
  40. using GxPress.Repository.Interface.Media;
  41. using GxPress.Repository.Interface.Teacher;
  42. using GxPress.Repository.Interface.SensitiveWord;
  43. using GxPress.Repository.Interface.Attach;
  44. using GxPress.Repository.Interface.SystemRoleMenus;
  45. using GxPress.Repository.Interface.AppStartPage;
  46. using GxPress.Repository.Interface.Organization;
  47. using GxPress.Repository.Interface.VipEquity;
  48. using GxPress.Repository.Interface.TrackLog;
  49. using GxPress.Repository.Interface.SpecialLabel;
  50. using GxPress.Repository.Interface.Group;
  51. using GxPress.Repository.Interface.AppChannel;
  52. using GxPress.Repository.Interface.DepartmentUser;
  53. using GxPress.Repository.Interface.Friends;
  54. namespace GxPress.Api.AdminControllers
  55. {
  56. /// <summary>
  57. /// Utils
  58. /// </summary>
  59. [Route("api/admin/utils")]
  60. [ApiController]
  61. public class AdminUtilsController : ControllerBase
  62. {
  63. private readonly IWebHostEnvironment _environment;
  64. private readonly IFlowFieldValueRepository _flowFieldValueRepository;
  65. private readonly IFlowRepository _flowRepository;
  66. private readonly IFlowMessageRepository _flowMessageRepository;
  67. private readonly IFlowTodoRepository _flowTodoRepository;
  68. private readonly IProcessFieldRepository _processFieldRepository;
  69. private readonly IProcessGroupRepository _processGroupRepository;
  70. private readonly IProcessNodeRepository _processNodeRepository;
  71. private readonly IProcessRepository _processRepository;
  72. private readonly IProcessRequestLimitRepository _processRequestLimitRepository;
  73. private readonly IRuleApproverCheckRepository _ruleApproverCheckRepository;
  74. private readonly IRuleCarbonCopyRepository _ruleCarbonCopyRepository;
  75. private readonly IRuleConditionRepository _ruleConditionRuleRepository;
  76. private readonly IMeetingLocationRepository _meetingLocationRepository;
  77. private readonly IMeetingOrderRepository _meetingOrderRepository;
  78. private readonly IMeetingRepository _meetingRepository;
  79. private readonly IMeetingRoomRepository _meetingRoomRepository;
  80. private readonly IMeetingSummaryRepository _meetingSummaryRepository;
  81. private readonly ICarOrderRepository _carOrderRepository;
  82. private readonly ICarRepository _carRepository;
  83. private readonly ICarTypeRepository _carTypeRepository;
  84. private readonly IAdminRepository _adminRepository;
  85. private readonly IArticleGroupRepository _articleGroupRepository;
  86. private readonly IArticleRepository _articleRepository;
  87. private readonly IDepartmentRepository _departmentRepository;
  88. private readonly IRoleGroupRepository _roleGroupRepository;
  89. private readonly IRoleRepository _roleRepository;
  90. private readonly ISlideRepository _slideRepository;
  91. private readonly IUserRepository _userRepository;
  92. private readonly ICommentRepository _commentRepository;
  93. private readonly IAppVersionRepository _appVersionRepository;
  94. private readonly IFeedbackRepository _feedbackRepository;
  95. private readonly IBlacklistArticleRepository _blacklistArticleRepository;
  96. private readonly IThesaurusRepository _thesaurusRepository;
  97. private readonly IArticleGroupUserRepository _articleGroupUserRepository;
  98. private readonly IAddressBookGroupRepository _addressBookGroupRepository;
  99. private readonly IAddressBookGroupUserRepository _addressBookGroupUserRepository;
  100. private readonly IGroupChatRepository _groupChatRepository;
  101. private readonly IGroupChatUserRepository _groupChatUserRepository;
  102. private readonly INoticeRepository _noticeRepository;
  103. private readonly IAddresseeRepository _addresseeRepository;
  104. private readonly ICcRepository _ccRepository;
  105. private readonly IBlacklistUserRepository _blacklistUserRepository;
  106. private readonly IFinanceRepository _financeRepository;
  107. private readonly IPrintRepository _printRepository;
  108. private readonly ISellRepository _sellRepository;
  109. private readonly IStorehouseRepository _storehouseRepository;
  110. private readonly IHumanAffairsRepository _humanAffairsRepository;
  111. private readonly IOftenContactRepository _oftenContactRepository;
  112. private readonly IChatRecordRepository _chatRecordRepository;
  113. private readonly ITopicRepository _topicRepository;
  114. private readonly ITopicAddresseeRepository _topicAddresseeRepository;
  115. private readonly IFileLibraryRepository _fileLibraryRepository;
  116. private readonly IIMService _imService;
  117. private readonly IGroupRepository _groupRepository;
  118. private readonly IGroupUserRepository _groupUserRepository;
  119. private readonly IGroupFolderRepository _groupFolderRepository;
  120. private readonly IMiddleRepository _middleRepository;
  121. private readonly IElasticSearchService _elasticSearchService;
  122. private readonly ICollectionRepository _collectionRepository;
  123. private readonly INoteRepository _noteRepository;
  124. private readonly IAppReportRepository _appReportRepository;
  125. private readonly ITopicGroupRepository _topicGroupRepository;
  126. private readonly ITopicGroupUserRepository _topicGroupUserRepository;
  127. private readonly IAdminVerifyRepository _adminVerifyRepository;
  128. private readonly IMissiveRepository _missiveRepository;
  129. private readonly IFolderUserRepository _folderUserRepository;
  130. private readonly IWaitHandleLabelRepository _waitHandleLabelRepository;
  131. private readonly IWaitHandleRepository _waitHandleRepository;
  132. private readonly IVisitRepository _vsitRepository;
  133. private readonly IAnalyzeRepository _analyzeRepository;
  134. private readonly IUserMiddleRepository _userMiddleRepository;
  135. private readonly IArticleInnerLabelRepository _articleInnerLabelRepository;
  136. private readonly IArticleLabelRepository _articleLabelRepository;
  137. private readonly IVerificationCodeRepository verificationCodeRepository;
  138. private readonly IFlowAttachmentRepository flowAttachmentRepository;
  139. private readonly IMeetingSummaryTodoRepository meetingSummaryTodoRepository;
  140. private readonly IRecordFolderRepository recordFolderRepository;
  141. private readonly IVipRepository vipRepository;
  142. private readonly IOrderRepository orderRepository;
  143. private readonly ISystemRoleRepository systemRoleRepository;
  144. private readonly IMenusRepository menusRepository;
  145. private readonly INavigationRepository navigationRepository;
  146. private readonly ISystemLabelRepository systemLabelRepository;
  147. private readonly ICategoryRepository categoryRepository;
  148. private readonly IMediaRepository mediaRepository;
  149. private readonly IMediaLibraryRepository mediaLibraryRepository;
  150. private readonly ITeacherRepository teacherRepository;
  151. private readonly ISensitiveWordRepository sensitiveWordRepository;
  152. private readonly IAttachRepository attachRepository;
  153. private readonly ISystemRoleMenusRepository systemRoleMenusRepository;
  154. private readonly IMediaLableRepository mediaLableRepository;
  155. private readonly IAppStartPageRepository appStartPageRepository;
  156. private readonly IOrganizationRepository organizationRepository;
  157. private readonly IOrganizationUserRepository organizationUserRepository;
  158. private readonly ITrackLogRepository trackLogRepository;
  159. private readonly IVipEquityRepository vipEquityRepository;
  160. private readonly IUserLoginRepository userLoginRepository;
  161. private readonly IMiddleLableRepository middleLableRepository;
  162. private readonly ISpecialLabelRepository specialLabelRepository;
  163. private readonly IMiddleLableNexusRepository middleLableNexusRepository;
  164. private readonly IGroupCategoryRepository groupCategoryRepository;
  165. private readonly ISystemLableMediaRepository systemLableMediaRepository;
  166. private readonly IChannelCategoryMediaRepository channelCategoryMediaRepository;
  167. private readonly IChannelCategoryRepository channelCategoryRepository;
  168. private readonly IAppChannelRepository appChannelRepository;
  169. private readonly IDepartmentUserRepository departmentUserRepository;
  170. private readonly IFriendsRepository friendsRepository;
  171. private readonly IUserGroupCategoryRepository userGroupCategoryRepository;
  172. public AdminUtilsController(IWebHostEnvironment environment, IFlowFieldValueRepository flowFieldValueRepository,
  173. IFlowRepository flowRepository, IFlowMessageRepository flowMessageRepository,
  174. IFlowTodoRepository flowTodoRepository, IAdminRepository adminRepository,
  175. IArticleGroupRepository articleGroupRepository,
  176. IArticleRepository articleRepository,
  177. IDepartmentRepository departmentRepository,
  178. IProcessFieldRepository processFieldRepository, IProcessGroupRepository processGroupRepository,
  179. IProcessNodeRepository processNodeRepository, IProcessRepository processRepository,
  180. IProcessRequestLimitRepository processRequestLimitRepository,
  181. IRuleApproverCheckRepository ruleApproverCheckRepository,
  182. IRuleCarbonCopyRepository ruleCarbonCopyRepository, IRuleConditionRepository ruleConditionRuleRepository,
  183. IMeetingLocationRepository meetingLocationRepository, IMeetingOrderRepository meetingOrderRepository,
  184. IMeetingRepository meetingRepository, IMeetingRoomRepository meetingRoomRepository,
  185. IMeetingSummaryRepository meetingSummaryRepository,
  186. ICarOrderRepository carOrderRepository, ICarRepository carRepository, ICarTypeRepository carTypeRepository,
  187. IRoleGroupRepository roleGroupRepository,
  188. IRoleRepository roleRepository, IUserRepository userRepository, ISlideRepository slideRepository,
  189. ICommentRepository commentRepository, IAppVersionRepository appVersionRepository,
  190. IFeedbackRepository feedbackRepository, IBlacklistArticleRepository blacklistArticleRepository,
  191. IThesaurusRepository thesaurusRepository, IArticleGroupUserRepository articleGroupUserRepository,
  192. IAddressBookGroupRepository addressBookGroupRepository,
  193. IAddressBookGroupUserRepository addressBookGroupUserRepository, IGroupChatRepository groupChatRepository,
  194. IGroupChatUserRepository groupChatUserRepository, INoticeRepository noticeRepository,
  195. IAddresseeRepository addresseeRepository, ICcRepository ccRepository, IBlacklistUserRepository blacklistUserRepository,
  196. IFinanceRepository financeRepository, IPrintRepository printRepository, ISellRepository sellRepository,
  197. IStorehouseRepository storehouseRepository, IHumanAffairsRepository humanAffairsRepository,
  198. IOftenContactRepository oftenContactRepository, IChatRecordRepository chatRecordRepository,
  199. ITopicRepository topicRepository, ITopicAddresseeRepository topicAddresseeRepository,
  200. IFileLibraryRepository fileLibraryRepository, IIMService imService, IGroupRepository groupRepository,
  201. IGroupFolderRepository groupFolderRepository, IGroupUserRepository groupUserRepository,
  202. IMiddleRepository middleRepository, IElasticSearchService elasticSearchService,
  203. ICollectionRepository collectionRepository, INoteRepository noteRepository,
  204. IAppReportRepository appReportRepository, ITopicGroupRepository topicGroupRepository,
  205. ITopicGroupUserRepository topicGroupUserRepository, IAdminVerifyRepository adminVerifyRepository,
  206. IMissiveRepository missiveRepository, IWaitHandleLabelRepository waitHandleLabelRepository,
  207. IWaitHandleRepository waitHandleRepository, IVisitRepository visitRepository, IAnalyzeRepository analyzeRepository, IUserMiddleRepository userMiddleRepository, IArticleInnerLabelRepository articleInnerLabelRepository, IArticleLabelRepository articleLabelRepository, IVerificationCodeRepository verificationCodeRepository, IFlowAttachmentRepository flowAttachmentRepository, IMeetingSummaryTodoRepository meetingSummaryTodoRepository, IFolderUserRepository folderUserRepository, IRecordFolderRepository recordFolderRepository, IVipRepository vipRepository, IOrderRepository orderRepository, ISystemRoleRepository systemRoleRepository, IMenusRepository menusRepository, INavigationRepository navigationRepository, ISystemLabelRepository systemLabelRepository, ICategoryRepository categoryRepository, IMediaRepository mediaRepository, IMediaLibraryRepository mediaLibraryRepository, ITeacherRepository teacherRepository, ISensitiveWordRepository sensitiveWordRepository, IAttachRepository attachRepository, ISystemRoleMenusRepository systemRoleMenusRepository, IMediaLableRepository mediaLableRepository, IAppStartPageRepository appStartPageRepository, IOrganizationRepository organizationRepository, IOrganizationUserRepository organizationUserRepository, IVipEquityRepository vipEquityRepository, ITrackLogRepository trackLogRepository, IUserLoginRepository userLoginRepository, IMiddleLableRepository middleLableRepository, ISpecialLabelRepository specialLabelRepository, IMiddleLableNexusRepository middleLableNexusRepository, IGroupCategoryRepository groupCategoryRepository, ISystemLableMediaRepository systemLableMediaRepository, IChannelCategoryMediaRepository channelCategoryMediaRepository, IChannelCategoryRepository channelCategoryRepository, IAppChannelRepository appChannelRepository, IDepartmentUserRepository departmentUserRepository, IFriendsRepository friendsRepository,IUserGroupCategoryRepository userGroupCategoryRepository)
  208. {
  209. _environment = environment;
  210. _flowFieldValueRepository = flowFieldValueRepository;
  211. _flowRepository = flowRepository;
  212. _flowMessageRepository = flowMessageRepository;
  213. _flowTodoRepository = flowTodoRepository;
  214. _processFieldRepository = processFieldRepository;
  215. _processGroupRepository = processGroupRepository;
  216. _processNodeRepository = processNodeRepository;
  217. _processRepository = processRepository;
  218. _processRequestLimitRepository = processRequestLimitRepository;
  219. _ruleApproverCheckRepository = ruleApproverCheckRepository;
  220. _ruleCarbonCopyRepository = ruleCarbonCopyRepository;
  221. _ruleConditionRuleRepository = ruleConditionRuleRepository;
  222. _adminRepository = adminRepository;
  223. _articleGroupRepository = articleGroupRepository;
  224. _articleRepository = articleRepository;
  225. _departmentRepository = departmentRepository;
  226. _meetingLocationRepository = meetingLocationRepository;
  227. _meetingOrderRepository = meetingOrderRepository;
  228. _meetingRepository = meetingRepository;
  229. _meetingRoomRepository = meetingRoomRepository;
  230. _meetingSummaryRepository = meetingSummaryRepository;
  231. _carOrderRepository = carOrderRepository;
  232. _carRepository = carRepository;
  233. _carTypeRepository = carTypeRepository;
  234. _roleGroupRepository = roleGroupRepository;
  235. _roleRepository = roleRepository;
  236. _userRepository = userRepository;
  237. _slideRepository = slideRepository;
  238. _commentRepository = commentRepository;
  239. _appVersionRepository = appVersionRepository;
  240. _feedbackRepository = feedbackRepository;
  241. _blacklistArticleRepository = blacklistArticleRepository;
  242. _thesaurusRepository = thesaurusRepository;
  243. _articleGroupUserRepository = articleGroupUserRepository;
  244. _addressBookGroupRepository = addressBookGroupRepository;
  245. _addressBookGroupUserRepository = addressBookGroupUserRepository;
  246. _groupChatRepository = groupChatRepository;
  247. _groupChatUserRepository = groupChatUserRepository;
  248. _noticeRepository = noticeRepository;
  249. _addresseeRepository = addresseeRepository;
  250. _ccRepository = ccRepository;
  251. _blacklistUserRepository = blacklistUserRepository;
  252. _humanAffairsRepository = humanAffairsRepository;
  253. _financeRepository = financeRepository;
  254. _sellRepository = sellRepository;
  255. _storehouseRepository = storehouseRepository;
  256. _printRepository = printRepository;
  257. _oftenContactRepository = oftenContactRepository;
  258. _chatRecordRepository = chatRecordRepository;
  259. _topicAddresseeRepository = topicAddresseeRepository;
  260. _topicRepository = topicRepository;
  261. _fileLibraryRepository = fileLibraryRepository;
  262. _imService = imService;
  263. _groupFolderRepository = groupFolderRepository;
  264. _groupUserRepository = groupUserRepository;
  265. _groupRepository = groupRepository;
  266. _middleRepository = middleRepository;
  267. _elasticSearchService = elasticSearchService;
  268. _collectionRepository = collectionRepository;
  269. _noteRepository = noteRepository;
  270. _appReportRepository = appReportRepository;
  271. _topicGroupRepository = topicGroupRepository;
  272. _topicGroupUserRepository = topicGroupUserRepository;
  273. _adminVerifyRepository = adminVerifyRepository;
  274. _missiveRepository = missiveRepository;
  275. _folderUserRepository = folderUserRepository;
  276. _waitHandleRepository = waitHandleRepository;
  277. _waitHandleLabelRepository = waitHandleLabelRepository;
  278. _vsitRepository = visitRepository;
  279. _analyzeRepository = analyzeRepository;
  280. _userMiddleRepository = userMiddleRepository;
  281. _articleInnerLabelRepository = articleInnerLabelRepository;
  282. _articleLabelRepository = articleLabelRepository;
  283. this.verificationCodeRepository = verificationCodeRepository;
  284. this.flowAttachmentRepository = flowAttachmentRepository;
  285. this.meetingSummaryTodoRepository = meetingSummaryTodoRepository;
  286. this.recordFolderRepository = recordFolderRepository;
  287. this.vipRepository = vipRepository;
  288. this.orderRepository = orderRepository;
  289. this.menusRepository = menusRepository;
  290. this.systemRoleRepository = systemRoleRepository;
  291. this.navigationRepository = navigationRepository;
  292. this.systemLabelRepository = systemLabelRepository;
  293. this.categoryRepository = categoryRepository;
  294. this.mediaRepository = mediaRepository;
  295. this.mediaLibraryRepository = mediaLibraryRepository;
  296. this.teacherRepository = teacherRepository;
  297. this.sensitiveWordRepository = sensitiveWordRepository;
  298. this.attachRepository = attachRepository;
  299. this.systemRoleMenusRepository = systemRoleMenusRepository;
  300. this.mediaLableRepository = mediaLableRepository;
  301. this.appStartPageRepository = appStartPageRepository;
  302. this.organizationRepository = organizationRepository;
  303. this.organizationUserRepository = organizationUserRepository;
  304. this.vipEquityRepository = vipEquityRepository;
  305. this.trackLogRepository = trackLogRepository;
  306. this.userLoginRepository = userLoginRepository;
  307. this.middleLableRepository = middleLableRepository;
  308. this.specialLabelRepository = specialLabelRepository;
  309. this.middleLableNexusRepository = middleLableNexusRepository;
  310. this.groupCategoryRepository = groupCategoryRepository;
  311. this.systemLableMediaRepository = systemLableMediaRepository;
  312. this.channelCategoryMediaRepository = channelCategoryMediaRepository;
  313. this.channelCategoryRepository = channelCategoryRepository;
  314. this.appChannelRepository = appChannelRepository;
  315. this.departmentUserRepository = departmentUserRepository;
  316. this.friendsRepository = friendsRepository;
  317. this.userGroupCategoryRepository=userGroupCategoryRepository;
  318. }
  319. [HttpGet("works")]
  320. public async Task<string> WorksAsync()
  321. {
  322. var retVal = await _adminRepository.Database.IsConnectionWorksAsync();
  323. return retVal.IsConnectionWorks ? "Database Connection Works" : retVal.ErrorMessage;
  324. }
  325. [HttpGet("sync_database")]
  326. public async Task<string> SyncDatabase()
  327. {
  328. var database = _adminRepository.Database;
  329. var repositories = new List<IRepository>
  330. {
  331. _adminRepository,
  332. _flowFieldValueRepository,
  333. _flowRepository,
  334. _flowMessageRepository,
  335. _flowTodoRepository,
  336. _processFieldRepository,
  337. _processGroupRepository,
  338. _processNodeRepository,
  339. _processRepository,
  340. _processRequestLimitRepository,
  341. _ruleApproverCheckRepository,
  342. _ruleCarbonCopyRepository,
  343. _ruleConditionRuleRepository,
  344. _articleGroupRepository,
  345. _articleRepository,
  346. _departmentRepository,
  347. _meetingLocationRepository,
  348. _meetingOrderRepository,
  349. _meetingRepository,
  350. _meetingRoomRepository,
  351. _meetingSummaryRepository,
  352. _carOrderRepository,
  353. _carRepository,
  354. _carTypeRepository,
  355. _roleGroupRepository,
  356. _roleRepository,
  357. _slideRepository,
  358. _userRepository,
  359. _commentRepository,
  360. _appVersionRepository,
  361. _feedbackRepository,
  362. _blacklistArticleRepository,
  363. _thesaurusRepository,
  364. _articleGroupUserRepository,
  365. _addressBookGroupRepository,
  366. _addressBookGroupUserRepository,
  367. _groupChatRepository,
  368. _groupChatUserRepository,
  369. _noticeRepository,
  370. _addresseeRepository,
  371. _ccRepository,
  372. _blacklistUserRepository,
  373. _humanAffairsRepository,
  374. _financeRepository,
  375. _sellRepository,
  376. _storehouseRepository,
  377. _printRepository,
  378. _chatRecordRepository,
  379. _oftenContactRepository,
  380. _topicAddresseeRepository,
  381. _topicRepository,
  382. _fileLibraryRepository,
  383. _groupFolderRepository,
  384. _groupUserRepository,
  385. _groupRepository,
  386. _middleRepository,
  387. _collectionRepository,
  388. _noteRepository,
  389. _appReportRepository,
  390. _topicGroupRepository,
  391. _topicGroupUserRepository,
  392. _adminVerifyRepository,
  393. _missiveRepository,
  394. _folderUserRepository,
  395. _waitHandleRepository,
  396. _waitHandleLabelRepository,
  397. _vsitRepository,
  398. _analyzeRepository,
  399. _userMiddleRepository,
  400. _articleInnerLabelRepository,
  401. _articleLabelRepository,
  402. verificationCodeRepository,
  403. flowAttachmentRepository,
  404. meetingSummaryTodoRepository,
  405. recordFolderRepository,
  406. vipRepository,
  407. orderRepository,
  408. menusRepository,
  409. systemRoleRepository,
  410. navigationRepository,
  411. systemLabelRepository,
  412. categoryRepository,
  413. mediaRepository,
  414. mediaLibraryRepository,
  415. teacherRepository,
  416. sensitiveWordRepository,
  417. attachRepository,
  418. systemRoleMenusRepository,
  419. mediaLableRepository,
  420. appStartPageRepository,
  421. organizationRepository,
  422. organizationUserRepository,
  423. vipEquityRepository,
  424. trackLogRepository,
  425. userLoginRepository,
  426. middleLableRepository,
  427. specialLabelRepository,
  428. middleLableNexusRepository,
  429. groupCategoryRepository,
  430. systemLableMediaRepository,
  431. channelCategoryMediaRepository,
  432. channelCategoryRepository,
  433. appChannelRepository,
  434. departmentUserRepository,
  435. friendsRepository,
  436. userGroupCategoryRepository
  437. };
  438. var alterCount = 0;
  439. var createCount = 0;
  440. foreach (var repository in repositories)
  441. {
  442. if (await database.IsTableExistsAsync(repository.TableName))
  443. {
  444. await database.AlterTableAsync(repository.TableName, repository.TableColumns);
  445. alterCount++;
  446. }
  447. else
  448. {
  449. await database.CreateTableAsync(repository.TableName, repository.TableColumns);
  450. createCount++;
  451. }
  452. }
  453. //var database = new Database();
  454. //database.IsTableExistsAsync()
  455. return $"alter: {alterCount}, create: {createCount}";
  456. }
  457. [HttpGet("qrcoder")]
  458. public async Task<bool> SendQRCode()
  459. {
  460. var users = await _userRepository.FindAllUserAsync(Q.Where(nameof(Entity.User.Id), ">", 0));
  461. foreach (var user in users)
  462. {
  463. if (string.IsNullOrEmpty(user.QRCoder))
  464. {
  465. //生成二维码
  466. var qrCodeData = new { key = QRCodeTypeConst.UserInfo, value = user.Guid };
  467. var resultPath =
  468. FileHelper.SaveQRCodeFile(StringUtils.GetWebRootPath(_environment.WebRootPath),
  469. JsonConvert.SerializeObject(qrCodeData));
  470. user.QRCoder = resultPath.RelativePath;
  471. await _userRepository.UpdateAsync(user);
  472. }
  473. }
  474. var groupChats = await _groupChatRepository.GetAllGroupChatAsync();
  475. foreach (var groupChat in groupChats)
  476. {
  477. if (string.IsNullOrEmpty(groupChat.QRCoder))
  478. {
  479. //生成二维码
  480. var qrCodeData = new { key = QRCodeTypeConst.GroupChatInfo, value = groupChat.Guid };
  481. var resultPath =
  482. FileHelper.SaveQRCodeFile(StringUtils.GetWebRootPath(_environment.WebRootPath),
  483. JsonConvert.SerializeObject(qrCodeData));
  484. groupChat.QRCoder = resultPath.RelativePath;
  485. var request = new GroupChatUpRequest { Id = groupChat.Id, QrCode = groupChat.QRCoder };
  486. await _groupChatRepository.UpdateAsync(request);
  487. }
  488. }
  489. return true;
  490. }
  491. [HttpGet("test")]
  492. public async Task<bool> Test()
  493. {
  494. //return await new MinIOHelper().PutObjectAsync("test", "1234.jpeg", "C:\\Users\\zuoxi\\Desktop\\1234.jpeg", "application/octet-stream");
  495. //return await _imService.GetTokenImAsync();
  496. return await _elasticSearchService.ElasticSearchData();
  497. }
  498. [HttpGet("im-token")]
  499. public async Task<bool> SetImToken()
  500. {
  501. return await _imService.GetTokenImAsync();
  502. }
  503. /// <summary>
  504. /// 插入环信用户
  505. /// </summary>
  506. /// <returns></returns>
  507. [HttpGet("im-user")]
  508. public async Task<bool> SetImUser()
  509. {
  510. var users = await _userRepository.GetAllAsync(Q.Where(nameof(Entity.User.Id), ">", 0));
  511. foreach (var item in users)
  512. {
  513. await _userRepository.CreateMiUserAsync(item);
  514. }
  515. return true;
  516. }
  517. /// <summary>
  518. /// 设置图片
  519. /// </summary>
  520. /// <returns></returns>
  521. [HttpGet("set-img")]
  522. public async Task<bool> SetImg()
  523. {
  524. //获取文章
  525. var articles = await _articleRepository.GetAllAsync();
  526. foreach (var article in articles)
  527. {
  528. var strings = StringUtils.StringCollectionToStringList(article.ImageUrls);
  529. foreach (var imageUrl in strings)
  530. {
  531. var imageUrlFullName = imageUrl.Split('/')[imageUrl.Split('/').Length - 1];
  532. //获取文件路径
  533. var file = StringUtils.GetWebRootPath(_environment.WebRootPath + "\\cache");
  534. DirectoryInfo info = new DirectoryInfo(file);
  535. foreach (var item in info.GetFileSystemInfos())
  536. {
  537. //判读是否是文件夹
  538. if (Directory.Exists(item.FullName))
  539. {
  540. //获取文件夹下面的文件
  541. var infos = new DirectoryInfo(item.FullName);
  542. foreach (var fileIo in infos.GetFileSystemInfos())
  543. {
  544. if (fileIo.FullName.Contains(imageUrlFullName))
  545. {
  546. //压缩图片
  547. CompressImage.Execute(fileIo.FullName);
  548. //压缩图片
  549. CompressImage.Execute(fileIo.FullName, 100);
  550. }
  551. }
  552. }
  553. }
  554. }
  555. }
  556. return true;
  557. }
  558. }
  559. }