本文整理汇总了C#中SemplestModel.Semplest.GetMondayChart方法的典型用法代码示例。如果您正苦于以下问题:C# Semplest.GetMondayChart方法的具体用法?C# Semplest.GetMondayChart怎么用?C# Semplest.GetMondayChart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SemplestModel.Semplest
的用法示例。
在下文中一共展示了Semplest.GetMondayChart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReportGraph
public ActionResult ReportGraph(string promotionFk, string advertisingEngineFk, DateTime? startDate, DateTime? endDate, string mode)
{
var dbContext = new SemplestModel.Semplest();
var userid = ((Credential)(Session[SharedResources.SEMplestConstants.SESSION_USERID])).UsersFK;
var promotionFks = Array.ConvertAll(promotionFk.Split(','), int.Parse);
var adFks = Array.ConvertAll(advertisingEngineFk.Split(','), int.Parse);
List<vwPromotionChart> promotionCharts;
var reports = new List<ReportChartModel>();
var reports1 = new List<ReportChartModel>();
IEnumerable<IGrouping<DateTime, vwPromotionChart>> grp;
IEnumerable<IGrouping<string, vwPromotionChart>> grpa;
IEnumerable<IGrouping<string, ReportChartModel>> grp1;
switch (mode)
{
case "1":
promotionCharts = dbContext.vwPromotionCharts.Where(t => promotionFks.Contains(t.PromotionFK) && adFks.Contains(t.AdvertisingEngineFK) && t.UserPK == userid && t.TransactionDate >= startDate && t.TransactionDate <= endDate).ToList();
grp = promotionCharts.GroupBy(t => t.TransactionDate);
foreach (var data in grp)
{
var count = data.Count();
reports.Add(new ReportChartModel { Clicks = data.Sum(t => t.NumberClick) / count, Impressions = data.Sum(t => t.NumberImpressions) / count, Date = data.Key.ToString("MM/dd"), AveragePosition = data.Sum(t => t.AveragePosition) / count, AverageCPC = data.Sum(t => t.AverageCPC) / count });
}
grp1 = reports.GroupBy(t => t.Date);
foreach (var data in grp1)
{
var count = data.Count();
reports1.Add(new ReportChartModel { Clicks = data.Sum(t => t.Clicks) / count, Impressions = data.Sum(t => t.Impressions) / count, Date = data.Key, AveragePosition = data.Sum(t => t.AveragePosition) / count, AverageCPC = data.Sum(t => t.AverageCPC) / count });
}
return Json(reports1, JsonRequestBehavior.AllowGet);
case "2":
promotionCharts = dbContext.GetMondayChart(startDate, endDate).Where(t => promotionFks.Contains(t.PromotionFK) && adFks.Contains(t.AdvertisingEngineFK) && t.UserPK == userid).ToList();
grp = promotionCharts.GroupBy(t => t.TransactionDate);
foreach (var data in grp)
{
var count = data.Count();
reports.Add(new ReportChartModel { Clicks = data.Sum(t => t.NumberClick) / count, Impressions = data.Sum(t => t.NumberImpressions) / count, Date = data.Key.ToString("MM/dd"), AveragePosition = data.Sum(t => t.AveragePosition) / count, AverageCPC = data.Sum(t => t.AverageCPC) / count });
}
grp1 = reports.GroupBy(t => t.Date);
foreach (var data in grp1)
{
var count = data.Count();
reports1.Add(new ReportChartModel { Clicks = data.Sum(t => t.Clicks) / count, Impressions = data.Sum(t => t.Impressions) / count, Date = data.Key, AveragePosition = data.Sum(t => t.AveragePosition) / count, AverageCPC = data.Sum(t => t.AverageCPC) / count });
}
return Json(reports1, JsonRequestBehavior.AllowGet);
case "3":
promotionCharts = dbContext.vwPromotionCharts.Where(t => promotionFks.Contains(t.PromotionFK) && adFks.Contains(t.AdvertisingEngineFK) && t.UserPK == userid && t.TransactionDate >= startDate && t.TransactionDate <= endDate).ToList();
grpa = promotionCharts.GroupBy(t => (t.TransactionDate.Month) + "/" + (t.TransactionDate.Year));
foreach (var data in grpa)
{
var count = data.Count();
reports.Add(new ReportChartModel { Clicks = data.Sum(t => t.NumberClick) / count, Impressions = data.Sum(t => t.NumberImpressions) / count, Date = data.Key.ToString(), AveragePosition = data.Sum(t => t.AveragePosition) / count, AverageCPC = data.Sum(t => t.AverageCPC) / count });
}
grp1 = reports.GroupBy(t => t.Date);
foreach (var data in grp1)
{
var count = data.Count();
reports1.Add(new ReportChartModel { Clicks = data.Sum(t => t.Clicks) / count, Impressions = data.Sum(t => t.Impressions) / count, Date = data.Key, AveragePosition = data.Sum(t => t.AveragePosition) / count, AverageCPC = data.Sum(t => t.AverageCPC) / count });
}
return Json(reports1, JsonRequestBehavior.AllowGet);
case "4":
promotionCharts = dbContext.vwPromotionCharts.Where(t => promotionFks.Contains(t.PromotionFK) && adFks.Contains(t.AdvertisingEngineFK) && t.UserPK == userid && t.TransactionDate >= startDate && t.TransactionDate <= endDate).ToList();
grpa = promotionCharts.GroupBy(t => t.TransactionDate.Year.ToString());
foreach (var data in grpa)
{
var count = data.Count();
reports.Add(new ReportChartModel { Clicks = data.Sum(t => t.NumberClick) / count, Impressions = data.Sum(t => t.NumberImpressions) / count, Date = data.Key.ToString(), AveragePosition = data.Sum(t => t.AveragePosition) / count, AverageCPC = data.Sum(t => t.AverageCPC) / count });
}
grp1 = reports.GroupBy(t => t.Date);
foreach (var data in grp1)
{
var count = data.Count();
reports1.Add(new ReportChartModel { Clicks = data.Sum(t => t.Clicks) / count, Impressions = data.Sum(t => t.Impressions) / count, Date = data.Key, AveragePosition = data.Sum(t => t.AveragePosition) / count, AverageCPC = data.Sum(t => t.AverageCPC) / count });
}
return Json(reports1, JsonRequestBehavior.AllowGet);
}
return Json(null, JsonRequestBehavior.AllowGet);
}