예제 #1
0
 public PerformanceMeasureValueSubcategoryOption(int primaryKey, int performanceMeasureSubcategoryOptionID, PerformanceMeasure performanceMeasure, PerformanceMeasureSubcategory performanceMeasureSubcategory)
 {
     PrimaryKey = primaryKey;
     PerformanceMeasureSubcategoryOptionID = performanceMeasureSubcategoryOptionID;
     PerformanceMeasure            = performanceMeasure;
     PerformanceMeasureSubcategory = performanceMeasureSubcategory;
 }
예제 #2
0
        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 PerformanceMeasureReportedValue(PerformanceMeasure performanceMeasure, Project project, int calendarYear, double reportedValue)
 {
     PerformanceMeasure = performanceMeasure;
     CalendarYear       = calendarYear;
     ReportedValue      = reportedValue;
     Project            = project;
     PerformanceMeasureActualSubcategoryOptions = new List <IPerformanceMeasureValueSubcategoryOption>();
 }
예제 #4
0
 public static string GetEditReportedValuesUrl(this PerformanceMeasure performanceMeasure)
 {
     if (performanceMeasure != null)
     {
         return(null);
     }
     throw new NotImplementedException($"PerformanceMeasure {0} is not reported in the {Models.FieldDefinition.Project.GetFieldDefinitionLabel()} Tracker!  No way to edit {FieldDefinition.ReportedValue.GetFieldDefinitionLabel()}!");
 }
예제 #5
0
        public static PerformanceMeasureChartViewData GetPerformanceMeasureChartViewData(
            this Classification classification,
            PerformanceMeasure performanceMeasure,
            FirmaSession currentFirmaSession)
        {
            var projects = classification.GetAssociatedProjects(currentFirmaSession);

            return(new PerformanceMeasureChartViewData(performanceMeasure, currentFirmaSession, false, projects));
        }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureReportingPeriod(PerformanceMeasure performanceMeasure, DateTime performanceMeasureReportingPeriodBeginDate, string performanceMeasureReportingPeriodLabel)
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureReportingPeriodID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     this.PerformanceMeasureReportingPeriodBeginDate = performanceMeasureReportingPeriodBeginDate;
     this.PerformanceMeasureReportingPeriodLabel     = performanceMeasureReportingPeriodLabel;
 }
        public static PerformanceMeasureChartViewData GetPerformanceMeasureChartViewData(
            this GeospatialArea geospatialArea,
            PerformanceMeasure performanceMeasure,
            FirmaSession currentFirmaSession)
        {
            var projects = geospatialArea.GetAssociatedProjects(currentFirmaSession);

            return(new PerformanceMeasureChartViewData(geospatialArea, performanceMeasure, currentFirmaSession, false, projects));
        }
 /// <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;
 }
예제 #9
0
 public PerformanceMeasureSimple(PerformanceMeasure performanceMeasure)
     : this(
         performanceMeasure.PerformanceMeasureID,
         performanceMeasure.MeasurementUnitTypeID,
         performanceMeasure.PerformanceMeasureDisplayName,
         performanceMeasure.MeasurementUnitType.MeasurementUnitTypeDisplayName,
         performanceMeasure.HasRealSubcategories(),
         performanceMeasure.GetDefinitionAndGuidanceUrl())
 {
 }
        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 decimal?TotalExpenditurePerPerformanceMeasureUnit(this PerformanceMeasure performanceMeasure, FirmaSession currentFirmaSession)
        {
            var totalReportedValues = SubcategoriesTotalReportedValues(currentFirmaSession, performanceMeasure).Where(x => x.CalculateWeightedTotalExpenditure() > 0).Sum(x => x.TotalReportedValue ?? 0);

            if (Math.Abs(totalReportedValues) < Double.Epsilon)
            {
                return(null);
            }
            return(performanceMeasure.TotalExpenditure(currentFirmaSession) / (decimal)totalReportedValues);
        }
 /// <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;
 }
예제 #13
0
 /// <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);
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public ProjectTypePerformanceMeasure(ProjectType projectType, PerformanceMeasure performanceMeasure, bool isPrimaryProjectType) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ProjectTypePerformanceMeasureID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectTypeID = projectType.ProjectTypeID;
     this.ProjectType   = projectType;
     projectType.ProjectTypePerformanceMeasures.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.ProjectTypePerformanceMeasures.Add(this);
     this.IsPrimaryProjectType = isPrimaryProjectType;
 }
 public static PerformanceMeasureTargetValueType GetTargetValueType(this PerformanceMeasure performanceMeasure)
 {
     if (performanceMeasure.PerformanceMeasureReportingPeriodTargets.Any())
     {
         return(PerformanceMeasureTargetValueType.TargetPerYear);
     }
     if (performanceMeasure.PerformanceMeasureFixedTargets.Any())
     {
         return(PerformanceMeasureTargetValueType.FixedTarget);
     }
     return(PerformanceMeasureTargetValueType.NoTarget);
 }
 /// <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;
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureActualUpdate(ProjectUpdateBatch projectUpdateBatch, PerformanceMeasure performanceMeasure, int calendarYear) : 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.CalendarYear = calendarYear;
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasureActual(Project project, PerformanceMeasure performanceMeasure, int calendarYear, double actualValue) : 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.CalendarYear = calendarYear;
     this.ActualValue  = actualValue;
 }
예제 #19
0
        public static GoogleChartConfiguration GetDefaultPerformanceMeasureChartConfigurationJson(
            PerformanceMeasure performanceMeasure)
        {
            var googleChartType           = GoogleChartType.ColumnChart;
            var googleChartAxisHorizontal =
                new GoogleChartAxis("Reporting Year", null, null)
            {
                Gridlines = new GoogleChartGridlinesOptions(-1, "transparent")
            };
            var googleChartAxisVerticals = new List <GoogleChartAxis>();
            var defaultSubcategoryChartConfigurationJson = new GoogleChartConfiguration(
                performanceMeasure.PerformanceMeasureDisplayName, true, googleChartType, googleChartAxisHorizontal,
                googleChartAxisVerticals);

            return(defaultSubcategoryChartConfigurationJson);
        }
        public static List <GoogleChartJson> MakeGoogleChartJsons(PerformanceMeasure performanceMeasure, List <ProjectPerformanceMeasureReportingPeriodValue> projectPerformanceMeasureReportingPeriodValues)
        {
            var performanceMeasureSubcategoryOptionReportedValues = projectPerformanceMeasureReportingPeriodValues.SelectMany(x => x.PerformanceMeasureSubcategoryOptionReportedValues).GroupBy(x => x.PerformanceMeasureSubcategory);
            var performanceMeasureReportingPeriods = projectPerformanceMeasureReportingPeriodValues.Select(x => x.PerformanceMeasureReportingPeriod).Distinct(new HavePrimaryKeyComparer <PerformanceMeasureReportingPeriod>()).ToList();
            var googleChartJsons = new List <GoogleChartJson>();

            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.DisplayName
                };
                var hasTargets           = GetTargetValueType(performanceMeasureReportingPeriods) != PerformanceMeasureTargetValueType.NoTarget;
                var googleChartDataTable = performanceMeasure.SwapChartAxes
                    ? GetGoogleChartDataTableWithReportingPeriodsAsVerticalAxis(performanceMeasure, hasTargets, performanceMeasureReportingPeriods, groupedBySubcategoryOption)
                    : GetGoogleChartDataTableWithReportingPeriodsAsHorixontalAxis(performanceMeasure, performanceMeasureReportingPeriods, hasTargets, groupedBySubcategoryOption, chartColumns, performanceMeasure.CanCalculateTotal);
                var legendTitle          = performanceMeasure.HasRealSubcategories ? performanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName : performanceMeasure.DisplayName;
                var chartName            = $"{performanceMeasure.GetJavascriptSafeChartUniqueName()}PerformanceMeasureSubcategory{performanceMeasureSubcategory.PerformanceMeasureSubcategoryID}";
                var saveConfigurationUrl = SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x =>
                                                                                                             x.SaveChartConfiguration(performanceMeasure,
                                                                                                                                      performanceMeasureSubcategory.PerformanceMeasureSubcategoryID));

                var resetConfigurationUrl =
                    SitkaRoute <PerformanceMeasureController> .BuildUrlFromExpression(x =>
                                                                                      x.ResetChartConfiguration(performanceMeasure,
                                                                                                                performanceMeasureSubcategory.PerformanceMeasureSubcategoryID));

                var chartConfiguration = JsonConvert.DeserializeObject <GoogleChartConfiguration>(performanceMeasureSubcategory.ChartConfigurationJson);
                if (performanceMeasureSubcategory.PerformanceMeasure.CanCalculateTotal && !performanceMeasure.SwapChartAxes)
                {
                    chartConfiguration.Tooltip = new GoogleChartTooltip(true);
                }

                var googleChartJson = new GoogleChartJson(legendTitle, chartName, chartConfiguration,
                                                          performanceMeasureSubcategory.GoogleChartType, googleChartDataTable,
                                                          chartColumns, saveConfigurationUrl, resetConfigurationUrl);
                googleChartJsons.Add(googleChartJson);
            }
            return(googleChartJsons);
        }
예제 #21
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static PerformanceMeasureExpected CreateNewBlank(Project project, PerformanceMeasure performanceMeasure)
 {
     return(new PerformanceMeasureExpected(project, performanceMeasure));
 }
예제 #22
0
        public PerformanceMeasureChartViewData GetPerformanceMeasureChartViewData(PerformanceMeasure performanceMeasure, Person currentPerson)
        {
            var projects = GetAssociatedProjectsVisibleToUser(currentPerson);

            return(new PerformanceMeasureChartViewData(performanceMeasure, currentPerson, false, projects));
        }
예제 #23
0
 private static string GetActualValueDisplay(double expectedValue, PerformanceMeasure performanceMeasure)
 {
     return(performanceMeasure.MeasurementUnitType.DisplayValue(expectedValue));
 }
        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);
        }
예제 #25
0
 public static string GetJavascriptSafeChartUniqueName(this PerformanceMeasure performanceMeasure)
 {
     return($"PerformanceMeasure{performanceMeasure.PerformanceMeasureID}");
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static PerformanceMeasureNote CreateNewBlank(PerformanceMeasure performanceMeasure)
 {
     return(new PerformanceMeasureNote(performanceMeasure, default(string), default(DateTime)));
 }
예제 #27
0
        public List <ProjectPerformanceMeasureReportingPeriodValue> GetProjectPerformanceMeasureSubcategoryOptionReportedValues(PerformanceMeasure performanceMeasure, List <Project> projects)
        {
            var performanceMeasureValues = performanceMeasure.PerformanceMeasureDataSourceType.GetReportedPerformanceMeasureValues(
                performanceMeasure,
                projects);

            var performanceMeasureActualsFiltered =
                projects?.Any() == true?performanceMeasureValues.Where(pmav => projects.Contains(pmav.Project)).ToList() : performanceMeasureValues;

            var groupByProjectAndSubcategory = performanceMeasureActualsFiltered.GroupBy(pirv => new { pirv.Project, pirv.PerformanceMeasureSubcategoriesAsString, pirv.CalendarYear }).OrderBy(x => x.Key.PerformanceMeasureSubcategoriesAsString).ToList();

            var projectPerformanceMeasureReportingPeriodValues = groupByProjectAndSubcategory.Select(reportedValuesGroup =>
            {
                var project = reportedValuesGroup.Key.Project;
                var performanceMeasureReportingPeriodSubcategoryOptionReportedValues = reportedValuesGroup.First().PerformanceMeasureSubcategoryOptions.OrderBy(y =>
                                                                                                                                                                y.PerformanceMeasureSubcategory.PerformanceMeasureSubcategoryDisplayName).Select(
                    (y, index) =>
                {
                    if (y.PerformanceMeasureSubcategoryOption != null)
                    {
                        return(new
                               PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue(
                                   reportedValuesGroup.Key.CalendarYear, y.PerformanceMeasureSubcategoryOption,
                                   reportedValuesGroup.Sum(x => x.ReportedValue ?? 0)));
                    }
                    else
                    {
                        return(new
                               PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue(
                                   reportedValuesGroup.Key.CalendarYear,
                                   reportedValuesGroup.Sum(x => x.ReportedValue ?? 0), y.PerformanceMeasureSubcategory, y.PerformanceMeasureSubcategoryOptionName));
                    }
                }).ToList();

                return(new ProjectPerformanceMeasureReportingPeriodValue(project, performanceMeasureReportingPeriodSubcategoryOptionReportedValues));
            }).ToList();

            return(projectPerformanceMeasureReportingPeriodValues.OrderByDescending(pma => pma.CalendarYear).ThenBy(pma => pma.Project.ProjectName).ToList());
        }
예제 #28
0
        public virtual List <PerformanceMeasureReportedValue> GetReportedPerformanceMeasureValues(PerformanceMeasure performanceMeasure, List <Project> projects)
        {
            List <PerformanceMeasureActual> performanceMeasureActuals;

            if (projects == null || !projects.Any())
            {
                performanceMeasureActuals = HttpRequestStorage.DatabaseEntities.PerformanceMeasureActuals.Where(pmav => pmav.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID).ToList();
            }
            else
            {
                var projectIDs = projects.Select(x => x.ProjectID).ToList();
                performanceMeasureActuals =
                    HttpRequestStorage.DatabaseEntities.PerformanceMeasureActuals.Where(
                        pmav => pmav.PerformanceMeasureID == performanceMeasure.PerformanceMeasureID && projectIDs.Contains(pmav.Project.ProjectID)).ToList();
            }
            var performanceMeasureReportedValues = PerformanceMeasureReportedValue.MakeFromList(performanceMeasureActuals);

            return(performanceMeasureReportedValues.OrderByDescending(pma => pma.CalendarYear).ThenBy(pma => pma.ProjectName).ToList());
        }
 public ReportingCategoryForDisplay(PerformanceMeasure performanceMeasure)
 {
     PerformanceMeasureSubcategoryOptionID = null;
     DisplayName = performanceMeasure.PerformanceMeasureDisplayName;
     SortOrder   = 1;
 }
예제 #30
0
 public static string GetDeleteUrl(this PerformanceMeasure performanceMeasure)
 {
     return(DeleteUrlTemplate.ParameterReplace(performanceMeasure.PerformanceMeasureID));
 }