Exemplo n.º 1
0
        public ActionResult HousePicList(long houseId)
        {
            var housePics = HousePicService.GetPics(houseId);

            ViewBag.HouseId = houseId;
            return(View(housePics));
        }
Exemplo n.º 2
0
        private void CreateStaticPage(long houseId)
        {
            HouseIndexViewModel houseIndexView = null;

            HouseDTO house = HouseService.GetById(houseId);

            if (house == null)
            {
                return;
            }

            var housePics   = HousePicService.GetPics(houseId);
            var attachments = AttachmentService.GetAttachment(houseId);

            houseIndexView = new HouseIndexViewModel
            {
                House       = house,
                HousePics   = housePics,
                Attachments = attachments
            };
            this.ControllerContext.Controller.ViewData.Model = houseIndexView;
            string html = WebCommonHelper.RendViewToString(
                this.ControllerContext,
                "~/views/House/StaticIndex.cshtml",
                "");

            System.IO.File.AppendAllText(String.Format(@"D:\PersonalWorkSpace\github\ZSZ\ZSZ.FrontWeb\{0}.html", houseId), html);
        }
Exemplo n.º 3
0
        public ActionResult Index(long id = 1)
        {
            #region Cache缓存
            //string cacheKey = "houseIndex_" + id;
            //HouseIndexViewModel houseIndexView = null;
            //if (HttpContext.Cache[cacheKey] == null)
            //{
            //    HouseDTO house = HouseService.GetById(id);
            //    if (house == null)
            //    {
            //        return View("~/Views/Shared/Error.cshtml", (object)"不存在的房源id");
            //    }

            //    var housePics = HousePicService.GetPics(id);
            //    var attachments = AttachmentService.GetAttachment(id);
            //    houseIndexView = new HouseIndexViewModel
            //    {
            //        House = house,
            //        HousePics = housePics,
            //        Attachments = attachments
            //    };


            //    HttpContext.Cache.Insert(cacheKey, houseIndexView, null, DateTime.Now.AddMinutes(1), TimeSpan.Zero);
            //}
            //else
            //{
            //    houseIndexView = (HouseIndexViewModel)HttpContext.Cache[cacheKey];
            //}
            #endregion

            #region Memcached缓存



            string cacheKey = "houseIndex_" + id;



            HouseIndexViewModel houseIndexView = MemcachedMgr.Instance.GetValue <HouseIndexViewModel>(cacheKey);

            if (houseIndexView == null)
            {
                HouseDTO house = HouseService.GetById(id);
                if (house == null)
                {
                    return(View("~/Views/Shared/Error.cshtml", (object)"不存在的房源id"));
                }

                var housePics   = HousePicService.GetPics(id);
                var attachments = AttachmentService.GetAttachment(id);
                houseIndexView = new HouseIndexViewModel
                {
                    House       = house,
                    HousePics   = housePics,
                    Attachments = attachments
                };


                MemcachedMgr.Instance.SetValue(cacheKey, houseIndexView, TimeSpan.FromMinutes(1));//还可以指定第四个
            }


            #endregion

            return(View(houseIndexView));
        }