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
|
}
|
}
|