MakeAppCodePub.cs 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using System.Web;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Data;
  6. using System.IO;
  7. using System.IO.Compression;
  8. using Infrastructure;
  9. using Customer.Source;
  10. using Common;
  11. namespace Util.MakeApp
  12. {
  13. public class MakeAppCodePub
  14. {
  15. public static Dictionary<string, string> getAppFile(AppProjectVersion ver, List<AppProjectPage> pages, List<AppProjectBottom> bottoms, string htmlPath)
  16. {
  17. foreach (AppProjectBottom bottominfo in bottoms)
  18. {
  19. string selectIcon = "/static/bottom/" + bottominfo.selectIcon.Substring(bottominfo.selectIcon.LastIndexOf("/") + 1);
  20. bottominfo.selectIcon = selectIcon;
  21. string normalIcon = "/static/bottom/" + bottominfo.normalIcon.Substring(bottominfo.normalIcon.LastIndexOf("/") + 1);
  22. bottominfo.normalIcon = normalIcon;
  23. string pagDefaultIcon = "/static/bottom/" + bottominfo.pagDefaultIcon.Substring(bottominfo.pagDefaultIcon.LastIndexOf("/") + 1);
  24. bottominfo.pagDefaultIcon = pagDefaultIcon;
  25. string pagLocalPath = "/static/bottom/" + bottominfo.pagLocalPath.Substring(bottominfo.pagLocalPath.LastIndexOf("/") + 1);
  26. bottominfo.pagLocalPath = pagLocalPath;
  27. }
  28. foreach(var page in pages)
  29. {
  30. if (page.leftBtn != null)
  31. {
  32. foreach (var btn in page.leftBtn)
  33. {
  34. if (!string.IsNullOrEmpty(btn.btnIcon))
  35. {
  36. string btnIcon = "static/page/" + btn.btnIcon.Substring(btn.btnIcon.LastIndexOf("/") + 1);
  37. btn.btnIcon = btnIcon;
  38. }
  39. }
  40. }
  41. if (page.rightBtn != null)
  42. {
  43. foreach (var btn in page.rightBtn)
  44. {
  45. if(!string.IsNullOrEmpty(btn.btnIcon))
  46. {
  47. string btnIcon = "static/page/" + btn.btnIcon.Substring(btn.btnIcon.LastIndexOf("/") + 1);
  48. btn.btnIcon = btnIcon;
  49. }
  50. }
  51. }
  52. }
  53. Dictionary<string, string> dic = new Dictionary<string, string>();
  54. string str = Newtonsoft.Json.JsonConvert.SerializeObject(bottoms);
  55. str = Dbconn.Encrypt3DES(str, "*ga34|^7");
  56. dic.Add("AppInfoList", str);
  57. string PageInfoList = "{";
  58. string LibFile = "{";
  59. foreach (AppProjectPage pageinfo in pages)
  60. {
  61. string FileName = pageinfo.modulePath.Split('.')[0];
  62. pageinfo.dataId = Function.MD5_16(pageinfo.id.ToString() + "123890");
  63. PageInfoList += "\"page" + FileName + "\":" + Newtonsoft.Json.JsonConvert.SerializeObject(pageinfo) + ",";
  64. // string PagePath = "/app/" + ver.appId + "/" + ver.version + "/" + pageinfo.modulePath;
  65. string pageContent = Function.ReadInstanceByFull(htmlPath + pageinfo.moduleFile);
  66. pageContent = Dbconn.Encrypt3DES(pageContent, "*ga34|^7");
  67. LibFile += "\"page" + FileName + "\":\"" + pageContent + "\",";
  68. }
  69. PageInfoList = PageInfoList.TrimEnd(',');
  70. PageInfoList += "}";
  71. LibFile = LibFile.TrimEnd(',');
  72. LibFile += "}";
  73. str = Dbconn.Encrypt3DES(PageInfoList, "*ga34|^7");
  74. dic.Add("PageInfoList", str);
  75. str = Dbconn.Encrypt3DES(LibFile, "*ga34|^7");
  76. dic.Add("LibFile", str);
  77. return dic;
  78. }
  79. public static void ProcessSet(int projectId)
  80. {
  81. int step = RedisServer.Cache.Get<int>("ProjectMakeProcess:" + projectId);
  82. step += 10;
  83. if (step > 100)
  84. {
  85. step = 100;
  86. }
  87. RedisServer.Cache.Set("ProjectMakeProcess:" + projectId, step, 60);
  88. }
  89. }
  90. }