Ejemplo n.º 1
0
 /// <summary>
 ///     same as
 ///     <see cref="GetPlausibilityReport(BO4E.BO.Energiemenge,BO4E.BO.Energiemenge,Itenso.TimePeriod.ITimeRange,bool)" />
 ///     but with a strongly typed container as input.
 /// </summary>
 /// <param name="config">container containing the relevant data</param>
 /// <param name="energiemenge"></param>
 /// <returns></returns>
 public static PlausibilityReport GetPlausibilityReport(this BO.Energiemenge energiemenge,
                                                        PlausibilityReportConfiguration config)
 {
     return(energiemenge.GetPlausibilityReport(config.Other,
                                               new TimeRange(config.Timeframe.Startdatum.Value.UtcDateTime,
                                                             config.Timeframe.Enddatum.Value.UtcDateTime), config.IgnoreLocation));
 }
        /// <summary>
        /// Get Monthly Completeness Reports for overall time range defined in <paramref name="config"/>.
        /// </summary>
        /// <param name="em">Energiemenge</param>
        /// <param name="config">configuration that contains the overall time range in <see cref="PlausibilityReportConfiguration.Timeframe"/></param>
        /// <returns></returns>
        public static IDictionary <ITimeRange, PlausibilityReport> GetMonthlyPlausibilityReports(this BO4E.BO.Energiemenge em, PlausibilityReportConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (config.Timeframe == null)
            {
                throw new ArgumentNullException(nameof(config.Timeframe));
            }
            var slices = GetLocalMonthlySlices(new TimeRange()
            {
                Start = config.Timeframe.Startdatum.Value,
                End   = config.Timeframe.Enddatum.Value
            });

            return(em.GetSlicedPlausibilityReports(config, slices));
        }
        /// <summary>
        /// creates a dictionary of completeness reports for a given list of reference time ranges.
        /// </summary>
        /// <param name="em">Energiemenge</param>
        /// <param name="ranges">list of ranges for which the completeness reports are generated</param>
        /// <returns></returns>
        public static IDictionary <ITimeRange, PlausibilityReport> GetSlicedPlausibilityReports(this BO4E.BO.Energiemenge em, PlausibilityReportConfiguration config, IEnumerable <ITimeRange> ranges)
        {
            if (ranges == null)
            {
                throw new ArgumentNullException(nameof(ranges), "list of time ranges must not be null");
            }
            Dictionary <ITimeRange, PlausibilityReport> result = new Dictionary <ITimeRange, PlausibilityReport>();

            foreach (var range in ranges)
            {
                var localConfig = JsonConvert.DeserializeObject <PlausibilityReportConfiguration>(JsonConvert.SerializeObject(config));
                localConfig.Timeframe = new Zeitraum()
                {
                    Startdatum = range.Start,
                    Enddatum   = range.End
                };
                var subResult = GetPlausibilityReport(em, localConfig);
                result.Add(range, subResult);
            }
            return(result);
        }