public ActionResult Index(int id) { Response.Cache.SetOmitVaryStar(true); ActivityBuild activityBuild = ActivitySystem.GetActivityBuildById(id).ToList().FirstOrDefault(); //object obj = HuodongCacheHelper.GetCache(id.ToString()); //object obj = HttpRuntime.Cache.Get(id.ToString()); //if (obj != null) //{ // activityBuild = obj as ActivityBuild; //} //else //{ // activityBuild = ActivitySystem.GetActivityBuildById(id).ToList().FirstOrDefault(); // //System.TimeSpan ts = new TimeSpan(0, 1, 0, 0); // //HuodongCacheHelper.SetCache(id.ToString(), activityBuild, ts); // HttpRuntime.Cache.Add(id.ToString(), activityBuild, null, DateTime.Now.AddHours(12), Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal, null); //} htmlActivity = GetActivityContent(activityBuild); return(this.Content(htmlActivity)); }
private static string GetActivityContent(ActivityBuild model) { if (string.IsNullOrWhiteSpace(model.Title) || string.IsNullOrWhiteSpace(model.Content)) { return(""); } string pureHtml = GetPureHtml("/ActivityHtml/ActivityTemplate.html"); pureHtml = pureHtml.Replace("$title$", model.Title); var activityContent = JsonConvert.DeserializeObject <List <ActivityContent> >(model.Content); string content = string.Empty; foreach (var item in activityContent.OrderBy(x => x.OrderBy).ToList()) { if (!string.IsNullOrWhiteSpace(item.PID)) { if (item.Type == 0 && item.BigImg == 1) //轮胎,1图 { content += " <a href=\"javascript:void(0);\" class=\"img\" iostype=\"#testapp#customSegue#TNTireInfoVC#\" androidtype=\"cn.TuHu.Activity.TireInfoUI\" pid=\"" + item.PID + "\" vid=\"" + item.VID + "\" activityid=\"" + item.ActivityId + "\" ><img src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 1 && item.BigImg == 1) //车品,1图 { content += " <a href=\"javascript:void(0);\" class=\"img\" iostype=\"#testapp#customSegue#TNGoodsListDetailViewController#\" androidtype=\"cn.TuHu.Activity.AutomotiveProducts.AutomotiveProductsDetialUI\" pid=\"" + item.PID + "\" vid=\"" + item.VID + "\" activityid=\"" + item.ActivityId + "\"><img src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 0 && item.BigImg == 0) //轮胎,2图 { content += " <a href=\"javascript:void(0);\" class=\"content\" iostype=\"#testapp#customSegue#TNTireInfoVC#\" androidtype=\"cn.TuHu.Activity.TireInfoUI\" pid=\"" + item.PID + "\" vid=\"" + item.VID + "\" activityid=\"" + item.ActivityId + "\"><img src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 1 && item.BigImg == 0)//车品,2图 { content += " <a href=\"javascript:void(0);\" class=\"content\" iostype=\"#testapp#customSegue#TNGoodsListDetailViewController#\" androidtype=\"cn.TuHu.Activity.AutomotiveProducts.AutomotiveProductsDetialUI\" pid=\"" + item.PID + "\" vid=\"" + item.VID + "\" activityid=\"" + item.ActivityId + "\"><img src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 0 && item.BigImg == 2)//轮胎,3图 { content += " <a href=\"javascript:void(0);\" class=\"content\" iostype=\"#testapp#customSegue#TNTireInfoVC#\" androidtype=\"cn.TuHu.Activity.TireInfoUI\" pid=\"" + item.PID + "\" vid=\"" + item.VID + "\" activityid=\"" + item.ActivityId + "\"><img class=\"img3\" src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 1 && item.BigImg == 2)//轮胎,3图 { content += " <a href=\"javascript:void(0);\" class=\"content\" iostype=\"#testapp#customSegue#TNGoodsListDetailViewController#\" androidtype=\"cn.TuHu.Activity.AutomotiveProducts.AutomotiveProductsDetialUI\" pid=\"" + item.PID + "\" vid=\"" + item.VID + "\" activityid=\"" + item.ActivityId + "\"><img class=\"img3\" src=\"" + item.Image + "\" alt=\"\" /></a>"; } } else { if (item.Type == 2 && item.BigImg == 2)//链接,3图 { content += " <a href=\"" + item.LinkUrl + "\" class=\"content\"><img class=\"img3\" src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 2 && item.BigImg == 0)//链接,2图 { content += " <a href=\"" + item.LinkUrl + "\" class=\"content\"><img src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 2 && item.BigImg == 1)//链接,1图 { content += " <a href=\"" + item.LinkUrl + "\" class=\"img\"><img src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 3 && item.BigImg == 1)//无,1图 { content += " <a href=\"javascript:void(0);\" class=\"img\"><img src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 3 && item.BigImg == 0)//无,2图 { content += " <a href=\"javascript:void(0);\" class=\"content\"><img src=\"" + item.Image + "\" alt=\"\" /></a>"; } else if (item.Type == 3 && item.BigImg == 2)//无,3图 { content += " <a href=\"javascript:void(0);\" class=\"content\"><img class=\"img3\" src=\"" + item.Image + "\" alt=\"\" /></a>"; } } } pureHtml = pureHtml.Replace("$content$", content); return(pureHtml); }