using System.Data; using Common; using Infrastructure; using LitJson; using Microsoft.Extensions.Localization; using Model; using Model.Customer; using NuGet.Packaging; using Services; using System.Linq; using System.Net.Mime; using System.Text.RegularExpressions; namespace Util { public class CopyProject { //发奖入口 public static void Copy(int fromProjectId, int toProjectId) { var projectService = App.GetService(); var listService = App.GetService(); var listAmountSetService = App.GetService(); var loopSetService = App.GetService(); var conditionService = App.GetService(); var prizeInFieldService = App.GetService(); var prizeInQueryFieldService = App.GetService(); var prizeInSetService = App.GetService(); var prizeInTableService = App.GetService(); var prizeObjectFieldService = App.GetService(); var prizeObjectTableService = App.GetService(); var projectParamService = App.GetService(); var queryFieldService = App.GetService(); var queryTableService = App.GetService(); var recursionStartConditionService = App.GetService(); var recursionStartFieldService = App.GetService(); var recursionStartReturnFieldService = App.GetService(); var recursionStartTableService = App.GetService(); var returnFieldService = App.GetService(); var list = listService.GetList(m => m.projectId == fromProjectId); foreach(var subList in list) { subList.projectId = toProjectId; int listId = listService.InsertReturnIdentity(subList); var listAmountSet = listAmountSetService.GetList(m => m.listId == subList.id); foreach(var subListAmountSet in listAmountSet) { subListAmountSet.projectId = toProjectId; subListAmountSet.listId = listId; listAmountSetService.InsertReturnIdentity(subListAmountSet); } var loopSet = loopSetService.GetList(m => m.listId == subList.id); foreach(var subLoopSet in loopSet) { subLoopSet.projectId = toProjectId; subLoopSet.listId = listId; int loopSetId = loopSetService.InsertReturnIdentity(subLoopSet); var recursionStartCondition = recursionStartConditionService.GetList(m => m.loopSetId == subLoopSet.id); foreach(var subRecursionStartCondition in recursionStartCondition) { subRecursionStartCondition.projectId = toProjectId; subRecursionStartCondition.loopSetId = loopSetId; recursionStartConditionService.InsertReturnIdentity(subRecursionStartCondition); } } var condition = conditionService.GetList(m => m.listId == subList.id); foreach(var subCondition in condition) { subCondition.projectId = toProjectId; subCondition.listId = listId; conditionService.InsertReturnIdentity(subCondition); } var prizeInTable = prizeInTableService.GetList(m => m.listId == subList.id); foreach(var subPrizeInTable in prizeInTable) { subPrizeInTable.projectId = toProjectId; subPrizeInTable.listId = listId; int prizeInTableId = prizeInTableService.InsertReturnIdentity(subPrizeInTable); var prizeInQueryField = prizeInQueryFieldService.GetList(m => m.inTableId == subPrizeInTable.id); foreach(var subPrizeInQueryField in prizeInQueryField) { subPrizeInQueryField.inTableId = prizeInTableId; prizeInQueryFieldService.InsertReturnIdentity(subPrizeInQueryField); } var prizeInField = prizeInFieldService.GetList(m => m.inTableId == subPrizeInTable.id); foreach(var subPrizeInField in prizeInField) { subPrizeInField.inTableId = prizeInTableId; prizeInFieldService.InsertReturnIdentity(subPrizeInField); } } var recursionStartTable = recursionStartTableService.GetList(m => m.listId == subList.id); foreach(var subRecursionStartTable in recursionStartTable) { subRecursionStartTable.projectId = toProjectId; subRecursionStartTable.listId = listId; int recursionStartTableId = recursionStartTableService.InsertReturnIdentity(subRecursionStartTable); var recursionStartField = recursionStartFieldService.GetList(m => m.objectTableId == subRecursionStartTable.id); foreach(var subRecursionStartField in recursionStartField) { subRecursionStartField.objectTableId = recursionStartTableId; recursionStartFieldService.InsertReturnIdentity(subRecursionStartField); } var recursionStartReturnField = recursionStartReturnFieldService.GetList(m => m.objectTableId == subRecursionStartTable.id); foreach(var subRecursionStartReturnField in recursionStartReturnField) { subRecursionStartReturnField.objectTableId = recursionStartTableId; recursionStartReturnFieldService.InsertReturnIdentity(subRecursionStartReturnField); } } } var projectParam = projectParamService.GetList(m => m.projectId == fromProjectId); foreach(var subProjectParam in projectParam) { subProjectParam.projectId = toProjectId; projectParamService.InsertReturnIdentity(subProjectParam); } var queryTable = queryTableService.GetList(m => m.projectId == fromProjectId); foreach(var subQueryTable in queryTable) { subQueryTable.projectId = toProjectId; int tableId = queryTableService.InsertReturnIdentity(subQueryTable); var queryField = queryFieldService.GetList(m => m.queryTableId == subQueryTable.id); foreach(var subQueryField in queryField) { subQueryField.queryTableId = tableId; queryFieldService.InsertReturnIdentity(subQueryField); } var returnField = returnFieldService.GetList(m => m.queryTableId == subQueryTable.id); foreach(var subReturnField in returnField) { subReturnField.queryTableId = tableId; returnFieldService.InsertReturnIdentity(subReturnField); } } } } }