本文整理汇总了C#中DataConnection.GetDayAveragesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# DataConnection.GetDayAveragesAsync方法的具体用法?C# DataConnection.GetDayAveragesAsync怎么用?C# DataConnection.GetDayAveragesAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataConnection
的用法示例。
在下文中一共展示了DataConnection.GetDayAveragesAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFittedMeasurements
private static Task<IEnumerable<Measurement>> GetFittedMeasurements(
DataConnection Connection, int SensorId, DateTime StartTime, DateTime EndTime,
int MaxMeasurementCount)
{
if (EndTime < StartTime)
throw new ArgumentException($"{nameof(StartTime)} was greater than {nameof(EndTime)}");
var timeSpan = EndTime - StartTime;
if (timeSpan.TotalMinutes <= MaxMeasurementCount)
{
// Assume that one measurement was made per minute.
// This assumption may not _always_ prove to be correct,
// but we'd like to keep database chatter to a minimum.
return Connection.GetMeasurementsAsync(SensorId, StartTime, EndTime);
}
else if (timeSpan.TotalHours <= MaxMeasurementCount)
{
return Connection.GetHourAveragesAsync(
SensorId, MeasurementAggregation.Quantize(StartTime, TimeSpan.FromHours(1)),
(int)Math.Round(timeSpan.TotalHours));
}
else if (timeSpan.TotalDays <= MaxMeasurementCount)
{
return Connection.GetDayAveragesAsync(
SensorId, MeasurementAggregation.Quantize(StartTime, TimeSpan.FromDays(1)),
(int)Math.Round(timeSpan.TotalDays));
}
else
{
int yearCount = EndTime.Year - StartTime.Year;
int monthCount = 12 * yearCount + EndTime.Month - StartTime.Month;
if (monthCount <= MaxMeasurementCount)
{
return Connection.GetMonthAveragesAsync(
SensorId, MeasurementAggregation.QuantizeMonth(StartTime), monthCount);
}
else
{
return Connection.GetYearAveragesAsync(
SensorId, MeasurementAggregation.QuantizeYear(StartTime), yearCount);
}
}
}
示例2: GetAggregatedRangeAsync
public override Task<IEnumerable<Measurement>> GetAggregatedRangeAsync(DataConnection Connection, int SensorId, DateTime StartTime, int ResultCount)
{
return Connection.GetDayAveragesAsync(SensorId, StartTime, ResultCount);
}