username@email.com
2025-05-14 99ddfbcecf0fa2881eb3a91028257eef87dab6de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL;
using CY.Infrastructure.Cache;
using System.Data;
using CY.BLL.Sys;
using CY.Model;
using CY.Infrastructure.Common;
using CY.Infrastructure.Query;
using CY.BLL.EC;
using CY.WebForm.cs;
using System.IO;
 
namespace CY.WebForm.Pages.front
{
    //吴辉
    //前台-首页
    public partial class Home : MainPage
    {
        Info_ContentBLL bll_Info_ContentBLL = null;
        Info_SortBLL bll_Info_SortBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
        EC_MemberBasicBLL bll_EC_MemberBasicBLL = null;
        EC_PrizeInfoBLL bll_EC_PrizeInfoBLL = null;
        Pay_PaymentAccountBLL bll_Pay_PaymentAccountBLL = null;
        Info_AdBLL bll_Info_AdBLL = null;
        private static ICacheStrategy CACHE = null;//缓存接口对象 
        private const string ASSEMBLYFORHomeKEYNews = "AssemblyForHomeNews";//首页新闻缓存键 
        private const string ASSEMBLYFORHomeKEYWebLink = "AssemblyForHomeWebLink";//首页新闻缓存键 
        private const string ASSEMBLYFORHomeKEYSupply = "AssemblyForHomeSupply";//首页供应信息缓存键 
        private const string ASSEMBLYFORHomeKEYPrize = "AssemblyForHomePrize";//首页礼品信息缓存键 
        private const string ASSEMBLYFORHomeKEYMemberScore = "AssemblyForHomeMemberScore";//首页积分排名缓存键 
        private const string ASSEMBLYFORHomeKEYAD = "AssemblyForHomeAD";//首页广告缓存键 
 
        //初始化
        public Home()
        {
            bll_Info_ContentBLL = new Info_ContentBLL();
            bll_Info_SortBLL = new Info_SortBLL();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
            bll_EC_MemberBasicBLL = new EC_MemberBasicBLL();
            bll_EC_PrizeInfoBLL = new EC_PrizeInfoBLL();
            bll_Pay_PaymentAccountBLL = new Pay_PaymentAccountBLL();
            bll_Info_AdBLL = new Info_AdBLL();
            CacheFactory.InitializeCacheFactory(new DefaultCacheStrategy());//初始化缓存工厂
            CACHE = CacheFactory.GetCacher();//创建缓存
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            string ss = CY.Infrastructure.DESEncrypt.DESEncrypt.Decrypt("EBBF83CAB8B97B8D");
            if (!IsPostBack)
            {
                InitDataNews();
                InitDataWebLink();
                InitDataSupply();
                InitDataPrize();
                InitDataMemberScore();
                InitDataAD();
                InitDataOrder();
                InitDataSeckillBusiness();
                InitDataQuoteDemand();
            }
        }
 
        #region 缓存新闻
 
        //绑定数据
        public void InitDataNews()
        {
            try
            {
                string NewsCacheHtml = "";
                object ablDal = CACHE.RetrieveObject(ASSEMBLYFORHomeKEYNews);//从缓存中获取数据访问值
                if (null != ablDal)
                    NewsCacheHtml = ablDal.ToString();//缓存中有值则直接返回值
                else
                {
                    NewsCacheHtml = InitialSelectNewsData();
                    CACHE.AddObject(ASSEMBLYFORHomeKEYNews, NewsCacheHtml);//将值写入缓存
                }
                this.divNewsHtml.InnerHtml = NewsCacheHtml;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
        }
 
        //加载查询条件
        protected string InitialSelectNewsData()
        {
            try
            {
                DataTable ds = bll_Info_SortBLL.SelectList("11111111-1111-1111-1111-111111111111".ToGuid2());
                string SortTypeHtml = "";
                if (ds != null && ds.Rows.Count > 0)
                {
                    GetDataByLevelNews(ref SortTypeHtml, ds, bll_Sys_DictionaryBLL.GetKeyIdByKeyid(3, "网站资讯类型"), 1);
                }
                return SortTypeHtml;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return "";
            }
        }
 
        //遍历数据
        public void GetDataByLevelNews(ref string SortTypeHtml, DataTable data, int? parentId, int level)
        {
            try
            {
                if (data == null || data.Rows.Count == 0)
                    return;
                DataRow[] result = data.Select(string.Format("ParentId={0}", parentId));
                int i = -1;
                while (++i < 4)
                {
 
                    if (level == 1)
                    {
                        SortTypeHtml += "<div class='dfourbox mt10 fl tyborder1 " + (i == 3 ? "lastbox" : "") + "'><h2 class='title'><a href='/newslist/" + result[i]["Keyid"].ToInt32().Value + ".html' target='_blank'>更多>></a>" + result[i]["Title"].ToString2() + "</h2><ul class='newlist'>";
                        List<Info_Content> m_Info_ContentList = bll_Info_ContentBLL.SelectListByWhere(result[i]["Keyid"].ToInt32(), 8, true) as List<Info_Content>;
                        if (m_Info_ContentList != null)
                        {
                            foreach (var item in m_Info_ContentList)
                            {
                                SortTypeHtml += "<li><a target='_blank' href='/newsdetail/" + item.Keyid + ".html'>" + item.Title.ToString2().JSubString(30, "..") + "</a></li>";
                            }
                        }
                        SortTypeHtml += "</ul></div>";
                    }
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
 
        }
 
        #endregion
 
        #region 缓存友情链接
 
        //绑定数据
        public void InitDataWebLink()
        {
            try
            {
 
                string WebLinkCacheHtml = "";
                object ablDal = CACHE.RetrieveObject(ASSEMBLYFORHomeKEYWebLink);//从缓存中获取数据访问值
                if (null != ablDal)
                    WebLinkCacheHtml = ablDal.ToString();//缓存中有值则直接返回值
                else
                {
                    WebLinkCacheHtml = InitialSelectWebLinkData();
                    CACHE.AddObject(ASSEMBLYFORHomeKEYWebLink, WebLinkCacheHtml);//将值写入缓存
                }
                this.ulWebLinkHtml.InnerHtml = WebLinkCacheHtml;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
        }
 
        //加载查询条件
        protected string InitialSelectWebLinkData()
        {
            try
            {
 
                DataTable ds = bll_Info_SortBLL.SelectList("11111111-1111-1111-1111-111111111111".ToGuid2());
                string HotWebLinkHtml = "<li class='long'><b>热门:</b>";
                string NormalWebLinkHtml = "";
                if (ds != null && ds.Rows.Count > 0)
                {
                    GetDataByLevelWebLink(ref HotWebLinkHtml, ref NormalWebLinkHtml, ds, bll_Sys_DictionaryBLL.GetKeyIdByKeyid(4, "网站资讯类型"), 1);
                }
                HotWebLinkHtml += "</li><p class='clear'></p>";
                return NormalWebLinkHtml + "<p class='clear'></p>";
 
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return "";
            }
        }
 
        //遍历数据
        public void GetDataByLevelWebLink(ref string HotWebLinkHtml, ref string NormalWebLinkHtml, DataTable data, int? parentId, int level)
        {
            try
            {
                if (data == null || data.Rows.Count == 0)
                    return;
                DataRow[] result = data.Select(string.Format("ParentId={0}", parentId));
                int i = -1;
                while (++i < result.Length)
                {
 
                    if (level == 1)
                    {
                        NormalWebLinkHtml += "<li " + (i == 0 ? " class='long'" : "") + "><a style='height: 20px; padding-left: 0px;float:left; background-image: none; background-repeat: no-repeat; background-position-x: 1px; background-position-y: 3px;' class='firstA'>" + result[i]["Title"].ToString2() + ":</a>";
                        List<Info_Content> m_Info_ContentList = bll_Info_ContentBLL.SelectListByWhere(result[i]["Keyid"].ToInt32(), 100, true) as List<Info_Content>;
                        if (m_Info_ContentList != null)
                        {
                            foreach (var item in m_Info_ContentList)
                            {
                                NormalWebLinkHtml += ("<a " + (i == 0 ? " style=\"background-position: 1px 3px;background-image:url('" + item.InfoContent + "');padding-left:20px;float:left; height:20px; background-repeat: no-repeat;\" " : "") + " href='http://" + item.WebLink.ToString2().Replace("http://", "") + "' target='_bank'>" + item.Title.ToString2() + "</a>");
                            }
                        }
                        NormalWebLinkHtml += "</li>" + (i == 0 ? " <p class='clear'></p>" : "");
                    }
                }
 
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
        }
 
        #endregion
 
        #region 缓存供应信息
 
        //绑定数据
        public void InitDataSupply()
        {
            try
            {
                string SupplyCacheHtml = "";
                object ablDal = CACHE.RetrieveObject(ASSEMBLYFORHomeKEYSupply);//从缓存中获取数据访问值
                if (null != ablDal)
                    SupplyCacheHtml = ablDal.ToString();//缓存中有值则直接返回值
                else
                {
                    SupplyCacheHtml = InitialSupplyData();
                    CACHE.AddObject(ASSEMBLYFORHomeKEYSupply, SupplyCacheHtml);//将值写入缓存
                }
                this.ulSupplyHtml.InnerHtml = SupplyCacheHtml;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
 
        }
 
        //加载数据
        public string InitialSupplyData()
        {
            try
            {
                Pagination pa = new Pagination();
                pa.PageSize = 20;
                pa.PageIndex = 1;
                string html = "";
                List<EC_FirmInfo> m_EC_FirmInfo = bll_EC_MemberBasicBLL.SelectModelPage(pa, "", "", "", "", "") as List<EC_FirmInfo>;
                if (m_EC_FirmInfo != null && m_EC_FirmInfo.Count > 0)
                {
                    foreach (var m_EC_Firm in m_EC_FirmInfo)
                    {
                        EC_MemberBasic m_EC_MemberBasic = bll_EC_MemberBasicBLL.GetMemberByMemberId(m_EC_Firm.MemberId);
                        if (m_EC_MemberBasic != null)
                        {
                            html += "<dl class='clearfix'><dt class='colcompany'><a target='_bank' href='" + (string.IsNullOrEmpty(m_EC_MemberBasic.bdomainname) ? ("/Pages/Templet/Default/CompanyIndex.aspx?i=" + m_EC_MemberBasic.bid) : ("http://" + m_EC_MemberBasic.bdomainname)) + "'>" + m_EC_Firm.CompanyName + "</a></dt><dd class='colfor'><span>" + m_EC_Firm.SupplyInfo + "</span></dd></dl>";
                        }
                    }
                }
                return html;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return "";
            }
 
        }
 
        #endregion
 
        #region 缓存奖品
 
        //绑定数据
        public void InitDataPrize()
        {
            try
            {
                string PrizeCacheHtml = "";
                object ablDal = CACHE.RetrieveObject(ASSEMBLYFORHomeKEYPrize);//从缓存中获取数据访问值
                if (null != ablDal)
                    PrizeCacheHtml = ablDal.ToString();//缓存中有值则直接返回值
                else
                {
                    PrizeCacheHtml = InitialPrizeData();
                    CACHE.AddObject(ASSEMBLYFORHomeKEYPrize, PrizeCacheHtml);//将值写入缓存
                }
                this.ulPrizeHtml.InnerHtml = PrizeCacheHtml;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
 
        }
 
        //加载数据
        public string InitialPrizeData()
        {
            try
            {
                Pagination pa = new Pagination();
                pa.PageSize = 20;
                pa.PageIndex = 1;
                string html = "";
                List<EC_PrizeInfo> m_EC_PrizeInfoList = bll_EC_PrizeInfoBLL.getAllPrizeInfo(pa) as List<EC_PrizeInfo>;
                if (m_EC_PrizeInfoList != null)
                {
                    foreach (var m_EC_PrizeInfo in m_EC_PrizeInfoList)
                    {
                        html += "<li><a target='_blank' href='/prizes/" + m_EC_PrizeInfo.Keyid + ".html'><img src='" + m_EC_PrizeInfo.FileId + "' width='81' height='81' onerror=\"this.src='../../images/admin/_LoadDefault.gif'\" /></a><span>" + m_EC_PrizeInfo.PrizeName + "</span><p>" + m_EC_PrizeInfo.NeedIntegral + "积分</p></li>";
                    }
                }
                return html;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return "";
            }
 
        }
 
        #endregion
 
        #region 缓存积分排名
 
        //绑定数据
        public void InitDataMemberScore()
        {
            try
            {
                string MemberScoreCacheHtml = "";
                object ablDal = CACHE.RetrieveObject(ASSEMBLYFORHomeKEYMemberScore);//从缓存中获取数据访问值
                if (null != ablDal)
                    MemberScoreCacheHtml = ablDal.ToString();//缓存中有值则直接返回值
                else
                {
                    MemberScoreCacheHtml = InitialMemberScoreData();
                    CACHE.AddObject(ASSEMBLYFORHomeKEYMemberScore, MemberScoreCacheHtml);//将值写入缓存
                }
                this.ulMemberScoreHtml.InnerHtml = MemberScoreCacheHtml;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
 
        }
 
        //加载数据
        public string InitialMemberScoreData()
        {
            try
            {
                string html = "";
                List<Pay_PaymentAccount> m_Pay_PaymentAccountList = bll_Pay_PaymentAccountBLL.SelectModleByRows(20) as List<Pay_PaymentAccount>;
                if (m_Pay_PaymentAccountList != null)
                {
                    foreach (var m_Pay_PaymentAccount in m_Pay_PaymentAccountList)
                    {
                        html += "<li class='clearfix'><dt class='coldate'>" + GetLastSunday().AddDays(1).ToString("yyyy/MM/dd") + "</dt><dt class='colhyname'>" + m_Pay_PaymentAccount.MemberName + "</dt><dt class='colhyscore'>" + (m_Pay_PaymentAccount.LastWeekScore ?? 0) + "分</dt> </li>";
                        //html += "<li class='clearfix'><dt class='coldate'>" + GetLastSunday().AddDays(1).ToString("yyyy/MM/dd") + "</dt><dt class='colhyname'>印刷厂商测印刷厂商测试帐号</dt><dt class='colhyscore'>2000分</dt> </li>";
                    }
                }
                return html;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return "";
            }
 
        }
 
        //获取上周周末日期
        public DateTime GetLastSunday()
        {
            DateTime? time = DateTime.Now.ToString("yyyy-MM-dd").ToDateTime2();
            if (time.Value.DayOfWeek == DayOfWeek.Sunday)
            {
                time = time.Value.AddDays(-2);
            }
            else
                time = time.Value.AddDays(-1);
            while (time.Value.DayOfWeek != DayOfWeek.Sunday)
            {
                time = time.Value.AddDays(-1);
            }
            return time.Value;
        }
 
        #endregion
 
        #region 缓存广告
 
        //绑定数据
        public void InitDataAD()
        {
            try
            {
                string ADCacheHtml0 = "";
                string ADCacheHtml1 = "";
                string ADCacheHtml2 = "";
                string ADCacheHtml3 = "";
                string ADCacheHtml4 = "";
                string ADCacheHtml5 = "";
                string ADCacheHtml6 = "";
 
                List<string> ADList = new List<string>();
                object ablDal = CACHE.RetrieveObject(ASSEMBLYFORHomeKEYAD);//从缓存中获取数据访问值
                ADList = ablDal as List<string>;
                if (null != ablDal)
                {
                    ADCacheHtml0 = ADList[0];//缓存中有值则直接返回值
                    ADCacheHtml1 = ADList[1];//缓存中有值则直接返回值
                    ADCacheHtml2 = ADList[2];//缓存中有值则直接返回值
                    ADCacheHtml3 = ADList[3];//缓存中有值则直接返回值
                    ADCacheHtml4 = ADList[4];//缓存中有值则直接返回值
                    ADCacheHtml5 = ADList[5];//缓存中有值则直接返回值
                    ADCacheHtml6 = ADList[6];//缓存中有值则直接返回值
                }
                else
                {
                    ADList = new List<string>();
                    ADCacheHtml0 = InitialADData("网站首页", "顶部横幅广告(滚动1)") + InitialADData("网站首页", "顶部横幅广告(滚动2)") + InitialADData("网站首页", "顶部横幅广告(滚动3)") + InitialADData("网站首页", "顶部横幅广告(滚动4)") + InitialADData("网站首页", "顶部横幅广告(滚动5)");
                    ADList.Add(ADCacheHtml0);
                    ADCacheHtml1 = InitialADData("网站首页", "特价秒杀(下)");
                    ADList.Add(ADCacheHtml1);
                    ADCacheHtml2 = InitialADData("网站首页", "大家都在本网交易(下)");
                    ADList.Add(ADCacheHtml2);
                    ADCacheHtml3 = InitialADData("网站首页", "最新需求信息(下左)");
                    ADList.Add(ADCacheHtml3);
                    ADCacheHtml4 = InitialADData("网站首页", "最新需求信息(下中)");
                    ADList.Add(ADCacheHtml4);
                    ADCacheHtml5 = InitialADData("网站首页", "最新需求信息(下右)");
                    ADList.Add(ADCacheHtml5);
                    ADCacheHtml6 = InitialADData("网站首页", "最新供应信息(左)");
                    ADList.Add(ADCacheHtml6);
 
                    CACHE.AddObject(ASSEMBLYFORHomeKEYAD, ADList);//将值写入缓存
                }
 
                this.ad0.InnerHtml = ADCacheHtml0;
                this.ad1.InnerHtml = ADCacheHtml1;
                this.ad2.InnerHtml = ADCacheHtml2;
                this.ad3.InnerHtml = ADCacheHtml3;
                this.ad4.InnerHtml = ADCacheHtml4;
                this.ad5.InnerHtml = ADCacheHtml5;
                this.ad6.InnerHtml = ADCacheHtml6;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
 
        }
 
        //加载数据
        public string InitialADData(string ForumName, string LocationName)
        {
            try
            {
                if (!string.IsNullOrEmpty(ForumName) && !string.IsNullOrEmpty(LocationName))
                {
                    return bll_Info_AdBLL.SelectAdByLocationName(ForumName, LocationName);
                }
                else
                {
                    return "";
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return "";
            }
        }
 
        #endregion
 
        #region 加载订单
 
        //初始化最新订单信息
        private void InitDataOrder()
        {
            try
            {
                rptOrders.DataSource = WebUtil.LatestOrders();
                rptOrders.DataBind();
            }
            catch (Exception ex)
            {
                return;
            }
        }
 
        #endregion
 
        #region 加载秒杀
 
        //初始化最新秒杀业务信息
        private void InitDataSeckillBusiness()
        {
            try
            {
                rptSeckillBusiness.DataSource = WebUtil.LatestSeckillBusiness();
                rptSeckillBusiness.DataBind();
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return;
            }
        }
 
        #endregion
 
        #region 加载需求
 
        //初始化最新需求信息
        private void InitDataQuoteDemand()
        {
            try
            {
                rptQuoteDemand.DataSource = WebUtil.LatestQuoteDemand();
                rptQuoteDemand.DataBind();
            }
            catch (Exception ex)
            {
                return;
            }
 
        }
 
        #endregion
    }
}