public override void Import() { var woCheckList = ClosureWOCheckList.FirstOrDefault(e => e.Id.ToString().Equals(_closureWOCheckList.Id.ToString())); if (woCheckList != null) { woCheckList.RE_Original = _closureWOCheckList.RE_Original; woCheckList.LHI_Original = _closureWOCheckList.LHI_Original; woCheckList.ESSD_Original = _closureWOCheckList.ESSD_Original; woCheckList.Equipment_Original = _closureWOCheckList.Equipment_Original; woCheckList.Signage_Original = _closureWOCheckList.Signage_Original; woCheckList.Seating_Original = _closureWOCheckList.Seating_Original; woCheckList.Decoration_Original = _closureWOCheckList.Decoration_Original; woCheckList.RE_NBV = _closureWOCheckList.RE_NBV; woCheckList.LHI_NBV = _closureWOCheckList.LHI_NBV; woCheckList.ESSD_NBV = _closureWOCheckList.ESSD_NBV; woCheckList.Equipment_NBV = _closureWOCheckList.Equipment_NBV; woCheckList.Signage_NBV = _closureWOCheckList.Signage_NBV; woCheckList.Seating_NBV = _closureWOCheckList.Seating_NBV; woCheckList.Decoration_NBV = _closureWOCheckList.Decoration_NBV; woCheckList.EquipmentTransfer = _closureWOCheckList.EquipmentTransfer; woCheckList.TotalCost_Original = _closureWOCheckList.TotalCost_Original; woCheckList.TotalCost_NBV = _closureWOCheckList.TotalCost_NBV; woCheckList.TotalCost_WriteOFF = _closureWOCheckList.TotalCost_WriteOFF; woCheckList.RECost_WriteOFF = _closureWOCheckList.RECost_WriteOFF; woCheckList.LHI_WriteOFF = _closureWOCheckList.LHI_WriteOFF; woCheckList.ESSD_WriteOFF = _closureWOCheckList.ESSD_WriteOFF; woCheckList.Equipment_WriteOFF = _closureWOCheckList.Equipment_WriteOFF; woCheckList.Signage_WriteOFF = _closureWOCheckList.Signage_WriteOFF; woCheckList.Seating_WriteOFF = _closureWOCheckList.Seating_WriteOFF; woCheckList.Decoration_WriteOFF = _closureWOCheckList.Decoration_WriteOFF; woCheckList.ClosingCost = _closureWOCheckList.ClosingCost; ClosureWOCheckList.Update(woCheckList); } else { ClosureWOCheckList.Add(_closureWOCheckList); } }
public Guid?GetRefId(string projectId, string flowTable) { Guid?refId = null; switch (flowTable) { case "MajorLeaseConsInfo": var majorConsInfo = MajorLeaseConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory); if (majorConsInfo != null && majorConsInfo.Id != Guid.Empty) { refId = majorConsInfo.Id; } else { refId = Guid.NewGuid(); majorConsInfo = new MajorLeaseConsInfo { Id = refId.Value, ProjectId = projectId, CreateTime = DateTime.Now, IsHistory = false }; MajorLeaseConsInfo.Add(majorConsInfo); } break; case "MajorLeaseConsInvtChecking": var checkInfo = MajorLeaseConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault(); if (checkInfo != null && checkInfo.Id != Guid.Empty) { refId = checkInfo.Id; } else { refId = Guid.NewGuid(); checkInfo = new MajorLeaseConsInvtChecking { Id = refId.Value, ProjectId = projectId, CreateTime = DateTime.Now, IsHistory = false }; MajorLeaseConsInvtChecking.Add(checkInfo); } break; case "ReimageConsInfo": var reimageConsInfo = ReimageConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory); if (reimageConsInfo != null && reimageConsInfo.Id != Guid.Empty) { refId = reimageConsInfo.Id; } else { refId = Guid.NewGuid(); reimageConsInfo = new ReimageConsInfo { Id = refId.Value, ProjectId = projectId, IsHistory = false, CreateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode }; ReimageConsInfo.Add(reimageConsInfo); } break; case "ReimageConsInvtChecking": var reimageCheckInfo = ReimageConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault(); if (reimageCheckInfo != null && reimageCheckInfo.Id != Guid.Empty) { refId = reimageCheckInfo.Id; } else { refId = Guid.NewGuid(); reimageCheckInfo = new ReimageConsInvtChecking { Id = refId.Value, ProjectId = projectId, CreateTime = DateTime.Now, IsHistory = false }; ReimageConsInvtChecking.Add(reimageCheckInfo); } break; case "RebuildConsInfo": var rbdConsInfo = RebuildConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory); if (rbdConsInfo != null && rbdConsInfo.Id != Guid.Empty) { refId = rbdConsInfo.Id; } else { refId = Guid.NewGuid(); rbdConsInfo = new RebuildConsInfo { Id = refId.Value, ProjectId = projectId, IsHistory = false, CreateTime = DateTime.Now, LastUpdateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserNameENUS = ClientCookie.UserNameENUS, CreateUserNameZHCN = ClientCookie.UserNameZHCN }; RebuildConsInfo.Add(rbdConsInfo); } break; case "RebuildConsInvtChecking": var rbdCheckInfo = RebuildConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault(); if (rbdCheckInfo != null && rbdCheckInfo.Id != Guid.Empty) { refId = rbdCheckInfo.Id; } else { refId = Guid.NewGuid(); rbdCheckInfo = new RebuildConsInvtChecking { Id = refId.Value, ProjectId = projectId, IsHistory = false, CreateTime = DateTime.Now, LastUpdateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserNameENUS = ClientCookie.UserNameENUS, CreateUserNameZHCN = ClientCookie.UserNameZHCN }; RebuildConsInvtChecking.Add(rbdCheckInfo); } ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Downlod); ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Input); ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking, NodeCode.Rebuild_ConsInvtChecking_Upload); break; case "ClosureWOCheckList": var closureWOCheckList = ClosureWOCheckList.Get(projectId); if (closureWOCheckList != null && closureWOCheckList.Id != Guid.Empty) { refId = closureWOCheckList.Id; _woCheckList = closureWOCheckList; } else { refId = Guid.NewGuid(); closureWOCheckList = new ClosureWOCheckList { Id = refId.Value, ProjectId = projectId, CreateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserName = ClientCookie.UserNameENUS, IsHistory = false }; ClosureWOCheckList.Add(closureWOCheckList); } break; } return(refId); }
/// <summary> /// 提交Closure /// </summary> /// <param name="entity"></param> /// <returns></returns> public IHttpActionResult PostClosure(ClosureInfo entity) { using (TransactionScope tranScope = new TransactionScope()) { // bll.BeginTransAction(); // try // { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (entity.ClosureReasonCode != "Others") { entity.ClosureReasonRemark = string.Empty; } if (entity.Id == new Guid()) { entity.Id = Guid.NewGuid(); entity.CreateDate = DateTime.Now; entity.ProjectId = ProjectInfo.CreateMainProject(FlowCode.Closure, entity.USCode, NodeCode.Start, entity.CreateUserAccount); ClosureInfo.Add(entity); } else { ClosureInfo.Update(entity); } // bll.Commit(); //} //catch (Exception ex) //{ // bll.Rollback(); // return BadRequest(ex.Message); //} var usersList = new List <ProjectUsers>(); var assetActor = GetClosureUsers(ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, entity.AssetActorAccount, entity.AssetActorNameENUS, entity.AssetActorNameZHCN, entity.ProjectId); usersList.Add(assetActor); var assetRep = GetClosureUsers(ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, entity.AssetRepAccount, entity.AssetRepNameENUS, entity.AssetRepNameZHCN, entity.ProjectId); usersList.Add(assetRep); var finance = GetClosureUsers(ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, entity.FinanceAccount, entity.FinanceNameENUS, entity.FinanceNameZHCN, entity.ProjectId); usersList.Add(finance); var Legal = GetClosureUsers(ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, entity.LegalAccount, entity.LegalNameENUS, entity.LegalNameZHCN, entity.ProjectId); usersList.Add(Legal); var PM = GetClosureUsers(ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, entity.PMAccount, entity.PMNameZHCN, entity.PMNameENUS, entity.ProjectId); usersList.Add(PM); var assertMgr = GetClosureUsers(ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, entity.AssetManagerAccount, entity.AssetManagerNameENUS, entity.AssetManagerNameZHCN, entity.ProjectId); usersList.Add(assertMgr); var cm = GetClosureUsers(ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, entity.CMAccount, entity.CMNameENUS, entity.CMNameZHCN, entity.ProjectId); usersList.Add(cm); if (entity.NecessaryNoticeUserList != null && entity.NecessaryNoticeUserList.Count > 0) { usersList.AddRange(entity.NecessaryNoticeUserList.Select( user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN, entity.ProjectId))); } if (entity.NoticeUserList != null && entity.NoticeUserList.Count > 0) { usersList.AddRange(entity.NoticeUserList.Select( user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN, entity.ProjectId))); } ProjectUsers.Add(usersList.ToArray()); SendRemind(entity); SendWorkTaskAndEmail(entity); //初始化项目信息 ProjectInfo.CreateSubProject(FlowCode.Closure_WOCheckList, entity.ProjectId, entity.USCode, NodeCode.Start, PM.UserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_LegalReview, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_ClosureTool, entity.ProjectId, entity.USCode, NodeCode.Start, finance.UserAccount); var store = StoreBasicInfo.GetStorInfo(entity.USCode); var closureTool = new ClosureTool(); closureTool.Id = Guid.NewGuid(); closureTool.ProjectId = entity.ProjectId; closureTool.IsHistory = false; closureTool.IsOptionOffered = entity.IsRelocation(); closureTool.PipelineName = store.PipelineNameENUS; closureTool.RelocationPipelineID = store.PipelineID; closureTool.Add(); var woCheckList = new ClosureWOCheckList { Id = Guid.NewGuid(), ProjectId = entity.ProjectId, CreateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserName = ClientCookie.UserNameENUS, IsHistory = false }; woCheckList.Add(); var legalReview = new ClosureLegalReview { Id = Guid.NewGuid(), ProjectId = entity.ProjectId, CreateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserName = ClientCookie.UserNameENUS, IsHistory = false }; legalReview.Add(); var executiveSummary = new ClosureExecutiveSummary { Id = Guid.NewGuid(), ProjectId = entity.ProjectId, CreateTime = DateTime.Now, CreatorAccount = ClientCookie.UserCode, CreatorName = ClientCookie.UserNameENUS, IsHistory = false }; executiveSummary.Add(); //var package = new ClosurePackage //{ // Id = Guid.NewGuid(), // ProjectId = entity.ProjectId, // CreateTime = DateTime.Now, // CreateUserAccount = ClientCookie.UserCode, // IsHistory = false //}; //package.Add(); var projectContractInfo = ProjectContractInfo.GetContractWithHistory(entity.ProjectId).Current; projectContractInfo.Add(); ProjectInfo.CreateSubProject(FlowCode.Closure_ExecutiveSummary, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_ClosurePackage, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_ConsInvtChecking, entity.ProjectId, entity.USCode, NodeCode.Start, entity.PMAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_ContractInfo, entity.ProjectId, entity.USCode, NodeCode.Start, entity.CreateUserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_Memo, entity.ProjectId, entity.USCode, NodeCode.Start, entity.CreateUserAccount); ProjectNode.GenerateOnCreate(FlowCode.Closure, entity.ProjectId); try { //bllActionLog.Add(new ActionLog //{ // Id = Guid.NewGuid(), // ProjectId = entity.ProjectId, // Action = ActionType.Submit, // CreateTime = DateTime.Now, // Operator = entity.CreateUserAccount, // OperatorENUS = entity.CreateUserNameENUS, // OperatorZHCN = entity.CreateUserNameZHCN, // Remark = "", // OperatorTitle = "创建流程" //}); tranScope.Complete(); //bll.GetDb().SaveChanges(); } catch (DbEntityValidationException dbEx) { tranScope.Dispose(); } return(Ok(entity)); } }