public static ConsInfoDTO <RenewalInfo, RenewalConsInfo> InitPage(string projectId, string id = "") { RenewalInfo info = RenewalInfo.Get(projectId); var consInfo = RenewalConsInfo.Get(projectId, id); if (consInfo == null) { consInfo = new RenewalConsInfo(); consInfo.ProjectId = projectId; } var isOriginator = ClientCookie.UserCode == info.PMAccount; consInfo.IsProjectFreezed = consInfo.CheckIfFreezeProject(projectId); var nextRefTableId = new Guid(FlowInfo.GetRefTableId("RenewalTool", projectId)); var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Tool); var haveTask = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Tool && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode); var projectComment = ProjectComment.GetSavedComment(consInfo.Id, "RenewalConsInfo", ClientCookie.UserCode); if (string.IsNullOrEmpty(id)) { consInfo.HasReinvenstment = info.NeedProjectCostEst; } ConsInfoDTO <RenewalInfo, RenewalConsInfo> dto = new ConsInfoDTO <RenewalInfo, RenewalConsInfo>(); dto.Entity = consInfo; dto.Info = info; dto.ReinBasicInfo = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id); dto.ReinCost = ReinvestmentCost.GetByConsInfoId(consInfo.Id); dto.WriteOff = WriteOffAmount.GetByConsInfoId(consInfo.Id); dto.ProjectComment = projectComment != null ? projectComment.Content : ""; dto.Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_ConsInfo); dto.Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_ConsInfo); dto.Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_ConsInfo) && string.IsNullOrEmpty(id); return(dto); }
public override void Finish(TaskWorkStatus status, TaskWork task) { var info = RenewalInfo.Get(ProjectId); switch (status) { case TaskWorkStatus.K2ProcessApproved: ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_LLNegotiation, NodeCode.Finish, ProjectStatus.Finished); if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_Letter)) { ProjectProgress.SetProgress(ProjectId, "30%"); if (info.NeedProjectCostEst) { if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_ConsInfo)) { info.GenerateSubmitTask(FlowCode.Renewal_ConsInfo); } } else { ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_ConsInfo, NodeCode.Finish, ProjectStatus.Finished); if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_Tool)) { info.GenerateSubmitTask(FlowCode.Renewal_Tool); } } } break; case TaskWorkStatus.K2ProcessDeclined: break; } }
public override void Finish(TaskWorkStatus status, TaskWork task) { var info = RenewalInfo.Get(ProjectId); switch (status) { case TaskWorkStatus.K2ProcessApproved: ProjectProgress.SetProgress(ProjectId, "70%"); ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_ConfirmLetter, NodeCode.Finish, ProjectStatus.Finished); if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_LegalApproval)) { info.GenerateSubmitTask(FlowCode.Renewal_LegalApproval); } break; case TaskWorkStatus.K2ProcessDeclined: break; } }
/// <summary> /// Edit准备 /// </summary> /// <param name="projectId"></param> /// <returns></returns> public bool PreEdit(string projectId) { //如果流程已经到了ClosurePackage审批环节就不能Edit if (ProjectInfo.IsFlowStarted(projectId, FlowCode.Closure_ClosurePackage)) { return(false); } else { #region Package撤回 var needWidthDraw = TaskWork.Count(i => i.TypeCode == FlowCode.Closure_ClosurePackage && i.RefID == projectId && i.Status == TaskWorkStatus.UnFinish) > 0; if (needWidthDraw) { //任务取消 var taskList = TaskWork.Search(i => i.TypeCode == FlowCode.Closure_ClosurePackage && i.RefID == projectId && i.Status != TaskWorkStatus.Cancel).ToArray(); foreach (var taskItem in taskList) { taskItem.Status = TaskWorkStatus.Cancel; } if (taskList.Length > 0) { TaskWork.Update(taskList); } //Package数据isHistory置成true var package = ClosurePackage.Search(i => i.ProjectId == projectId && i.IsHistory == false).ToArray(); foreach (var pacItem in package) { pacItem.IsHistory = true; pacItem.LastUpdateTime = DateTime.Now; pacItem.LastUpdateUserAccount = ClientCookie.UserCode; } if (package.Length > 0) { ClosurePackage.Update(package); } } #endregion return(true); } }
public static RenewalLegalApprovalDTO InitPage(string projectId, string id = null) { RenewalLegalApprovalDTO dto = new RenewalLegalApprovalDTO(); var entity = Get(projectId, id); var info = RenewalInfo.Get(projectId); var isActor = ClientCookie.UserCode == info.AssetActorAccount; entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId); var nextRefTableId = new Guid(FlowInfo.GetRefTableId(entity.TableName, projectId)); var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package); var haveTask = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_LegalApproval && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode); var projectComment = ProjectComment.GetSavedComment(entity.Id, entity.TableName, ClientCookie.UserCode); var appUser = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString()); dto.Info = info; dto.Entity = entity; dto.ProjectComment = projectComment != null ? projectComment.Content : ""; dto.IsGeneralCounsel = appUser != null && appUser.GeneralCounselCode == ClientCookie.UserCode; dto.Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_LegalApproval); dto.Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_LegalApproval); dto.Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_LegalApproval) && string.IsNullOrEmpty(id); return(dto); }
public override void Finish(TaskWorkStatus status, TaskWork task) { switch (status) { case TaskWorkStatus.K2ProcessApproved: { ProjectInfo.FinishNode(ProjectId, this.WorkflowCode, NodeCode.Finish); ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_LLNegotiation, NodeCode.Renewal_LLNegotiation_ConfirmLetter); if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_ConsInfo)) { var info = RenewalInfo.Get(task.RefID); if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_LLNegotiation)) { ProjectProgress.SetProgress(ProjectId, "30%"); if (info.NeedProjectCostEst) { if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_ConsInfo)) { info.GenerateSubmitTask(FlowCode.Renewal_ConsInfo); } } else { ProjectInfo.FinishNode(ProjectId, FlowCode.Renewal_ConsInfo, NodeCode.Finish, ProjectStatus.Finished); if (!ProjectInfo.IsFlowStarted(ProjectId, FlowCode.Renewal_Tool)) { info.GenerateSubmitTask(FlowCode.Renewal_Tool); } } } } TaskWork.Finish(t => t.TypeCode == this.WorkflowCode && t.RefID == this.ProjectId && t.Status == TaskWorkStatus.UnFinish); } break; } }
public static RenewalToolDTO InitPage(string projectId, string id = null) { RenewalToolDTO dto = new RenewalToolDTO(); var tool = RenewalTool.Get(projectId, id); var project = ProjectInfo.Get(projectId, FlowCode.Renewal_Tool); var info = RenewalInfo.Get(projectId); var isFinance = ClientCookie.UserCode == info.FinanceAccount; tool.IsProjectFreezed = tool.CheckIfFreezeProject(projectId); var nextRefTableId = new Guid(FlowInfo.GetRefTableId("RenewalAnalysis", projectId)); var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Analysis); var haveTask = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Tool && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode); var projectComment = ProjectComment.GetSavedComment(tool.Id, "RenewalTool", ClientCookie.UserCode); var projectNode = NodeInfo.GetNodeInfo(project.NodeCode); var packageStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package); string selectedYearMonth = null; dto.Info = info; dto.Entity = tool; dto.TTMDataYearMonths = RenewalToolFinMeasureInput.GetYearMonths(projectId, out selectedYearMonth); dto.FinMeasureInput = RenewalToolFinMeasureInput.Get(projectId, dto.Entity.Id); if (string.IsNullOrEmpty(dto.FinMeasureInput.FinanceYear) || string.IsNullOrEmpty(dto.FinMeasureInput.FinanceMonth)) { var ym = selectedYearMonth.Split('-'); dto.FinMeasureInput.FinanceYear = ym[0]; dto.FinMeasureInput.FinanceMonth = ym[1]; } dto.FinMeasureInput.FinanceDataYearMonth = dto.FinMeasureInput.FinanceYear + "-" + dto.FinMeasureInput.FinanceMonth; //dto.FinMeasureInput.ContributionMargin = StoreCM.Get(dto.Info.USCode).ContributionMargin; McdAMEntities amdb = new McdAMEntities(); var finfo = amdb.DataSync_LDW_AM_STFinanceData2.FirstOrDefault(f => f.UsCode == dto.Info.USCode && f.FinanceYear == dto.FinMeasureInput.FinanceYear && f.FinanceMonth == dto.FinMeasureInput.FinanceMonth); decimal cm = 0; if (finfo != null && !string.IsNullOrEmpty(finfo.contribution_marginPct)) { cm = decimal.Parse(finfo.contribution_marginPct); } dto.FinMeasureInput.ContributionMargin = cm; var coninfo = RenewalConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory); var conProj = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId && e.FlowCode == "Renewal_ConsInfo"); dto.WriteOffAndReinCost = RenewalToolWriteOffAndReinCost.Get(projectId, dto.Entity.Id, projectNode); if (coninfo != null && !coninfo.HasReinvenstment) { dto.WriteOffAndReinCost.REWriteOff = null; dto.WriteOffAndReinCost.LHIWriteOff = null; dto.WriteOffAndReinCost.ESSDWriteOff = null; dto.WriteOffAndReinCost.ESSDWriteOff = null; dto.WriteOffAndReinCost.RECost = null; dto.WriteOffAndReinCost.LHICost = null; dto.WriteOffAndReinCost.ESSDCost = null; } dto.Uploadable = projectNode.Sequence >= 3 && ClientCookie.UserCode == dto.Info.AssetActorAccount && !packageStarted; dto.ProjectComment = projectComment != null ? projectComment.Content : ""; dto.Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Tool); dto.Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Tool); dto.Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Tool) && string.IsNullOrEmpty(id); dto.IsFinished = ProjectInfo.Any( e => e.ProjectId == projectId && e.FlowCode == FlowCode.Renewal_Tool && e.Status == ProjectStatus.Finished); return(dto); }