示例#1
0
        public override string Edit()
        {
            var info     = RenewalInfo.Get(ProjectId);
            var analysis = Duplicator.AutoCopy(this);

            analysis.Id        = Guid.NewGuid();
            analysis.IsHistory = false;
            analysis.Add();
            this.IsHistory = true;
            this.Update();
            ProjectInfo.Reset(ProjectId, this.WorkflowCode);
            RenewalPackage package = RenewalPackage.Get(ProjectId);

            package.AnalysisId = analysis.Id;
            package.Update();
            TaskWork.Cancel(e => e.TypeCode == FlowCode.Renewal_Analysis && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish);
            var task = info.GenerateSubmitTask(FlowCode.Renewal_Analysis);

            return(task.Url);
        }
示例#2
0
        public override string Edit()
        {
            string url;

            using (var tranScope = new TransactionScope())
            {
                var info = RenewalInfo.Get(this.ProjectId);
                var tool = Duplicator.AutoCopy(this);
                tool.Id                = Guid.NewGuid();
                tool.IsHistory         = false;
                tool.CreateTime        = DateTime.Now;
                tool.CreateUserAccount = ClientCookie.UserCode;
                tool.Add();

                NewEntityId = tool.Id;
                IsHistory   = true;
                this.Update();
                ProjectInfo.Reset(ProjectId, this.WorkflowCode);
                var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty);
                attachments.ForEach(att =>
                {
                    att.RefTableID = tool.Id.ToString();
                    att.ID         = Guid.NewGuid();
                });
                Attachment.Add(attachments.ToArray());

                var FinMI    = RenewalToolFinMeasureInput.Get(this.ProjectId, this.Id);
                var newFinMI = Duplicator.AutoCopy(FinMI);
                newFinMI.Id     = Guid.NewGuid();
                newFinMI.ToolId = tool.Id;
                newFinMI.Add();

                var WfRc    = RenewalToolWriteOffAndReinCost.Get(this.ProjectId, this.Id);
                var newWfRc = Duplicator.AutoCopy(WfRc);
                newWfRc.Id     = Guid.NewGuid();
                newWfRc.ToolId = tool.Id;
                newWfRc.Add();

                var FinMO    = RenewalToolFinMeasureOutput.GetByToolId(this.Id);
                var newFinMO = Duplicator.AutoCopy(FinMO);
                newFinMO.Id     = Guid.NewGuid();
                newFinMO.ToolId = tool.Id;
                newFinMO.Add();

                var package = RenewalPackage.Get(this.ProjectId);
                package.ToolId = tool.Id;
                package.Update();

                var oldTasks = TaskWork.Search(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && new string[] { this.WorkflowCode, FlowCode.Renewal_Analysis }.Contains(t.TypeCode)).ToList();
                oldTasks.ForEach(t =>
                {
                    t.Status = TaskWorkStatus.Cancel;
                });
                TaskWork.Update(oldTasks.ToArray());

                var anlysisProj = ProjectInfo.FirstOrDefault(e => e.FlowCode == FlowCode.Renewal_Analysis &&
                                                             e.Status == ProjectStatus.UnFinish && e.ProjectId == ProjectId);
                if (anlysisProj != null)
                {
                    var taskAnlysis = TaskWork.FirstOrDefault(e => e.TypeCode == FlowCode.Renewal_Analysis && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish);
                    if (taskAnlysis != null)
                    {
                        taskAnlysis.Status     = TaskWorkStatus.Finished;
                        taskAnlysis.FinishTime = DateTime.Now;
                        taskAnlysis.Update();
                    }
                }
                var task = info.GenerateSubmitTask(this.WorkflowCode);
                url = task.Url;
                tranScope.Complete();
            }

            return(url);
        }
示例#3
0
        public static void Create(PostCreateWorkflow <RenewalInfo> postCreateRenewal)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var usCode    = postCreateRenewal.Entity.USCode;
                var store     = StoreBasicInfo.GetStorInfo(usCode);
                var projectId = ProjectInfo.CreateMainProject(FlowCode.Renewal, usCode, NodeCode.Start, ClientCookie.UserCode);
                postCreateRenewal.Entity.Id = Guid.NewGuid();
                postCreateRenewal.Entity.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Entity.CreateTime        = DateTime.Now;
                postCreateRenewal.Entity.StoreNameENUS     = store.NameENUS;
                postCreateRenewal.Entity.StoreNameZHCN     = store.NameZHCN;

                postCreateRenewal.Entity.AssetRepAccount  = postCreateRenewal.Team.AssetRep.UserAccount;
                postCreateRenewal.Entity.AssetRepNameENUS = postCreateRenewal.Team.AssetRep.UserNameENUS;
                postCreateRenewal.Entity.AssetRepNameZHCN = postCreateRenewal.Team.AssetRep.UserNameZHCN;

                postCreateRenewal.Entity.AssetActorAccount  = postCreateRenewal.Team.AssetActor.UserAccount;
                postCreateRenewal.Entity.AssetActorNameENUS = postCreateRenewal.Team.AssetActor.UserNameENUS;
                postCreateRenewal.Entity.AssetActorNameZHCN = postCreateRenewal.Team.AssetActor.UserNameZHCN;

                postCreateRenewal.Entity.FinanceAccount  = postCreateRenewal.Team.Finance.UserAccount;
                postCreateRenewal.Entity.FinanceNameENUS = postCreateRenewal.Team.Finance.UserNameENUS;
                postCreateRenewal.Entity.FinanceNameZHCN = postCreateRenewal.Team.Finance.UserNameZHCN;

                postCreateRenewal.Entity.PMAccount  = postCreateRenewal.Team.PM.UserAccount;
                postCreateRenewal.Entity.PMNameENUS = postCreateRenewal.Team.PM.UserNameENUS;
                postCreateRenewal.Entity.PMNameZHCN = postCreateRenewal.Team.PM.UserNameZHCN;

                postCreateRenewal.Entity.LegalAccount  = postCreateRenewal.Team.Legal.UserAccount;
                postCreateRenewal.Entity.LegalNameENUS = postCreateRenewal.Team.Legal.UserNameENUS;
                postCreateRenewal.Entity.LegalNameZHCN = postCreateRenewal.Team.Legal.UserNameZHCN;

                postCreateRenewal.Entity.AssetManagerAccount  = postCreateRenewal.Team.AssetMgr.UserAccount;
                postCreateRenewal.Entity.AssetManagerNameENUS = postCreateRenewal.Team.AssetMgr.UserNameENUS;
                postCreateRenewal.Entity.AssetManagerNameZHCN = postCreateRenewal.Team.AssetMgr.UserNameZHCN;

                postCreateRenewal.Entity.CMAccount  = postCreateRenewal.Team.CM.UserAccount;
                postCreateRenewal.Entity.CMNameENUS = postCreateRenewal.Team.CM.UserNameENUS;
                postCreateRenewal.Entity.CMNameZHCN = postCreateRenewal.Team.CM.UserNameZHCN;

                postCreateRenewal.Entity.ProjectId = projectId;
                postCreateRenewal.Entity.Add();
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Letter, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLetter.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_LLNegotiation, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLLNegotiation.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ConsInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);
                RenewalConsInfo.Create(projectId, postCreateRenewal.Team.PM.UserAccount, postCreateRenewal.Entity.NeedProjectCostEst);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Tool, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.Finance.UserAccount);
                var tool = RenewalTool.Create(projectId, postCreateRenewal.Team.Finance.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ClearanceReport, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalClearanceReport.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ConfirmLetter, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalConfirmLetter.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Analysis, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                var analysis = RenewalAnalysis.Create(postCreateRenewal.Entity);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_LegalApproval, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalLegalApproval.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_Package, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalPackage.Create(projectId, postCreateRenewal.Team.AssetActor.UserAccount, analysis.Id, tool.Id);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_ContractInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.AssetActor.UserAccount);
                RenewalContractInfo.Create(projectId);
                ProjectInfo.CreateSubProject(FlowCode.Renewal_SiteInfo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);
                RenewalSiteInfo.Create(projectId, postCreateRenewal.Team.PM.UserAccount);

                ProjectInfo.CreateSubProject(FlowCode.Renewal_GBMemo, projectId, usCode, NodeCode.Start, postCreateRenewal.Team.PM.UserAccount);

                List <ProjectUsers> projectUsers = new List <ProjectUsers>();

                postCreateRenewal.Team.AssetRep.Id                = Guid.NewGuid();
                postCreateRenewal.Team.AssetRep.ProjectId         = projectId;
                postCreateRenewal.Team.AssetRep.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.AssetRep.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.AssetRep.RoleCode          = ProjectUserRoleCode.AssetRep;
                postCreateRenewal.Team.AssetRep.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetRep, SystemLanguage.ENUS);
                postCreateRenewal.Team.AssetRep.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetRep, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.AssetRep);

                postCreateRenewal.Team.AssetActor.Id                = Guid.NewGuid();
                postCreateRenewal.Team.AssetActor.ProjectId         = projectId;
                postCreateRenewal.Team.AssetActor.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.AssetActor.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.AssetActor.RoleCode          = ProjectUserRoleCode.AssetActor;
                postCreateRenewal.Team.AssetActor.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetActor, SystemLanguage.ENUS);
                postCreateRenewal.Team.AssetActor.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetActor, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.AssetActor);

                postCreateRenewal.Team.Finance.Id                = Guid.NewGuid();
                postCreateRenewal.Team.Finance.ProjectId         = projectId;
                postCreateRenewal.Team.Finance.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.Finance.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.Finance.RoleCode          = ProjectUserRoleCode.Finance;
                postCreateRenewal.Team.Finance.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Finance, SystemLanguage.ENUS);
                postCreateRenewal.Team.Finance.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Finance, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.Finance);

                postCreateRenewal.Team.PM.Id                = Guid.NewGuid();
                postCreateRenewal.Team.PM.ProjectId         = projectId;
                postCreateRenewal.Team.PM.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.PM.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.PM.RoleCode          = ProjectUserRoleCode.PM;
                postCreateRenewal.Team.PM.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.PM, SystemLanguage.ENUS);
                postCreateRenewal.Team.PM.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.PM, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.PM);

                postCreateRenewal.Team.Legal.Id                = Guid.NewGuid();
                postCreateRenewal.Team.Legal.ProjectId         = projectId;
                postCreateRenewal.Team.Legal.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.Legal.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.Legal.RoleCode          = ProjectUserRoleCode.Legal;
                postCreateRenewal.Team.Legal.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Legal, SystemLanguage.ENUS);
                postCreateRenewal.Team.Legal.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.Legal, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.Legal);

                postCreateRenewal.Team.AssetMgr.Id                = Guid.NewGuid();
                postCreateRenewal.Team.AssetMgr.ProjectId         = projectId;
                postCreateRenewal.Team.AssetMgr.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.AssetMgr.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.AssetMgr.RoleCode          = ProjectUserRoleCode.AssetManager;
                postCreateRenewal.Team.AssetMgr.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetManager, SystemLanguage.ENUS);
                postCreateRenewal.Team.AssetMgr.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.AssetManager, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.AssetMgr);

                postCreateRenewal.Team.CM.Id                = Guid.NewGuid();
                postCreateRenewal.Team.CM.ProjectId         = projectId;
                postCreateRenewal.Team.CM.CreateDate        = DateTime.Now;
                postCreateRenewal.Team.CM.CreateUserAccount = ClientCookie.UserCode;
                postCreateRenewal.Team.CM.RoleCode          = ProjectUserRoleCode.CM;
                postCreateRenewal.Team.CM.RoleNameENUS      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.CM, SystemLanguage.ENUS);
                postCreateRenewal.Team.CM.RoleNameZHCN      = SystemCode.Instance.GetCodeName(ProjectUserRoleCode.CM, SystemLanguage.ZHCN);
                projectUsers.Add(postCreateRenewal.Team.CM);

                ProjectUsers.Add(projectUsers.ToArray());

                postCreateRenewal.Viewers.ForEach(v =>
                {
                    v.Id                = Guid.NewGuid();
                    v.ProjectId         = projectId;
                    v.CreateDate        = DateTime.Now;
                    v.CreateUserAccount = ClientCookie.UserCode;
                    v.RoleCode          = ProjectUserRoleCode.View;
                });
                ProjectUsers.Add(postCreateRenewal.Viewers.ToArray());
                //postCreateRenewal.NecessaryViewers.ForEach(v =>
                //{
                //    v.Id = Guid.NewGuid();
                //    v.ProjectId = projectId;
                //    v.CreateDate = DateTime.Now;
                //    v.CreateUserAccount = ClientCookie.UserCode;
                //    v.RoleCode = ProjectUserRoleCode.View;
                //});
                //ProjectUsers.Add(postCreateRenewal.NecessaryViewers.ToArray());
                Remind.SendRemind(projectId, FlowCode.Renewal, projectUsers);
                Remind.SendRemind(projectId, FlowCode.Renewal, postCreateRenewal.Viewers);
                postCreateRenewal.Entity.GenerateSubmitTask(FlowCode.Renewal_Letter);
                postCreateRenewal.Entity.GenerateSubmitTask(FlowCode.Renewal_LLNegotiation);
                postCreateRenewal.Entity.CreateAttachmentsMemo();
                ProjectNode.GenerateOnCreate(FlowCode.Renewal, projectId);
                ProjectProgress.SetProgress(projectId, "10%");
                tranScope.Complete();
            }
        }