當前位置: 首頁>>代碼示例>>C#>>正文


C# Semplest.GetMondayChart方法代碼示例

本文整理匯總了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);

        }
開發者ID:rajskumar,項目名稱:semplest2,代碼行數:85,代碼來源:ReportingController.cs


注:本文中的SemplestModel.Semplest.GetMondayChart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。