Ejemplo n.º 1
0
        public void ConfirmUploadTool(string SerialNumber)
        {
            Save(null);
            var renewalToolAttachment =
                Attachment.FirstOrDefault(att => att.RefTableID == this.Id.ToString() && att.TypeCode == "RenewalTool");

            if (renewalToolAttachment == null)
            {
                throw new Exception("Please upload Renewal Tool first!");
            }

            var fileName      = SiteFilePath.UploadFiles_DIRECTORY + "\\" + renewalToolAttachment.InternalName;
            var fileInfo      = new FileInfo(fileName);
            var excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.RenewalTool);
            var excelDto      = new ExcelInputDTO();

            excelDto.ComSalesDesc = ComSalesDesc;
            excelDirector.Edit(excelDto);

            var project = ProjectInfo.Get(this.ProjectId, this.WorkflowCode);

            if (project.Status != ProjectStatus.Finished)
            {
                string comment = "upload Renewal Tool";
                K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Approve", comment);
                ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.Finish, ProjectStatus.Finished);
            }
        }
Ejemplo n.º 2
0
        public static ReinvestmentCost GetByConsInfoId(Guid consInfoId)
        {
            var ci  = FirstOrDefault(e => e.ConsInfoID == consInfoId);
            var att = Attachment.FirstOrDefault(a => a.RefTableID == consInfoId.ToString() && a.TypeCode == "ReinCost");

            if (att != null && ci != null)
            {
                if (att.CreateTime.HasValue)
                {
                    ci.ReinCostTime = att.CreateTime.Value;
                }

                ci.ReinCostUser = att.CreatorNameENUS;
            }
            return(ci);
        }
Ejemplo n.º 3
0
        public static WriteOffAmount GetByConsInfoId(Guid consInfoId)
        {
            var wa  = FirstOrDefault(e => e.ConsInfoID == consInfoId);
            var att = Attachment.FirstOrDefault(a => a.RefTableID == consInfoId.ToString() && a.TypeCode == "WriteOff");

            if (att != null && wa != null)
            {
                if (att.CreateTime.HasValue)
                {
                    wa.WriteOffTime = att.CreateTime.Value;
                }

                wa.WriteOffUser = att.CreatorNameENUS;
            }
            return(wa);
        }
Ejemplo n.º 4
0
        public void UploadTool()
        {
            var context = HttpContext.Current;
            var files   = context.Request.Files;

            if (files.Count > 0)
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    var file             = files[0];
                    var templateFileName = string.Concat(SiteFilePath.Template_DIRECTORY, "/", SiteFilePath.RenewalTool_Template);
                    if (!ExcelHelper.MatchVersionNumber(templateFileName, file.InputStream))
                    {
                        throw new Exception("Version not matched!");
                    }
                    var extetion     = Path.GetExtension(file.FileName);
                    var internalName = string.Concat(Guid.NewGuid(), extetion);
                    var fileName     = context.Server.MapPath(string.Format("~/UploadFiles/{0}", internalName));
                    file.SaveAs(fileName);
                    FileInfo fileInfo = new FileInfo(fileName);
                    ExcelDataImportDirector excelDirector = new ExcelDataImportDirector(fileInfo, ExcelDataImportType.RenewalTool);
                    var finOutput = RenewalToolFinMeasureOutput.GetByToolId(this.Id);
                    if (finOutput == null)
                    {
                        finOutput        = new RenewalToolFinMeasureOutput();
                        finOutput.ToolId = this.Id;
                        finOutput.Id     = Guid.NewGuid();
                    }
                    excelDirector.ExcelData.Entity = finOutput;
                    excelDirector.ParseAndImport();
                    var  att     = Attachment.FirstOrDefault(e => e.RefTableID == this.Id.ToString() && e.TypeCode == "RenewalTool");
                    bool hasTool = true;
                    if (att == null)
                    {
                        hasTool = false;
                        att     = new Attachment();
                        att.ID  = Guid.NewGuid();
                    }

                    att.TypeCode        = "RenewalTool";
                    att.RefTableID      = this.Id.ToString();
                    att.RefTableName    = this.TableName;
                    att.Name            = "Renewal Tool";
                    att.Extension       = extetion;
                    att.RelativePath    = "/";
                    att.InternalName    = internalName;
                    att.ContentType     = "microsoft/excel";
                    att.Length          = file.ContentLength;
                    att.CreatorID       = ClientCookie.UserCode;
                    att.CreatorNameENUS = ClientCookie.UserNameENUS;
                    att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                    att.CreateTime      = DateTime.Now;
                    att.RequirementId   = new Guid("CE111514-65E3-45C7-AD22-DF4937B1686E");
                    if (hasTool)
                    {
                        att.Update();
                    }
                    else
                    {
                        att.Add();
                    }
                    tranScope.Complete();
                }
            }
            else
            {
                throw new Exception("Please select Renewal Tool to upload");
            }
        }
Ejemplo n.º 5
0
        public void GenerateAttachment()
        {
            var    info             = RenewalInfo.Get(this.ProjectId);
            var    storeInfo        = PrepareStoreInfo(this.ProjectId, info.USCode);
            string templateFileName = string.Concat(SiteFilePath.Template_DIRECTORY, "/", SiteFilePath.RenewalAnalysis_Template);
            string fileName         = HttpContext.Current.Server.MapPath(string.Format("~/UploadFiles/{0}.xlsx", Guid.NewGuid()));
            var    extetion         = Path.GetExtension(fileName);
            var    internalName     = Path.GetFileName(fileName);

            File.Copy(templateFileName, fileName);
            FileInfo fileInfo = new FileInfo(fileName);
            ExcelDataInputDirector excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.RenewalAnalysis);
            ExcelInputDTO          excelDto      = new ExcelInputDTO();

            excelDto.USCode             = storeInfo.UsCode;
            excelDto.StoreNameEN        = storeInfo.NameENUS;
            excelDto.StoreNameCN        = storeInfo.NameZHCN;
            excelDto.MinimarketPriority = string.IsNullOrEmpty(storeInfo.MinimarketPriority) ? null : Dictionary.GetDictionary(storeInfo.MinimarketPriority).NameENUS;
            excelDto.TADesrability      = string.IsNullOrEmpty(storeInfo.TADesrability) ? null : Dictionary.GetDictionary(storeInfo.TADesrability).NameENUS;
            excelDto.MMTADescription    = this.MMTADescription;
            excelDto.MajorGenerators    = this.MajorGenerators;
            excelDto.SitePortfolioType  = storeInfo.SitePortfolioType;
            excelDto.SiteRerating       = string.IsNullOrEmpty(storeInfo.SiteRerating) ? null : Dictionary.GetDictionary(storeInfo.SiteRerating).NameENUS;
            excelDto.SiteDescription    = this.SiteDescription;
            excelDto.TADesrabilityNew   = string.IsNullOrEmpty(this.TADesirability) ? null : Dictionary.GetDictionary(this.TADesirability).NameENUS;
            excelDto.MMTADescriptionNew = this.MMTADescriptionNew;
            excelDto.MajorGeneratorsNew = this.MajorGeneratorsNew;
            excelDto.SiteRERatingFuture = string.IsNullOrEmpty(this.SiteRERating) ? null : Dictionary.GetDictionary(this.SiteRERating).NameENUS;
            excelDto.LeasedArea         = storeInfo.LeasedArea;
            excelDto.OperationSize      = storeInfo.OperationSize;
            excelDto.Floors             = storeInfo.Floors;
            excelDto.Seats                 = storeInfo.Seats;
            excelDto.BEType                = storeInfo.BEType;
            excelDto.LeaseTenureAndTerm    = storeInfo.LeaseTenureAndTerm;
            excelDto.FreeRentalPeriod      = storeInfo.FreeRentalPeriod;
            excelDto.RentStructure         = storeInfo.RentStructure;
            excelDto.MFStructure           = this.MFStructure;
            excelDto.LeasedAreaNew         = this.LeasedArea;
            excelDto.OperationSizeNew      = this.OperationSize;
            excelDto.FloorsNew             = this.Floors;
            excelDto.SeatsNew              = this.Seats;
            excelDto.BETypeNew             = this.BEType;
            excelDto.LeaseTenureAndTermNew = this.LeaseTenureAndTerm;
            excelDto.FreeRentalPeriodNew   = this.FreeRentalPeriod;
            excelDto.RentStructureNew      = this.RentStructure;
            excelDto.MFStructureNew        = this.MFStructureNew;
            excelDto.DRMFLastTY            = this.DRMFLastTY;
            excelDto.DRMFLastTYSales       = this.DRMFLastTYSales;
            excelDto.DRMF1stTY             = this.DRMF1stTY;
            excelDto.DRMF1stTYSales        = this.DRMF1stTYSales;
            excelDto.SRMFLastTY            = storeInfo.SRMFLastTY;
            excelDto.SRMFLastTYSales       = storeInfo.SRMFLastTYSales;
            excelDto.SRMF1stTY             = storeInfo.SRMF1stTY;
            excelDto.SRMF1stTYSales        = storeInfo.SRMF1stTYSales;
            excelDto.FairMarketRentAmount  = this.FairMarketRentAmount;
            excelDto.FairMarketRentAgent   = this.FairMarketRentAgent;
            excelDto.DR1stTYAmount         = this.DR1stTYAmount;
            excelDto.AnnualSOILastTY       = this.AnnualSOILastTY;
            excelDto.AnnualSOIAvg          = storeInfo.AnnualSOIAvg;
            excelDto.CashROILastTY         = this.CashROILastTY;
            excelDto.CashROIAvg            = storeInfo.CashROIAvg;
            excelDto.LastRemodeling        = this.LastRemodeling;
            excelDto.OriginalInvestment    = storeInfo.OriginalInvestment;
            excelDto.NBV = storeInfo.NBV;
            excelDto.AdditionalInvestmentCost  = storeInfo.AdditionalInvestmentCost;
            excelDto.ExclusivityClause         = DataConverter.ToYesNo(storeInfo.ExclusivityClause);
            excelDto.McDsEarlyTerminationRight = storeInfo.McDsEarlyTerminationRight;
            excelDto.McDsEPRight                  = this.McDsEPRight;
            excelDto.LandlordEntity               = storeInfo.LandlordEntity;
            excelDto.SpecialClauses               = this.SpecialClauses;
            excelDto.OtherIssues                  = this.OtherIssues;
            excelDto.ExclusivityClauseNew         = this.ExclusivityClauseNew;
            excelDto.McDsEarlyTerminationRightNew = this.McDsEarlyTerminationRightNew;
            excelDto.McDsEPRightNew               = this.McDsEPRightNew;
            excelDto.LandlordEntityNew            = this.LandlordEntityNew;
            excelDto.SpecialClausesNew            = this.SpecialClausesNew;
            excelDto.OtherIssuesNew               = this.OtherIssuesNew;
            excelDto.DecisionLogic                = this.DecisionLogic;
            excelDto.SpecialApprovalRequired      = this.SpecialApprovalRequired;
            excelDirector.Input(excelDto);
            var  att       = Attachment.FirstOrDefault(e => e.RefTableID == this.Id.ToString() && e.TypeCode == "RenewalAnalysis");
            bool hasAttach = true;

            if (att == null)
            {
                hasAttach = false;
                att       = new Attachment();
                att.ID    = Guid.NewGuid();
            }

            att.TypeCode        = "RenewalAnalysis";
            att.RefTableID      = this.Id.ToString();
            att.RefTableName    = "RenewalAnalysis";
            att.Name            = "Renewal Analysis";
            att.Extension       = extetion;
            att.RelativePath    = "/";
            att.InternalName    = internalName;
            att.ContentType     = "application/vnd.ms-excel";
            att.Length          = (int)fileInfo.Length;
            att.CreatorID       = ClientCookie.UserCode;
            att.CreatorNameENUS = ClientCookie.UserNameENUS;
            att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
            att.CreateTime      = DateTime.Now;
            att.RequirementId   = new Guid("06F33F98-76B9-440F-8E8C-9167B4C202B9");
            if (hasAttach)
            {
                att.Update();
            }
            else
            {
                att.Add();
            }
        }
Ejemplo n.º 6
0
        public static ReimageConsInfo GetConsInfo(string strProjectId, string entityId = "")
        {
            ReimageConsInfo 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 reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == strProjectId);

            if (entity != null)
            {
                entity.IsProjectFreezed = entity.CheckIfFreezeProject(strProjectId);
                entity.ReinCost         = ReinvestmentCost.GetByConsInfoId(entity.Id);
                entity.ReinBasicInfo    = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id);
                if (entity.ReinBasicInfo != null)
                {
                    entity.ReinBasicInfo.GBDate     = reimageInfo.GBDate;
                    entity.ReinBasicInfo.ReopenDate = reimageInfo.ReopenDate;
                }
                else
                {
                    entity.ReinBasicInfo =
                        new ReinvestmentBasicInfo
                    {
                        GBDate     = reimageInfo.GBDate,
                        ReopenDate = reimageInfo.ReopenDate
                    };
                }
                entity.WriteOff = WriteOffAmount.GetByConsInfoId(entity.Id);
                var attachmentReinCost = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "ReinCost");
                if (attachmentReinCost != null && entity.ReinCost != null)
                {
                    entity.ReinCost.ReinCostUser = attachmentReinCost.CreatorNameENUS;
                    entity.ReinCost.ReinCostTime = attachmentReinCost.CreateTime;
                }
                var attachmentWriteOff = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "WriteOff");
                if (attachmentWriteOff != null)
                {
                    entity.WriteOff.WriteOffUser = attachmentWriteOff.CreatorNameENUS;
                    entity.WriteOff.WriteOffTime = attachmentWriteOff.CreateTime;
                }
                //entity.ProcInstID = entity.ProcInstId;
                entity.IsShowEdit   = ProjectInfo.IsFlowEditable(strProjectId, FlowCode.Reimage_ConsInfo);
                entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, FlowCode.Reimage_ConsInfo);
            }
            else
            {
                //var reimage = ReimageInfo.FirstOrDefault(e => e.ProjectId == strProjectId);
                //if (reimage != null)
                //{
                //    entity = new ReimageConsInfo
                //    {
                //        ReinBasicInfo =
                //            new ReinvestmentBasicInfo
                //            {
                //                GBDate = reimage.GBDate,
                //                ReopenDate = reimage.ReopenDate
                //            },
                //        IsProjectFreezed =entity.CheckIfFreezeProject(strProjectId),
                //        ReinvenstmentType = 1
                //    };
                //}
                entity.IsProjectFreezed = entity.CheckIfFreezeProject(strProjectId);
                entity.ReinBasicInfo    = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id);
                if (entity.ReinBasicInfo != null)
                {
                    entity.ReinBasicInfo.GBDate     = reimageInfo.GBDate;
                    entity.ReinBasicInfo.ReopenDate = reimageInfo.ReopenDate;
                }
                else
                {
                    entity.ReinBasicInfo =
                        new ReinvestmentBasicInfo
                    {
                        GBDate     = reimageInfo.GBDate,
                        ReopenDate = reimageInfo.ReopenDate
                    };
                }
            }
            entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Reimage_ConsInfo);
            entity.PopulateAppUsers();
            return(entity);
        }
Ejemplo n.º 7
0
        public RebuildConsInfo GetConsInfo(string strProjectId, string entityId = "")
        {
            RebuildConsInfo 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();
            }

            if (entity != null)
            {
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
                entity.ReinCost         = ReinvestmentCost.GetByConsInfoId(entity.Id);
                entity.ReinBasicInfo    = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id);
                var attachmentReinCost = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "ReinCost");
                if (entity.ReinCost != null && attachmentReinCost != null)
                {
                    entity.ReinCost.ReinCostUser = attachmentReinCost.CreatorNameENUS;
                    entity.ReinCost.ReinCostTime = attachmentReinCost.CreateTime;
                }

                if (entity.ReinBasicInfo == null)
                {
                    var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == strProjectId);
                    if (rbdInfo != null)
                    {
                        entity.ReinBasicInfo = new ReinvestmentBasicInfo
                        {
                            GBDate             = rbdInfo.GBDate,
                            ReopenDate         = rbdInfo.ReopenDate,
                            ConsCompletionDate = rbdInfo.ConstCompletionDate
                        };
                    }
                }
                entity.WriteOff = WriteOffAmount.GetByConsInfoId(entity.Id);
                var attachmentWriteOff = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "WriteOff");
                if (entity.WriteOff != null && attachmentWriteOff != null)
                {
                    entity.WriteOff.WriteOffUser = attachmentWriteOff.CreatorNameENUS;
                    entity.WriteOff.WriteOffTime = attachmentWriteOff.CreateTime;
                }

                entity.IsShowEdit   = ProjectInfo.IsFlowEditable(strProjectId, FlowCode.Rebuild_ConsInfo);
                entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, FlowCode.Rebuild_ConsInfo);
                entity.IsShowSave   = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Rebuild_ConsInfo);
            }
            else
            {
                var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == strProjectId);
                if (rbdInfo != null)
                {
                    entity = new RebuildConsInfo
                    {
                        ReinBasicInfo =
                            new ReinvestmentBasicInfo
                        {
                            GBDate     = rbdInfo.GBDate,
                            ReopenDate = rbdInfo.ReopenDate
                        },
                        IsProjectFreezed = CheckIfFreezeProject(strProjectId),
                        ProjectId        = strProjectId
                    };
                }
            }
            PopulateAppUsers(entity);
            return(entity);
        }
Ejemplo n.º 8
0
        public Attachment GenerateAttachment(out string filePath)
        {
            var info = ReimageInfo.FirstOrDefault(e => e.ProjectId == this.ProjectId);

            _refId = GetRefId(this.ProjectId);
            var    storeInfo        = StoreBasicInfo.GetStorInfo(info.USCode);
            string templateFileName = string.Concat(SiteFilePath.Template_DIRECTORY, "/", SiteFilePath.Reimage_Summary_Template);
            string fileName         = HttpContext.Current.Server.MapPath(string.Format("~/UploadFiles/{0}.xlsx", Guid.NewGuid()));
            var    extetion         = Path.GetExtension(fileName);
            var    internalName     = Path.GetFileName(fileName);

            File.Copy(templateFileName, fileName);
            FileInfo fileInfo = new FileInfo(fileName);
            ExcelDataInputDirector excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.ReimageSummary);
            ExcelInputDTO          excelDto      = new ExcelInputDTO();

            excelDto.USCode    = info.USCode;
            excelDto.ProjectId = info.ProjectId;
            excelDirector.Input(excelDto);
            var  att       = Attachment.FirstOrDefault(e => e.RefTableID == this.Id.ToString() && e.TypeCode == "ReimageSummary");
            bool hasAttach = true;

            if (att == null)
            {
                hasAttach = false;
                att       = new Attachment();
                att.ID    = Guid.NewGuid();
            }

            att.TypeCode        = "ReimageSummary";
            att.RefTableID      = this.Id.ToString();
            att.RefTableName    = "ReimageSummary";
            att.Name            = "Reimage Summary";
            att.Extension       = extetion;
            att.RelativePath    = "/";
            att.InternalName    = internalName;
            att.ContentType     = "application/vnd.ms-excel";
            att.Length          = (int)fileInfo.Length;
            att.CreatorID       = ClientCookie.UserCode;
            att.CreatorNameENUS = ClientCookie.UserNameENUS;
            att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
            att.CreateTime      = DateTime.Now;
            att.RequirementId   = new Guid("5647BDBB-5B5F-47CD-9AD2-3E35A16DD303");
            if (hasAttach)
            {
                att.Update();
            }
            else
            {
                att.Add();
            }
            //fileInfo = new FileInfo(fileName);
            //var importDirector = new ExcelDataImportDirector(fileInfo, ExcelDataImportType.FinancialPreAnalysis);
            //importDirector.FillEntityEvent += FillFinancialPreAnalysisEntity;
            //using (var scope = new TransactionScope())
            //{
            //    importDirector.ParseAndImport();
            //    scope.Complete();
            //}

            filePath = fileName;
            return(att);
        }