CopyProject.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System.Data;
  2. using Common;
  3. using Infrastructure;
  4. using LitJson;
  5. using Microsoft.Extensions.Localization;
  6. using Model;
  7. using Model.Customer;
  8. using NuGet.Packaging;
  9. using Services;
  10. using System.Linq;
  11. using System.Net.Mime;
  12. using System.Text.RegularExpressions;
  13. namespace Util
  14. {
  15. public class CopyProject
  16. {
  17. //发奖入口
  18. public static void Copy(int fromProjectId, int toProjectId)
  19. {
  20. var projectService = App.GetService<IPriProjectService>();
  21. var listService = App.GetService<IPriListService>();
  22. var listAmountSetService = App.GetService<IPriListAmountSetService>();
  23. var loopSetService = App.GetService<IPriLoopSetService>();
  24. var conditionService = App.GetService<IPriConditionService>();
  25. var prizeInFieldService = App.GetService<IPriPrizeInFieldService>();
  26. var prizeInQueryFieldService = App.GetService<IPriPrizeInQueryFieldService>();
  27. var prizeInSetService = App.GetService<IPriPrizeInSetService>();
  28. var prizeInTableService = App.GetService<IPriPrizeInTableService>();
  29. var prizeObjectFieldService = App.GetService<IPriPrizeObjectFieldService>();
  30. var prizeObjectTableService = App.GetService<IPriPrizeObjectTableService>();
  31. var projectParamService = App.GetService<IPriProjectParamService>();
  32. var queryFieldService = App.GetService<IPriQueryFieldService>();
  33. var queryTableService = App.GetService<IPriQueryTableService>();
  34. var recursionStartConditionService = App.GetService<IPriRecursionStartConditionService>();
  35. var recursionStartFieldService = App.GetService<IPriRecursionStartFieldService>();
  36. var recursionStartReturnFieldService = App.GetService<IPriRecursionStartReturnFieldService>();
  37. var recursionStartTableService = App.GetService<IPriRecursionStartTableService>();
  38. var returnFieldService = App.GetService<IPriReturnFieldService>();
  39. var list = listService.GetList(m => m.projectId == fromProjectId);
  40. foreach(var subList in list)
  41. {
  42. subList.projectId = toProjectId;
  43. int listId = listService.InsertReturnIdentity(subList);
  44. var listAmountSet = listAmountSetService.GetList(m => m.listId == subList.id);
  45. foreach(var subListAmountSet in listAmountSet)
  46. {
  47. subListAmountSet.projectId = toProjectId;
  48. subListAmountSet.listId = listId;
  49. listAmountSetService.InsertReturnIdentity(subListAmountSet);
  50. }
  51. var loopSet = loopSetService.GetList(m => m.listId == subList.id);
  52. foreach(var subLoopSet in loopSet)
  53. {
  54. subLoopSet.projectId = toProjectId;
  55. subLoopSet.listId = listId;
  56. int loopSetId = loopSetService.InsertReturnIdentity(subLoopSet);
  57. var recursionStartCondition = recursionStartConditionService.GetList(m => m.loopSetId == subLoopSet.id);
  58. foreach(var subRecursionStartCondition in recursionStartCondition)
  59. {
  60. subRecursionStartCondition.projectId = toProjectId;
  61. subRecursionStartCondition.loopSetId = loopSetId;
  62. recursionStartConditionService.InsertReturnIdentity(subRecursionStartCondition);
  63. }
  64. }
  65. var condition = conditionService.GetList(m => m.listId == subList.id);
  66. foreach(var subCondition in condition)
  67. {
  68. subCondition.projectId = toProjectId;
  69. subCondition.listId = listId;
  70. conditionService.InsertReturnIdentity(subCondition);
  71. }
  72. var prizeInTable = prizeInTableService.GetList(m => m.listId == subList.id);
  73. foreach(var subPrizeInTable in prizeInTable)
  74. {
  75. subPrizeInTable.projectId = toProjectId;
  76. subPrizeInTable.listId = listId;
  77. int prizeInTableId = prizeInTableService.InsertReturnIdentity(subPrizeInTable);
  78. var prizeInQueryField = prizeInQueryFieldService.GetList(m => m.inTableId == subPrizeInTable.id);
  79. foreach(var subPrizeInQueryField in prizeInQueryField)
  80. {
  81. subPrizeInQueryField.inTableId = prizeInTableId;
  82. prizeInQueryFieldService.InsertReturnIdentity(subPrizeInQueryField);
  83. }
  84. var prizeInField = prizeInFieldService.GetList(m => m.inTableId == subPrizeInTable.id);
  85. foreach(var subPrizeInField in prizeInField)
  86. {
  87. subPrizeInField.inTableId = prizeInTableId;
  88. prizeInFieldService.InsertReturnIdentity(subPrizeInField);
  89. }
  90. }
  91. var recursionStartTable = recursionStartTableService.GetList(m => m.listId == subList.id);
  92. foreach(var subRecursionStartTable in recursionStartTable)
  93. {
  94. subRecursionStartTable.projectId = toProjectId;
  95. subRecursionStartTable.listId = listId;
  96. int recursionStartTableId = recursionStartTableService.InsertReturnIdentity(subRecursionStartTable);
  97. var recursionStartField = recursionStartFieldService.GetList(m => m.objectTableId == subRecursionStartTable.id);
  98. foreach(var subRecursionStartField in recursionStartField)
  99. {
  100. subRecursionStartField.objectTableId = recursionStartTableId;
  101. recursionStartFieldService.InsertReturnIdentity(subRecursionStartField);
  102. }
  103. var recursionStartReturnField = recursionStartReturnFieldService.GetList(m => m.objectTableId == subRecursionStartTable.id);
  104. foreach(var subRecursionStartReturnField in recursionStartReturnField)
  105. {
  106. subRecursionStartReturnField.objectTableId = recursionStartTableId;
  107. recursionStartReturnFieldService.InsertReturnIdentity(subRecursionStartReturnField);
  108. }
  109. }
  110. }
  111. var projectParam = projectParamService.GetList(m => m.projectId == fromProjectId);
  112. foreach(var subProjectParam in projectParam)
  113. {
  114. subProjectParam.projectId = toProjectId;
  115. projectParamService.InsertReturnIdentity(subProjectParam);
  116. }
  117. var queryTable = queryTableService.GetList(m => m.projectId == fromProjectId);
  118. foreach(var subQueryTable in queryTable)
  119. {
  120. subQueryTable.projectId = toProjectId;
  121. int tableId = queryTableService.InsertReturnIdentity(subQueryTable);
  122. var queryField = queryFieldService.GetList(m => m.queryTableId == subQueryTable.id);
  123. foreach(var subQueryField in queryField)
  124. {
  125. subQueryField.queryTableId = tableId;
  126. queryFieldService.InsertReturnIdentity(subQueryField);
  127. }
  128. var returnField = returnFieldService.GetList(m => m.queryTableId == subQueryTable.id);
  129. foreach(var subReturnField in returnField)
  130. {
  131. subReturnField.queryTableId = tableId;
  132. returnFieldService.InsertReturnIdentity(subReturnField);
  133. }
  134. }
  135. }
  136. }
  137. }