/* * public static string GetTargetValueDisplayForGrid(this GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure) * { * if (!performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID).Any(x => x.GeospatialAreaPerformanceMeasureTargetValue.HasValue)) * { * return "No Target Set"; * } * * if (performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID).Select(x => $"{x.GeospatialAreaPerformanceMeasureTargetValue}{x.GeospatialAreaPerformanceMeasureTargetValueLabel}").Distinct().Count() == 1) * { * //we know all targetValues are the same so just get the first geospatial target * var geospatialAreaPerformanceMeasureTarget = performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID).First(x => x.GeospatialAreaPerformanceMeasureTargetValue.HasValue); * Check.EnsureNotNull(geospatialAreaPerformanceMeasureTarget.GeospatialAreaPerformanceMeasureTargetValue, "geospatialAreaPerformanceMeasureTarget.GeospatialAreaPerformanceMeasureTargetValue != null"); * var targetValue = geospatialAreaPerformanceMeasureTarget.GeospatialAreaPerformanceMeasureTargetValue.Value.ToString(); * var performanceMeasureMeasurementUnitType = geospatialAreaPerformanceMeasureTarget.PerformanceMeasure.MeasurementUnitType; * var measurementUnit = performanceMeasureMeasurementUnitType == MeasurementUnitType.Number ? "" : performanceMeasureMeasurementUnitType.LegendDisplayName; * return $"{targetValue} {measurementUnit}"; * } * return "Target by Year"; * } */ public static string GetTargetValueDisplayForGrid(this GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure) { PerformanceMeasureTargetValueTypeEnum performanceMeasureTargetValueTypeEnum = performanceMeasure.GetPerformanceMeasureTargetValueTypeForGeospatialArea(geospatialArea); switch (performanceMeasureTargetValueTypeEnum) { case PerformanceMeasureTargetValueTypeEnum.NoTarget: return("No Target"); case PerformanceMeasureTargetValueTypeEnum.FixedTarget: var areaPerformanceMeasureFixedTarget = performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.SingleOrDefault(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID); Check.EnsureNotNull(areaPerformanceMeasureFixedTarget); Check.EnsureNotNull(areaPerformanceMeasureFixedTarget.GeospatialAreaPerformanceMeasureTargetValue, "geospatialAreaPerformanceMeasureTarget.GeospatialAreaPerformanceMeasureTargetValue != null"); var targetValue = areaPerformanceMeasureFixedTarget.GeospatialAreaPerformanceMeasureTargetValue.ToString(); var performanceMeasureMeasurementUnitType = areaPerformanceMeasureFixedTarget.PerformanceMeasure.MeasurementUnitType; var measurementUnit = performanceMeasureMeasurementUnitType == MeasurementUnitType.Number ? "" : performanceMeasureMeasurementUnitType.LegendDisplayName; return($"{targetValue} {measurementUnit}"); case PerformanceMeasureTargetValueTypeEnum.TargetPerYear: return("Target By Year"); default: throw new NotImplementedException("There should never be a valid target value type here"); } }
public static GeospatialArea Create() { var geospatialAreaType = TestFramework.TestGeospatialAreaType.Create(); var geospatialArea = GeospatialArea.CreateNewBlank(geospatialAreaType); geospatialArea.GeospatialAreaName = MakeTestGeospatialAreaName(); return(geospatialArea); }
public static Feature MakeFeatureWithRelevantProperties(this GeospatialArea geospatialArea) { var feature = DbGeometryToGeoJsonHelper.FromDbGeometry(geospatialArea.GeospatialAreaFeature); feature.Properties.Add(geospatialArea.GeospatialAreaType.GeospatialAreaTypeName, geospatialArea.GetDisplayNameAsUrl().ToString()); return(feature); }
public static PerformanceMeasureChartViewData GetPerformanceMeasureChartViewData( this GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure, FirmaSession currentFirmaSession) { var projects = geospatialArea.GetAssociatedProjects(currentFirmaSession); return(new PerformanceMeasureChartViewData(geospatialArea, performanceMeasure, currentFirmaSession, false, projects)); }
private PartialViewResult ViewDeleteGeospatialArea(GeospatialArea geospatialArea, ConfirmDialogFormViewModel viewModel) { var canDelete = !geospatialArea.HasDependentObjects(); var confirmMessage = canDelete ? $"Are you sure you want to delete this {geospatialArea.GeospatialAreaType.GeospatialAreaTypeName} '{geospatialArea.GeospatialAreaShortName}'?" : ConfirmDialogFormViewData.GetStandardCannotDeleteMessage($"{geospatialArea.GeospatialAreaType.GeospatialAreaTypeDefinition}", SitkaRoute <GeospatialAreaController> .BuildLinkFromExpression(x => x.Detail(geospatialArea), "here")); var viewData = new ConfirmDialogFormViewData(confirmMessage, canDelete); return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel)); }
private PartialViewResult ViewDelete(GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure, ConfirmDialogFormViewModel viewModel) { var geospatialAreaPerformanceMeasureTargets = HttpRequestStorage.DatabaseEntities.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID && x.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID); var confirmMessage = $"Are you sure you want to delete all targets associated with this {FieldDefinitionEnum.GeospatialArea.ToType().GetFieldDefinitionLabel()} '{geospatialArea.GeospatialAreaShortName}'?"; var viewData = new ConfirmDialogFormViewData(confirmMessage, true); return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel)); }
private ActionResult ViewEdit(GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure, EditPerformanceMeasureTargetsViewModel viewModel) { var performanceMeasureTargetValueTypes = PerformanceMeasureTargetValueType.All.ToList(); var reportingPeriods = performanceMeasure.GetPerformanceMeasureReportingPeriodsFromTargetsAndActualsAndGeospatialAreaTargets(geospatialArea); var defaultReportingPeriodYear = reportingPeriods.Any() ? reportingPeriods.Max(x => x.PerformanceMeasureReportingPeriodCalendarYear) + 1 : DateTime.Now.Year; var viewDataForAngular = new EditPerformanceMeasureTargetsViewDataForAngular(performanceMeasure, defaultReportingPeriodYear, performanceMeasureTargetValueTypes, true); var viewData = new EditPerformanceMeasureTargetsViewData(performanceMeasure, viewDataForAngular, EditPerformanceMeasureTargetsViewData.PerformanceMeasureTargetType.TargetByGeospatialArea); return(RazorPartialView <EditPerformanceMeasureTargets, EditPerformanceMeasureTargetsViewData, EditPerformanceMeasureTargetsViewModel>(viewData, viewModel)); }
public static GeospatialAreaPerformanceMeasureNoTarget GetOrCreateGeospatialAreaPerformanceMeasureNoTarget(PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea) { var noTarget = HttpRequestStorage.DatabaseEntities.GeospatialAreaPerformanceMeasureNoTargets.SingleOrDefault(pmnt => pmnt.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID && pmnt.GeospatialAreaID == geospatialArea.GeospatialAreaID); if (noTarget == null) { noTarget = new GeospatialAreaPerformanceMeasureNoTarget(geospatialArea, performanceMeasure); } return(noTarget); }
public static ProjectGeospatialArea Create(Project project, GeospatialArea geospatialArea) { var projectGeospatialArea = ProjectGeospatialArea.CreateNewBlank(project, geospatialArea); return(projectGeospatialArea); }
public static string GetDetailUrl(this GeospatialArea geospatialArea) { return(GetDetailUrl(geospatialArea.GeospatialAreaID)); }
/// <summary> /// This overload includes the PerformanceMeasureReportingPeriods tied to GeospatialArea Targets /// </summary> /// <param name="performanceMeasure"></param> /// <returns></returns> public static List <PerformanceMeasureReportingPeriod> GetPerformanceMeasureReportingPeriodsFromTargetsAndActualsAndGeospatialAreaTargets(this PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea) { List <PerformanceMeasureReportingPeriod> performanceMeasureReportingPeriods = new List <PerformanceMeasureReportingPeriod>(); performanceMeasureReportingPeriods.AddRange(performanceMeasure.GetPerformanceMeasureReportingPeriodsFromTargetsAndActuals()); performanceMeasureReportingPeriods.AddRange(performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Where(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID).Select(x => x.PerformanceMeasureReportingPeriod)); return(performanceMeasureReportingPeriods.Distinct().ToList()); }
public static HtmlString GetDisplayNameAsUrl(this GeospatialArea geospatialArea) { return(UrlTemplate.MakeHrefString(geospatialArea.GetDetailUrl(), geospatialArea.GeospatialAreaShortName)); }
public static GoogleChartDataTable GetGoogleChartDataTableWithReportingPeriodsAsHorizontalAxis(PerformanceMeasure performanceMeasure, ICollection <PerformanceMeasureReportingPeriod> performanceMeasureReportingPeriods, bool hasTargets, bool hasGeospatialAreaTargets, GeospatialArea geospatialArea, IReadOnlyCollection <IGrouping <Tuple <string, int>, PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue> > groupedBySubcategoryOption, IEnumerable <string> chartColumns, bool hasToolTipWithTotal, bool reverseTooltipOrder, bool showCumulativeResults) { var googleChartRowCs = new List <GoogleChartRowC>(); foreach (var performanceMeasureReportingPeriod in performanceMeasureReportingPeriods.OrderBy(x => x.PerformanceMeasureReportingPeriodCalendarYear)) { var googleChartRowVs = new List <GoogleChartRowV> { new GoogleChartRowV(performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel) }; var firstReportingPeriod = performanceMeasureReportingPeriods.OrderBy(x => x.PerformanceMeasureReportingPeriodCalendarYear).First(); var targetValue = performanceMeasureReportingPeriod.GetTargetValue(performanceMeasure); var geospatialAreaTargetValue = hasGeospatialAreaTargets ? performanceMeasureReportingPeriod.GetGeospatialAreaTargetValue(performanceMeasure, geospatialArea) : null; if (hasToolTipWithTotal) { var targetValueDescription = performanceMeasureReportingPeriod.GetTargetValueLabel(performanceMeasure); var geospatialAreaTargetValueDescription = hasGeospatialAreaTargets ? performanceMeasureReportingPeriod.GetGeospatialAreaTargetValueLabel(performanceMeasure, geospatialArea) : string.Empty; var formattedDataTooltip = FormattedDataTooltip(groupedBySubcategoryOption, performanceMeasureReportingPeriod, performanceMeasure.MeasurementUnitType, reverseTooltipOrder, targetValue, targetValueDescription, geospatialAreaTargetValue, geospatialAreaTargetValueDescription, showCumulativeResults, firstReportingPeriod); googleChartRowVs.Add(new GoogleChartRowV(null, formattedDataTooltip)); } if (hasTargets) { googleChartRowVs.Add(new GoogleChartRowV(targetValue, GetFormattedTargetValue(performanceMeasureReportingPeriod, performanceMeasure))); } if (hasGeospatialAreaTargets) { googleChartRowVs.Add(new GoogleChartRowV(geospatialAreaTargetValue, GetFormattedGeospatialAreaTargetValue(performanceMeasureReportingPeriod, performanceMeasure, geospatialArea))); } googleChartRowVs.AddRange(groupedBySubcategoryOption.OrderBy(x => x.Key.Item2).Select(x => { double calendarYearReportedValue; if (showCumulativeResults) { calendarYearReportedValue = x.Where(pmsorv => pmsorv.PerformanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear <= performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear) .Sum(pmsorv => pmsorv.ReportedValue) ?? 0; } else { calendarYearReportedValue = x.Where(pmsorv => pmsorv.PerformanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear == performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear) .Sum(pmsorv => pmsorv.ReportedValue) ?? 0; } return(new GoogleChartRowV(calendarYearReportedValue, GoogleChartJson.GetFormattedValue(calendarYearReportedValue, performanceMeasure.MeasurementUnitType))); })); googleChartRowCs.Add(new GoogleChartRowC(googleChartRowVs)); } // reporting period is going to be the first column and it will be our horizontal axis var googleChartColumns = new List <GoogleChartColumn> { new GoogleChartColumn("Reporting Period", GoogleChartColumnDataType.String) }; // add column with row tooltip if (hasToolTipWithTotal) { googleChartColumns.Add(new GoogleChartColumn(GoogleChartColumnDataType.String.ColumnDataType, "tooltip", new GoogleChartProperty())); } if (hasTargets) { // GoogleChartType for targets is always LINE; we also always render the target line first to stay consistent googleChartColumns.Add(new GoogleChartColumn(GetTargetColumnLabel(performanceMeasure), GoogleChartColumnDataType.Number)); } if (hasGeospatialAreaTargets) { // GoogleChartType for targets is always LINE; we also always render the target line first to stay consistent googleChartColumns.Add(new GoogleChartColumn(GetGeospatialAreaTargetColumnLabel(performanceMeasure, geospatialArea), GoogleChartColumnDataType.Number)); } // all the subcategory option values are individual columns and series and they will be on the vertical axis googleChartColumns.AddRange(chartColumns.Select(x => new GoogleChartColumn(x, GoogleChartColumnDataType.Number))); var googleChartDataTable = new GoogleChartDataTable(googleChartColumns, googleChartRowCs); return(googleChartDataTable); }
public static string GetEditGeospatialAreaPerformanceMeasureTargetUrl(this GeospatialArea geospatialArea, PerformanceMeasure performanceMeasure) { return(SitkaRoute <GeospatialAreaPerformanceMeasureTargetController> .BuildUrlFromExpression(t => t.Edit(geospatialArea.GeospatialAreaID, performanceMeasure.PerformanceMeasureID))); }
private static string GetFormattedGeospatialAreaTargetValue(PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod, PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea) { return($"{GoogleChartJson.GetFormattedValue(performanceMeasureReportingPeriod.GetGeospatialAreaTargetValue(performanceMeasure, geospatialArea), performanceMeasure.MeasurementUnitType)} ({performanceMeasureReportingPeriod.GetGeospatialAreaTargetValueLabel(performanceMeasure, geospatialArea)})"); }
private PartialViewResult ViewEditDescriptionInDialog(EditGeospatialAreaDescriptionViewModel viewModel, GeospatialArea geospatialArea) { var ckEditorToolbar = CkEditorExtension.CkEditorToolbar.All; var viewData = new EditGeospatialAreaDescriptionViewData(ckEditorToolbar, SitkaRoute <FileResourceController> .BuildUrlFromExpression(x => x.CkEditorUploadFileResourceForGeospatialAreaDescription(geospatialArea))); return(RazorPartialView <EditGeospatialAreaDescription, EditGeospatialAreaDescriptionViewData, EditGeospatialAreaDescriptionViewModel>(viewData, viewModel)); }
public static List <LayerGeoJson> GetGeospatialAreaAndAssociatedProjectLayers(this GeospatialArea geospatialArea, FirmaSession currentFirmaSession, List <Project> projects, out LayerGeoJson projectLayerGeoJson) { projectLayerGeoJson = new LayerGeoJson( $"Mapped {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}", projects.MappedPointsToGeoJsonFeatureCollection(false, true, false), "#ffff00", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); var geospatialAreaLayerGeoJson = new LayerGeoJson(geospatialArea.GeospatialAreaShortName, new List <GeospatialArea> { geospatialArea }.ToGeoJsonFeatureCollection(), "#2dc3a1", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); var layerGeoJsons = new List <LayerGeoJson> { geospatialAreaLayerGeoJson, geospatialArea.GeospatialAreaType.GetGeospatialAreaWmsLayerGeoJson("#59ACFF", 0.6m, LayerInitialVisibility.LayerInitialVisibilityEnum.Show) }; return(layerGeoJsons); }
public static bool HasGeospatialAreaTargets(this PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea) { if (geospatialArea == null) { return(false); } bool hasTargets = performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Any(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID) || performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.Any(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID); return(hasTargets); }
public static PerformanceMeasureTargetValueType GetGeospatialAreaTargetValueType(this PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea) { if (performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.Any(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID)) { return(PerformanceMeasureTargetValueType.FixedTarget); } if (performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Any(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID)) { return(PerformanceMeasureTargetValueType.TargetPerYear); } return(PerformanceMeasureTargetValueType.NoTarget); }
public static List <GoogleChartJson> MakeGoogleChartJsons(PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea, List <ProjectPerformanceMeasureReportingPeriodValue> projectPerformanceMeasureReportingPeriodValues) { var performanceMeasureSubcategoryOptionReportedValues = projectPerformanceMeasureReportingPeriodValues.SelectMany(x => x.PerformanceMeasureSubcategoryOptionReportedValues).GroupBy(x => x.PerformanceMeasureSubcategory); // This was changed to only use the performance measure reporting period from the actuals. Requested in PF#1901: https://projects.sitkatech.com/projects/projectfirma/cards/1901 var performanceMeasureReportingPeriods = performanceMeasure.GetPerformanceMeasureReportingPeriodsFromActuals(); var googleChartJsons = new List <GoogleChartJson>(); bool hasTargets = performanceMeasure.HasTargets(); bool hasGeospatialAreaTargets = false; if (geospatialArea != null) { hasGeospatialAreaTargets = performanceMeasure.GetGeospatialAreaTargetValueType(geospatialArea) != PerformanceMeasureTargetValueType.NoTarget; } if (performanceMeasureSubcategoryOptionReportedValues.Any()) { foreach (var groupedBySubcategory in performanceMeasureSubcategoryOptionReportedValues.Where(x => x.Key.ShowOnChart())) { var performanceMeasureSubcategory = groupedBySubcategory.Key; Check.RequireNotNull(performanceMeasureSubcategory.ChartConfigurationJson, "All PerformanceMeasure Subcategories need to have a Google Chart Configuration Json"); var groupedBySubcategoryOption = groupedBySubcategory.GroupBy(c => new Tuple <string, int>(c.ChartName, c.SortOrder)).ToList(); // Item1 is ChartName, Item2 is SortOrder var chartColumns = performanceMeasure.HasRealSubcategories() ? groupedBySubcategoryOption.OrderBy(x => x.Key.Item2).Select(x => x.Key.Item1).ToList() : new List <string> { performanceMeasure.GetDisplayName() }; var reverseTooltipOrder = performanceMeasureSubcategory.GoogleChartType == GoogleChartType.ColumnChart || performanceMeasureSubcategory.GoogleChartType == GoogleChartType.ComboChart; var googleChartDataTable = GetGoogleChartDataTableWithReportingPeriodsAsHorizontalAxis(performanceMeasure, performanceMeasureReportingPeriods, hasTargets, hasGeospatialAreaTargets, geospatialArea, groupedBySubcategoryOption, chartColumns, performanceMeasure.IsSummable, reverseTooltipOrder, false); var legendTitle = performanceMeasure.HasRealSubcategories() ? performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName : performanceMeasure.GetDisplayName(); var chartName = $"{performanceMeasure.GetJavascriptSafeChartUniqueName()}PerformanceMeasureSubcategory{performanceMeasureSubcategory.PerformanceMeasureSubcategoryID}"; var saveConfigurationUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.SaveChartConfiguration(performanceMeasure, performanceMeasureSubcategory.PerformanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration.ChartConfiguration)); var resetConfigurationUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.ResetChartConfiguration(performanceMeasure, performanceMeasureSubcategory.PerformanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration.ChartConfiguration)); GoogleChartConfiguration chartConfiguration; GoogleChartType chartType; if (hasGeospatialAreaTargets) { chartConfiguration = JsonConvert.DeserializeObject <GoogleChartConfiguration>(performanceMeasureSubcategory.GeospatialAreaTargetChartConfigurationJson); chartType = performanceMeasureSubcategory.GeospatialAreaTargetGoogleChartType; } else { chartConfiguration = JsonConvert.DeserializeObject <GoogleChartConfiguration>(performanceMeasureSubcategory.ChartConfigurationJson); chartType = performanceMeasureSubcategory.GoogleChartType; } if (performanceMeasureSubcategory.PerformanceMeasure.IsSummable) { chartConfiguration.Tooltip = new GoogleChartTooltip(true); } chartConfiguration.Series = GoogleChartSeries.CalculateChartSeriesFromCurrentChartSeries(chartConfiguration.Series, performanceMeasure, geospatialArea); var googleChartJson = new GoogleChartJson(legendTitle, chartName, chartConfiguration, chartType, googleChartDataTable, chartColumns, saveConfigurationUrl, resetConfigurationUrl, false); googleChartJsons.Add(googleChartJson); } // Add Cumulative charts if appropriate if (performanceMeasure.CanBeChartedCumulatively) { foreach (var groupedBySubcategory in performanceMeasureSubcategoryOptionReportedValues.Where(x => x.Key.ShowOnCumulativeChart())) { var performanceMeasureSubcategory = groupedBySubcategory.Key; var groupedBySubcategoryOption = groupedBySubcategory.GroupBy(c => new Tuple <string, int>(c.ChartName, c.SortOrder)).ToList(); // Item1 is ChartName, Item2 is SortOrder var chartColumns = performanceMeasure.HasRealSubcategories() ? groupedBySubcategoryOption.OrderBy(x => x.Key.Item2).Select(x => x.Key.Item1).ToList() : new List <string> { performanceMeasure.GetDisplayName() }; var reverseTooltipOrder = performanceMeasureSubcategory.GoogleChartType == GoogleChartType.ColumnChart || performanceMeasureSubcategory.GoogleChartType == GoogleChartType.ComboChart; var googleChartDataTable = GetGoogleChartDataTableWithReportingPeriodsAsHorizontalAxis(performanceMeasure, performanceMeasureReportingPeriods, hasTargets, hasGeospatialAreaTargets, geospatialArea, groupedBySubcategoryOption, chartColumns, performanceMeasure.IsSummable, reverseTooltipOrder, true); var legendTitle = performanceMeasure.HasRealSubcategories() ? performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName : performanceMeasure.GetDisplayName(); var chartName = $"{performanceMeasure.GetJavascriptSafeChartUniqueName()}PerformanceMeasureSubcategory{performanceMeasureSubcategory.PerformanceMeasureSubcategoryID}Cumulative"; var saveConfigurationUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.SaveChartConfiguration(performanceMeasure, performanceMeasureSubcategory.PerformanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration.CumulativeConfiguration)); var resetConfigurationUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.ResetChartConfiguration(performanceMeasure, performanceMeasureSubcategory.PerformanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration.CumulativeConfiguration)); var chartConfiguration = !string.IsNullOrEmpty(performanceMeasureSubcategory.CumulativeChartConfigurationJson) ? JsonConvert.DeserializeObject <GoogleChartConfiguration>(performanceMeasureSubcategory.CumulativeChartConfigurationJson) : GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(performanceMeasureSubcategory.ChartConfigurationJson); if (performanceMeasureSubcategory.PerformanceMeasure.IsSummable) { chartConfiguration.Tooltip = new GoogleChartTooltip(true); } chartConfiguration.Series = GoogleChartSeries.CalculateChartSeriesFromCurrentChartSeries(chartConfiguration.Series, performanceMeasure, geospatialArea); var googleChartJson = new GoogleChartJson(legendTitle, chartName, chartConfiguration, performanceMeasureSubcategory.CumulativeGoogleChartType ?? GoogleChartType.ColumnChart, googleChartDataTable, chartColumns, saveConfigurationUrl, resetConfigurationUrl, true); googleChartJsons.Add(googleChartJson); } } } else if (performanceMeasure.HasTargets()) { //build chart for just for targets if there is no project data var performanceMeasureSubcategory = performanceMeasure.PerformanceMeasureSubcategories.First(); var legendTitle = performanceMeasure.GetDisplayName(); var chartName = $"{performanceMeasure.GetJavascriptSafeChartUniqueName()}PerformanceMeasureSubcategory{performanceMeasureSubcategory.PerformanceMeasureSubcategoryID}"; var chartConfiguration = performanceMeasure.GetDefaultPerformanceMeasureChartConfigurationJson(); chartConfiguration.Series = GoogleChartSeries.CalculateChartSeriesFromCurrentChartSeries(chartConfiguration.Series, performanceMeasure, geospatialArea); var chartColumns = new List <string> { performanceMeasure.GetDisplayName() }; var reverseTooltipOrder = performanceMeasureSubcategory.GoogleChartType == GoogleChartType.ColumnChart || performanceMeasureSubcategory.GoogleChartType == GoogleChartType.ComboChart; var googleChartDataTable = GetGoogleChartDataTableWithReportingPeriodsAsHorizontalAxis(performanceMeasure, performanceMeasureReportingPeriods, true, false, null, new List <IGrouping <Tuple <string, int>, PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue> >(), chartColumns, false, reverseTooltipOrder, false); var saveConfigurationUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.SaveChartConfiguration(performanceMeasure, performanceMeasureSubcategory.PerformanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration.CumulativeConfiguration)); var resetConfigurationUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x => x.ResetChartConfiguration(performanceMeasure, performanceMeasureSubcategory.PerformanceMeasureSubcategoryID, PerformanceMeasureSubcategoryChartConfiguration.CumulativeConfiguration)); var googleChartJson = new GoogleChartJson(legendTitle, chartName, chartConfiguration, GoogleChartType.LineChart, googleChartDataTable, chartColumns, saveConfigurationUrl, resetConfigurationUrl, false); googleChartJsons.Add(googleChartJson); } return(googleChartJsons); }
private static string GetGeospatialAreaTargetColumnLabel(PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea) { var isFixedTarget = performanceMeasure.GetGeospatialAreaTargetValueType(geospatialArea) == PerformanceMeasureTargetValueType.FixedTarget; string response = isFixedTarget ? performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.First(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID).GeospatialAreaPerformanceMeasureTargetValueLabel : $"{FieldDefinitionEnum.GeospatialArea.ToType().GetFieldDefinitionLabel()} Target"; return(response); }
public static List <Project> GetAssociatedProjects(this GeospatialArea geospatialArea, FirmaSession currentFirmaSession) { return(geospatialArea.ProjectGeospatialAreas.Select(ptc => ptc.Project).ToList() .GetActiveProjectsAndProposals(currentFirmaSession.CanViewProposals())); }
public static List <GoogleChartJson> GetGoogleChartJsonDictionary(this PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea, List <Project> projects, string chartUniqueName) { var reportedValues = performanceMeasure.GetProjectPerformanceMeasureSubcategoryOptionReportedValues(projects); return(PerformanceMeasureSubcategoryModelExtensions.MakeGoogleChartJsons(performanceMeasure, geospatialArea, reportedValues)); }
public static GeospatialAreaPerformanceMeasureFixedTarget GetOrCreateGeospatialAreaPerformanceMeasureFixedTarget(this PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea, double fixedTargetValue) { var fixedTarget = HttpRequestStorage.DatabaseEntities.GeospatialAreaPerformanceMeasureFixedTargets.SingleOrDefault(pmot => pmot.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID && pmot.GeospatialAreaID == geospatialArea.GeospatialAreaID); if (fixedTarget == null) { fixedTarget = new GeospatialAreaPerformanceMeasureFixedTarget(geospatialArea, performanceMeasure, fixedTargetValue); } return(fixedTarget); }
public static string GetGeospatialAreaTargetValueLabel(this PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod, PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea) { var fixedTarget = performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.FirstOrDefault(x => x.GeospatialAreaID == geospatialArea.GeospatialAreaID); if (fixedTarget != null) { return(fixedTarget.GeospatialAreaPerformanceMeasureTargetValueLabel); } return(performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.SingleOrDefault(x => x.PerformanceMeasureReportingPeriodID == performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodID && x.GeospatialAreaID == geospatialArea.GeospatialAreaID)?.GeospatialAreaPerformanceMeasureTargetValueLabel); }