예제 #1
0
        public StoreContractRevision ToStoreContractRevision()
        {
            StoreContractRevision revision = new StoreContractRevision();

            revision.Id = this.RevisionId;
            revision.StoreContractInfoId = this.StoreContractInfoId;
            revision.StoreID             = this.StoreID;
            revision.StoreCode           = this.StoreCode;
            revision.LeaseRecapID        = this.LeaseRecapID;
            revision.ChangeDate          = this.ChangeDate.HasValue ? this.ChangeDate.Value.ToString("yyyy-MM-dd") : null;
            revision.Rent                 = this.Rent;
            revision.Size                 = this.Size;
            revision.LeaseTerm            = this.LeaseTerm;
            revision.Entity               = this.Entity;
            revision.Others               = this.Others;
            revision.RentStructureOld     = this.RentStructureOld;
            revision.RentStructureNew     = this.RentStructureNew;
            revision.RedlineAreaOld       = this.RedlineAreaOld;
            revision.RedlineAreaNew       = this.RedlineAreaNew;
            revision.LeaseChangeExpiryOld = this.LeaseChangeExpiryOld;
            revision.LeaseChangeExpiryNew = this.LeaseChangeExpiryNew;
            revision.LandlordOld          = this.LandlordOld;
            revision.LandlordNew          = this.LandlordNew;
            revision.Description          = this.Description;
            revision.CreatedTime          = this.CreatedTime;
            revision.OthersDescription    = this.OthersDescription;
            return(revision);
        }
예제 #2
0
        public void Save(List <StoreContractRevision> revisions)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                if (revisions.Count > 0)
                {
                    revisions = revisions.OrderBy(r => r.ChangeDate).ToList();
                    revisions.ForEach(r =>
                    {
                        r.ChangeDate = DateTime.Parse(r.ChangeDate).ToString("yyyy-MM-dd");
                        r.Save();
                        //回写到ContractInfo中
                        if (r.Rent == "Y")
                        {
                            this.RentStructure = r.RentStructureNew;
                        }
                        if (r.Size == "Y")
                        {
                            this.TotalLeasedArea = r.RedlineAreaNew;
                        }
                        if (r.LeaseTerm == "Y")
                        {
                            this.EndDate = r.LeaseChangeExpiryNew;
                        }
                        if (r.Entity == "Y")
                        {
                            this.PartyAFullName = r.LandlordNew;
                        }
                    });
                    var rIds = revisions.Select(e => e.Id).ToList();
                    StoreContractRevision.Delete(e => e.StoreContractInfoId == this.Id && !rIds.Contains(e.Id));
                }
                else
                {
                    StoreContractRevision.Delete(e => e.StoreContractInfoId == this.Id);
                }

                if (StoreContractInfo.Any(c => c.Id == this.Id))
                {
                    this.LastEditTime = DateTime.Now;
                    this.Update();
                }
                else
                {
                    this.CreatedTime = DateTime.Now;
                    this.Add();
                }
                tranScope.Complete();
            }
        }
예제 #3
0
 public static List <ProjectContractRevision> Get(string projectId, Guid contractId)
 {
     if (ProjectContractRevision.Any(r => r.StoreContractInfoId == contractId && r.ProjectId == projectId))
     {
         return(Search(r => r.StoreContractInfoId == contractId && r.ProjectId == projectId).OrderBy(r => r.ChangeDate).ToList());
     }
     else
     {
         return(StoreContractRevision.Search(r => r.StoreContractInfoId == contractId).AsNoTracking().ToList().Select(r =>
         {
             var revision = r.ToProjectContractRevision();
             revision.ProjectId = projectId;
             return revision;
         }).OrderBy(r => r.ChangeDate).ToList());
     }
 }
예제 #4
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();
            }
        }