/// <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 BO4E.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 = reference.Start, Enddatum = reference.End }, Coverage = coverage, ErrorMessage = errorMessage }); } var combi = combis.First(); return(em.GetCompletenessReport(reference, combi.Item1, combi.Item2, combi.Item3)); }
/// <summary> /// <see cref="GetCompletenessReport(BO.Energiemenge, ITimeRange, Wertermittlungsverfahren, string, Mengeneinheit)"/> /// for pure Energiemengen within their own time range. /// </summary> /// <param name="em">Energiemenge</param> /// <returns><see cref="GetCompletenessReport(BO.Energiemenge, ITimeRange, Wertermittlungsverfahren, string, Mengeneinheit)"/></returns> public static CompletenessReport GetCompletenessReport(this BO4E.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 <Verbrauch>(); } 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(BO.Energiemenge, TimeRange, Wertermittlungsverfahren, string, Mengeneinheit)"/> 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 BO4E.BO.Energiemenge em, CompletenessReport.CompletenessReportConfiguration config) { return(em.GetCompletenessReport(new TimeRange(config.ReferenceTimeFrame.Startdatum.Value, config.ReferenceTimeFrame.Enddatum.Value), config.Wertermittlungsverfahren, config.Obis, config.Einheit)); }