BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs
/// <summary>
///     Get average of Mengeneinheit for given time interval
/// </summary>
/// <param name="em">Energiemenge</param>
/// <param name="reference">reference time frame</param>
/// <param name="wev">Wertermittlungsverfahren</param>
/// <param name="obiskennzahl">OBIS</param>
/// <param name="me">an extensive or intensive unit</param>
/// <returns>the average value or null if no Verbrauch overlapped with the specified time interval</returns>
Get average of Mengeneinheit for given time interval
Get average of Mengeneinheit for given time interval
public static decimal? GetAverage(this BO.Energiemenge em, TimeRange reference,
            Wertermittlungsverfahren? wev, string obiskennzahl, Mengeneinheit me)
        {
            decimal? result = null;
            var overallDenominator = 0.0M;
            foreach (var v in em.Energieverbrauch.Where(v => v.Einheit == me))
            {
                var overlapFactor = GetOverlapFactor(new TimeRange((v.Startdatum ?? DateTimeOffset.MinValue).DateTime, (v.Enddatum ?? DateTimeOffset.MinValue).DateTime), reference, true);
                if (result.HasValue)
                    result += overlapFactor * v.Wert;
                else
                    result = v.Wert;
                overallDenominator += overlapFactor;
            }
            if (result.HasValue) return result / overallDenominator;
            return null;
        }
public static decimal ? GetAverage ( this BO . Energiemenge em , TimeRange reference , Wertermittlungsverfahren ? wev , string obiskennzahl , Mengeneinheit me ) { decimal ? result = null ; var overallDenominator = 0.0M ; foreach ( var v in em . Energieverbrauch . Where ( v => v . Einheit == me ) ) { var overlapFactor = GetOverlapFactor ( new TimeRange ( ( v . Startdatum ?? DateTimeOffset . MinValue ) . DateTime , ( v . Enddatum ?? DateTimeOffset . MinValue ) . DateTime ) , reference , true ) ; if ( result . HasValue ) result += overlapFactor * v . Wert ; else result = v . Wert ; overallDenominator += overlapFactor ; } if ( result . HasValue ) return result / overallDenominator ; return null ; }
Get average of Mengeneinheit for given time interval
Get average of Mengeneinheit for given time interval
the average value or null if no Verbrauch overlapped with the specified time interval
the average value or null if no Verbrauch overlapped with the specified time interval
BO.Energiemenge
this
reference
TimeRange
reference time frame
reference time frame
wev
Wertermittlungsverfahren?
None
obiskennzahl
string
None
me
Mengeneinheit
an extensive or intensive unit
an extensive or intensive unit
em
None