📄 channel_add.aspx.cs
字号:
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;
using System.IO;
using NetCMS.Content.Common;
using System.Xml;
public partial class manage_channel_channel_add : NetCMS.Web.UI.ManagePage
{
public manage_channel_channel_add()
{
Authority_Code = "D016";
}
Channel rd = new Channel();
rootPublic pd = new rootPublic();
public string dable = "";
public static string dirdumm = NetCMS.Config.UIConfig.dirDumm;
public static string dirTemplet = NetCMS.Config.UIConfig.dirTemplet;
public static string dirHTML = NetCMS.Config.UIConfig.dirHtml;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["ChID"] != null && Request.QueryString["ChID"] != string.Empty)
{
this.Authority_Code = "D017";
}
else
{
this.Authority_Code = "D016";
}
this.CheckAdminAuthority();
if (!IsPostBack)
{
copyright.InnerHtml = CopyRight; //获取版权信息
//Response.CacheControl = "no-cache"; //设置页面无缓存
if (SiteID != "0"){PageError("您所在的频道不允许创建频道", "");}
string ChID = Request.QueryString["ChID"];
if (ChID != null && ChID != string.Empty)
{
IDataReader dt = rd.getModelinfo(int.Parse(ChID.ToString()));
if (dt.Read())
{
GetClassList(this.ParentID, 0, 0, int.Parse(dt["Parentid"].ToString()));
getchannelType.InnerHtml = NetCMS.Common.Public.getModelContentType(dt["channelType"].ToString());
this.channelName.Text = dt["channelName"].ToString();
this.channelItem.Text = dt["channelItem"].ToString();
this.channelEItem.Text = dt["channelEItem"].ToString();
this.channelEItem.Enabled = false;
DataRe.Visible = false;
TSdiv.Visible = false;
this.channelDescript.Text = dt["channelDescript"].ToString();
this.DataLib.Text = dt["DataLib"].ToString();
this.DataLib.Enabled = false;
this.channelunit.Text = dt["channelunit"].ToString();
this.upfilessize.Text = dt["upfilessize"].ToString();
if(dt["isHTML"].ToString()=="1")
{
this.isHTML.Checked=true;
}
int isSys = int.Parse(dt["issys"].ToString());
for (int k = 0; k < this.issys.Items.Count; k++)
{
if (this.issys.Items[k].Value == isSys.ToString())
{
this.issys.Items[k].Selected = true;
}
}
if (isSys == 1)
{
this.issys.Enabled = false;
}
this.htmldir.Text = dt["htmldir"].ToString();
this.indexFileName.Text = dt["indexFileName"].ToString();
this.ClassSave.Text = dt["ClassSave"].ToString();
this.ClassFileName.Text = dt["ClassFileName"].ToString();
this.SavePath.Text = dt["SavePath"].ToString();
this.FileName.Text = dt["FileName"].ToString();
this.binddomain.Text = dt["binddomain"].ToString();
this.TempletPath.Text = dt["TempletPath"].ToString();
if(dt["isConstr"].ToString()=="1")
{
this.isconstr.Checked=true;
}
this.upfiletype.Text = dt["upfiletype"].ToString();
this.indextemplet.Text = dt["indextemplet"].ToString();
this.classtemplet.Text = dt["classtemplet"].ToString();
this.newstemplet.Text = dt["newstemplet"].ToString();
this.specialtemplet.Text = dt["specialtemplet"].ToString();
if (dt["ischeck"].ToString() == "1")
{
this.ischeck.Checked = true;
}
if (dt["isHTML"].ToString() == "1")
{
this.isHTML.Checked = true;
}
}
dt.Close();
}
else
{
GetClassList(this.ParentID, 0, 0, 0);
getchannelType.InnerHtml = NetCMS.Common.Public.getModelContentType("999");
}
}
}
/// <summary>
/// 获取栏目列表
/// </summary>
/// <param name="lst"></param>
/// <param name="ParentID"></param>
/// <param name="Layer"></param>
/// <param name="sClassID"></param>
protected void GetClassList(DropDownList lst, int ParentID, int Layer, int sClassID)
{
IDataReader dr = rd.GetChannelClassList(ParentID);
while (dr.Read())
{
ListItem it = new ListItem();
string stxt = "";
it.Value = dr["ID"].ToString();
if (Layer > 0)
stxt = "┝";
for (int i = 1; i < Layer; i++)
{
stxt += " ┉ ";
}
it.Text = stxt + dr["channelName"].ToString();
if (sClassID == int.Parse(dr["id"].ToString()))
{
it.Selected = true;
}
lst.Items.Add(it);
GetClassList(lst, int.Parse(dr["ID"].ToString()), (Layer + 1), sClassID);
}
dr.Close();
}
/// <summary>
/// 提交数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
int ChID = 0;
int channelType = 0;
if (Request.QueryString["ChID"] != null && Request.QueryString["ChID"] != string.Empty)
{
ChID = int.Parse(Request.QueryString["ChID"]);
}
else
{
channelType = int.Parse(Request.Form["channelType"]);
}
string channelName = this.channelName.Text;
string channelItem = this.channelItem.Text;
string channelEItem = this.channelEItem.Text;
//判断英文是否存在
if (rd.getItemCount(channelEItem.ToString(), ChID) != 0)
{
PageError("频道标志已经存在", "javascript:history.back()", true);
}
string channelDescript = this.channelDescript.Text;
string DataLib = NetCMS.Config.UIConfig.dataRe + "channel_" + this.DataLib.Text;
//判断英文是否存在
if (rd.getDbCount(DataLib.ToString(), ChID) != 0)
{
PageError("数据库表已经存在", "javascript:history.back()", true);
}
string channelunit = this.channelunit.Text;
string htmldir = this.htmldir.Text;
string indexFileName = this.indexFileName.Text;
string ClassSave = this.ClassSave.Text;
string ClassFileName = this.ClassFileName.Text;
string SavePath = this.SavePath.Text;
string FileName = this.FileName.Text;
string binddomain = this.binddomain.Text;
string TempletPath = this.TempletPath.Text;
int ParentID = 0;
if (this.ParentID.SelectedValue != string.Empty)
{
ParentID = int.Parse(this.ParentID.SelectedValue);
}
int isconstr = 0;
if (this.isconstr.Checked)
{
isconstr = 1;
}
int isHTML = 0;
if (this.isHTML.Checked) { isHTML = 1; }
int upfilessize = 0;
if (this.upfilessize.Text != null && this.upfilessize.Text != string.Empty)
{
upfilessize = int.Parse(this.upfilessize.Text);
}
string upfiletype = "jpg,gif,jpeg,png,swf,rar,zip,doc,txt,pdf";
if (this.upfiletype.Text != null && this.upfiletype.Text != string.Empty)
{
upfiletype = this.upfiletype.Text;
}
int ischeck = 0;
if (this.ischeck.Checked) { ischeck = 1; }
int issys = int.Parse(this.issys.SelectedValue.ToString());
string indextemplet = this.indextemplet.Text;
string classtemplet = this.classtemplet.Text;
string newstemplet = this.newstemplet.Text;
string specialtemplet = this.specialtemplet.Text;
int isDelPoint = this.UserPop1.AuthorityType;
int Gpoint = this.UserPop1.Gold;
int iPoint = this.UserPop1.Point;
string[] _GroupNumber = this.UserPop1.MemberGroup;
string GroupNumber = "";
foreach (string gnum in _GroupNumber)
{
if (GroupNumber != "")
GroupNumber += ",";
GroupNumber += gnum;
}
//开始创建表
//插入数据
DateTime _Temp_date = DateTime.Now;
NetCMS.Model.ChannelInfo uc = new NetCMS.Model.ChannelInfo();
uc.Id = ChID;
uc.channelType = channelType;
uc.ParentID = ParentID;
uc.channelName = channelName;
uc.channelItem = channelItem;
uc.channelEItem = channelEItem;
uc.isConstr = isconstr;
uc.ClassSave = pd.getResultPage(ClassSave, _Temp_date, "0", channelEItem);
uc.ClassFileName = pd.getResultPage(ClassFileName, _Temp_date, "0", channelEItem);
uc.binddomain = binddomain;
uc.TempletPath = TempletPath;
uc.SavePath = SavePath;
uc.FileName = FileName;
uc.channelDescript = channelDescript;
uc.DataLib = DataLib;
uc.channelunit = channelunit;
uc.htmldir = htmldir;
uc.indexFileName = indexFileName;
uc.isHTML = isHTML;
uc.isDelPoint = isDelPoint;
uc.Gpoint = Gpoint;
uc.iPoint = iPoint;
uc.GroupNumber = GroupNumber;
uc.issys = issys;
uc.upfilessize = upfilessize;
uc.upfiletype = upfiletype;
uc.ischeck = ischeck;
uc.indextemplet = indextemplet;
uc.classtemplet = classtemplet;
uc.newstemplet = newstemplet;
uc.specialtemplet = specialtemplet;
//创建模板目录
if (TempletPath.Trim() != string.Empty)
{
if (dirdumm.Trim() != string.Empty){dirdumm = "/" + dirdumm;}
string TempletDir = dirdumm + "/" + dirTemplet + "/" + TempletPath;
TempletDir = TempletDir.Replace("//", "/");
string dimmTempletDir = Server.MapPath(TempletDir);
if (!Directory.Exists(dimmTempletDir))
{
Directory.CreateDirectory(dimmTempletDir);
}
}
if (Request.QueryString["ChID"] != null && Request.QueryString["ChID"] != string.Empty)
{
rd.updateDate1(uc);
}
else
{
try
{
rd.creatModeltable(DataLib, channelType, isconstr);
}
catch (Exception es)
{
PageError("创建频道数据表失败.原因:<li>"+es.ToString()+"</li>", "javascript:history.back();", true);
}
rd.updateDate(uc);
}
//开始写配置文件
StreamWriter sw = null;
int gChID = 0;
if (ChID != 0)
{
gChID = ChID;
}
else
{
gChID = rd.GetTopChID(channelEItem);
}
string ConfigFileName = HttpContext.Current.Server.MapPath("~/xml/sys/Channel/ChParams/CH_" + gChID + ".config");
if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/xml/sys/Channel/ChParams")))
{
Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/xml/sys/Channel/ChParams"));
}
sw = File.CreateText(ConfigFileName);
sw.WriteLine("<?xml version=\"1.0\" ?>\r");
sw.WriteLine("<rss version=\"2.0\">\r");
sw.WriteLine("<channel>\r");
sw.WriteLine(" <channelname>" + channelName + "</channelname>\r");
sw.WriteLine(" <parentID>" + ParentID.ToString() + "</parentID>\r");
sw.WriteLine(" <channeltemplet>" + TempletPath + "/" + indextemplet + "</channeltemplet>\r");
sw.WriteLine(" <channelindexname>" + indexFileName + "</channelindexname>\r");
sw.WriteLine(" <channelindexpath>" + htmldir + "/" + indexFileName + "</channelindexpath>\r");
sw.WriteLine(" <isHTML>" + isHTML + "</isHTML>\r");
sw.WriteLine(" <bdomain>" + binddomain + "</bdomain>\r");
sw.WriteLine(" <htmldir>" + htmldir + "</htmldir>\r");
sw.WriteLine("</channel>\r");
sw.WriteLine("</rss>\r");
sw.Flush();
sw.Close(); sw.Dispose();
Response.Write("<script>alert('频道操作成功');window.top.location.href=\"../index.aspx?urls=channel/list.aspx\"</script>");
Response.End();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -