예제 #1
0
        public void GenerateConsInvtCheckingTask(bool isScheduled = false)
        {
            if (CheckIfNeedGenerateConsInvtCheckingTask())
            {
                var taskUrl        = string.Format("/MajorLease/Main#/ConsInvtChecking?projectId={0}", ProjectId);
                var majorLeaseInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).AsNoTracking().FirstOrDefault();
                if (majorLeaseInfo == null)
                {
                    throw new Exception("Could not find the Major Lease Info, please check it!");
                }
                var task = majorLeaseInfo.GenerateTaskWork(WorkflowCode, WorkflowCode, WorkflowCode, taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                task.CreateTime   = DateTime.Now;

                if (!isScheduled)
                {
                    TaskWork.Add(task);
                }
                else
                {
                    var consInfoRepos = new MajorLeaseConsInfo();
                    var consInfo      = consInfoRepos.GetConsInfo(ProjectId);
                    //到达Cons Info中的工程完工时间后60天 发出任务
                    if (consInfo.ReinBasicInfo != null &&
                        consInfo.ReinBasicInfo.ConsCompletionDate.HasValue)
                    {
                        ScheduleLog.GenerateTaskSchedule(consInfo.ReinBasicInfo.ConsCompletionDate.Value.AddDays(60), task, ClientCookie.UserCode, ProjectId, WorkflowCode, majorLeaseInfo.USCode);
                    }
                }
            }
        }
예제 #2
0
        public override void GenerateDefaultWorkflowInfo(string projectId)
        {
            var entity = new MajorLeaseConsInfo();

            entity.ProjectId          = projectId;
            entity.Id                 = Guid.NewGuid();
            entity.CreateTime         = DateTime.Now;
            entity.CreateUserAccount  = ClientCookie.UserCode;
            entity.CreateUserNameENUS = ClientCookie.UserNameENUS;
            entity.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
            entity.IsHistory          = false;

            var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId == projectId);

            if (majorLeaseInfo != null)
            {
                entity.ReinBasicInfo = new ReinvestmentBasicInfo
                {
                    GBDate     = majorLeaseInfo.GBDate,
                    ReopenDate = majorLeaseInfo.ReopenDate
                };
                ReinvenstmentType = 1;
            }
            Add(entity);
        }
예제 #3
0
        public override string Edit()
        {
            var taskUrl = string.Format("/MajorLease/Main#/GBMemo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var rbdInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
                if (rbdInfo == null)
                {
                    throw new Exception("Could not find the Rebuild Info, please check it!");
                }
                var task = rbdInfo.GenerateTaskWork(WorkflowCode, "MajorLease GBMemo", "MajorLease GBMemo", taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);
                CompleteNotifyTask(ProjectId);
                AttachmentsMemoProcessInfo.UpdateNotifyDate(ProjectId, FlowCode.GBMemo, false);
                IsHistory = true;
                Update(this);

                Mapper.CreateMap <MajorLeaseGBMemo, MajorLeaseGBMemo>();
                var entity = Mapper.Map <MajorLeaseGBMemo>(this);
                entity.Id         = Guid.Empty;
                entity.ProcInstID = null;
                entity.IsHistory  = false;
                entity.Comments   = null;
                entity.Save("Edit");

                CopyAppUsers(Id.ToString(), entity.Id.ToString());

                scope.Complete();
            }
            return(taskUrl);
        }
예제 #4
0
        public override string Edit()
        {
            var taskUrl = string.Format("/MajorLease/Main#/LegalReview?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var majorLeaseInfo = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
                if (majorLeaseInfo == null)
                {
                    throw new Exception("Could not find the Major Lease Info, please check it!");
                }
                TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == this.WorkflowCode);//取消老的流程实例的所有未完成任务
                var task = majorLeaseInfo.GenerateTaskWork(WorkflowCode,
                                                           "LegalReview",
                                                           "LegalReview",
                                                           taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);

                var package = MajorLeaseChangePackage.GetMajorPackageInfo(ProjectId);
                if (package != null)
                {
                    package.ProjectId = ProjectId;
                    package.CompleteActorPackageTask(majorLeaseInfo.AssetActorAccount);
                }
                IsHistory = true;
                Update(this);
                var attachments = Attachment.Search(e => e.RefTableID == Id.ToString() &&
                                                    e.RefTableName == WFMajorLeaseLegalReview.TableName).ToList();

                ProjectInfo.Reset(ProjectId, WorkflowCode);


                Mapper.CreateMap <MajorLeaseLegalReview, MajorLeaseLegalReview>();
                var newMajorLeaseLR = Mapper.Map <MajorLeaseLegalReview>(this);
                newMajorLeaseLR.Id         = Guid.Empty;
                newMajorLeaseLR.ProcInstID = null;
                newMajorLeaseLR.IsHistory  = false;
                newMajorLeaseLR.Comments   = null;
                newMajorLeaseLR.Save();

                var newAttachmentList = new List <Attachment>();
                Mapper.CreateMap <Attachment, Attachment>();
                foreach (var attachment in attachments)
                {
                    var newAttachment = Mapper.Map <Attachment>(attachment);
                    newAttachment.RefTableID = newMajorLeaseLR.Id.ToString();
                    newAttachment.ID         = Guid.NewGuid();
                    newAttachmentList.Add(newAttachment);
                }
                Attachment.Add(newAttachmentList.ToArray());
                scope.Complete();
            }

            return(taskUrl);
        }
예제 #5
0
        public override string Edit()
        {
            var taskUrl = string.Format("/MajorLease/Main#/ConsInfo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));
                if (majorLeaseInfo == null)
                {
                    throw new Exception("Could not find the Major Lease Info, please check it!");
                }
                var task = majorLeaseInfo.GenerateTaskWork(FlowCode.MajorLease_ConsInfo,
                                                           "ConsInfo",
                                                           "ConsInfo",
                                                           taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);

                var package = MajorLeaseChangePackage.GetMajorPackageInfo(ProjectId);
                if (package != null)
                {
                    package.ProjectId = ProjectId;
                    package.CompleteActorPackageTask(majorLeaseInfo.AssetActorAccount);
                }

                IsHistory = true;
                Update(this);
                var attachments = Attachment.Search(e => e.RefTableID == Id.ToString() &&
                                                    e.RefTableName == WFMajorLeaseConsInfo.TableName).AsNoTracking().ToList();

                ProjectInfo.Reset(ProjectId, FlowCode.MajorLease_ConsInfo);

                Mapper.CreateMap <MajorLeaseConsInfo, MajorLeaseConsInfo>();
                var form = Mapper.Map <MajorLeaseConsInfo>(this);
                form.Id         = Guid.Empty;
                form.ProcInstID = null;
                form.IsHistory  = false;
                form.Comments   = null;
                form.Save("Edit");

                var newAttachmentList = new List <Attachment>();
                Mapper.CreateMap <Attachment, Attachment>();
                foreach (var attachment in attachments)
                {
                    var newAttachment = Mapper.Map <Attachment>(attachment);
                    newAttachment.RefTableID = form.Id.ToString();
                    newAttachment.ID         = Guid.NewGuid();
                    newAttachmentList.Add(newAttachment);
                }
                Attachment.Add(newAttachmentList.ToArray());
                scope.Complete();
            }

            return(taskUrl);
        }
예제 #6
0
        public MajorLeaseConsInfo GetConsInfo(string strProjectId, string entityId = "")
        {
            MajorLeaseConsInfo entity = null;
            var majorLeaseInfo        = MajorLeaseInfo.Search(e => e.ProjectId == strProjectId).FirstOrDefault();

            if (string.IsNullOrEmpty(entityId))
            {
                entity = Search(e => e.ProjectId.Equals(strProjectId) && !e.IsHistory).FirstOrDefault();
            }
            else
            {
                entity = Search(e => e.Id.ToString().Equals(entityId)).FirstOrDefault();
            }

            if (entity != null)
            {
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
                entity.ReinCost         = ReinvestmentCost.GetByConsInfoId(entity.Id);
                entity.ReinBasicInfo    = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id);
                if (entity.ReinBasicInfo == null)
                {
                    entity.ReinBasicInfo = new ReinvestmentBasicInfo
                    {
                        GBDate     = majorLeaseInfo.GBDate,
                        ReopenDate = majorLeaseInfo.ReopenDate
                    };
                }
                entity.WriteOff = WriteOffAmount.GetByConsInfoId(entity.Id);

                entity.IsShowEdit   = ProjectInfo.IsFlowEditable(strProjectId, WorkflowCode);
                entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, WorkflowCode);
            }
            else
            {
                if (majorLeaseInfo != null)
                {
                    entity = new MajorLeaseConsInfo
                    {
                        ReinBasicInfo =
                            new ReinvestmentBasicInfo
                        {
                            GBDate     = majorLeaseInfo.GBDate,
                            ReopenDate = majorLeaseInfo.ReopenDate
                        },
                        IsProjectFreezed  = CheckIfFreezeProject(strProjectId),
                        ReinvenstmentType = 1
                    };
                }
            }
            entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.MajorLease_ConsInfo);
            PopulateAppUsers(entity);
            return(entity);
        }
예제 #7
0
        private void UpdateMajorLeaseInfo()
        {
            //update GBDate and ReopenDate Info
            var majorleaseInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId == ProjectId);

            if (majorleaseInfo != null &&
                ReinBasicInfo != null)
            {
                majorleaseInfo.GBDate     = ReinBasicInfo.GBDate;
                majorleaseInfo.ReopenDate = ReinBasicInfo.ReopenDate;

                MajorLeaseInfo.Update(majorleaseInfo);
            }
        }
예제 #8
0
        public override ApproveDialogUser GetApproveDialogUser()
        {
            var approvers = ApproveDialogUser.FirstOrDefault(e => e.RefTableID == Id.ToString());

            if (approvers == null)
            {
                approvers = new ApproveDialogUser();
                var majorLeaesInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (majorLeaesInfo != null)
                {
                    approvers.ConstructionManagerCode = majorLeaesInfo.CMAccount;
                }
            }
            return(approvers);
        }
예제 #9
0
        private void PopulateAppUsers(MajorLeaseConsInvtChecking entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                entity.AppUsers.ConstructionManager = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.FMCode
                };
                entity.AppUsers.FM = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.FinanceControllerCode
                };
                entity.AppUsers.FinanceController = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.VPGMCode
                };
                entity.AppUsers.VPGM = simp;
            }
            else
            {
                var majorLeaesInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (majorLeaesInfo != null)
                {
                    entity.AppUsers.ConstructionManager = new SimpleEmployee()
                    {
                        Code = majorLeaesInfo.CMAccount
                    };
                }
            }
        }
예제 #10
0
        private void PopulateAppUsers(MajorLeaseConsInfo entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                entity.AppUsers.ConstructionManager = simp;

                simp = new SimpleEmployee
                {
                    Code = approvedUsers.MCCLConsManagerCode
                };
                entity.AppUsers.MCCLConsManager = simp;

                //simp = new SimpleEmployee
                //{
                //    Code = approvedUsers.MCCLAssetMgrCode
                //};
                //entity.AppUsers.MCCLAssetMgr = simp;

                //simp = new SimpleEmployee
                //{
                //    Code = approvedUsers.MCCLAssetDtrCode
                //};
                //entity.AppUsers.MCCLAssetDtr = simp;
            }
            else
            {
                var majorLeaesInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (majorLeaesInfo != null)
                {
                    entity.AppUsers.ConstructionManager = new SimpleEmployee()
                    {
                        Code = majorLeaesInfo.CMAccount
                    };
                }
            }
        }
예제 #11
0
 public override void Finish(TaskWorkStatus status, TaskWork task)
 {
     using (var scope = new TransactionScope())
     {
         switch (status)
         {
         case TaskWorkStatus.K2ProcessApproved:
             var mjInfo    = MajorLeaseInfo.Search(e => e.ProjectId.Equals(ProjectId)).FirstOrDefault();
             var pmTaskUrl = string.Format(@"/MajorLease/Main#/GBMemo/Process/Notify?projectId={0}", ProjectId);
             var pmTask    = mjInfo.GenerateTaskWork(WorkflowCode, "MajorLease GBMemo", "MajorLease GBMemo",
                                                     pmTaskUrl);
             pmTask.ActivityName = "Notify";
             pmTask.ActionName   = "Notify";
             TaskWork.Add(pmTask);
             break;
         }
         scope.Complete();
     }
 }
예제 #12
0
        private int StartProcess(TaskWork task)
        {
            CreateUserAccount = LastUpdateUserAccount;
            var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));

            if (majorLeaseInfo == null)
            {
                throw new Exception("Could not find the Major Lease Info, please check it!");
            }
            //var processDataFields = new List<ProcessDataField>()
            //{
            //    new ProcessDataField("dest_Creator", CreateUserAccount),
            //    new ProcessDataField("dest_FinancialManager",AppUsers.FM.Code ),
            //    new ProcessDataField("ProcessCode", WFMajorLeaseFinancAnalysis.ProcessCode),
            //    new ProcessDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task))
            //};
            var processDataFields = SetWorkflowDataFields(task);

            return(K2FxContext.Current.StartProcess(WFMajorLeaseFinancAnalysis.ProcessCode, CreateUserAccount,
                                                    processDataFields));
        }
예제 #13
0
        public MajorLeaseConsInvtChecking GetConsInvtChecking(string strProjectId, string entityId = "")
        {
            ProjectId = strProjectId;
            MajorLeaseConsInvtChecking entity = null;

            if (string.IsNullOrEmpty(entityId))
            {
                entity = Search(e => e.ProjectId.Equals(strProjectId) && !e.IsHistory).FirstOrDefault();
            }
            else
            {
                entity = Search(e => e.Id.ToString().Equals(entityId)).FirstOrDefault();
            }

            var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId == strProjectId);

            USCode = majorLeaseInfo.USCode;
            if (entity != null)
            {
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
                entity.ApprovalType     = entity.GetApprovalType();

                entity.IsShowEdit   = ProjectInfo.IsFlowEditable(strProjectId, FlowCode.MajorLease_ConsInvtChecking);
                entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, FlowCode.MajorLease_ConsInvtChecking);
            }
            else
            {
                entity           = new MajorLeaseConsInvtChecking();
                entity.ProjectId = strProjectId;
                entity.Save();
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
            }

            entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.MajorLease_ConsInvtChecking);
            PopulateAppUsers(entity);
            return(entity);
        }
예제 #14
0
        private int?StartProcess(TaskWork task)
        {
            var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));

            if (majorLeaseInfo == null)
            {
                throw new Exception("Could not find the Major Lease Info, please check it!");
            }
            //var processDataFields = new List<ProcessDataField>()
            //{
            //    new ProcessDataField("dest_Creator", CreateUserAccount),
            //    new ProcessDataField("dest_ConsManager",AppUsers.ConstructionManager.Code ),
            //    new ProcessDataField("dest_MCCLConsManager",AppUsers.MCCLConsManager.Code),
            //    new ProcessDataField("ProcessCode", WFMajorLeaseConsInfo.ProcessCode),
            //    new ProcessDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task)),
            //    new ProcessDataField("IsNoReinvestment",CheckIfHasNoReinvestment().ToString(),"BOOLEAN")
            //};


            var processDataFields = SetWorkflowDataFields(task);

            return(K2FxContext.Current.StartProcess(WFMajorLeaseConsInfo.ProcessCode, ClientCookie.UserCode,
                                                    processDataFields));
        }
예제 #15
0
        public static ReopenMemo GetReopenMemo(string projectId)
        {
            var  memo        = FirstOrDefault(e => e.ProjectId.Equals(projectId));
            bool isEmptyMemo = false;

            if (memo == null)
            {
                memo        = new ReopenMemo();
                isEmptyMemo = true;
            }

            memo.ProjectId = projectId;
            if (projectId.ToLower().IndexOf("rebuild") >= 0)
            {
                var rbdInfo = new RebuildInfo();
                memo.RbdInfo = rbdInfo.GetRebuildInfo(projectId);
                memo.Store   = StoreBasicInfo.GetStore(memo.RbdInfo.USCode);
                var consInfo = new RebuildConsInfo();
                consInfo = consInfo.GetConsInfo(projectId);
                var rein = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = GBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;

                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("reimage") >= 0)
            {
                memo.RmgInfo = ReimageInfo.GetReimageInfo(projectId);
                memo.Store   = StoreBasicInfo.GetStore(memo.RmgInfo.USCode);
                var consInfo = ReimageConsInfo.GetConsInfo(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = ReimageGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("majorlease") >= 0)
            {
                var mjrInfo = new MajorLeaseInfo().GetMajorLeaseInfo(projectId);
                memo.ReopenDate = mjrInfo.ReopenDate;
                memo.Store      = StoreBasicInfo.GetStore(mjrInfo.USCode);
                var consInfo = new MajorLeaseConsInfo().GetConsInfo(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = MajorLeaseGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            else if (projectId.ToLower().IndexOf("renewal") >= 0)
            {
                var renewalInfo = RenewalInfo.Get(projectId);
                memo.ReopenDate = renewalInfo.NewLeaseStartDate;
                memo.Store      = StoreBasicInfo.GetStore(renewalInfo.USCode);
                var consInfo = RenewalConsInfo.Get(projectId);
                var rein     = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentBasicInfo();
                memo.ReinvestInfo = rein;
                var recos = ReinvestmentCost.GetByConsInfoId(consInfo.Id) ?? new ReinvestmentCost();
                memo.TotalReinvestmentBudget = recos.TotalReinvestmentBudget;
                if (!memo.ReopenDate.HasValue)
                {
                    memo.ReopenDate = memo.ReinvestInfo.ReopenDate;
                }
                if (!memo.GBDate.HasValue)
                {
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                }
                var gbMemo = RenewalGBMemo.GetGBMemo(projectId);
                if (!memo.CompletionDate.HasValue && gbMemo != null)
                {
                    memo.CompletionDate = gbMemo.ConstCompletionDate;
                }
                //if (string.IsNullOrEmpty(memo.DesignConcept))
                //    memo.DesignConcept = memo.ReinvestInfo.NewDesignType;
                var writeoff = WriteOffAmount.GetByConsInfoId(consInfo.Id) ?? new WriteOffAmount();
                memo.WriteOff = writeoff;
            }
            if (isEmptyMemo)
            {
                if (memo.ReinvestInfo != null)
                {
                    if (memo.ReinvestInfo.NewMcCafe.HasValue && memo.ReinvestInfo.NewMcCafe.Value)
                    {
                        memo.NewMcCafe = true;
                    }
                    if ((memo.ReinvestInfo.NewAttachedKiosk.HasValue && memo.ReinvestInfo.NewAttachedKiosk.Value) ||
                        (memo.ReinvestInfo.NewRemoteKiosk.HasValue && memo.ReinvestInfo.NewRemoteKiosk.Value))
                    {
                        memo.NewKiosk = true;
                    }
                    if (memo.ReinvestInfo.NewMDS.HasValue && memo.ReinvestInfo.NewMDS.Value)
                    {
                        memo.NewMDS = true;
                    }
                    if (memo.ReinvestInfo.NewTwientyFourHour.HasValue && memo.ReinvestInfo.NewTwientyFourHour.Value)
                    {
                        memo.Is24H = true;
                    }
                    //if (!string.IsNullOrEmpty(memo.ReinvestInfo.NewOperationSize))
                    //{
                    //    memo.AftOperationSize = memo.ReinvestInfo.NewOperationSize;
                    //}
                    //if (!string.IsNullOrEmpty(memo.ReinvestInfo.EstimatedSeatNo))
                    //{
                    //    memo.AftARSN = memo.ReinvestInfo.EstimatedSeatNo;
                    //}
                }
                memo.TTMNetSales = GetTTFinanceData(memo.Store.StoreBasicInfo.StoreCode);
            }
            memo.PriceTiter = GetPriceTier(memo.Store.StoreBasicInfo.StoreCode);
            //if (string.IsNullOrEmpty(memo.AftARPT))
            //{
            //    memo.AftARPT = memo.PriceTiter;
            //}
            //if (memo.Store != null)
            //{
            //    memo.OriginalOperationSize = memo.Store.StoreSTLocation.TotalArea;
            //    memo.OriginalSeatNumber = memo.Store.StoreSTLocation.TotalSeatsNo;
            //}
            memo.YearMonthList = GetSelectYearMonth(memo.Store.StoreBasicInfo.StoreCode);
            if (isEmptyMemo)
            {
                SaveReopenMemo(memo);
            }
            return(memo);
        }
예제 #16
0
        public void Save(bool pushOrNot)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var projectInfo = ProjectInfo.Get(Id);
                if (projectInfo == null)
                {
                    ProjectId = ProjectInfo.CreateDLProject(Id, FlowCode.MajorLease, USCode, NodeCode.Start, ClientCookie.UserCode, pushOrNot);

                    var mlcInfo = new MajorLeaseInfo();
                    mlcInfo.Id                    = Guid.NewGuid();
                    mlcInfo.ProjectId             = ProjectId;
                    mlcInfo.USCode                = USCode;
                    mlcInfo.ChangeRentalType      = ChangeRentalType;
                    mlcInfo.ChangeRentalTypeDESC  = ChangeRentalTypeDESC;
                    mlcInfo.ChangeRedLineType     = ChangeRedLineType;
                    mlcInfo.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC;
                    mlcInfo.ChangeLeaseTermType   = ChangeLeaseTermType;
                    mlcInfo.ChangeLeaseTermDESC   = ChangeLeaseTermDESC;
                    mlcInfo.CreateTime            = DateTime.Now;
                    mlcInfo.CreateUserAccount     = ClientCookie.UserCode;
                    mlcInfo.CreateUserNameENUS    = ClientCookie.UserNameENUS;
                    mlcInfo.CreateUserNameZHCN    = ClientCookie.UserNameZHCN;
                    mlcInfo.ChangeLandlordType    = ChangeLandlordType;
                    mlcInfo.ChangeLandLordDESC    = ChangeLandLordDESC;
                    mlcInfo.Add();

                    var mlcPackage = new MajorLeaseChangePackage();
                    mlcPackage.Id                = Guid.NewGuid();
                    mlcPackage.ProjectId         = ProjectId;
                    mlcPackage.WriteOff          = MLCNetWriteOff_Act;
                    mlcPackage.IsHistory         = false;
                    mlcPackage.CreateUserAccount = ClientCookie.UserCode;
                    mlcPackage.CreateTime        = DateTime.Now;
                    mlcPackage.Add();

                    var mlcConsInvtChecking = new MajorLeaseConsInvtChecking();
                    mlcConsInvtChecking.Id         = Guid.NewGuid();
                    mlcConsInvtChecking.ProjectId  = ProjectId;
                    mlcConsInvtChecking.IsHistory  = false;
                    mlcConsInvtChecking.CreateTime = DateTime.Now;
                    mlcConsInvtChecking.Add();

                    var reinvestmentCost = new ReinvestmentCost();
                    reinvestmentCost.Id                     = Guid.NewGuid();
                    reinvestmentCost.ConsInfoID             = mlcConsInvtChecking.Id;
                    reinvestmentCost.TotalReinvestmentFAAct = MLC_TotalReinvestment_Act;
                    reinvestmentCost.Add();

                    var projectContractInfo = new ProjectContractInfo();
                    projectContractInfo.Id                           = Guid.NewGuid();
                    projectContractInfo.ProjectId                    = ProjectId;
                    projectContractInfo.ContractInfoId               = Guid.Empty;
                    projectContractInfo.CreatedTime                  = DateTime.Now;
                    projectContractInfo.WriteBack                    = false;
                    projectContractInfo.EditMode                     = EditMode;
                    projectContractInfo.PartyAFullName               = PartyAFullName;
                    projectContractInfo.McDLegalEntity               = ContractEntityName;
                    projectContractInfo.McDOwnership                 = McdOwnership;
                    projectContractInfo.ContactPerson                = ContactPerson;
                    projectContractInfo.ContactMode                  = ContactMode;
                    projectContractInfo.RentType                     = RentType;
                    projectContractInfo.TotalLeasedArea              = RentSize;
                    projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                    projectContractInfo.LeasePurchase                = ContractType;
                    projectContractInfo.StartDate                    = ContractStartDate;
                    projectContractInfo.EndDate                      = ContraceEndDate;
                    projectContractInfo.StartYear                    = ContractStartYear;
                    projectContractInfo.EndYear                      = ContraceEndYear;
                    projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                    projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                    projectContractInfo.Changedafter2010             = ChangedAfter2010;
                    projectContractInfo.RentStructure                = RentStructure;
                    projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                    projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                    projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                    projectContractInfo.HasDeposit                   = Deposit;
                    projectContractInfo.DepositAmount                = DepositAmount;
                    projectContractInfo.RefundableDate               = WhenRefund;
                    projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                    projectContractInfo.HasBankGuarantee             = BankGuarantee;
                    projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                    projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                    projectContractInfo.BGCommencementDate           = BGCommencementDate;
                    projectContractInfo.BGEndDate                    = BGEndDate;
                    projectContractInfo.Add();
                }
                else
                {
                    ProjectId            = projectInfo.ProjectId;
                    projectInfo.IsPushed = pushOrNot;
                    projectInfo.Update();

                    var mlcInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == ProjectId);
                    if (mlcInfo != null)
                    {
                        mlcInfo.ChangeRentalType      = ChangeRentalType;
                        mlcInfo.ChangeRentalTypeDESC  = ChangeRentalTypeDESC;
                        mlcInfo.ChangeRedLineType     = ChangeRedLineType;
                        mlcInfo.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC;
                        mlcInfo.ChangeLeaseTermType   = ChangeLeaseTermType;
                        mlcInfo.ChangeLeaseTermDESC   = ChangeLeaseTermDESC;
                        mlcInfo.ChangeLandlordType    = ChangeLandlordType;
                        mlcInfo.ChangeLandLordDESC    = ChangeLandLordDESC;
                        mlcInfo.Update();
                    }
                    else
                    {
                        mlcInfo                       = new MajorLeaseInfo();
                        mlcInfo.Id                    = Guid.NewGuid();
                        mlcInfo.ProjectId             = ProjectId;
                        mlcInfo.USCode                = USCode;
                        mlcInfo.ChangeRentalType      = ChangeRentalType;
                        mlcInfo.ChangeRentalTypeDESC  = ChangeRentalTypeDESC;
                        mlcInfo.ChangeRedLineType     = ChangeRedLineType;
                        mlcInfo.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC;
                        mlcInfo.ChangeLeaseTermType   = ChangeLeaseTermType;
                        mlcInfo.ChangeLeaseTermDESC   = ChangeLeaseTermDESC;
                        mlcInfo.CreateTime            = DateTime.Now;
                        mlcInfo.CreateUserAccount     = ClientCookie.UserCode;
                        mlcInfo.CreateUserNameENUS    = ClientCookie.UserNameENUS;
                        mlcInfo.CreateUserNameZHCN    = ClientCookie.UserNameZHCN;
                        mlcInfo.ChangeLandlordType    = ChangeLandlordType;
                        mlcInfo.ChangeLandLordDESC    = ChangeLandLordDESC;
                        mlcInfo.Add();
                    }

                    var mlcPackage = MajorLeaseChangePackage.GetMajorPackageInfo(ProjectId);
                    if (mlcPackage != null)
                    {
                        mlcPackage.WriteOff = MLCNetWriteOff_Act;
                        mlcPackage.Update();
                    }
                    else
                    {
                        mlcPackage                   = new MajorLeaseChangePackage();
                        mlcPackage.Id                = Guid.NewGuid();
                        mlcPackage.ProjectId         = ProjectId;
                        mlcPackage.WriteOff          = MLCNetWriteOff_Act;
                        mlcPackage.IsHistory         = false;
                        mlcPackage.CreateUserAccount = ClientCookie.UserCode;
                        mlcPackage.CreateTime        = DateTime.Now;
                        mlcPackage.Add();
                    }

                    var mlcConsInvtChecking = MajorLeaseConsInvtChecking.FirstOrDefault(i => i.ProjectId == ProjectId && i.IsHistory == false);
                    if (mlcConsInvtChecking == null)
                    {
                        mlcConsInvtChecking            = new MajorLeaseConsInvtChecking();
                        mlcConsInvtChecking.Id         = Guid.NewGuid();
                        mlcConsInvtChecking.ProjectId  = ProjectId;
                        mlcConsInvtChecking.IsHistory  = false;
                        mlcConsInvtChecking.CreateTime = DateTime.Now;
                        mlcConsInvtChecking.Add();
                    }

                    var reinvestmentCost = ReinvestmentCost.GetByConsInfoId(mlcConsInvtChecking.Id);
                    if (reinvestmentCost != null)
                    {
                        reinvestmentCost.TotalReinvestmentFAAct = MLC_TotalReinvestment_Act;
                        reinvestmentCost.Update();
                    }
                    else
                    {
                        reinvestmentCost                        = new ReinvestmentCost();
                        reinvestmentCost.Id                     = Guid.NewGuid();
                        reinvestmentCost.ConsInfoID             = mlcConsInvtChecking.Id;
                        reinvestmentCost.TotalReinvestmentFAAct = MLC_TotalReinvestment_Act;
                        reinvestmentCost.Add();
                    }

                    var projectContractInfo = ProjectContractInfo.FirstOrDefault(i => i.ProjectId == ProjectId);
                    if (projectContractInfo != null)
                    {
                        projectContractInfo.EditMode                     = EditMode;
                        projectContractInfo.PartyAFullName               = PartyAFullName;
                        projectContractInfo.McDLegalEntity               = ContractEntityName;
                        projectContractInfo.McDOwnership                 = McdOwnership;
                        projectContractInfo.ContactPerson                = ContactPerson;
                        projectContractInfo.ContactMode                  = ContactMode;
                        projectContractInfo.RentType                     = RentType;
                        projectContractInfo.TotalLeasedArea              = RentSize;
                        projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                        projectContractInfo.LeasePurchase                = ContractType;
                        projectContractInfo.StartDate                    = ContractStartDate;
                        projectContractInfo.EndDate                      = ContraceEndDate;
                        projectContractInfo.StartYear                    = ContractStartYear;
                        projectContractInfo.EndYear                      = ContraceEndYear;
                        projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                        projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                        projectContractInfo.Changedafter2010             = ChangedAfter2010;
                        projectContractInfo.RentStructure                = RentStructure;
                        projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                        projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                        projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                        projectContractInfo.HasDeposit                   = Deposit;
                        projectContractInfo.DepositAmount                = DepositAmount;
                        projectContractInfo.RefundableDate               = WhenRefund;
                        projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                        projectContractInfo.HasBankGuarantee             = BankGuarantee;
                        projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                        projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                        projectContractInfo.BGCommencementDate           = BGCommencementDate;
                        projectContractInfo.BGEndDate                    = BGEndDate;
                        projectContractInfo.Update();
                    }
                    else
                    {
                        projectContractInfo                              = new ProjectContractInfo();
                        projectContractInfo.Id                           = Guid.NewGuid();
                        projectContractInfo.ProjectId                    = ProjectId;
                        projectContractInfo.ContractInfoId               = Guid.Empty;
                        projectContractInfo.CreatedTime                  = DateTime.Now;
                        projectContractInfo.WriteBack                    = false;
                        projectContractInfo.EditMode                     = EditMode;
                        projectContractInfo.PartyAFullName               = PartyAFullName;
                        projectContractInfo.McDLegalEntity               = ContractEntityName;
                        projectContractInfo.McDOwnership                 = McdOwnership;
                        projectContractInfo.ContactPerson                = ContactPerson;
                        projectContractInfo.ContactMode                  = ContactMode;
                        projectContractInfo.RentType                     = RentType;
                        projectContractInfo.TotalLeasedArea              = RentSize;
                        projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                        projectContractInfo.LeasePurchase                = ContractType;
                        projectContractInfo.StartDate                    = ContractStartDate;
                        projectContractInfo.EndDate                      = ContraceEndDate;
                        projectContractInfo.StartYear                    = ContractStartYear;
                        projectContractInfo.EndYear                      = ContraceEndYear;
                        projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                        projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                        projectContractInfo.Changedafter2010             = ChangedAfter2010;
                        projectContractInfo.RentStructure                = RentStructure;
                        projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                        projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                        projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                        projectContractInfo.HasDeposit                   = Deposit;
                        projectContractInfo.DepositAmount                = DepositAmount;
                        projectContractInfo.RefundableDate               = WhenRefund;
                        projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                        projectContractInfo.HasBankGuarantee             = BankGuarantee;
                        projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                        projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                        projectContractInfo.BGCommencementDate           = BGCommencementDate;
                        projectContractInfo.BGEndDate                    = BGEndDate;
                        projectContractInfo.Add();
                    }
                }
                tranScope.Complete();
            }
        }
예제 #17
0
        public static MajorLeaseGBMemo GetGBMemo(string projectId, string entityId = "")
        {
            var memo = (string.IsNullOrEmpty(entityId) ?
                        FirstOrDefault(e => e.ProjectId.Equals(projectId) && !e.IsHistory)
                : FirstOrDefault(e => e.Id.ToString().Equals(entityId))) ?? new MajorLeaseGBMemo();

            memo.ProjectId = projectId;

            var majInfo = new MajorLeaseInfo();

            majInfo     = majInfo.GetMajorLeaseInfo(projectId);
            memo.Info   = majInfo;
            memo.UsCode = majInfo.USCode;

            memo.Store = StoreBasicInfo.GetStore(memo.UsCode);

            if (memo.Id == Guid.Empty)
            {
                memo.IsClosed      = (memo.Store.StoreBasicInfo.statusName == "Closed");
                memo.IsInOperation = false;
                var consInfo = new MajorLeaseConsInfo();
                memo.ReinvestInfo = consInfo.GetReinvestmentBasicInfo(projectId);
                if (memo.ReinvestInfo != null)
                {
                    if ((memo.ReinvestInfo.NewAttachedKiosk.HasValue && memo.ReinvestInfo.NewAttachedKiosk.Value) ||
                        (memo.ReinvestInfo.NewRemoteKiosk.HasValue && memo.ReinvestInfo.NewRemoteKiosk.Value))
                    {
                        memo.IsKiosk = true;
                    }
                    memo.IsMcCafe = memo.ReinvestInfo.NewMcCafe.HasValue && memo.ReinvestInfo.NewMcCafe.Value;
                    memo.IsMDS    = memo.ReinvestInfo.NewMDS.HasValue && memo.ReinvestInfo.NewMDS.Value;
                    memo.Is24Hour = memo.ReinvestInfo.NewTwientyFourHour.HasValue &&
                                    memo.ReinvestInfo.NewTwientyFourHour.Value;
                    memo.GBDate = memo.ReinvestInfo.GBDate;
                    memo.ConstCompletionDate = memo.ReinvestInfo.ConsCompletionDate;
                    memo.ReopenDate          = memo.ReinvestInfo.ReopenDate;
                }
                memo.Save();
            }
            else
            {
                var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId &&
                                                             e.FlowCode == FlowCode.MajorLease_GBMemo);

                if (projectInfo != null)
                {
                    if (ClientCookie.UserCode.Equals(majInfo.PMAccount))
                    {
                        var isFlowFlinshed =
                            TaskWork.Any(e =>
                                         e.RefID == projectId && e.TypeCode == FlowCode.MajorLease_GBMemo &&
                                         e.Status == TaskWorkStatus.K2ProcessApproved && e.ProcInstID == memo.ProcInstID);
                        var isExistTask = TaskWork.Any(e => e.RefID == projectId &&
                                                       e.TypeCode == FlowCode.MajorLease_GBMemo &&
                                                       e.Status == TaskWorkStatus.UnFinish &&
                                                       e.ReceiverAccount == ClientCookie.UserCode &&
                                                       (e.ActivityName == WFMajorLeaseLegalReview.Act_Originator || e.ActivityName == WFMajorLeaseLegalReview.Act_Start));
                        memo.IsShowEdit   = isFlowFlinshed;
                        memo.IsShowRecall = !isFlowFlinshed && !isExistTask;
                    }
                }
            }
            //if (ClientCookie.UserCode.Equals(majInfo.PMAccount))
            //    memo.IsShowSave = ProjectInfo.IsFlowSavable(projectId, FlowCode.MajorLease_GBMemo);
            PopulateAppUsers(memo);
            return(memo);
        }
예제 #18
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();
            }
        }