活动页面添加参赛作品瀑布流
[PumpkinHouse.git] / PumpkinHouseWeb / Default.aspx.cs
blob57541e35c440fe2eaf01e4cc46a455a150c465d4
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Web;
5 using System.Web.UI;
6 using System.Web.UI.WebControls;
7 using PumpkinHouseDatabase;
8 using PumpkinHouseDatabase.Contract;
9 using PumpkinHouse.Utils;
10 using log4net;
11 using System.Runtime.Serialization.Json;
12 using System.IO;
13 using System.Text;
15 namespace PumpkinHouse
17 public partial class _Default : System.Web.UI.Page
19 public HomePageMode OrderMode;
20 public string Tag;
21 public IList<CollectionToDisplay> pictures;
22 private ILog Log = LogManager.GetLogger(typeof(_Default));
23 public bool CommodityOnly = false;
24 public string JsonObject;
25 public IList<View_Recommended_Tag>[] rTags;
26 public int TagCategoryId;
28 protected string FindOrderString()
30 switch (OrderMode)
32 case HomePageMode.Default: return "default";
33 case HomePageMode.Hot: return "hot";
34 case HomePageMode.Latest: return "latest";
36 return null;
39 protected void Page_Load(object sender, EventArgs e)
41 string mode = Request.Params["mode"];
42 string tag = Request.Params["tag"];
44 if (mode == null && tag == null && Request.Params["commodityOnly"] == null)
46 // reset
47 Session["mode"] = "default";
48 Session["tag"] = "";
49 Session["commodityOnly"] = false;
51 else
53 if (!string.IsNullOrWhiteSpace(mode))
55 Session["mode"] = mode;
57 if (!string.IsNullOrWhiteSpace(tag))
59 Session["tag"] = tag;
61 if (Request.Params["commodityOnly"] != null)
63 CommodityOnly = "commodity".Equals(Request.Params["commodityOnly"] as string, StringComparison.OrdinalIgnoreCase);
64 Session["commodityOnly"] = CommodityOnly;
68 this.Tag = (string)Session["tag"] ?? "";
70 if (Session["mode"] == null)
72 this.OrderMode = HomePageMode.Default;
74 else
76 string m = (string)Session["mode"];
78 if (m == "default")
80 this.OrderMode = HomePageMode.Default;
82 else if (m == "hot")
84 this.OrderMode = HomePageMode.Hot;
86 else if (m == "latest")
88 this.OrderMode = HomePageMode.Latest;
92 if (Session["commodityOnly"] == null)
94 this.CommodityOnly = false;
96 else
98 this.CommodityOnly = (bool)Session["commodityOnly"];
101 // 标签推荐的页卡信息
102 int cateId;
103 bool parseResult = int.TryParse(Request.Params["cate"], out cateId);
104 if (parseResult)
106 Session["cate"] = cateId;
108 TagCategoryId = Session["cate"] == null ? 0 : (int)Session["cate"];
110 Log.Debug("prepare querying");
112 rTags = new IList<View_Recommended_Tag>[4];
114 using (DataUtils utils = new DataUtils(false))
116 Log.Debug("ready to query");
117 PagingList<CollectionToDisplay> list = Helper.FindAllOriginalViewCollections(utils, this.OrderMode, this.Tag, this.CommodityOnly, 0, 20000);
118 Log.Debug("picture list populated");
119 pictures = list.List;
121 JsonObject = JsonHelper<IList<CollectionToDisplay>>.ConvertToJson(pictures);
123 IEnumerable<View_Recommended_Tag> tags = utils.FindRecommendedViewTags().ToList();
125 rTags[0] = tags.Where(t => t.Category_Name == "").ToList();
126 rTags[1] = tags.Where(t => t.Category_Name == "空间").ToList();
127 rTags[2] = tags.Where(t => t.Category_Name == "潮品").ToList();
128 rTags[3] = tags.Where(t => t.Category_Name == "风格").ToList();