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.DESEncrypt;
using CY.Config;
using CY.Infrastructure.Common;
using System.Collections;
using System.IO;
using CY.Infrastructure.Cache;
using CY.Model;
namespace CY.WebForm.Pages.sysglobal
{
//吴辉
//网站基本信息配置
public partial class SysSiteConfig : BasePage
{
public string page_WebIco = "";
public string page_WebLogo = "";
public string page_WebDefaultImg = "";
Sys_CitySiteBLL bll_Sys_CitySiteBLL = new Sys_CitySiteBLL();
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";//首页广告缓存键
//页面加载
protected void Page_Load(object sender, EventArgs e)
{
CacheFactory.InitializeCacheFactory(new DefaultCacheStrategy());//初始化缓存工厂
CACHE = CacheFactory.GetCacher();//创建缓存
if (!IsPostBack)
{
this.txtWebName.Value = WebInfo.Instance.WebName;
this.txtWebDomain.Value = WebInfo.Instance.WebDomain;
this.txtWebSuffix.Value = WebInfo.Instance.WebSuffix;
this.selWebStatus.Value = WebInfo.Instance.WebStatus;
this.txtWebSEOTitle.Value = WebInfo.Instance.WebSEOTitle;
this.txtWebSEOKeyword.Value = WebInfo.Instance.WebSEOKeyword;
this.txtWebSEODetail.InnerText = WebInfo.Instance.WebSEODetail;
this.txtWebCloseMessage.Text = WebInfo.Instance.WebCloseMessage;
this.selIsBogusStatic.Value = WebInfo.Instance.IsBogusStatic.ToString2();
this.txtStaticPageSuffix.Value = WebInfo.Instance.StaticPageSuffix;
this.txtAnnouncementDetail.Value = WebInfo.Instance.AnnouncementDetail.ToString2();
this.txtVersionNumber.Value = WebInfo.Instance.VersionNumber.ToString2();
page_WebIco = WebInfo.Instance.WebIco;
page_WebLogo = WebInfo.Instance.WebLogo;
page_WebDefaultImg = WebInfo.Instance.WebDefaultImg;
this.selectProvince.DataSource = bll_Sys_CitySiteBLL.SelectProxyNextModel(0, 0, 1);
this.selectProvince.DataTextField = "Name";
this.selectProvince.DataValueField = "Keyid";
this.selectProvince.DataBind();
this.selectProvince.Items.Insert(0, new ListItem("请选择", ""));
this.selectProvince.SelectedValue = WebInfo.Instance.WebProvinceId.ToString2();
ChangeProvince(this, e);
this.selectCity.SelectedValue = WebInfo.Instance.WebCityId.ToString2();
}
}
//表单提交
protected void btn_Submit_Config(object sender, EventArgs e)
{
try
{
//网站图标上传
CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult1 = CY.WebForm.cs.UploadCS.Upload("fileWebIco", WebInfo.Instance.WebIco);
if (_UpFileResult1.returnerror.Count == 0)
{
if (_UpFileResult1.returnfilename.Count > 0)
{
WebInfo.Instance.WebIco = _UpFileResult1.returnfilename[0].ToString2();
}
}
else
{
JavaScript.MessageBox(string.Join("
", (string[])_UpFileResult1.returnerror.ToArray(typeof(string))), this);
return;
}
//网站Logo上传
CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult2 = CY.WebForm.cs.UploadCS.Upload("fileWebLogo", WebInfo.Instance.WebLogo);
if (_UpFileResult2.returnerror.Count == 0)
{
if (_UpFileResult2.returnfilename.Count > 0)
{
WebInfo.Instance.WebLogo = _UpFileResult2.returnfilename[0].ToString2();
}
}
else
{
JavaScript.MessageBox(string.Join("
", (string[])_UpFileResult2.returnerror.ToArray(typeof(string))), this);
return;
}
//网站默认图片上传
CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult3 = CY.WebForm.cs.UploadCS.Upload("fileWebDefaultImg", WebInfo.Instance.WebDefaultImg);
if (_UpFileResult3.returnerror.Count == 0)
{
if (_UpFileResult3.returnfilename.Count > 0)
{
WebInfo.Instance.WebDefaultImg = _UpFileResult3.returnfilename[0].ToString2();
}
}
else
{
JavaScript.MessageBox(string.Join("
", (string[])_UpFileResult3.returnerror.ToArray(typeof(string))), this);
return;
}
WebInfo.Instance.WebName = this.txtWebName.Value.ToString2();
WebInfo.Instance.WebDomain = this.txtWebDomain.Value.ToString2();
WebInfo.Instance.WebSuffix = this.txtWebSuffix.Value.ToString2();
WebInfo.Instance.WebStatus = this.selWebStatus.Value.ToString2();
WebInfo.Instance.WebSEOTitle = this.txtWebSEOTitle.Value.ToString2();
WebInfo.Instance.WebSEOKeyword = this.txtWebSEOKeyword.Value.ToString2();
WebInfo.Instance.WebSEODetail = this.txtWebSEODetail.InnerText.ToString2();
WebInfo.Instance.WebCloseMessage = this.txtWebCloseMessage.Text.ToString2();
WebInfo.Instance.IsBogusStatic = this.selIsBogusStatic.Value.ToBoolean2();
WebInfo.Instance.StaticPageSuffix = this.txtStaticPageSuffix.Value.ToString2();
WebInfo.Instance.AnnouncementDetail = this.txtAnnouncementDetail.Value.ToString2();
WebInfo.Instance.WebProvinceName = this.selectProvince.SelectedItem.Text.ToString2();
WebInfo.Instance.WebProvinceId = this.selectProvince.SelectedValue.ToInt32();
WebInfo.Instance.WebCityName = this.selectCity.SelectedItem.Text.ToString2();
WebInfo.Instance.WebCityId = this.selectCity.SelectedValue.ToInt32();
WebInfo.Instance.VersionNumber = this.txtVersionNumber.Value.ToString2();
WebInfo.Instance.Update();
page_WebIco = WebInfo.Instance.WebIco;
page_WebLogo = WebInfo.Instance.WebLogo;
page_WebDefaultImg = WebInfo.Instance.WebDefaultImg;
}
catch (Exception ex)
{
PAGEHandleException(ex);
JavaScript.MessageBox("操作失败", this);
}
JavaScript.MessageBox("操作成功", this);
}
//清除首页缓存
protected void btn_ClearHome_Data(object sender, EventArgs e)
{
try
{
CACHE.RemoveObject(ASSEMBLYFORHomeKEYNews);
CACHE.RemoveObject(ASSEMBLYFORHomeKEYWebLink);
CACHE.RemoveObject(ASSEMBLYFORHomeKEYSupply);
CACHE.RemoveObject(ASSEMBLYFORHomeKEYPrize);
CACHE.RemoveObject(ASSEMBLYFORHomeKEYMemberScore);
CACHE.RemoveObject(ASSEMBLYFORHomeKEYAD);
string filePath1 = Server.MapPath("~/CacheFiles/HomeCache.txt");
if (File.Exists(filePath1))
{
File.Delete(filePath1);
}
string filePath2 = Server.MapPath("~/CacheFiles/Orders.txt");
if (File.Exists(filePath2))
{
File.Delete(filePath2);
}
string filePath3 = Server.MapPath("~/CacheFiles/QuoteDemand.txt");
if (File.Exists(filePath3))
{
File.Delete(filePath3);
}
string filePath4 = Server.MapPath("~/CacheFiles/SeckillBusiness.txt");
if (File.Exists(filePath4))
{
File.Delete(filePath4);
}
JavaScript.MessageBox("清理成功",this);
Response.Redirect("/Pages/sysglobal/SysSiteConfig.aspx");
}
catch (Exception ex)
{
PAGEHandleException(ex);
JavaScript.MessageBox("清理失败", this);
}
}
//改变省
protected void ChangeProvince(object sender, EventArgs e)
{
this.selectCity.Items.Clear();
Sys_CitySite m_Sys_CitySite = bll_Sys_CitySiteBLL.GetModelByKeyid(this.selectProvince.SelectedValue.ToInt32()??0);
this.selectCity.DataSource = bll_Sys_CitySiteBLL.SelectAllNextModel(m_Sys_CitySite.Keyid, 0, 2);
this.selectCity.DataTextField = "Name";
this.selectCity.DataValueField = "Keyid";
this.selectCity.DataBind();
this.selectCity.Items.Insert(0, new ListItem("请选择", ""));
}
}
}