Exemple #1
0
        public static ConsInfoDTO <RenewalInfo, RenewalConsInfo> InitPage(string projectId, string id = "")
        {
            RenewalInfo info     = RenewalInfo.Get(projectId);
            var         consInfo = RenewalConsInfo.Get(projectId, id);

            if (consInfo == null)
            {
                consInfo           = new RenewalConsInfo();
                consInfo.ProjectId = projectId;
            }
            var isOriginator = ClientCookie.UserCode == info.PMAccount;

            consInfo.IsProjectFreezed = consInfo.CheckIfFreezeProject(projectId);
            var nextRefTableId  = new Guid(FlowInfo.GetRefTableId("RenewalTool", projectId));
            var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Tool);
            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(consInfo.Id, "RenewalConsInfo", ClientCookie.UserCode);

            if (string.IsNullOrEmpty(id))
            {
                consInfo.HasReinvenstment = info.NeedProjectCostEst;
            }
            ConsInfoDTO <RenewalInfo, RenewalConsInfo> dto = new ConsInfoDTO <RenewalInfo, RenewalConsInfo>();

            dto.Entity         = consInfo;
            dto.Info           = info;
            dto.ReinBasicInfo  = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id);
            dto.ReinCost       = ReinvestmentCost.GetByConsInfoId(consInfo.Id);
            dto.WriteOff       = WriteOffAmount.GetByConsInfoId(consInfo.Id);
            dto.ProjectComment = projectComment != null ? projectComment.Content : "";
            dto.Editable       = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_ConsInfo);
            dto.Recallable     = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_ConsInfo);
            dto.Savable        = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_ConsInfo) && string.IsNullOrEmpty(id);
            return(dto);
        }
        public static RenewalLegalApprovalDTO InitPage(string projectId, string id = null)
        {
            RenewalLegalApprovalDTO dto = new RenewalLegalApprovalDTO();
            var entity  = Get(projectId, id);
            var info    = RenewalInfo.Get(projectId);
            var isActor = ClientCookie.UserCode == info.AssetActorAccount;

            entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId);
            var nextRefTableId  = new Guid(FlowInfo.GetRefTableId(entity.TableName, projectId));
            var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package);
            var haveTask        = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_LegalApproval && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var projectComment  = ProjectComment.GetSavedComment(entity.Id, entity.TableName, ClientCookie.UserCode);
            var appUser         = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            dto.Info             = info;
            dto.Entity           = entity;
            dto.ProjectComment   = projectComment != null ? projectComment.Content : "";
            dto.IsGeneralCounsel = appUser != null && appUser.GeneralCounselCode == ClientCookie.UserCode;
            dto.Editable         = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_LegalApproval);
            dto.Recallable       = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_LegalApproval);
            dto.Savable          = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_LegalApproval) && string.IsNullOrEmpty(id);
            return(dto);
        }
Exemple #3
0
        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);
        }