PageUpdateInfoController.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Attribute;
  2. using Common;
  3. using Dto;
  4. using Vo;
  5. using Enums;
  6. using Filters;
  7. using Infrastructure;
  8. using Infrastructure.Model;
  9. using Mapster;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Middleware;
  12. using Model;
  13. using Services;
  14. using Model.Base;
  15. using System.IO.Compression;
  16. namespace Controllers
  17. {
  18. /// <summary>
  19. /// PageUpdateInfo)Controller
  20. /// </summary>
  21. // [Route("PageUpdateInfo")]
  22. // [ApiExplorerSettings(GroupName = "PageUpdateInfo")]
  23. public class PageUpdateInfoController : BaseController
  24. {
  25. private readonly IPageUpdateInfoService _PageUpdateInfoService;
  26. private readonly IAppBottomNavsService _AppBottomNavsService;
  27. private readonly IFileUpdateInfoService _FileUpdateInfoService;
  28. public PageUpdateInfoController(IPageUpdateInfoService PageUpdateInfoService, IAppBottomNavsService AppBottomNavsService, IFileUpdateInfoService FileUpdateInfoService)
  29. {
  30. _PageUpdateInfoService = PageUpdateInfoService;
  31. _AppBottomNavsService = AppBottomNavsService;
  32. _FileUpdateInfoService = FileUpdateInfoService;
  33. }
  34. /// <summary>
  35. /// 生成APP配置文件
  36. /// </summary>
  37. /// <param name="parm">请求参数</param>
  38. /// <returns>生成APP配置文件</returns>
  39. [HttpGet]
  40. [Route("/noauth/SystemSet/makeAppInitData")]
  41. public string makeAppInitData([FromQuery] MakeAppInitDataDto parm)
  42. {
  43. string AppInfoList = _AppBottomNavsService.makeAppInitData(parm.kind, parm.appVersion);
  44. // Function.WriteLog(AppInfoList);
  45. string FileInfoList = _FileUpdateInfoService.makeAppInitData(parm.kind, parm.appVersion);
  46. string PageInfoList = _PageUpdateInfoService.makeAppInitData(parm.kind, parm.appVersion);
  47. return AppInfoList + "#cut#" + FileInfoList + "#cut#" + PageInfoList;
  48. }
  49. [HttpGet]
  50. [Route("/noauth/reg")]
  51. public IActionResult Register(string v = "4.4.0", string k = "creater", string c = "")
  52. {
  53. string appini = makeAppInitData(new MakeAppInitDataDto()
  54. {
  55. kind = k,
  56. appVersion = v,
  57. }); //Function.GetWebRequest("http://" + url + "/noauth/SystemSet/makeAppInitData?kind=" + k + "&appVersion=" + v);
  58. if (!string.IsNullOrEmpty(appini))
  59. {
  60. if (appini.Contains("#cut#"))
  61. {
  62. string[] appinidata = appini.Split(new string[] { "#cut#" }, StringSplitOptions.None);
  63. string AppInfoList = appinidata[0];
  64. string SystemSet = appinidata[1];
  65. string PageInfoList = appinidata[2];
  66. string GotoPages = appinidata[3];
  67. string LibFile = appinidata[4];
  68. AppInfoList = System.Text.RegularExpressions.Regex.Unescape(AppInfoList);
  69. SystemSet = System.Text.RegularExpressions.Regex.Unescape(SystemSet);
  70. PageInfoList = System.Text.RegularExpressions.Regex.Unescape(PageInfoList);
  71. GotoPages = System.Text.RegularExpressions.Regex.Unescape(GotoPages);
  72. LibFile = System.Text.RegularExpressions.Regex.Unescape(LibFile);
  73. string startPath = "";
  74. string zipPath = "";
  75. if(c == "ios")
  76. {
  77. Function.WritePage("ini", "AppInfoList.ini", AppInfoList);
  78. Function.WritePage("ini", "SystemSet.ini", SystemSet);
  79. Function.WritePage("ini", "PageInfoList.ini", PageInfoList);
  80. Function.WritePage("ini", "GotoPages.ini", GotoPages);
  81. Function.WritePage("ini", "LibFile.ini", LibFile);
  82. startPath = Function.getPath("ini");
  83. zipPath = Function.getPath("ini.zip");
  84. }
  85. else
  86. {
  87. Function.WritePage("txt", "AppInfoList.txt", AppInfoList);
  88. Function.WritePage("txt", "SystemSet.txt", SystemSet);
  89. Function.WritePage("txt", "PageInfoList.txt", PageInfoList);
  90. Function.WritePage("txt", "GotoPages.txt", GotoPages);
  91. Function.WritePage("txt", "LibFile.txt", LibFile);
  92. startPath = Function.getPath(path_str: "txt");
  93. zipPath = Function.getPath("txt.zip");
  94. }
  95. if(System.IO.File.Exists(zipPath))
  96. {
  97. System.IO.File.Delete(zipPath);
  98. }
  99. ZipFile.CreateFromDirectory(startPath, zipPath);
  100. var stream = System.IO.File.OpenRead(zipPath);
  101. return File(stream, "text/plain", Path.GetFileName(zipPath));
  102. }
  103. }
  104. return Content("fail");
  105. }
  106. }
  107. }