コード例 #1
0
ファイル: RenewalTool.cs プロジェクト: XiaoYaTech/Demo
        public override string Edit()
        {
            string url;

            using (var tranScope = new TransactionScope())
            {
                var info = RenewalInfo.Get(this.ProjectId);
                var tool = Duplicator.AutoCopy(this);
                tool.Id                = Guid.NewGuid();
                tool.IsHistory         = false;
                tool.CreateTime        = DateTime.Now;
                tool.CreateUserAccount = ClientCookie.UserCode;
                tool.Add();

                NewEntityId = tool.Id;
                IsHistory   = true;
                this.Update();
                ProjectInfo.Reset(ProjectId, this.WorkflowCode);
                var attachments = Attachment.GetList(this.TableName, Id.ToString(), string.Empty);
                attachments.ForEach(att =>
                {
                    att.RefTableID = tool.Id.ToString();
                    att.ID         = Guid.NewGuid();
                });
                Attachment.Add(attachments.ToArray());

                var FinMI    = RenewalToolFinMeasureInput.Get(this.ProjectId, this.Id);
                var newFinMI = Duplicator.AutoCopy(FinMI);
                newFinMI.Id     = Guid.NewGuid();
                newFinMI.ToolId = tool.Id;
                newFinMI.Add();

                var WfRc    = RenewalToolWriteOffAndReinCost.Get(this.ProjectId, this.Id);
                var newWfRc = Duplicator.AutoCopy(WfRc);
                newWfRc.Id     = Guid.NewGuid();
                newWfRc.ToolId = tool.Id;
                newWfRc.Add();

                var FinMO    = RenewalToolFinMeasureOutput.GetByToolId(this.Id);
                var newFinMO = Duplicator.AutoCopy(FinMO);
                newFinMO.Id     = Guid.NewGuid();
                newFinMO.ToolId = tool.Id;
                newFinMO.Add();

                var package = RenewalPackage.Get(this.ProjectId);
                package.ToolId = tool.Id;
                package.Update();

                var oldTasks = TaskWork.Search(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && new string[] { this.WorkflowCode, FlowCode.Renewal_Analysis }.Contains(t.TypeCode)).ToList();
                oldTasks.ForEach(t =>
                {
                    t.Status = TaskWorkStatus.Cancel;
                });
                TaskWork.Update(oldTasks.ToArray());

                var anlysisProj = ProjectInfo.FirstOrDefault(e => e.FlowCode == FlowCode.Renewal_Analysis &&
                                                             e.Status == ProjectStatus.UnFinish && e.ProjectId == ProjectId);
                if (anlysisProj != null)
                {
                    var taskAnlysis = TaskWork.FirstOrDefault(e => e.TypeCode == FlowCode.Renewal_Analysis && e.RefID == ProjectId && e.Status == TaskWorkStatus.UnFinish);
                    if (taskAnlysis != null)
                    {
                        taskAnlysis.Status     = TaskWorkStatus.Finished;
                        taskAnlysis.FinishTime = DateTime.Now;
                        taskAnlysis.Update();
                    }
                }
                var task = info.GenerateSubmitTask(this.WorkflowCode);
                url = task.Url;
                tranScope.Complete();
            }

            return(url);
        }
コード例 #2
0
ファイル: RenewalTool.cs プロジェクト: XiaoYaTech/Demo
        public string DownloadToolTemplate()
        {
            var    templateFileName = string.Concat(SiteFilePath.Template_DIRECTORY, "/", SiteFilePath.RenewalTool_Template);
            string fileName         = string.Format("{0}/{1}.xlsx", SiteFilePath.TEMP_DIRECTORY, Guid.NewGuid());

            File.Copy(templateFileName, fileName);
            FileInfo fileInfo = new FileInfo(fileName);
            ExcelDataInputDirector excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.RenewalTool);
            ExcelInputDTO          excelDto      = new ExcelInputDTO();
            var info          = RenewalInfo.Get(this.ProjectId);
            var storeBasic    = StoreBasicInfo.GetStorInfo(info.USCode);
            var storeContract = StoreContractInfo.Get(info.USCode);
            var finInput      = RenewalToolFinMeasureInput.Get(this.ProjectId, this.Id);
            var wfAndReinCost = RenewalToolWriteOffAndReinCost.Get(this.ProjectId, this.Id);

            excelDto.USCode    = info.USCode;
            excelDto.Market    = storeBasic.Market;
            excelDto.StoreName = storeBasic.NameZHCN + "/" + storeBasic.NameENUS;
            excelDto.OpenDate  = storeBasic.OpenDate;
            if (storeContract.EndDate.HasValue)
            {
                excelDto.LeaseExpirationDate = storeContract.EndDate.Value;
            }
            excelDto.RenewalYears     = info.RenewalYears;
            excelDto.ProductSales     = finInput.ProductSalesAdjustment;
            excelDto.Pac              = finInput.PacAdjustment;
            excelDto.Rent             = finInput.RentAdjustment;
            excelDto.DepreciationLhi  = finInput.DepreciationLhiAdjustment;
            excelDto.InterestLhi      = finInput.InterestLhiAdjustment;
            excelDto.ServiceFee       = finInput.ServiceFeeAdjustment;
            excelDto.Accounting       = finInput.AccountingAdjustment;
            excelDto.Insurance        = finInput.InsuranceAdjustment;
            excelDto.TaxesAndLicenses = finInput.TaxesAndLicensesAdjustment;
            excelDto.DepreciationEssd = finInput.DepreciationEssdAdjustment;
            excelDto.InterestEssd     = finInput.InterestEssdAdjustment;
            excelDto.OtherIncExp      = finInput.OtherIncExpAdjustment;
            excelDto.NonProductSales  = finInput.NonProductSalesAdjustment;
            excelDto.NonProductCosts  = finInput.NonProductCostsAdjustment;
            excelDto.REII             = wfAndReinCost.REII;
            excelDto.LHIII            = wfAndReinCost.LHIII;
            excelDto.ESSDII           = wfAndReinCost.ESSDII;
            excelDto.RENBV            = wfAndReinCost.RENBV;
            if (wfAndReinCost.LHINBV.HasValue)
            {
                excelDto.LHINBV = wfAndReinCost.LHINBV.Value;
            }
            if (wfAndReinCost.ESSDNBV.HasValue)
            {
                excelDto.ESSDNBV = wfAndReinCost.ESSDNBV.Value;
            }
            excelDto.RECost             = wfAndReinCost.RECost;
            excelDto.LHICost            = wfAndReinCost.LHICost;
            excelDto.ESSDCost           = wfAndReinCost.ESSDCost;
            excelDto.TotalWriteOff      = wfAndReinCost.REWriteOff + wfAndReinCost.LHIWriteOff + wfAndReinCost.ESSDWriteOff;
            excelDto.RentalStructure    = !string.IsNullOrEmpty(finInput.RentalStructure) ? (Nullable <decimal>)decimal.Parse(finInput.RentalStructure) : null;
            excelDto.ContributionMargin = finInput.ContributionMargin;
            excelDto.SalesCompYr1       = finInput.SalesCompYr1;
            excelDto.SalesCompYr2       = finInput.SalesCompYr2;
            excelDto.SalesCompYr3       = finInput.SalesCompYr3;
            excelDto.SalesCompYr4       = finInput.SalesCompYr4;
            excelDto.SalesCompYr5       = finInput.SalesCompYr5;
            excelDto.SalesCompYr6       = finInput.SalesCompYr6;
            excelDto.SalesCompYr7       = finInput.SalesCompYr7;
            excelDto.SalesCompYr8       = finInput.SalesCompYr8;
            excelDto.SalesCompYr9       = finInput.SalesCompYr9;
            excelDto.SalesCompYr10      = finInput.SalesCompYr10;
            excelDto.SalesCompYr11      = finInput.SalesCompYr11;
            excelDto.SalesCompYr12      = finInput.SalesCompYr12;
            excelDto.SalesCompYr13      = finInput.SalesCompYr13;
            excelDto.SalesCompYr14      = finInput.SalesCompYr14;
            excelDto.SalesCompYr15      = finInput.SalesCompYr15;
            excelDto.SalesCompYr16      = finInput.SalesCompYr16;
            excelDto.SalesCompYr17      = finInput.SalesCompYr17;
            excelDto.SalesCompYr18      = finInput.SalesCompYr18;
            excelDto.SalesCompYr19      = finInput.SalesCompYr19;
            excelDto.SalesCompYr20      = finInput.SalesCompYr20;
            excelDto.ComSalesDesc       = this.ComSalesDesc;
            excelDto.CompSales          = finInput.CompSalesAdjustment;
            excelDto.FinanceYear        = finInput.FinanceYear;
            excelDto.FinanceMonth       = finInput.FinanceMonth;
            excelDirector.Input(excelDto);
            return(fileName);
        }
コード例 #3
0
ファイル: RenewalTool.cs プロジェクト: XiaoYaTech/Demo
        public static RenewalToolDTO InitPage(string projectId, string id = null)
        {
            RenewalToolDTO dto       = new RenewalToolDTO();
            var            tool      = RenewalTool.Get(projectId, id);
            var            project   = ProjectInfo.Get(projectId, FlowCode.Renewal_Tool);
            var            info      = RenewalInfo.Get(projectId);
            var            isFinance = ClientCookie.UserCode == info.FinanceAccount;

            tool.IsProjectFreezed = tool.CheckIfFreezeProject(projectId);
            var    nextRefTableId    = new Guid(FlowInfo.GetRefTableId("RenewalAnalysis", projectId));
            var    nextFlowStarted   = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Analysis);
            var    haveTask          = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Tool && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var    projectComment    = ProjectComment.GetSavedComment(tool.Id, "RenewalTool", ClientCookie.UserCode);
            var    projectNode       = NodeInfo.GetNodeInfo(project.NodeCode);
            var    packageStarted    = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package);
            string selectedYearMonth = null;

            dto.Info              = info;
            dto.Entity            = tool;
            dto.TTMDataYearMonths = RenewalToolFinMeasureInput.GetYearMonths(projectId, out selectedYearMonth);
            dto.FinMeasureInput   = RenewalToolFinMeasureInput.Get(projectId, dto.Entity.Id);
            if (string.IsNullOrEmpty(dto.FinMeasureInput.FinanceYear) || string.IsNullOrEmpty(dto.FinMeasureInput.FinanceMonth))
            {
                var ym = selectedYearMonth.Split('-');
                dto.FinMeasureInput.FinanceYear  = ym[0];
                dto.FinMeasureInput.FinanceMonth = ym[1];
            }
            dto.FinMeasureInput.FinanceDataYearMonth = dto.FinMeasureInput.FinanceYear + "-" + dto.FinMeasureInput.FinanceMonth;
            //dto.FinMeasureInput.ContributionMargin = StoreCM.Get(dto.Info.USCode).ContributionMargin;
            McdAMEntities amdb  = new McdAMEntities();
            var           finfo = amdb.DataSync_LDW_AM_STFinanceData2.FirstOrDefault(f => f.UsCode == dto.Info.USCode &&
                                                                                     f.FinanceYear == dto.FinMeasureInput.FinanceYear && f.FinanceMonth == dto.FinMeasureInput.FinanceMonth);
            decimal cm = 0;

            if (finfo != null && !string.IsNullOrEmpty(finfo.contribution_marginPct))
            {
                cm = decimal.Parse(finfo.contribution_marginPct);
            }
            dto.FinMeasureInput.ContributionMargin = cm;
            var coninfo = RenewalConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory);
            var conProj = ProjectInfo.FirstOrDefault(e => e.ProjectId == projectId && e.FlowCode == "Renewal_ConsInfo");

            dto.WriteOffAndReinCost = RenewalToolWriteOffAndReinCost.Get(projectId, dto.Entity.Id, projectNode);
            if (coninfo != null && !coninfo.HasReinvenstment)
            {
                dto.WriteOffAndReinCost.REWriteOff   = null;
                dto.WriteOffAndReinCost.LHIWriteOff  = null;
                dto.WriteOffAndReinCost.ESSDWriteOff = null;
                dto.WriteOffAndReinCost.ESSDWriteOff = null;
                dto.WriteOffAndReinCost.RECost       = null;
                dto.WriteOffAndReinCost.LHICost      = null;
                dto.WriteOffAndReinCost.ESSDCost     = null;
            }

            dto.Uploadable     = projectNode.Sequence >= 3 && ClientCookie.UserCode == dto.Info.AssetActorAccount && !packageStarted;
            dto.ProjectComment = projectComment != null ? projectComment.Content : "";
            dto.Editable       = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Tool);
            dto.Recallable     = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Tool);
            dto.Savable        = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Tool) && string.IsNullOrEmpty(id);
            dto.IsFinished     =
                ProjectInfo.Any(
                    e =>
                    e.ProjectId == projectId && e.FlowCode == FlowCode.Renewal_Tool &&
                    e.Status == ProjectStatus.Finished);
            return(dto);
        }