示例#1
0
        public PerformanceMeasuresViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Project project, ViewDataForAngularEditor viewDataForAngularEditor, ProposalSectionsStatus proposalSectionsStatus)
            : base(currentFirmaSession, project, ProjectCreateSection.ReportedAccomplishments.ProjectCreateSectionDisplayName, proposalSectionsStatus)
        {
            RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshReportedPerformanceMeasures(project));

            DiffUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.DiffReportedPerformanceMeasures(project));

            var performanceMeasureActuals = project.GetPerformanceMeasureReportedValues();
            var performanceMeasureSubcategoriesCalendarYearReportedValues =
                PerformanceMeasureSubcategoriesCalendarYearReportedValue.CreateFromPerformanceMeasuresAndCalendarYears(new List <IPerformanceMeasureReportedValue>(performanceMeasureActuals));

            PerformanceMeasureReportedValuesSummaryViewData = new PerformanceMeasureReportedValuesSummaryViewData(performanceMeasureSubcategoriesCalendarYearReportedValues,
                                                                                                                  project.GetPerformanceMeasuresExemptReportingYears().Select(x => x.CalendarYear).ToList(),
                                                                                                                  project.PerformanceMeasureActualYearsExemptionExplanation,
                                                                                                                  performanceMeasureActuals.Select(x => x.CalendarYear).Distinct().Select(x => new CalendarYearString(x)).ToList());
            ViewDataForAngular = viewDataForAngularEditor;

            IsImplementationStartYearValid = project.ImplementationStartYear.HasValue && project.ImplementationStartYear < project.CompletionYear;
            ReportingYearLabel             = "Year";
            if (new PerformanceMeasureManageFeature().HasPermissionByFirmaSession(currentFirmaSession))
            {
                ConfigurePerformanceMeasuresUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(pmc => pmc.Manage());
            }
            ShowCommentsSection = project.IsPendingApproval() || (project.ReportedAccomplishmentsComment != null &&
                                                                  project.ProjectApprovalStatus == ProjectApprovalStatus.Returned);
            CanEditComments = project.IsPendingApproval() && new ProjectEditAsAdminRegardlessOfStageFeature().HasPermission(currentFirmaSession, project).HasPermission;
        }
        public BackwardLookingFactSheetViewData(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.Project project,
                                                ProjectLocationSummaryMapInitJson projectLocationSummaryMapInitJson,
                                                GoogleChartJson projectFactSheetGoogleChart,
                                                List <GooglePieChartSlice> expenditureGooglePieChartSlices, List <string> chartColorRange,
                                                ProjectFirmaModels.Models.FirmaPage firmaPageFactSheet,
                                                List <TechnicalAssistanceParameter> technicalAssistanceParameters,
                                                bool withCustomAttributes,
                                                ProjectController.FactSheetPdfEnum factSheetPdfEnum) : base(currentFirmaSession, project)
        {
            PageTitle       = project.GetDisplayName();
            BreadCrumbTitle = "Fact Sheet";

            EstimatedTotalCost        = Project.GetEstimatedTotalRegardlessOfFundingType().HasValue ? Project.GetEstimatedTotalRegardlessOfFundingType().ToStringCurrency() : "";
            NoFundingSourceIdentified = project.GetNoFundingSourceIdentifiedAmount() != null?Project.GetNoFundingSourceIdentifiedAmount().ToStringCurrency() : "";

            ProjectedFunding = Project.GetProjectedFunding().ToStringCurrency();

            PerformanceMeasureReportedValues =
                project.GetPerformanceMeasureReportedValues().GroupBy(x => x.PerformanceMeasure).OrderBy(x => x.Key.PerformanceMeasureSortOrder).ThenBy(x => x.Key.PerformanceMeasureDisplayName).ToList();
            PerformanceMeasureExpectedValues = project.PerformanceMeasureExpecteds.GroupBy(x => x.PerformanceMeasure, new HavePrimaryKeyComparer <ProjectFirmaModels.Models.PerformanceMeasure>())
                                               .OrderBy(x => x.Key.PerformanceMeasureSortOrder).ThenBy(x => x.Key.PerformanceMeasureDisplayName).ToList();

            ShowExpectedPerformanceMeasures =
                MultiTenantHelpers.GetTenantAttributeFromCache().ShowExpectedPerformanceMeasuresOnFactSheet&&
                (project.ProjectStage == ProjectStage.Implementation || project.ProjectStage == ProjectStage.PostImplementation) && !PerformanceMeasureReportedValues.Any();

            ChartID  = $"fundingChartForProject{project.ProjectID}";
            KeyPhoto = project.GetKeyPhoto();
            ProjectImagesExceptKeyPhotoGroupedByTiming =
                project.ProjectImages.Where(x => !x.IsKeyPhoto && x.ProjectImageTiming != ProjectImageTiming.Unknown && !x.ExcludeFromFactSheet)
                .GroupBy(x => x.ProjectImageTiming)
                .OrderBy(x => x.Key.SortOrder)
                .ToList();
            ProjectImagesPerTimingGroup = ProjectImagesExceptKeyPhotoGroupedByTiming.Count == 1 ? 6 : 2;
            Classifications             = project.ProjectClassifications.Select(x => x.Classification).ToList().SortByOrderThenName().ToList();

            ProjectLocationSummaryMapInitJson = projectLocationSummaryMapInitJson;
            GoogleChartJson = projectFactSheetGoogleChart;

            ExpenditureGooglePieChartSlices = expenditureGooglePieChartSlices;
            ChartColorRange = chartColorRange;
            //Dynamically resize chart based on how much space the legend requires
            CalculatedChartHeight = 350 - ExpenditureGooglePieChartSlices.Count * 19;
            FactSheetPdfUrl       = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.FactSheetPdf(project));

            FactSheetWithCustomAttributesPdfUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.FactSheetWithCustomAttributesPdf(project));

            if (project.GetTaxonomyLeaf() == null)
            {
                TaxonomyColor = "blue";
            }
            else
            {
                switch (MultiTenantHelpers.GetTaxonomyLevel().ToEnum)
                {
                case TaxonomyLevelEnum.Leaf:
                    TaxonomyColor = project.GetTaxonomyLeaf().ThemeColor;
                    break;

                case TaxonomyLevelEnum.Branch:
                    TaxonomyColor = project.GetTaxonomyLeaf().TaxonomyBranch.ThemeColor;
                    break;

                case TaxonomyLevelEnum.Trunk:
                    TaxonomyColor = project.GetTaxonomyLeaf().TaxonomyBranch.TaxonomyTrunk.ThemeColor;
                    break;
                }
            }
            TaxonomyLeafName                = project.GetTaxonomyLeaf() == null ? $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} Taxonomy Not Set" : project.GetTaxonomyLeaf().GetDisplayName();
            TaxonomyBranchName              = project.GetTaxonomyLeaf() == null ? $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} Taxonomy Not Set" : project.GetTaxonomyLeaf().TaxonomyBranch.GetDisplayName();
            TaxonomyLeafDisplayName         = FieldDefinitionEnum.TaxonomyLeaf.ToType().GetFieldDefinitionLabel();
            PrimaryContactPerson            = project.GetPrimaryContact();
            CustomFactSheetPageTextViewData = new ViewPageContentViewData(firmaPageFactSheet, false);
            TechnicalAssistanceParameters   = technicalAssistanceParameters;
            TechnicalAssistanceRequests     = project.TechnicalAssistanceRequests.ToList();

            ViewableProjectCustomAttributeTypes = HttpRequestStorage.DatabaseEntities.ProjectCustomAttributeTypes.ToList().Where(x => x.HasViewPermission(currentFirmaSession) && x.IsViewableOnFactSheet).ToList();
            ViewableProjectCustomAttributes     = project.ProjectCustomAttributes.Where(x => x.ProjectCustomAttributeType.HasViewPermission(currentFirmaSession) && ViewableProjectCustomAttributeTypes.Contains(x.ProjectCustomAttributeType)).ToList();

            WithCustomAttributes = withCustomAttributes;
            LastUpdated          = project.LastUpdatedDate;
            FactSheetPdfEnum     = factSheetPdfEnum;

            // No delay loading our fake image by default
            int fakeImageDelayInMilliseconds = 0;

            // When set the page is being rendered for PDF
            if (factSheetPdfEnum == ProjectController.FactSheetPdfEnum.Pdf)
            {
                // If we are printing for PDF, we have a fake 1x1 transparent image that we deliberately take time to load. This causes Headless Chrome
                // to delay printing the page until the map is ready to be viewed.
                //
                // We hope that 4 seconds is enough to allow the mapping components to load. Increase if they don't render properly.
                fakeImageDelayInMilliseconds = ForwardLookingFactSheetViewData.FactSheetPdfEmptyImageLoadDelayInMilliseconds;
            }

            FakeImageWithDelayUrl = new SitkaRoute <FakeImageController>(c => c.ReturnEmptyImageAfterDelayInMilliseconds(fakeImageDelayInMilliseconds)).BuildAbsoluteUrlHttpsFromExpression();

            ProjectLocationIsProvided = project.ProjectLocationPoint != null || project.ProjectLocations.Any();
        }