/// <summary> /// <see /// cref="GetCompletenessReport(BO4E.BO.Energiemenge,Itenso.TimePeriod.ITimeRange,BO4E.ENUM.Wertermittlungsverfahren,string,BO4E.ENUM.Mengeneinheit)" /> /// for pure Energiemengen within their own time range. /// </summary> /// <param name="em">Energiemenge</param> /// <returns> /// <see /// cref="GetCompletenessReport(BO4E.BO.Energiemenge,Itenso.TimePeriod.ITimeRange,BO4E.ENUM.Wertermittlungsverfahren,string,BO4E.ENUM.Mengeneinheit)" /> /// </returns> public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em) { if (!em.IsPure()) { throw new ArgumentException( "The provided Energiemenge is not pure. Please use overloaded method GetCompletenessReport(... , wertermittlungsverfahren, obiskennzahl, mengeneinheit)."); } Verbrauch v; try { v = em.Energieverbrauch.First(); } catch (InvalidOperationException) { return(new CompletenessReport { Coverage = null, LokationsId = em.LokationsId, ErrorMessage = "energieverbrauch is empty" }); } return(em.GetCompletenessReport(em.GetTimeRange(), v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit)); }
/// <summary> /// Generate a <see cref="CompletenessReport" /> for the given configuration. Same as /// <see cref="GetCompletenessReport(BO4E.BO.Energiemenge,BO4E.Reporting.CompletenessReport.CompletenessReportConfiguration)" /> /// but with all parameters in a configuration container instead of loose arguments. /// </summary> /// <param name="em">Energiemenge</param> /// <param name="config">configuration container</param> /// <returns></returns> public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, CompletenessReport.CompletenessReportConfiguration config) { return(em.GetCompletenessReport( new TimeRange(config.ReferenceTimeFrame.Startdatum.Value.UtcDateTime, config.ReferenceTimeFrame.Enddatum.Value.UtcDateTime), config.Wertermittlungsverfahren, config.Obis, config.Einheit)); }
/// <summary> /// Generate a <see cref="CompletenessReport" /> for the given refenrence time frame <paramref name="reference" /> /// </summary> /// <param name="em">Energiemenge</param> /// <param name="reference">reference time frame</param> /// <returns></returns> public static CompletenessReport GetCompletenessReport(this BO.Energiemenge em, ITimeRange reference) { var combis = em.GetWevObisMeCombinations(); if (combis.Count != 1) { string errorMessage; decimal?coverage; if (combis.Count == 0) { errorMessage = "Cannot use autoconfigured method because there are no values."; coverage = 0; } else { errorMessage = $"Cannot use autoconfigured method because there are {combis.Count}>1 distinct (wertermittlungsverfahren, obis, einheit) tuple present: {JsonConvert.SerializeObject(combis, new StringEnumConverter())}"; coverage = null; } return(new CompletenessReport { LokationsId = em.LokationsId, ReferenceTimeFrame = new Zeitraum { Startdatum = new DateTimeOffset(reference.Start), Enddatum = new DateTimeOffset(reference.End) }, Coverage = coverage, ErrorMessage = errorMessage }); } var combi = combis.First(); return(em.GetCompletenessReport(reference, combi.Item1, combi.Item2, combi.Item3)); }