public PerformanceMeasureExpectedGridSpec(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure)
        {
            Add(FieldDefinitionEnum.Project.ToType().ToGridHeaderString(),
                a => UrlTemplate.MakeHrefString(a.Project.GetDetailUrl(), a.Project.GetDisplayName()),
                350,
                DhtmlxGridColumnFilterType.Html);
            if (MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship())
            {
                Add(FieldDefinitionEnum.ProjectsStewardOrganizationRelationshipToProject.ToType().ToGridHeaderString(), x => x.Project.GetCanStewardProjectsOrganization().GetShortNameAsUrl(), 150,
                    DhtmlxGridColumnFilterType.Html);
            }
            Add(FieldDefinitionEnum.IsPrimaryContactOrganization.ToType().ToGridHeaderString(), x => x.Project.GetPrimaryContactOrganization().GetShortNameAsUrl(), 150, DhtmlxGridColumnFilterType.Html);
            Add(FieldDefinitionEnum.ProjectStage.ToType().ToGridHeaderString(), a => a.Project.ProjectStage.ProjectStageDisplayName, 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            foreach (var performanceMeasureSubcategory in performanceMeasure.PerformanceMeasureSubcategories.OrderBy(x => x.PerformanceMeasureSubcategoryDisplayName))
            {
                Add(performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName,
                    a =>
                {
                    var performanceMeasureExpectedSubcategoryOption =
                        a.PerformanceMeasureExpectedSubcategoryOptions.SingleOrDefault(x => x.PerformanceMeasureSubcategoryID == performanceMeasureSubcategory.PerformanceMeasureSubcategoryID);
                    if (performanceMeasureExpectedSubcategoryOption != null)
                    {
                        return(performanceMeasureExpectedSubcategoryOption.PerformanceMeasureSubcategoryOption.PerformanceMeasureSubcategoryOptionName);
                    }
                    return(string.Empty);
                },
                    120,
                    DhtmlxGridColumnFilterType.SelectFilterStrict);
            }
            var expectedValueColumnName = $"{FieldDefinitionEnum.ExpectedValue.ToType().ToGridHeaderString()} ({performanceMeasure.MeasurementUnitType.LegendDisplayName})";

            Add(expectedValueColumnName, a => a.ExpectedValue, 150, DhtmlxGridColumnFormatType.Decimal, DhtmlxGridColumnAggregationType.Total);
        }
 public PerformanceMeasureSubcategoriesTotalReportedValue(ProjectFirmaModels.Models.Project project, List <IPerformanceMeasureValueSubcategoryOption> subcategoryOptions, ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, double?totalReportedValue)
 {
     Project = project;
     PerformanceMeasureActualSubcategoryOptions = subcategoryOptions;
     PerformanceMeasure = performanceMeasure;
     TotalReportedValue = totalReportedValue;
 }
Exemple #3
0
        public PerformanceMeasureChartViewData(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
                                               int height,
                                               FirmaSession currentFirmaSession,
                                               bool showLastUpdatedDate,
                                               bool fromPerformanceMeasureDetailPage,
                                               List<ProjectFirmaModels.Models.Project> projects,
                                               string chartUniqueName,
                                               ProjectFirmaModels.Models.GeospatialArea geospatialArea)
        {
            PerformanceMeasure = performanceMeasure;
            HyperlinkPerformanceMeasureName = !fromPerformanceMeasureDetailPage;

            GoogleChartJsons = performanceMeasure.GetGoogleChartJsonDictionary(geospatialArea, projects, chartUniqueName);

            var performanceMeasureActuals = PerformanceMeasure.PerformanceMeasureActuals.Where(x => projects.Contains(x.Project)).ToList();
            ChartTotal = performanceMeasureActuals.Any() ? performanceMeasureActuals.Sum(x => x.ActualValue) : (double?) null;
            ChartTotalFormatted = PerformanceMeasure.MeasurementUnitType.DisplayValue(ChartTotal);

            var currentPersonHasManagePermission = new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession);
            CanManagePerformanceMeasures = currentPersonHasManagePermission && fromPerformanceMeasureDetailPage;

            ShowLastUpdatedDate = showLastUpdatedDate;
            ChartTitle = performanceMeasure.GetDisplayName();
            ViewGoogleChartViewData = new ViewGoogleChartViewData(GoogleChartJsons,
                ChartTitle,
                height,
                null,
                chartUniqueName,
                CanManagePerformanceMeasures,
                SitkaRoute<GoogleChartController>.BuildUrlFromExpression(c => c.DownloadPerformanceMeasureChartData()),
                true,
                true,
                performanceMeasure,
                HyperlinkPerformanceMeasureName);
        }
        public void SetGoogleChartConfigurationForGeospatialAreaPerformanceMeasure(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, ProjectFirmaModels.Models.GeospatialArea geospatialArea)
        {
            // Google Chart Configuration
            if (performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Any() || performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.Any())
            {
                foreach (var pfSubcategory in performanceMeasure.PerformanceMeasureSubcategories)
                {
                    var tempChartConfig = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                    tempChartConfig.SeriesType = "bars";
                    tempChartConfig.Series     =
                        performanceMeasure.HasGeospatialAreaTargets(geospatialArea) && performanceMeasure.HasTargets()
                            ? GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTwoTargets()
                            : GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTargets();

                    pfSubcategory.GeospatialAreaTargetChartConfigurationJson = JObject.FromObject(tempChartConfig).ToString();
                    pfSubcategory.GeospatialAreaTargetGoogleChartTypeID      = performanceMeasure.HasGeospatialAreaTargets(geospatialArea) ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                    if (performanceMeasure.CanBeChartedCumulatively)
                    {
                        var cumulativeChartConfigurationJson = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                        cumulativeChartConfigurationJson.SeriesType    = "bars";
                        pfSubcategory.CumulativeChartConfigurationJson = JObject.FromObject(cumulativeChartConfigurationJson).ToString();
                        pfSubcategory.CumulativeGoogleChartTypeID      = performanceMeasure.HasTargets() ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                    }
                }
            }
        }
 public EditPerformanceMeasureTargetsViewDataForAngular(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, int defaultReportingPeriodYear, List <PerformanceMeasureTargetValueType> performanceMeasureTargetValueTypes, bool isGeospatialAreaTarget)
 {
     PerformanceMeasureTargetValueTypes = performanceMeasureTargetValueTypes;
     DefaultReportingPeriodYear         = defaultReportingPeriodYear;
     ReportingPeriodsWithActuals        = performanceMeasure.PerformanceMeasureActuals.Select(x => x.PerformanceMeasureReportingPeriod).Select(x => x.PerformanceMeasureReportingPeriodID).ToList();
     DefaultTargetLabel = isGeospatialAreaTarget ? $"{FieldDefinitionEnum.GeospatialArea.ToType().GetFieldDefinitionLabel()} Target" : $"{FieldDefinitionEnum.PerformanceMeasure.ToType().GetFieldDefinitionLabel()} Target";
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureFixedTarget(PerformanceMeasure performanceMeasure) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureFixedTargetID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure = performanceMeasure;
     performanceMeasure.PerformanceMeasureFixedTargets.Add(this);
 }
Exemple #7
0
 public PerformanceMeasureReportedValue(PerformanceMeasure performanceMeasure, Project project, int calendarYear, double reportedValue)
 {
     PerformanceMeasure = performanceMeasure;
     CalendarYear       = calendarYear;
     _reportedValue     = reportedValue;
     Project            = project;
     PerformanceMeasureActualSubcategoryOptions = new List <IPerformanceMeasureValueSubcategoryOption>();
 }
        public void UpdateModel(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure)
        {
            var performanceMeasureSubcategoriesFromDatabase      = HttpRequestStorage.DatabaseEntities.AllPerformanceMeasureSubcategories.Local;
            var performanceMeasureSubcategoryOptionsFromDatabase = HttpRequestStorage.DatabaseEntities.AllPerformanceMeasureSubcategoryOptions.Local;

            var performanceMeasureSubcategoriesToUpdate = PerformanceMeasureSubcategorySimples.Select(x =>
            {
                var performanceMeasureSubcategory = new PerformanceMeasureSubcategory(new ProjectFirmaModels.Models.PerformanceMeasure(String.Empty, default(int), default(int), false, PerformanceMeasureDataSourceType.Project.PerformanceMeasureDataSourceTypeID, false, false),
                                                                                      x.PerformanceMeasureSubcategoryDisplayName);
                performanceMeasureSubcategory.PerformanceMeasure = performanceMeasure;
                performanceMeasureSubcategory.PerformanceMeasureSubcategoryID      = x.PerformanceMeasureSubcategoryID;
                performanceMeasureSubcategory.PerformanceMeasureSubcategoryOptions =
                    x.PerformanceMeasureSubcategoryOptions.OrderBy(y => y.SortOrder).Select(
                        (y, index) =>
                        new PerformanceMeasureSubcategoryOption(
                            new PerformanceMeasureSubcategory(new ProjectFirmaModels.Models.PerformanceMeasure(String.Empty, default(int), default(int), false, PerformanceMeasureDataSourceType.Project.PerformanceMeasureDataSourceTypeID, false, false), String.Empty),
                            y.PerformanceMeasureSubcategoryOptionName,
                            false)
                {
                    PerformanceMeasureSubcategory =
                        performanceMeasure.PerformanceMeasureSubcategories.SingleOrDefault(z => z.PerformanceMeasureSubcategoryID == x.PerformanceMeasureSubcategoryID),
                    PerformanceMeasureSubcategoryOptionID = y.PerformanceMeasureSubcategoryOptionID,
                    SortOrder       = index + 1,
                    ShowOnFactSheet = y.ShowOnFactSheet
                }).ToList();
                var chartConfigurationJson = JObject.FromObject(performanceMeasure.GetDefaultPerformanceMeasureChartConfigurationJson()).ToString();
                performanceMeasureSubcategory.ChartConfigurationJson = chartConfigurationJson;
                performanceMeasureSubcategory.GoogleChartTypeID      = performanceMeasure.HasTargets() ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                if (performanceMeasure.CanBeChartedCumulatively)
                {
                    var cumulativeChartConfigurationJson = JObject.FromObject(performanceMeasure.GetDefaultPerformanceMeasureChartConfigurationJson()).ToString();
                    performanceMeasureSubcategory.CumulativeChartConfigurationJson = cumulativeChartConfigurationJson;
                    performanceMeasureSubcategory.CumulativeGoogleChartTypeID      = performanceMeasure.HasTargets() ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                }
                return(performanceMeasureSubcategory);
            }).ToList();

            var performanceMeasureSubcategoryOptionsToUpdate = performanceMeasureSubcategoriesToUpdate.SelectMany(x => x.PerformanceMeasureSubcategoryOptions).ToList();

            performanceMeasure.PerformanceMeasureSubcategories.SelectMany(x => x.PerformanceMeasureSubcategoryOptions).ToList().Merge(
                performanceMeasureSubcategoryOptionsToUpdate,
                performanceMeasureSubcategoryOptionsFromDatabase,
                (x, y) => x.PerformanceMeasureSubcategoryOptionID == y.PerformanceMeasureSubcategoryOptionID,
                (x, y) =>
            {
                x.PerformanceMeasureSubcategoryOptionName = y.PerformanceMeasureSubcategoryOptionName;
                x.SortOrder       = y.SortOrder;
                x.ShowOnFactSheet = y.ShowOnFactSheet;
            }, HttpRequestStorage.DatabaseEntities);

            performanceMeasure.PerformanceMeasureSubcategories.Merge(performanceMeasureSubcategoriesToUpdate,
                                                                     performanceMeasureSubcategoriesFromDatabase,
                                                                     (x, y) => x.PerformanceMeasureSubcategoryID == y.PerformanceMeasureSubcategoryID,
                                                                     (x, y) =>
            {
                x.PerformanceMeasureSubcategoryDisplayName = y.PerformanceMeasureSubcategoryDisplayName;
            }, HttpRequestStorage.DatabaseEntities);
        }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureSubcategory(PerformanceMeasure performanceMeasure, string performanceMeasureSubcategoryDisplayName) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureSubcategoryID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.PerformanceMeasureID            = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure = performanceMeasure;
     performanceMeasure.PerformanceMeasureSubcategories.Add(this);
     this.PerformanceMeasureSubcategoryDisplayName = performanceMeasureSubcategoryDisplayName;
 }
 public void UpdateModel(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, FirmaSession currentFirmaSession)
 {
     performanceMeasure.PerformanceMeasureDisplayName = PerformanceMeasureDisplayName;
     performanceMeasure.PerformanceMeasureTypeID      = PerformanceMeasureTypeID.Value;
     performanceMeasure.MeasurementUnitTypeID         = MeasurementUnitTypeID;
     performanceMeasure.PerformanceMeasureDefinition  = PerformanceMeasureDefinition;
     performanceMeasure.IsSummable = IsSummable.GetValueOrDefault();                             // will never be null due to RequiredAttribute
     performanceMeasure.CanBeChartedCumulatively = CanBeChartedCumulatively.GetValueOrDefault(); // will never be null due to RequiredAttribute
 }
 public EditPerformanceMeasureTargetsViewData(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
                                              EditPerformanceMeasureTargetsViewDataForAngular viewDataForAngular,
                                              PerformanceMeasureTargetType performanceMeasureTargetType)
 {
     PerformanceMeasure = performanceMeasure;
     ViewDataForAngular = viewDataForAngular;
     PerformanceMeasureFieldDefinition = FieldDefinitionEnum.PerformanceMeasure.ToType();
     ShowGeoSpatialAreaInstructions    = performanceMeasureTargetType == PerformanceMeasureTargetType.TargetByGeospatialArea;
 }
 public EditViewModel(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureID          = performanceMeasure.PerformanceMeasureID;
     PerformanceMeasureDisplayName = performanceMeasure.PerformanceMeasureDisplayName;
     PerformanceMeasureTypeID      = performanceMeasure.PerformanceMeasureTypeID;
     MeasurementUnitTypeID         = performanceMeasure.MeasurementUnitTypeID;
     PerformanceMeasureDefinition  = performanceMeasure.PerformanceMeasureDefinition;
     IsSummable = performanceMeasure.IsSummable;
     CanBeChartedCumulatively = performanceMeasure.CanBeChartedCumulatively;
 }
Exemple #13
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureNote(PerformanceMeasure performanceMeasure, string note, DateTime createDate) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureNoteID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.PerformanceMeasureID     = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure       = performanceMeasure;
     performanceMeasure.PerformanceMeasureNotes.Add(this);
     this.Note       = note;
     this.CreateDate = createDate;
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public TaxonomyLeafPerformanceMeasure(TaxonomyLeaf taxonomyLeaf, PerformanceMeasure performanceMeasure) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.TaxonomyLeafPerformanceMeasureID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.TaxonomyLeafID = taxonomyLeaf.TaxonomyLeafID;
     this.TaxonomyLeaf   = taxonomyLeaf;
     taxonomyLeaf.TaxonomyLeafPerformanceMeasures.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.TaxonomyLeafPerformanceMeasures.Add(this);
 }
 public EditPerformanceMeasureTargetsViewModel(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureReportingPeriodSimples = PerformanceMeasureReportingPeriodSimple.MakeFromList(performanceMeasure.PerformanceMeasureReportingPeriodTargets, performanceMeasure.PerformanceMeasureActuals);
     PerformanceMeasureTargetValueTypeID      = performanceMeasure.GetTargetValueType().PerformanceMeasureTargetValueTypeID;
     if (performanceMeasure.GetTargetValueType() == PerformanceMeasureTargetValueType.FixedTarget)
     {
         var fixedTarget = performanceMeasure.PerformanceMeasureFixedTargets.First();
         FixedTargetValue      = fixedTarget.PerformanceMeasureTargetValue;
         FixedTargetValueLabel = fixedTarget.PerformanceMeasureTargetValueLabel;
     }
 }
Exemple #16
0
 public PerformanceMeasureChartViewData(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, FirmaSession currentFirmaSession, bool showLastUpdatedDate, List<ProjectFirmaModels.Models.Project> projects) : this(
     performanceMeasure,
     DefaultHeight,
     currentFirmaSession,
     showLastUpdatedDate,
     false, 
     projects,
     performanceMeasure.GetJavascriptSafeChartUniqueName(),
     null)
 {
 }
Exemple #17
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureImage(PerformanceMeasure performanceMeasure, FileResourceInfo fileResourceInfo) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureImageID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.PerformanceMeasureID      = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure        = performanceMeasure;
     performanceMeasure.PerformanceMeasureImages.Add(this);
     this.FileResourceInfoID = fileResourceInfo.FileResourceInfoID;
     this.FileResourceInfo   = fileResourceInfo;
     fileResourceInfo.PerformanceMeasureImages.Add(this);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public MatchmakerOrganizationPerformanceMeasure(Organization organization, PerformanceMeasure performanceMeasure) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.MatchmakerOrganizationPerformanceMeasureID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.OrganizationID = organization.OrganizationID;
     this.Organization   = organization;
     organization.MatchmakerOrganizationPerformanceMeasures.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.MatchmakerOrganizationPerformanceMeasures.Add(this);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureExpected(Project project, PerformanceMeasure performanceMeasure) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureExpectedID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectID = project.ProjectID;
     this.Project   = project;
     project.PerformanceMeasureExpecteds.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.PerformanceMeasureExpecteds.Add(this);
 }
        public PerformanceMeasureReportedValuesGridSpec(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure)
        {
            Add(FieldDefinitionEnum.ReportingYear.ToType().ToGridHeaderString(), a => a.GetCalendarYearDisplay(), 60, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.Project.ToType().ToGridHeaderString(),
                a => a.Project.GetDisplayNameAsUrl(),
                350,
                DhtmlxGridColumnFilterType.Html);
            if (MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship())
            {
                Add(FieldDefinitionEnum.ProjectsStewardOrganizationRelationshipToProject.ToType().ToGridHeaderString(), x => x.Project.GetCanStewardProjectsOrganization().GetShortNameAsUrl(), 150,
                    DhtmlxGridColumnFilterType.Html);
            }
            Add(FieldDefinitionEnum.IsPrimaryContactOrganization.ToType().ToGridHeaderString(), x => x.Project.GetPrimaryContactOrganization().GetShortNameAsUrl(), 150, DhtmlxGridColumnFilterType.Html);
            Add(FieldDefinitionEnum.ProjectStage.ToType().ToGridHeaderString(), a => a.Project.ProjectStage.ProjectStageDisplayName, 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            if (performanceMeasure.HasRealSubcategories())
            {
                foreach (var performanceMeasureSubcategory in
                         performanceMeasure.PerformanceMeasureSubcategories.OrderBy(x =>
                                                                                    x.PerformanceMeasureSubcategoryDisplayName))
                {
                    Add(performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName,
                        a =>
                    {
                        var performanceMeasureActualSubcategoryOption =
                            a.PerformanceMeasureActualSubcategoryOptions.SingleOrDefault(x =>
                                                                                         x.PerformanceMeasureSubcategoryID ==
                                                                                         performanceMeasureSubcategory.PerformanceMeasureSubcategoryID);
                        if (performanceMeasureActualSubcategoryOption != null)
                        {
                            return(performanceMeasureActualSubcategoryOption.PerformanceMeasureSubcategoryOption
                                   .PerformanceMeasureSubcategoryOptionName);
                        }

                        return(string.Empty);
                    }, 120, DhtmlxGridColumnFilterType.SelectFilterStrict);
                }
            }
            var reportedValueColumnName = $"{FieldDefinitionEnum.ReportedValue.ToType().ToGridHeaderString()} ({performanceMeasure.MeasurementUnitType.LegendDisplayName})";

            if (performanceMeasure.IsSummable)
            {
                Add(reportedValueColumnName, a => a.GetReportedValue(), 150, DhtmlxGridColumnFormatType.Decimal,
                    DhtmlxGridColumnAggregationType.Total);
            }
            else
            {
                Add(reportedValueColumnName, a => a.GetReportedValue(), 150, DhtmlxGridColumnFormatType.Decimal);
            }
            foreach (var geospatialAreaType in new List <GeospatialAreaType>())
            {
                Add($"{geospatialAreaType.GeospatialAreaTypeNamePluralized}", a => a.Project.GetProjectGeospatialAreaNamesAsHyperlinks(geospatialAreaType), 350, DhtmlxGridColumnFilterType.Html);
            }
        }
Exemple #21
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public ClassificationPerformanceMeasure(Classification classification, PerformanceMeasure performanceMeasure, bool isPrimaryChart) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ClassificationPerformanceMeasureID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ClassificationID = classification.ClassificationID;
     this.Classification   = classification;
     classification.ClassificationPerformanceMeasures.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.ClassificationPerformanceMeasures.Add(this);
     this.IsPrimaryChart = isPrimaryChart;
 }
Exemple #22
0
 public PerformanceMeasureChartViewData(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
     FirmaSession currentFirmaSession, bool showLastUpdatedDate, List<ProjectFirmaModels.Models.Project> projects,
     string chartUniqueName) : this(
     performanceMeasure,
     DefaultHeight,
     currentFirmaSession,
     showLastUpdatedDate,
     false,
     projects,
     chartUniqueName,
     null)
 {
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureActualUpdate(ProjectUpdateBatch projectUpdateBatch, PerformanceMeasure performanceMeasure, PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureActualUpdateID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectUpdateBatchID             = projectUpdateBatch.ProjectUpdateBatchID;
     this.ProjectUpdateBatch = projectUpdateBatch;
     projectUpdateBatch.PerformanceMeasureActualUpdates.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.PerformanceMeasureActualUpdates.Add(this);
     this.PerformanceMeasureReportingPeriodID = performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodID;
     this.PerformanceMeasureReportingPeriod   = performanceMeasureReportingPeriod;
     performanceMeasureReportingPeriod.PerformanceMeasureActualUpdates.Add(this);
 }
Exemple #24
0
        public string GetPerformanceMeasureSubcategoriesAsString()
        {
            if (PerformanceMeasure.HasRealSubcategories())
            {
                return(PerformanceMeasureExpectedSubcategoryOptions.Any()
                    ? String.Join("\r\n",
                                  PerformanceMeasureExpectedSubcategoryOptions.OrderBy(x =>
                                                                                       x.PerformanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName)
                                  .Select(x =>
                                          $"{x.PerformanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName}: {x.PerformanceMeasureSubcategoryOption.PerformanceMeasureSubcategoryOptionName}"))
                    : ViewUtilities.NoneString);
            }

            return(string.Empty);
        }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureActual(Project project, PerformanceMeasure performanceMeasure, double actualValue, PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureActualID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectID = project.ProjectID;
     this.Project   = project;
     project.PerformanceMeasureActuals.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.PerformanceMeasureActuals.Add(this);
     this.ActualValue = actualValue;
     this.PerformanceMeasureReportingPeriodID = performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodID;
     this.PerformanceMeasureReportingPeriod   = performanceMeasureReportingPeriod;
     performanceMeasureReportingPeriod.PerformanceMeasureActuals.Add(this);
 }
        public RelatedTaxonomyTiersViewData(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, TaxonomyLevel associatePerformanceMeasureTaxonomyLevel, bool showHelpLinks)
        {
            TaxonomyLeafPerformanceMeasures = performanceMeasure.GetTaxonomyTiers();
            PerformanceMeasureDisplayName   = MultiTenantHelpers.GetPerformanceMeasureName();
            var fieldDefinitionForTaxonomyTier = associatePerformanceMeasureTaxonomyLevel.GetFieldDefinition();

            TaxonomyTierDisplayName       = fieldDefinitionForTaxonomyTier.GetFieldDefinitionLabel();
            TaxonomyTierHeaderDisplayName = showHelpLinks
                ? LabelWithSugarForExtensions.LabelWithSugarFor(
                fieldDefinitionForTaxonomyTier,
                LabelWithSugarForExtensions.DisplayStyle.HelpIconWithLabel, TaxonomyTierDisplayName)
                : new HtmlString(TaxonomyTierDisplayName);
            TaxonomyTierDisplayNamePluralized        = fieldDefinitionForTaxonomyTier.GetFieldDefinitionLabelPluralized();
            AssociatePerformanceMeasureTaxonomyLevel = associatePerformanceMeasureTaxonomyLevel;
        }
        public void DeleteOtherPerformanceMeasureTargetValueTypes(
            ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
            PerformanceMeasureTargetValueTypeEnum performanceMeasureTargetValueTypeEnum)
        {
            if (performanceMeasureTargetValueTypeEnum != PerformanceMeasureTargetValueTypeEnum.FixedTarget)
            {
                var overallTargetsToDelete = performanceMeasure.PerformanceMeasureFixedTargets.ToList();
                overallTargetsToDelete.ForEach(oa => oa.DeleteFull(HttpRequestStorage.DatabaseEntities));
            }

            if (performanceMeasureTargetValueTypeEnum != PerformanceMeasureTargetValueTypeEnum.TargetPerYear)
            {
                var reportingPeriodTargetsToDelete = performanceMeasure.PerformanceMeasureReportingPeriodTargets.ToList();
                reportingPeriodTargetsToDelete.ForEach(oa => oa.DeleteFull(HttpRequestStorage.DatabaseEntities));
            }
        }
        public void SetGoogleChartConfigurationForPerformanceMeasure(
            ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
            PerformanceMeasureTargetValueTypeEnum performanceMeasureTargetValueTypeEnum)
        {
            var geospatialAreasWithTargets = new List <ProjectFirmaModels.Models.GeospatialArea>();

            geospatialAreasWithTargets.AddRange(performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.Select(x => x.GeospatialArea));
            geospatialAreasWithTargets.AddRange(performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Select(x => x.GeospatialArea));

            //Google Chart Configuration for the Performance Measure
            foreach (var pfSubcategory in performanceMeasure.PerformanceMeasureSubcategories)
            {
                var tempChartConfig = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                tempChartConfig.SeriesType = "bars";
                if (performanceMeasure.HasTargets())
                {
                    tempChartConfig.Series          = GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTargets();
                    pfSubcategory.GoogleChartTypeID = GoogleChartType.ComboChart.GoogleChartTypeID;
                }
                else
                {
                    tempChartConfig.Series          = null;
                    pfSubcategory.GoogleChartTypeID = GoogleChartType.ColumnChart.GoogleChartTypeID;
                }
                pfSubcategory.ChartConfigurationJson = JObject.FromObject(tempChartConfig).ToString();
                if (performanceMeasure.CanBeChartedCumulatively)
                {
                    var cumulativeChartConfigurationJson = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                    cumulativeChartConfigurationJson.SeriesType    = "bars";
                    pfSubcategory.CumulativeChartConfigurationJson = JObject.FromObject(cumulativeChartConfigurationJson).ToString();
                    pfSubcategory.CumulativeGoogleChartTypeID      = performanceMeasure.HasTargets() ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                }

                // We need to adjust the chart JSON for the the geospatial area as well if there are geospatial area targets for this performance measure by adding an additional line series to the configuration json
                if (geospatialAreasWithTargets.Any())
                {
                    var tempGeospatialChartConfig = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                    tempGeospatialChartConfig.SeriesType = "bars";
                    tempGeospatialChartConfig.Series     = performanceMeasure.HasTargets() ? GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTwoTargets() : GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTargets();
                    pfSubcategory.GeospatialAreaTargetChartConfigurationJson = JObject.FromObject(tempGeospatialChartConfig).ToString();
                    pfSubcategory.GeospatialAreaTargetGoogleChartTypeID      = GoogleChartType.ComboChart.GoogleChartTypeID;
                }
            }
        }
Exemple #29
0
        public void UpdateModel(FirmaSession currentFirmaSession, ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure)
        {
            if (GeospatialAreas == null || !GeospatialAreas.Any())
            {
                return;
            }
            foreach (var geospatialAreaID in GeospatialAreas)
            {
                var geospatialArea = HttpRequestStorage.DatabaseEntities.GeospatialAreas.Single(x => x.GeospatialAreaID == geospatialAreaID);
                if (geospatialArea == null)
                {
                    //bad geospatialAreaID from front-end
                    continue;
                }

                // Default to a "No Target"
                var noTarget = GeospatialAreaPerformanceMeasureNoTargetModelExtensions.GetOrCreateGeospatialAreaPerformanceMeasureNoTarget(performanceMeasure, geospatialArea);
                HttpRequestStorage.DatabaseEntities.AllGeospatialAreaPerformanceMeasureNoTargets.Add(noTarget);
            }
            HttpRequestStorage.DatabaseEntities.SaveChanges(currentFirmaSession);
        }
Exemple #30
0
        public SpendingByPerformanceMeasureByProjectGridSpec(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure)
        {
            Add(FieldDefinitionEnum.Project.ToType().ToGridHeaderString(), a => UrlTemplate.MakeHrefString(a.ProjectUrl, a.ProjectName), 350, DhtmlxGridColumnFilterType.Html);
            Add(FieldDefinitionEnum.ProjectStage.ToType().ToGridHeaderString(), x => x.Project.ProjectStage.ProjectStageDisplayName, 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            foreach (var performanceMeasureSubcategory in performanceMeasure.PerformanceMeasureSubcategories.OrderBy(x => x.PerformanceMeasureSubcategoryDisplayName))
            {
                Add(performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName,
                    a =>
                {
                    var performanceMeasureActualSubcategoryOption =
                        a.PerformanceMeasureActualSubcategoryOptions.SingleOrDefault(x => x.PerformanceMeasureSubcategoryID == performanceMeasureSubcategory.PerformanceMeasureSubcategoryID);
                    if (performanceMeasureActualSubcategoryOption != null)
                    {
                        return(performanceMeasureActualSubcategoryOption.PerformanceMeasureSubcategoryOption.PerformanceMeasureSubcategoryOptionName);
                    }
                    return(string.Empty);
                },
                    120,
                    DhtmlxGridColumnFilterType.SelectFilterStrict);
            }

            var reportedValueColumnName = $"{FieldDefinitionEnum.ReportedValue.ToType().ToGridHeaderString()} ({performanceMeasure.MeasurementUnitType.LegendDisplayName})";

            Add(reportedValueColumnName, a => a.TotalReportedValue, 150, DhtmlxGridColumnFormatType.Decimal, DhtmlxGridColumnAggregationType.Total);
            Add(FieldDefinitionEnum.ReportedExpenditure.ToType().ToGridHeaderString(), x => x.CalculateWeightedTotalExpenditure(), 100, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);

            var reportedValueUnitCostColumnName = $"Estimated Cost Per {performanceMeasure.MeasurementUnitType.SingularDisplayName} ";

            Add(reportedValueUnitCostColumnName, a => a.CalculateWeightedTotalExpenditurePerPerformanceMeasure(), 100, DhtmlxGridColumnFormatType.Currency);

            Add($"Other Reported {MultiTenantHelpers.GetPerformanceMeasureNamePluralized()}",
                a =>
            {
                var reportedPerformanceMeasures = a.Project.GetPerformanceMeasureReportedValues().Where(x => a.PerformanceMeasureID != x.PerformanceMeasure.PerformanceMeasureID).ToList();
                var htmlStrings = reportedPerformanceMeasures.DistinctBy(x => x.PerformanceMeasureID).Select(x => UrlTemplate.MakeHrefString(x.PerformanceMeasure.GetSummaryUrl(), x.PerformanceMeasure.PerformanceMeasureID.ToString())).ToList();
                return(new HtmlString(string.Join(", ", htmlStrings)));
            },
                200,
                DhtmlxGridColumnFilterType.Html);
        }