private bool DoAdd() { Model.channel_category model = new Model.channel_category(); BLL.channel_category bll = new BLL.channel_category(); model.title = txtTitle.Text.Trim(); model.build_path = txtBuildPath.Text.Trim(); model.domain = txtDomain.Text.Trim(); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (cbIsDefault.Checked == true) { model.is_default = 1; } else { model.is_default = 0; } if (bll.Add(model) > 0) { //更新一下域名缓存 CacheHelper.Remove(AXKeys.CACHE_SITE_HTTP_DOMAIN); AddAdminLog(AXEnums.ActionEnum.Add.ToString(), "添加频道分类:" + model.title); //记录日志 return(true); } return(false); }
private bool DoEdit(int _id) { bool result = false; BLL.channel_category bll = new BLL.channel_category(); Model.channel_category model = bll.GetModel(_id); model.title = txtTitle.Text.Trim(); model.build_path = txtBuildPath.Text.Trim(); model.domain = txtDomain.Text.Trim(); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (cbIsDefault.Checked == true) { model.is_default = 1; } else { model.is_default = 0; } if (bll.Update(model)) { //更新一下域名缓存 CacheHelper.Remove(AXKeys.CACHE_SITE_HTTP_DOMAIN); AddAdminLog(AXEnums.ActionEnum.Edit.ToString(), "修改频道分类:" + model.title); //记录日志 result = true; } return(result); }
private bool DoAdd() { Model.channel_category model = new Model.channel_category(); BLL.channel_category bll = new BLL.channel_category(); model.title = txtTitle.Text.Trim(); model.build_path = txtBuildPath.Text.Trim(); model.domain = txtDomain.Text.Trim(); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (cbIsDefault.Checked == true) { model.is_default = 1; } else { model.is_default = 0; } if (bll.Add(model) > 0) { //更新一下域名缓存 CacheHelper.Remove(DTKeys.CACHE_SITE_HTTP_DOMAIN); AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加频道分类:" + model.title); //记录日志 return true; } return false; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.channel model) { //取得所属频道分类的生成目录 string build_path = new BLL.channel_category().GetBuildPath(model.category_id); if (string.IsNullOrEmpty(build_path)) { return(0); } //开始插入频道信息 int channelId = dal.Add(model); if (channelId > 0) { //添加导航菜单 int newNavId = new BLL.navigation().Add("channel_" + build_path, "channel_" + model.name, model.title, "", model.sort_id, channelId, "Show"); if (newNavId < 1) { dal.Delete(channelId); return(0); } //添加子导航菜单 new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_list", "内容管理", "article/article_list.aspx", 99, channelId, "Show,View,Add,Edit,Delete,Audit"); new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_category", "栏目类别", "article/category_list.aspx", 100, channelId, "Show,View,Add,Edit,Delete"); new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_comment", "评论管理", "article/comment_list.aspx", 101, channelId, "Show,View,Delete,Reply"); } return(channelId); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.channel model) { //取得所属频道分类的生成目录 string build_path =new BLL.channel_category().GetBuildPath(model.category_id); if (string.IsNullOrEmpty(build_path)) { return 0; } //开始插入频道信息 int channelId = dal.Add(model); if (channelId > 0) { //添加导航菜单 int newNavId = new BLL.navigation().Add("channel_" + build_path, "channel_" + model.name, model.title, "", model.sort_id, channelId, "Show"); if (newNavId < 1) { dal.Delete(channelId); return 0; } //添加子导航菜单 new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_list", "内容管理", "article/article_list.aspx", 99, channelId, "Show,View,Add,Edit,Delete,Audit"); new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_category", "栏目类别", "article/category_list.aspx", 100, channelId, "Show,View,Add,Edit,Delete"); new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_comment", "评论管理", "article/comment_list.aspx", 101, channelId, "Show,View,Delete,Reply"); } return channelId; }
/// <summary> /// ����һ������ /// </summary> public int Add(Model.channel model) { //ȡ������Ƶ�����������Ŀ¼ string build_path =new BLL.channel_category().GetBuildPath(model.category_id); if (string.IsNullOrEmpty(build_path)) { return 0; } //��ʼ����Ƶ����Ϣ int channelId = dal.Add(model); if (channelId > 0) { //��ӵ����˵� int newNavId = new BLL.navigation().Add("channel_" + build_path, "channel_" + model.name, model.title, "", model.sort_id, channelId, "Show"); if (newNavId < 1) { dal.Delete(channelId); return 0; } //����ӵ����˵� new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_list", "���ݹ���", "article/article_list.aspx", 99, channelId, "Show,View,Add,Edit,Delete,Audit"); new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_category", "��Ŀ���", "article/category_list.aspx", 100, channelId, "Show,View,Add,Edit,Delete"); new BLL.navigation().Add("channel_" + model.name, "channel_" + model.name + "_comment", "���۹���", "article/comment_list.aspx", 101, channelId, "Show,View,Delete,Reply"); } return channelId; }
private void RptBind() { BLL.channel_category bll = new BLL.channel_category(); DataSet ds = bll.GetList(0, "", "sort_id asc,id desc"); this.rptList.DataSource = ds; this.rptList.DataBind(); }
private void TreeBind() { BLL.channel_category bll = new BLL.channel_category(); DataTable dt = bll.GetList(0, "", "sort_id asc,id desc").Tables[0]; this.ddlCategoryId.Items.Clear(); this.ddlCategoryId.Items.Add(new ListItem("所有类别", "")); foreach (DataRow dr in dt.Rows) { this.ddlCategoryId.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString())); } }
private void TreeBind() { BLL.channel_category bll = new BLL.channel_category(); DataTable dt = bll.GetList(0, "", "sort_id asc,id desc").Tables[0]; this.ddlCategoryId.Items.Clear(); this.ddlCategoryId.Items.Add(new ListItem("请选择类别...", "")); foreach (DataRow dr in dt.Rows) { this.ddlCategoryId.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString())); } }
private void RptBind(string _strWhere, string _orderby) { this.page = MXRequest.GetQueryInt("page", 1); this.txtKeywords.Text = this.keywords; BLL.channel_category bll = new BLL.channel_category(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("category_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//构造函数 public SiteDomains() { DefaultPath = new BLL.channel_category().GetDefaultPath(); //默认目录 CategoryDirs = new BLL.channel_category().GetCategoryDirs(); //分类目录 Domains = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> kvp in CategoryDirs) { if (kvp.Value.Length > 0 && !Domains.ContainsKey(kvp.Value)) { Domains.Add(kvp.Value, kvp.Key); } } }
private void RptBind(string _strWhere, string _orderby) { this.page = AXRequest.GetQueryInt("page", 1); this.txtKeywords.Text = this.keywords; BLL.channel_category bll = new BLL.channel_category(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("category_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("site_channel_category", AXEnums.ActionEnum.Edit.ToString()); //检查权限 BLL.channel_category bll = new BLL.channel_category(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "sort_id=" + sortId.ToString()); } AddAdminLog(AXEnums.ActionEnum.Edit.ToString(), "保存频道分类排序"); //记录日志 JscriptMsg("保存排序成功!", Utils.CombUrlTxt("category_list.aspx", "keywords={0}", this.keywords), "Success", "parent.loadMenuTree"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.channel model) { //取得所属频道分类的生成目录 string build_path = new BLL.channel_category().GetBuildPath(model.category_id); if (string.IsNullOrEmpty(build_path)) { return(false); } //取得所属频道分类在导航中的ID int parent_id = new BLL.navigation().GetNavId("channel_" + build_path); if (parent_id == 0) { return(false); } //取得旧的数据 Model.channel oldModel = dal.GetModel(model.id); //开始修改数据 if (dal.Update(model)) { //如果名称和标题发生改变则修改对应的导航 if (model.name != oldModel.name || model.title != oldModel.title || model.category_id != oldModel.category_id || model.sort_id != oldModel.sort_id) { Model.navigation navModel = new BLL.navigation().GetModel("channel_" + oldModel.name); if (navModel != null) { navModel.name = "channel_" + model.name; navModel.title = model.title; navModel.parent_id = parent_id; navModel.sort_id = model.sort_id; new BLL.navigation().Update(navModel); } } //如果名称发生变化则修改相应的子菜单名称 if (model.name != oldModel.name) { new BLL.navigation().UpdateNavName("channel_" + oldModel.name + "_list", "channel_" + model.name + "_list"); //内容管理 new BLL.navigation().UpdateNavName("channel_" + oldModel.name + "_category", "channel_" + model.name + "_category"); //栏目类别 new BLL.navigation().UpdateNavName("channel_" + oldModel.name + "_comment", "channel_" + model.name + "_comment"); //评论管理 } return(true); } return(false); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("site_channel_category", DTEnums.ActionEnum.Edit.ToString()); //检查权限 BLL.channel_category bll = new BLL.channel_category(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "sort_id=" + sortId.ToString()); } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "保存频道分类排序"); //记录日志 JscriptMsg("保存排序成功!", Utils.CombUrlTxt("category_list.aspx", "keywords={0}", this.keywords), "Success", "parent.loadMenuTree"); }
private void TreeBind() { BLL.channel_category bll = new BLL.channel_category(); DataTable dt = bll.GetList(0, "", "sort_id asc,id desc").Tables[0]; this.ddlCategoryPath.Items.Clear(); this.ddlCategoryPath.Items.Add(new ListItem("生成模板到", "")); foreach (DataRow dr in dt.Rows) { if (string.IsNullOrEmpty(dr["templet_path"].ToString())) { this.ddlCategoryPath.Items.Add(new ListItem("├ " + dr["title"].ToString(), dr["build_path"].ToString())); } else { this.ddlCategoryPath.Items.Add(new ListItem("├ " + dr["title"].ToString() + "(当前模板:" + dr["templet_path"].ToString() + ")", dr["build_path"].ToString())); } } }
private void ShowInfo(int _id) { BLL.channel_category bll = new BLL.channel_category(); Model.channel_category model = bll.GetModel(_id); txtTitle.Text = model.title; txtBuildPath.Text = model.build_path; txtBuildPath.Attributes.Add("ajaxurl", "../../tools/admin_ajax.ashx?action=channel_category_validate&old_build_path=" + Utils.UrlEncode(model.build_path)); txtBuildPath.Focus(); //设置焦点,防止JS无法提交 txtDomain.Text = model.domain; txtSortId.Text = model.sort_id.ToString(); if (model.is_default == 1) { cbIsDefault.Checked = true; } else { cbIsDefault.Checked = false; } }
private void TreeBind() { BLL.channel_category bll = new BLL.channel_category(); DataTable dt = bll.GetList(0, "", "sort_id asc,id desc").Tables[0]; this.ddlCategoryPath.Items.Clear(); this.ddlCategoryPath.Items.Add(new ListItem("生成模板到", "")); if (siteConfig.mobilestatus == 1) { this.ddlCategoryPath.Items.Add(new ListItem("├ 手机网站", "mobile")); } foreach (DataRow dr in dt.Rows) { if (string.IsNullOrEmpty(dr["templet_path"].ToString())) { this.ddlCategoryPath.Items.Add(new ListItem("├ " + dr["title"].ToString(), dr["build_path"].ToString())); } else { this.ddlCategoryPath.Items.Add(new ListItem("├ " + dr["title"].ToString() + "(当前模板:" + dr["templet_path"].ToString() + ")", dr["build_path"].ToString())); } } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("site_channel_category", AXEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.channel_category bll = new BLL.channel_category(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { //检查该分类下是否还有频道 int channelCount = new BLL.channel().GetCount("category_id=" + id); if (channelCount > 0) { errorCount += 1; continue; } Model.channel_category model = bll.GetModel(id); //删除成功后对应的目录及文件 if (bll.Delete(id)) { sucCount += 1; Utils.DeleteDirectory(siteConfig.webpath + AXKeys.DIRECTORY_REWRITE_ASPX + "/" + model.build_path); Utils.DeleteDirectory(siteConfig.webpath + AXKeys.DIRECTORY_REWRITE_HTML + "/" + model.build_path); } else { errorCount += 1; } } } AddAdminLog(AXEnums.ActionEnum.Delete.ToString(), "删除频道分类成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("category_list.aspx", "keywords={0}", this.keywords), "Success", "parent.loadMenuTree"); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("site_channel_category", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.channel_category bll = new BLL.channel_category(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { //检查该分类下是否还有频道 int channelCount = new BLL.channel().GetCount("category_id=" + id); if (channelCount > 0) { errorCount += 1; continue; } Model.channel_category model = bll.GetModel(id); //删除成功后对应的目录及文件 if (bll.Delete(id)) { sucCount += 1; Utils.DeleteDirectory(siteConfig.webpath + DTKeys.DIRECTORY_REWRITE_ASPX + "/" + model.build_path); Utils.DeleteDirectory(siteConfig.webpath + DTKeys.DIRECTORY_REWRITE_HTML + "/" + model.build_path); } else { errorCount += 1; } } } AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除频道分类成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("category_list.aspx", "keywords={0}", this.keywords), "Success", "parent.loadMenuTree"); }
private bool DoEdit(int _id) { bool result = false; BLL.channel_category bll = new BLL.channel_category(); Model.channel_category model = bll.GetModel(_id); model.title = txtTitle.Text.Trim(); model.build_path = txtBuildPath.Text.Trim(); model.domain = txtDomain.Text.Trim(); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (cbIsDefault.Checked == true) { model.is_default = 1; } else { model.is_default = 0; } if (bll.Update(model)) { //更新一下域名缓存 CacheHelper.Remove(MXKeys.CACHE_SITE_HTTP_DOMAIN); AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改频道分类:" + model.title); //记录日志 result = true; } return result; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.channel model) { //取得所属频道分类的生成目录 string build_path =new BLL.channel_category().GetBuildPath(model.category_id); if (string.IsNullOrEmpty(build_path)) { return false; } //取得所属频道分类在导航中的ID int parent_id = new BLL.navigation().GetNavId("channel_" + build_path); if (parent_id == 0) { return false; } //取得旧的数据 Model.channel oldModel = dal.GetModel(model.id); //开始修改数据 if (dal.Update(model)) { //如果名称和标题发生改变则修改对应的导航 if (model.name != oldModel.name || model.title != oldModel.title || model.category_id != oldModel.category_id || model.sort_id != oldModel.sort_id) { Model.navigation navModel = new BLL.navigation().GetModel("channel_" + oldModel.name); if (navModel != null) { navModel.name = "channel_" + model.name; navModel.title = model.title; navModel.parent_id = parent_id; navModel.sort_id = model.sort_id; new BLL.navigation().Update(navModel); } } return true; } return false; }
/// <summary> /// ����һ������ /// </summary> public bool Update(Model.channel model) { //ȡ������Ƶ�����������Ŀ¼ string build_path =new BLL.channel_category().GetBuildPath(model.category_id); if (string.IsNullOrEmpty(build_path)) { return false; } //ȡ������Ƶ�������ڵ����е�ID int parent_id = new BLL.navigation().GetNavId("channel_" + build_path); if (parent_id == 0) { return false; } //ȡ�þɵ����� Model.channel oldModel = dal.GetModel(model.id); //��ʼ������ if (dal.Update(model)) { //������ƺͱ��ⷢ���ı����Ķ�Ӧ�ĵ��� if (model.name != oldModel.name || model.title != oldModel.title || model.category_id != oldModel.category_id || model.sort_id != oldModel.sort_id) { Model.navigation navModel = new BLL.navigation().GetModel("channel_" + oldModel.name); if (navModel != null) { navModel.name = "channel_" + model.name; navModel.title = model.title; navModel.parent_id = parent_id; navModel.sort_id = model.sort_id; new BLL.navigation().Update(navModel); } } return true; } return false; }
private void channel_category_validate(HttpContext context) { string build_path = MXRequest.GetString("param"); string old_build_path = MXRequest.GetString("old_build_path"); if (string.IsNullOrEmpty(build_path)) { context.Response.Write("{ \"info\":\"该目录名不可为空!\", \"status\":\"n\" }"); return; } if (build_path.ToLower() == old_build_path.ToLower()) { context.Response.Write("{ \"info\":\"该目录名可使用\", \"status\":\"y\" }"); return; } BLL.channel_category bll = new BLL.channel_category(); if (bll.Exists(build_path)) { context.Response.Write("{ \"info\":\"该目录名已被占用,请更换!\", \"status\":\"n\" }"); return; } context.Response.Write("{ \"info\":\"该目录名可使用\", \"status\":\"y\" }"); return; }
//构造函数 public SiteDomains() { DefaultPath = new BLL.channel_category().GetDefaultPath(); //默认目录 CategoryDirs = new BLL.channel_category().GetCategoryDirs(); //分类目录 Domains = new Dictionary<string, string>(); foreach (KeyValuePair<string, string> kvp in CategoryDirs) { if (kvp.Value.Length > 0 && !Domains.ContainsKey(kvp.Value)) { Domains.Add(kvp.Value, kvp.Key); } } }