Exemple #1
0
        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;
            }
        }
Exemple #2
0
        public override void PrepareTask(TaskWork taskWork)
        {
            var info = RenewalInfo.Get(ProjectId);

            if (taskWork.ReceiverAccount == info.AssetActorAccount && taskWork.ActivityName == "AssetActor")
            {
                ProjectInfo.FinishNode(ProjectId, this.WorkflowCode, NodeCode.Renewal_Tool_Approval);
                if (!ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_ConsInfo))
                {
                    taskWork.Cancel();
                }
            }
        }
Exemple #3
0
 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;
     }
 }
Exemple #4
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();
            }
        }
Exemple #5
0
        public void Submit(List <ProjectContractRevision> revisions, string flowCode)
        {
            revisions = revisions ?? new List <ProjectContractRevision>();
            using (TransactionScope tranScope = new TransactionScope())
            {
                StoreContractInfo       contractInfo = this.ToStoreContractInfo();
                ProjectContractRevision reInfo       = new ProjectContractRevision();
                #region 初始化项目的Revision信息
                reInfo.Id        = Guid.NewGuid();
                reInfo.ProjectId = this.ProjectId;
                Guid srId = Guid.NewGuid();
                reInfo.ProjectContractId   = this.Id;
                reInfo.RevisionId          = srId;
                reInfo.StoreContractInfoId = contractInfo.Id;
                reInfo.StoreID             = this.StoreId;
                reInfo.StoreCode           = this.StoreCode;
                reInfo.LeaseRecapID        = this.LeaseRecapID;
                reInfo.ChangeDate          = DateTime.Now;
                if (flowCode == FlowCode.MajorLease_ContractInfo)
                {
                    MajorLeaseInfo info = MajorLeaseInfo.Search(e => e.ProjectId == ProjectId).FirstOrDefault();
                    reInfo.Rent                 = info.ChangeRentalType.HasValue && info.ChangeRentalType.Value ? "Y" : null;
                    reInfo.Size                 = info.ChangeRedLineType.HasValue && info.ChangeRedLineType.Value ? "Y" : null;
                    reInfo.LeaseTerm            = info.ChangeLeaseTermType.HasValue && info.ChangeLeaseTermType.Value ? "Y" : null;
                    reInfo.Entity               = info.ChangeLandlordType.HasValue && info.ChangeLandlordType.Value ? "Y" : null;
                    reInfo.Others               = info.ChangeOtherType.HasValue && info.ChangeOtherType.Value ? "Y" : null;
                    reInfo.RentStructureOld     = info.OldRentalStructure;
                    reInfo.RentStructureNew     = info.NewRentalStructure;
                    reInfo.RedlineAreaOld       = info.OldChangeRedLineRedLineArea.HasValue ? info.OldChangeRedLineRedLineArea.ToString() : null;
                    reInfo.RedlineAreaNew       = info.NewChangeRedLineRedLineArea.HasValue ? info.NewChangeRedLineRedLineArea.ToString() : null;
                    reInfo.LeaseChangeExpiryOld = info.OldChangeLeaseTermExpiraryDate;
                    reInfo.LeaseChangeExpiryNew = info.NewChangeLeaseTermExpiraryDate;
                    reInfo.LandlordOld          = info.OldLandlord;
                    reInfo.LandlordNew          = info.NewLandlord;
                    reInfo.OthersDescription    = info.Others;
                    reInfo.Description          = info.LeaseChangeDescription;
                }
                else if (flowCode == FlowCode.Rebuild_ContractInfo)
                {
                    RebuildPackage info = RebuildPackage.GetRebuildPackageInfo(ProjectId);
                    reInfo.Rent                 = info.ChangeRentalType.HasValue && info.ChangeRentalType.Value ? "Y" : null;
                    reInfo.Size                 = info.ChangeRedLineType.HasValue && info.ChangeRedLineType.Value ? "Y" : null;
                    reInfo.LeaseTerm            = info.ChangeLeaseTermType.HasValue && info.ChangeLeaseTermType.Value ? "Y" : null;
                    reInfo.Entity               = info.ChangeLandlordType.HasValue && info.ChangeLandlordType.Value ? "Y" : null;
                    reInfo.Others               = info.ChangeOtherType.HasValue && info.ChangeOtherType.Value ? "Y" : null;
                    reInfo.RentStructureOld     = info.OldRentalStructure;
                    reInfo.RentStructureNew     = info.NewRentalStructure;
                    reInfo.RedlineAreaOld       = info.OldChangeRedLineRedLineArea.HasValue ? info.OldChangeRedLineRedLineArea.ToString() : null;
                    reInfo.RedlineAreaNew       = info.NewChangeRedLineRedLineArea.HasValue ? info.NewChangeRedLineRedLineArea.ToString() : null;
                    reInfo.LeaseChangeExpiryOld = info.OldChangeLeaseTermExpiraryDate;
                    reInfo.LeaseChangeExpiryNew = info.NewChangeLeaseTermExpiraryDate;
                    reInfo.LandlordOld          = info.OldLandlord;
                    reInfo.LandlordNew          = info.NewLandlord;
                    reInfo.OthersDescription    = info.Others;
                    reInfo.Description          = info.LeaseChangeDescription;
                }
                #endregion
                if (this.EditMode == "EDIT")
                {
                    if (flowCode == FlowCode.Closure_ContractInfo)
                    {
                        revisions = revisions.OrderBy(r => r.ChangeDate).ToList();
                        revisions.ForEach(r =>
                        {
                            var sr = r.ToStoreContractRevision();
                            sr.Save();
                            r.RevisionId = sr.Id;
                            //回写到ContractInfo中
                            if (sr.Rent == "Y")
                            {
                                this.RentStructure = sr.RentStructureNew;
                            }
                            if (sr.Size == "Y")
                            {
                                this.TotalLeasedArea = sr.RedlineAreaNew;
                            }
                            if (sr.LeaseTerm == "Y")
                            {
                                this.EndDate = sr.LeaseChangeExpiryNew;
                            }
                            if (sr.Entity == "Y")
                            {
                                this.PartyAFullName = sr.LandlordNew;
                            }
                        });
                        contractInfo = this.ToStoreContractInfo();
                        var sRIds = revisions.Select(e => e.RevisionId).ToList();
                        StoreContractRevision.Delete(e => e.StoreContractInfoId == contractInfo.Id && !sRIds.Contains(e.Id));
                        this.Save(revisions);
                    }
                    else
                    {
                        this.Save();
                        reInfo.Save();
                        var sr = reInfo.ToStoreContractRevision();
                        sr.Id = srId;
                        sr.Save();
                    }
                    contractInfo.Update();
                }
                else
                {
                    contractInfo.Id          = Guid.NewGuid();
                    contractInfo.CreatedTime = DateTime.Now;
                    contractInfo.Add();
                    this.ContractInfoId = contractInfo.Id;
                    if (Any(e => e.Id == this.Id))
                    {
                        this.Update();
                    }
                    else
                    {
                        this.Add();
                    }
                    //新增时不需要带入修订信息
                    ProjectContractRevision.Delete(r => r.ProjectContractId == this.Id);
                    //if (flowCode != FlowCode.Renewal_ContractInfo)
                    //{
                    //    reInfo.StoreContractInfoId = contractInfo.Id;
                    //    reInfo.Save();
                    //    var sr = reInfo.ToStoreContractRevision();
                    //    sr.Id = srId;
                    //    sr.Save();
                    //}
                }
                //关闭任务
                var task = TaskWork.FirstOrDefault(e => e.ReceiverAccount == ClientCookie.UserCode &&
                                                   e.TypeCode.Contains("ContractInfo") && e.RefID == this.ProjectId);
                if (task != null)
                {
                    task.Finish();
                }
                var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == this.ProjectId && e.FlowCode.Contains("ContractInfo"));
                ProjectInfo.FinishNode(this.ProjectId, projectInfo.FlowCode, NodeCode.Finish, ProjectStatus.Finished);
                ProjectInfo.CompleteMainIfEnable(this.ProjectId);
                if (projectInfo.FlowCode == FlowCode.Renewal_ContractInfo)
                {
                    if (ProjectInfo.IsFlowFinished(ProjectId, FlowCode.Renewal_SiteInfo))
                    {
                        ProjectProgress.SetProgress(ProjectId, "100%");
                    }
                }

                tranScope.Complete();
            }
        }