Exemple #1
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();
            }
        }
Exemple #2
0
        private bool CheckIfNeedCDOApproval()
        {
            var analysis = RenewalAnalysis.Get(this.AnalysisId.Value);

            return(analysis.RentDeviation.HasValue ? Math.Abs(analysis.RentDeviation.Value * 100) > 10 : false);
        }
Exemple #3
0
        public void UpdateFromProjectList()
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var oldInfo  = RenewalInfo.Get(this.ProjectId);
                var consInfo = RenewalConsInfo.Get(this.ProjectId);
                var analysis = RenewalAnalysis.Get(this.ProjectId);
                analysis.LeaseTenureAndTerm = string.Format("{0} years,from {1:yyyy-MM-dd} to {2:yyyy-MM-dd}", this.RenewalYears, this.NewLeaseStartDate, this.NewLeaseEndDate);
                analysis.Update();
                if (oldInfo.NeedProjectCostEst != this.NeedProjectCostEst)
                {
                    consInfo.HasReinvenstment = this.NeedProjectCostEst;
                    consInfo.Update();
                    if (ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Letter) &&
                        ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_LLNegotiation))
                    {
                        if (!this.NeedProjectCostEst)
                        {
                            TaskWork.Cancel(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_ConsInfo);
                            ProjectInfo.FinishProject(this.ProjectId, FlowCode.Renewal_ConsInfo);
                            if (!ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Tool))
                            {
                                if (!TaskWork.Any(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_Tool))
                                {
                                    GenerateSubmitTask(FlowCode.Renewal_Tool);
                                }
                            }
                        }
                        else
                        {
                            ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_ConsInfo);

                            GenerateSubmitTask(FlowCode.Renewal_ConsInfo);
                            if (!ProjectInfo.IsFlowFinished(this.ProjectId, FlowCode.Renewal_Tool))
                            {
                                TaskWork.Cancel(e => e.RefID == this.ProjectId && e.TypeCode == FlowCode.Renewal_Tool && e.Status == TaskWorkStatus.UnFinish);
                                ProjectInfo.Reset(this.ProjectId, FlowCode.Renewal_Tool);
                            }
                        }
                    }
                }

                if (oldInfo.RenewalYears != this.RenewalYears)
                {
                    if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_Analysis))
                    {
                        if (this.RenewalYears <= 2)
                        {
                            TaskWork.Finish(e => e.RefID == this.ProjectId && e.Status == TaskWorkStatus.UnFinish && e.TypeCode == FlowCode.Renewal_ClearanceReport);
                            ProjectInfo.FinishProject(this.ProjectId, FlowCode.Renewal_ClearanceReport);
                        }
                        else
                        {
                            if (!TaskWork.Any(e => e.RefID == ProjectId && e.TypeCode == FlowCode.Renewal_ClearanceReport && e.Status == TaskWorkStatus.UnFinish))
                            {
                                GenerateSubmitTask(FlowCode.Renewal_ClearanceReport);
                            }
                        }
                    }
                }
                this.Update();
                tranScope.Complete();
            }
        }