2 using System
.Collections
.Generic
;
6 using System
.Web
.UI
.WebControls
;
7 using PumpkinHouseDatabase
;
8 using PumpkinHouseDatabase
.Contract
;
9 using PumpkinHouse
.Utils
;
11 using System
.Runtime
.Serialization
.Json
;
15 namespace PumpkinHouse
17 public partial class _Default
: System
.Web
.UI
.Page
19 public HomePageMode OrderMode
;
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()
32 case HomePageMode
.Default
: return "default";
33 case HomePageMode
.Hot
: return "hot";
34 case HomePageMode
.Latest
: return "latest";
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)
47 Session
["mode"] = "default";
49 Session
["commodityOnly"] = false;
53 if (!string.IsNullOrWhiteSpace(mode
))
55 Session
["mode"] = mode
;
57 if (!string.IsNullOrWhiteSpace(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
;
76 string m
= (string)Session
["mode"];
80 this.OrderMode
= HomePageMode
.Default
;
84 this.OrderMode
= HomePageMode
.Hot
;
86 else if (m
== "latest")
88 this.OrderMode
= HomePageMode
.Latest
;
92 if (Session
["commodityOnly"] == null)
94 this.CommodityOnly
= false;
98 this.CommodityOnly
= (bool)Session
["commodityOnly"];
103 bool parseResult
= int.TryParse(Request
.Params
["cate"], out cateId
);
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();