Beispiel #1
0
        public ActionResult Print(int id)
        {
            var scheme       = SchemeService.Find(id);
            var schemeItems  = SchemeItemService.GetALL().Where(x => x.SchemeID == id);
            var mediaIds     = schemeItems.Select(x => x.MediaID).ToList();
            var list         = new List <LinkItem>();
            var currentPrice = schemeItems.Sum(x => x.Price);

            if (mediaIds.Any())
            {
                using (MiniProfiler.Current.Step("LuceneSearch"))
                {
                    list = OutDoorLuceneService.Search(mediaIds);
                }
            }
            var model = new SchemePrintViewModel()
            {
                ID          = scheme.ID,
                Medias      = list,
                AddTime     = scheme.AddTime,
                Description = scheme.Description,
                Name        = scheme.Name
            };

            ViewBag.currentPrice = currentPrice.ToString("F2");
            //return View(scheme);
            return(View(model));
        }
Beispiel #2
0
        public ActionResult Download(int periodNumber, int periodCate, string mediaIds, string dq)
        {
            var idList       = Utilities.GetIdList(mediaIds);
            var list         = new List <LinkItem>();
            var currentPrice = 0m;

            if (idList.Any())
            {
                list = OutDoorLuceneService.Search(idList);
                var scheme = new Scheme()
                {
                    AddTime     = DateTime.Now,
                    Description = ConfigSetting.SiteName + "方案生成",
                    Name        = ConfigSetting.SiteName + "方案生成",
                    ID          = 0
                };
                var model = new SchemePrintViewModel()
                {
                    ID          = scheme.ID,
                    Medias      = list,
                    AddTime     = scheme.AddTime,
                    Description = scheme.Description,
                    Name        = scheme.Name
                };
                var day = periodNumber * periodCate;
                foreach (var item in list)
                {
                    currentPrice += ((item.Price / 365) * day);
                }
                model.TotalPrice = currentPrice.ToString("F2");

                model.DqDesc = Convert.ToDateTime(dq).ToString("yyyy-MM-dd")
                               + " 至 " + Convert.ToDateTime(dq).AddDays(day).ToString("yyyy-MM-dd");
                var html = Utilities.RenderPartialToString(this.ControllerContext,
                                                           "download",
                                                           new ViewDataDictionary(model),
                                                           new TempDataDictionary());
                byte[] data = System.Text.Encoding.UTF8.GetBytes(html);
                return(File(data, "text/html", Guid.NewGuid() + ".html"));
            }
            else
            {
                return(RedirectToAction("index"));
            }
        }
Beispiel #3
0
        public ActionResult Print(int periodNumber, int periodCate, string mediaIds, string dq)
        {
            var idList       = Utilities.GetIdList(mediaIds);
            var list         = new List <LinkItem>();
            var currentPrice = 0m;

            if (idList.Any())
            {
                list = OutDoorLuceneService.Search(idList);
                var scheme = new Scheme()
                {
                    AddTime     = DateTime.Now,
                    Description = ConfigSetting.SiteName + "方案生成",
                    Name        = ConfigSetting.SiteName + "方案生成",
                    ID          = 0
                };
                var model = new SchemePrintViewModel()
                {
                    ID          = scheme.ID,
                    Medias      = list,
                    AddTime     = scheme.AddTime,
                    Description = scheme.Description,
                    Name        = scheme.Name
                };
                var day = periodNumber * periodCate;
                foreach (var item in list)
                {
                    currentPrice += ((item.Price / 365) * day);
                }
                ViewBag.currentPrice = currentPrice.ToString("F2");
                model.DqDesc         = Convert.ToDateTime(dq).ToString("yyyy-MM-dd")
                                       + " 至 " + Convert.ToDateTime(dq).AddDays(day).ToString("yyyy-MM-dd");
                return(View(model));
            }
            else
            {
                return(RedirectToAction("index"));
            }
        }