本文整理汇总了C#中Frequency.CalculateItems方法的典型用法代码示例。如果您正苦于以下问题:C# Frequency.CalculateItems方法的具体用法?C# Frequency.CalculateItems怎么用?C# Frequency.CalculateItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frequency
的用法示例。
在下文中一共展示了Frequency.CalculateItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPlatformsGroups
public List<RequestGroup> GetPlatformsGroups(int typex, Frequency frequency, DateTime? @from, DateTime? to)
{
using (var db = base.NewDB())
{
var items = db.RequestLogs
.WhereByFromDate(from)
.WhereByToDate(to)
.WhereByType(typex)
.ToGroupedPlatformRequestDtos(frequency)
.OrderBy(x => x.Group)
.ToList();
var min = (from == null ? db.RequestLogs.Min(x => x.Date) : from.Value);
var max = (to == null ? DateTime.Today : to.Value);
if (frequency == Frequency.Hour)
{
max = max.AddHours(DateTime.Now.Hour);
}
if (frequency.CalculateItems(min, max) > 62)
{
throw new Exception("数据太多,请调整频率或者时间段");
}
var platforms = new List<Platform?>();
platforms.Add(null);
platforms.Add(Platform.Android);
platforms.Add(Platform.Ios);
var groups = new List<RequestGroup>();
foreach (var platform in platforms)
{
var typeItems = items.Where(x => x.Platform == platform).ToList();
var group = new RequestGroup(platform);
for (var value = min; value <= max; value = frequency.GetNextTime(value))
{
var valueGroup = value.ToGroupValue(frequency);
var item = typeItems.FirstOrDefault(x => x.Group == valueGroup);
group.Items.Add(new RequestItem(value.ToString(), item == null ? 0 : item.Value));
}
groups.Add(group);
}
return groups;
}
}