private bool DoAdd() { BLL.url_rewrite bll = new BLL.url_rewrite(); Model.url_rewrite model = new Model.url_rewrite(); model.name = txtName.Text.Trim(); model.type = ddlType.SelectedValue; model.channel = ddlChannel.SelectedValue; model.page = txtPage.Text.Trim(); model.inherit = txtInherit.Text.Trim(); model.templet = txtTemplet.Text.Trim(); //添加URL重写节点 List <Model.url_rewrite_item> items = new List <Model.url_rewrite_item>(); string[] itemPathArr = Request.Form.GetValues("itemPath"); string[] itemPatternArr = Request.Form.GetValues("itemPattern"); string[] itemQuerystringArr = Request.Form.GetValues("itemQuerystring"); if (itemPathArr != null && itemPatternArr != null && itemQuerystringArr != null) { for (int i = 0; i < itemPathArr.Length; i++) { items.Add(new Model.url_rewrite_item { path = itemPathArr[i], pattern = itemPatternArr[i], querystring = itemQuerystringArr[i] }); } } model.url_rewrite_items = items; if (bll.Add(model)) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加URL配置信息:" + model.name); //记录日志 return(true); } return(false); }
private bool DoAdd() { BLL.url_rewrite bll = new BLL.url_rewrite(); Model.url_rewrite model = new Model.url_rewrite(); model.name = txtName.Text.Trim(); model.type = ddlType.SelectedValue; model.channel = ddlChannel.SelectedValue; model.page = txtPage.Text.Trim(); if (!model.page.EndsWith(".aspx")) { model.page += ".aspx"; } model.cache = rblCache.SelectedValue; model.cachepath = txtCachePath.Text.Trim(); model.inherit = txtInherit.Text.Trim(); if (!model.inherit.StartsWith("DTcms.Web.UI.Page.")) { model.inherit = "DTcms.Web.UI.Page." + model.inherit; } model.templet = txtTemplet.Text.Trim(); if (!model.templet.EndsWith(".html")) { model.templet += ".html"; } if (!string.IsNullOrEmpty(txtPageSize.Text.Trim())) { model.pagesize = txtPageSize.Text.Trim(); } //添加URL重写节点 List <Model.url_rewrite_item> items = new List <Model.url_rewrite_item>(); string[] itemPathArr = Request.Form.GetValues("itemPath"); string[] itemPatternArr = Request.Form.GetValues("itemPattern"); string[] itemQuerystringArr = Request.Form.GetValues("itemQuerystring"); if (itemPathArr != null && itemPatternArr != null && itemQuerystringArr != null) { for (int i = 0; i < itemPathArr.Length; i++) { items.Add(new Model.url_rewrite_item { path = itemPathArr[i], pattern = itemPatternArr[i], querystring = itemQuerystringArr[i] }); } } model.url_rewrite_items = items; if (bll.Add(model)) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加URL配置信息:" + model.name); //记录日志 return(true); } return(false); }
private bool DoAdd() { Model.sys_channel model = new Model.sys_channel(); BLL.sys_channel bll = new BLL.sys_channel(); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); model.model_id = int.Parse(ddlModelId.SelectedValue); model.sort_id = int.Parse(txtSortId.Text.Trim()); int new_id = bll.Add(model); //儲存 if (new_id < 1) { return(false); } #region 儲存URL配置.開始=================================== BLL.url_rewrite bll2 = new BLL.url_rewrite(); bll2.Remove("channel", new_id.ToString()); //先刪除 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPathArr = Request.Form.GetValues("item_path"); string[] itemPatternArr = Request.Form.GetValues("item_pattern"); string[] itemQuerystringArr = Request.Form.GetValues("item_querystring"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); string[] itemPageArr = Request.Form.GetValues("item_page"); if (itemTypeArr != null && itemNameArr != null && itemPathArr != null && itemPatternArr != null && itemQuerystringArr != null && itemTempletArr != null && itemPageArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPathArr.Length) && (itemPathArr.Length == itemPatternArr.Length) && (itemPatternArr.Length == itemQuerystringArr.Length) && (itemQuerystringArr.Length == itemTempletArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { bll2.Add(new Model.url_rewrite { name = itemNameArr[i].Trim(), path = itemPathArr[i].Trim(), pattern = itemPatternArr[i].Trim(), //page = GetPageName(model.name, itemTypeArr[i].Trim()), //源頁面地址 page = itemPageArr[i].Trim(), querystring = itemQuerystringArr[i].Trim(), templet = itemTempletArr[i].Trim(), channel = new_id.ToString(), type = itemTypeArr[i].Trim(), inherit = GetInherit(model.model_id, itemTypeArr[i].Trim()) //繼承的類名 }); } } } #endregion 儲存URL配置.結束 return(true); }
private bool DoEdit(int _id) { DTcms.BLL.sys_channel bll = new DTcms.BLL.sys_channel(); DTcms.Model.sys_channel model = bll.GetModel(_id); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); model.model_id = int.Parse(ddlModelId.SelectedValue); model.sort_id = int.Parse(txtSortId.Text.Trim()); if (!bll.Update(model)) { return(false); } #region 保存URL配置.开始=================================== BLL.url_rewrite bll2 = new BLL.url_rewrite(); bll2.Remove("channel", model.id.ToString()); //先删除 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPathArr = Request.Form.GetValues("item_path"); string[] itemPatternArr = Request.Form.GetValues("item_pattern"); string[] itemQuerystringArr = Request.Form.GetValues("item_querystring"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); if (itemTypeArr != null && itemNameArr != null && itemPathArr != null && itemPatternArr != null && itemQuerystringArr != null && itemTempletArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPathArr.Length) && (itemPathArr.Length == itemPatternArr.Length) && (itemPatternArr.Length == itemQuerystringArr.Length) && (itemQuerystringArr.Length == itemTempletArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { bll2.Add(new Model.url_rewrite { name = itemNameArr[i].Trim(), path = itemPathArr[i].Trim(), pattern = itemPatternArr[i].Trim(), page = GetPageName(model.name, itemTypeArr[i].Trim()), //源页面地址 querystring = itemQuerystringArr[i].Trim(), templet = itemTempletArr[i].Trim(), channel = model.id.ToString(), type = itemTypeArr[i].Trim(), inherit = GetInherit(model.model_id, itemTypeArr[i].Trim()) //继承的类名 }); } } } #endregion 保存URL配置.结束 return(true); }
private bool DoAdd() { BLL.url_rewrite bll = new BLL.url_rewrite(); Model.url_rewrite model = new Model.url_rewrite(); model.name = txtName.Text.Trim(); model.path = txtPath.Text.Trim(); model.pattern = txtPattern.Text.Trim(); model.page = txtPage.Text.Trim(); model.querystring = txtQueryString.Text.Trim(); model.templet = txtTemplet.Text.Trim(); model.channel = txtChannel.Text.Trim(); model.type = ddlType.SelectedValue; model.inherit = txtInherit.Text.Trim(); return bll.Add(model); }
private bool DoAdd() { BLL.url_rewrite bll = new BLL.url_rewrite(); Model.url_rewrite model = new Model.url_rewrite(); model.name = txtName.Text.Trim(); model.path = txtPath.Text.Trim(); model.pattern = txtPattern.Text.Trim(); model.page = txtPage.Text.Trim(); model.querystring = txtQueryString.Text.Trim(); model.templet = txtTemplet.Text.Trim(); model.channel = txtChannel.Text.Trim(); model.type = ddlType.SelectedValue; model.inherit = txtInherit.Text.Trim(); return(bll.Add(model)); }
private bool DoEdit(int _id) { BLL.site_channel bll = new BLL.site_channel(); Model.site_channel model = bll.GetModel(_id); string old_name = model.name; model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); model.is_lock = 0; model.is_comment = 0; model.is_albums = 0; model.is_attach = 0; model.is_spec = 0; if (cbIsLock.Checked == false) { model.is_lock = 1; } if (cbIsComment.Checked == true) { model.is_comment = 1; } if (cbIsAlbums.Checked == true) { model.is_albums = 1; } if (cbIsAttach.Checked == true) { model.is_attach = 1; } if (cbIsSpec.Checked == true) { model.is_spec = 1; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); //添加频道扩展字段 List <Model.site_channel_field> ls = new List <Model.site_channel_field>(); for (int i = 0; i < cblAttributeField.Items.Count; i++) { if (cblAttributeField.Items[i].Selected) { string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值 ls.Add(new Model.site_channel_field { channel_id = model.id, field_id = Utils.StrToInt(fieldIdArr[1], 0) }); } } model.channel_fields = ls; if (!bll.Update(model)) { return(false); } #region 保存URL配置 BLL.url_rewrite urlBll = new BLL.url_rewrite(); urlBll.Remove("channel", old_name); //先删除旧的 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPageArr = Request.Form.GetValues("item_page"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize"); string[] itemRewriteArr = Request.Form.GetValues("item_rewrite"); if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) && (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { Model.url_rewrite urlModel = new Model.url_rewrite(); urlModel.name = itemNameArr[i].Trim(); urlModel.type = itemTypeArr[i].Trim(); urlModel.page = itemPageArr[i].Trim(); urlModel.inherit = GetInherit(urlModel.type); urlModel.templet = itemTempletArr[i].Trim(); if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0) { urlModel.pagesize = itemPageSizeArr[i].Trim(); } urlModel.channel = model.name; List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>(); string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串 for (int j = 0; j < urlRewriteArr.Length; j++) { string[] urlItemArr = urlRewriteArr[j].Split(','); if (urlItemArr.Length == 3) { itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] }); } } urlModel.url_rewrite_items = itemLs; urlBll.Add(urlModel); } } } #endregion AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改频道" + model.title); //记录日志 return(true); }
private bool DoAdd() { BLL.url_rewrite bll = new BLL.url_rewrite(); Model.url_rewrite model = new Model.url_rewrite(); model.name = txtName.Text.Trim(); model.type = ddlType.SelectedValue; model.channel = ddlChannel.SelectedValue; model.page = txtPage.Text.Trim(); model.inherit = txtInherit.Text.Trim(); model.templet = txtTemplet.Text.Trim(); //添加URL重写节点 List<Model.url_rewrite_item> items = new List<Model.url_rewrite_item>(); string[] itemPathArr = Request.Form.GetValues("itemPath"); string[] itemPatternArr = Request.Form.GetValues("itemPattern"); string[] itemQuerystringArr = Request.Form.GetValues("itemQuerystring"); if (itemPathArr != null && itemPatternArr != null && itemQuerystringArr != null) { for (int i = 0; i < itemPathArr.Length; i++) { items.Add(new Model.url_rewrite_item { path = itemPathArr[i], pattern = itemPatternArr[i], querystring = itemQuerystringArr[i] }); } } model.url_rewrite_items = items; if (bll.Add(model)) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加URL配置信息:" + model.name); //记录日志 return true; } return false; }
private bool DoAdd() { Model.channel model = new Model.channel(); BLL.channel bll = new BLL.channel(); model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); if (cbIsAlbums.Checked == true) { model.is_albums = 1; } if (cbIsAttach.Checked == true) { model.is_attach = 1; } if (cbIsGroupPrice.Checked == true) { model.is_group_price = 1; } model.page_size = Utils.StrToInt(txtPageSize.Text.Trim(), 10); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); //添加频道扩展字段 List <Model.channel_field> ls = new List <Model.channel_field>(); for (int i = 0; i < cblAttributeField.Items.Count; i++) { if (cblAttributeField.Items[i].Selected) { ls.Add(new Model.channel_field { field_id = Utils.StrToInt(cblAttributeField.Items[i].Value, 0) }); } } model.channel_fields = ls; if (bll.Add(model) < 1) { return(false); } #region 保存URL配置 BLL.url_rewrite urlBll = new BLL.url_rewrite(); urlBll.Remove("channel", model.name); //先删除 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPageArr = Request.Form.GetValues("item_page"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); string[] itemRewriteArr = Request.Form.GetValues("item_rewrite"); if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemRewriteArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) && (itemTempletArr.Length == itemRewriteArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { Model.url_rewrite urlModel = new Model.url_rewrite(); urlModel.name = itemNameArr[i].Trim(); urlModel.type = itemTypeArr[i].Trim(); urlModel.page = itemPageArr[i].Trim(); urlModel.inherit = GetInherit(urlModel.type); urlModel.templet = itemTempletArr[i].Trim(); urlModel.channel = model.name; List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>(); string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串 for (int j = 0; j < urlRewriteArr.Length; j++) { string[] urlItemArr = urlRewriteArr[j].Split(','); if (urlItemArr.Length == 3) { itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] }); } } urlModel.url_rewrite_items = itemLs; urlBll.Add(urlModel); } } } #endregion AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加频道" + model.title); //记录日志 return(true); }
private bool DoEdit(int _id) { BLL.channel bll = new BLL.channel(); Model.channel model = bll.GetModel(_id); string old_name = model.name; model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); model.is_albums = 0; model.is_attach = 0; model.is_spec = 0; if (cbIsAlbums.Checked == true) { model.is_albums = 1; } if (cbIsAttach.Checked == true) { model.is_attach = 1; } if (cbIsSpec.Checked == true) { model.is_spec = 1; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); //添加频道扩展字段 List<Model.channel_field> ls = new List<Model.channel_field>(); for (int i = 0; i < cblAttributeField.Items.Count; i++) { if (cblAttributeField.Items[i].Selected) { string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值 ls.Add(new Model.channel_field { channel_id = model.id, field_id = Utils.StrToInt(fieldIdArr[1], 0) }); } } model.channel_fields = ls; if (!bll.Update(model)) { return false; } #region 保存URL配置 BLL.url_rewrite urlBll = new BLL.url_rewrite(); urlBll.Remove("channel", old_name); //先删除旧的 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPageArr = Request.Form.GetValues("item_page"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize"); string[] itemRewriteArr = Request.Form.GetValues("item_rewrite"); if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) && (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { Model.url_rewrite urlModel = new Model.url_rewrite(); urlModel.name = itemNameArr[i].Trim(); urlModel.type = itemTypeArr[i].Trim(); urlModel.page = itemPageArr[i].Trim(); urlModel.inherit = GetInherit(urlModel.type); urlModel.templet = itemTempletArr[i].Trim(); if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0) { urlModel.pagesize = itemPageSizeArr[i].Trim(); } urlModel.channel = model.name; List<Model.url_rewrite_item> itemLs = new List<Model.url_rewrite_item>(); string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串 for (int j = 0; j < urlRewriteArr.Length; j++) { string[] urlItemArr = urlRewriteArr[j].Split(','); if (urlItemArr.Length == 3) { itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] }); } } urlModel.url_rewrite_items = itemLs; urlBll.Add(urlModel); } } } #endregion AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改频道" + model.title); //记录日志 return true; }
private bool DoAdd() { Model.channel model = new Model.channel(); BLL.channel bll = new BLL.channel(); model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); if (cbIsAlbums.Checked == true) { model.is_albums = 1; } if (cbIsAttach.Checked == true) { model.is_attach = 1; } if (cbIsGroupPrice.Checked == true) { model.is_group_price = 1; } model.page_size = Utils.StrToInt(txtPageSize.Text.Trim(), 10); model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); //添加频道扩展字段 List<Model.channel_field> ls = new List<Model.channel_field>(); for (int i = 0; i < cblAttributeField.Items.Count; i++) { if (cblAttributeField.Items[i].Selected) { ls.Add(new Model.channel_field { field_id = Utils.StrToInt(cblAttributeField.Items[i].Value, 0) }); } } model.channel_fields = ls; if (bll.Add(model) < 1) { return false; } #region 保存URL配置 BLL.url_rewrite urlBll = new BLL.url_rewrite(); urlBll.Remove("channel", model.name); //先删除 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPageArr = Request.Form.GetValues("item_page"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); string[] itemRewriteArr = Request.Form.GetValues("item_rewrite"); if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemRewriteArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) && (itemTempletArr.Length == itemRewriteArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { Model.url_rewrite urlModel = new Model.url_rewrite(); urlModel.name = itemNameArr[i].Trim(); urlModel.type = itemTypeArr[i].Trim(); urlModel.page = itemPageArr[i].Trim(); urlModel.inherit = GetInherit(urlModel.type); urlModel.templet = itemTempletArr[i].Trim(); urlModel.channel = model.name; List<Model.url_rewrite_item> itemLs = new List<Model.url_rewrite_item>(); string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串 for (int j = 0; j < urlRewriteArr.Length; j++) { string[] urlItemArr = urlRewriteArr[j].Split(','); if (urlItemArr.Length == 3) { itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] }); } } urlModel.url_rewrite_items = itemLs; urlBll.Add(urlModel); } } } #endregion AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加频道" + model.title); //记录日志 return true; }
private bool DoAdd() { Model.sys_channel model = new Model.sys_channel(); BLL.sys_channel bll = new BLL.sys_channel(); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); model.model_id = int.Parse(ddlModelId.SelectedValue); model.sort_id = int.Parse(txtSortId.Text.Trim()); int new_id = bll.Add(model); //保存 if (new_id < 1) { return false; } #region 保存URL配置.开始=================================== BLL.url_rewrite bll2 = new BLL.url_rewrite(); bll2.Remove("channel", new_id.ToString()); //先删除 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPathArr = Request.Form.GetValues("item_path"); string[] itemPatternArr = Request.Form.GetValues("item_pattern"); string[] itemQuerystringArr = Request.Form.GetValues("item_querystring"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); string[] itemPageArr = Request.Form.GetValues("item_page"); if (itemTypeArr != null && itemNameArr != null && itemPathArr != null && itemPatternArr != null && itemQuerystringArr != null && itemTempletArr != null && itemPageArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPathArr.Length) && (itemPathArr.Length == itemPatternArr.Length) && (itemPatternArr.Length == itemQuerystringArr.Length) && (itemQuerystringArr.Length == itemTempletArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { bll2.Add(new Model.url_rewrite { name = itemNameArr[i].Trim(), path = itemPathArr[i].Trim(), pattern = itemPatternArr[i].Trim(), //page = GetPageName(model.name, itemTypeArr[i].Trim()), //源页面地址 page = itemPageArr[i].Trim(), querystring = itemQuerystringArr[i].Trim(), templet = itemTempletArr[i].Trim(), channel = new_id.ToString(), type = itemTypeArr[i].Trim(), inherit = GetInherit(model.model_id, itemTypeArr[i].Trim()) //继承的类名 }); } } } #endregion return true; }
private bool DoAdd() { Model.site_channel model = new Model.site_channel(); BLL.site_channel bll = new BLL.site_channel(); model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); if (cbIsLock.Checked == false) { model.is_lock = 1; } if (cbIsComment.Checked == true) { model.is_comment = 1; } if (cbIsAlbums.Checked == true) { model.is_albums = 1; } if (cbIsAttach.Checked == true) { model.is_attach = 1; } if (cbIsSpec.Checked == true) { model.is_spec = 1; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); //添加频道扩展字段 List <Model.site_channel_field> ls = new List <Model.site_channel_field>(); for (int i = 0; i < cblAttributeField.Items.Count; i++) { if (cblAttributeField.Items[i].Selected) { string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值 ls.Add(new Model.site_channel_field { field_id = Utils.StrToInt(fieldIdArr[1], 0) }); } } model.channel_fields = ls; if (bll.Add(model) < 1) { return(false); } #region 保存URL配置 BLL.url_rewrite urlBll = new BLL.url_rewrite(); urlBll.Remove("channel", model.name); //先删除 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPageArr = Request.Form.GetValues("item_page"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize"); string[] itemRewriteArr = Request.Form.GetValues("item_rewrite"); if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) && (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { Model.url_rewrite urlModel = new Model.url_rewrite(); urlModel.name = itemNameArr[i].Trim(); urlModel.type = itemTypeArr[i].Trim(); urlModel.page = itemPageArr[i].Trim(); urlModel.inherit = GetInherit(urlModel.type); urlModel.templet = itemTempletArr[i].Trim(); if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0) { urlModel.pagesize = itemPageSizeArr[i].Trim(); } urlModel.channel = model.name; List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>(); string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串 for (int j = 0; j < urlRewriteArr.Length; j++) { string[] urlItemArr = urlRewriteArr[j].Split(','); if (urlItemArr.Length == 3) { itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] }); } } urlModel.url_rewrite_items = itemLs; urlBll.Add(urlModel); } } } else { #region 添加默认URl配置 //列表url Model.url_rewrite urlModelList = new Model.url_rewrite(); urlModelList.name = model.name; urlModelList.type = "list"; urlModelList.page = model.name + ".aspx"; urlModelList.inherit = GetInherit(urlModelList.type); urlModelList.templet = model.name + ".html"; urlModelList.pagesize = "20"; urlModelList.channel = model.name; List <Model.url_rewrite_item> listItems = new List <Model.url_rewrite_item> { new Model.url_rewrite_item() { path = model.name + ".aspx", pattern = model.name + ".aspx" }, new Model.url_rewrite_item() { path = model.name + "/{0}.aspx", pattern = model.name + "/(\\d+).aspx", querystring = "category_id=$1" }, new Model.url_rewrite_item() { path = model.name + "/{0}/{1}.aspx", pattern = model.name + "/(\\d+)/(\\w+).aspx", querystring = "category_id=$1^page=$2" } }; urlModelList.url_rewrite_items = listItems; urlBll.Add(urlModelList); //详情页url Model.url_rewrite urlModelShow = new Model.url_rewrite(); urlModelShow.name = model.name + "_show"; urlModelShow.type = "detail"; urlModelShow.page = model.name + "_show.aspx"; urlModelShow.inherit = GetInherit(urlModelShow.type); urlModelShow.templet = model.name + "_show.html"; urlModelShow.channel = model.name; List <Model.url_rewrite_item> showItems = new List <Model.url_rewrite_item> { new Model.url_rewrite_item() { path = model.name + "/show-{0}.aspx", pattern = model.name + "/show-(\\d+).aspx", querystring = "id=$1" } }; urlModelShow.url_rewrite_items = showItems; urlBll.Add(urlModelShow); #endregion } #endregion AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加频道" + model.title); //记录日志 return(true); }
private bool DoAdd() { Model.channel model = new Model.channel(); BLL.channel bll = new BLL.channel(); model.site_id = Utils.StrToInt(ddlSiteId.SelectedValue, 0); model.name = txtName.Text.Trim(); model.title = txtTitle.Text.Trim(); if (cbIsAlbums.Checked == true) { model.is_albums = 1; } if (cbIsAttach.Checked == true) { model.is_attach = 1; } if (cbIsSpec.Checked == true) { model.is_spec = 1; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); //扩展 if (cbIsComment.Checked == true) { model.is_comment = 1; } if (cbIsAttr.Checked == true) { model.is_attribute = 1; } if (cbIsRecycle.Checked == true) { model.is_recycle = 1; } model.is_type = Utils.StrToInt(rblIsType.SelectedValue, 0); model.height = int.Parse(txtHeight.Text.Trim(), 0); model.width = int.Parse(txtWidth.Text.Trim(), 0); //SEO优化 model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim().Replace(",", ","); model.seo_description = txtSeoDescription.Text.Trim(); //添加频道扩展字段 List <Model.channel_field> ls = new List <Model.channel_field>(); for (int i = 0; i < cblAttributeField.Items.Count; i++) { if (cblAttributeField.Items[i].Selected) { string[] fieldIdArr = cblAttributeField.Items[i].Value.Split(','); //分解出ID值 ls.Add(new Model.channel_field { field_id = Utils.StrToInt(fieldIdArr[1], 0) }); } } model.channel_fields = ls; if (bll.Add(model) < 1) { return(false); } #region 保存URL配置 BLL.url_rewrite urlBll = new BLL.url_rewrite(); urlBll.Remove("channel", model.name); //先删除 string[] itemTypeArr = Request.Form.GetValues("item_type"); string[] itemNameArr = Request.Form.GetValues("item_name"); string[] itemPageArr = Request.Form.GetValues("item_page"); string[] itemTempletArr = Request.Form.GetValues("item_templet"); string[] itemPageSizeArr = Request.Form.GetValues("item_pagesize"); string[] itemRewriteArr = Request.Form.GetValues("item_rewrite"); if (itemTypeArr != null && itemNameArr != null && itemPageArr != null && itemTempletArr != null && itemPageSizeArr != null && itemRewriteArr != null) { if ((itemTypeArr.Length == itemNameArr.Length) && (itemNameArr.Length == itemPageArr.Length) && (itemPageArr.Length == itemTempletArr.Length) && (itemTempletArr.Length == itemPageSizeArr.Length) && (itemPageSizeArr.Length == itemRewriteArr.Length)) { for (int i = 0; i < itemTypeArr.Length; i++) { Model.url_rewrite urlModel = new Model.url_rewrite(); urlModel.name = itemNameArr[i].Trim(); urlModel.type = itemTypeArr[i].Trim(); urlModel.page = itemPageArr[i].Trim(); urlModel.inherit = GetInherit(urlModel.type); urlModel.templet = itemTempletArr[i].Trim(); if (Utils.StrToInt(itemPageSizeArr[i].Trim(), 0) > 0) { urlModel.pagesize = itemPageSizeArr[i].Trim(); } urlModel.channel = model.name; List <Model.url_rewrite_item> itemLs = new List <Model.url_rewrite_item>(); string[] urlRewriteArr = itemRewriteArr[i].Split('&'); //分解URL重写字符串 for (int j = 0; j < urlRewriteArr.Length; j++) { string[] urlItemArr = urlRewriteArr[j].Split(','); if (urlItemArr.Length == 3) { itemLs.Add(new Model.url_rewrite_item { path = urlItemArr[0], pattern = urlItemArr[1], querystring = urlItemArr[2] }); } } urlModel.url_rewrite_items = itemLs; urlBll.Add(urlModel); } } } #endregion AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加频道" + model.title); //记录日志 return(true); }