protected void btnTemplateNodeEdit_Click(object sender, EventArgs e) { string returnMsg = ""; KingTop.Model.SysManage.WebSiteTemplateNode mode = new KingTop.Model.SysManage.WebSiteTemplateNode(); mode.ID = Utils.ParseInt(ID, 0); mode.TemplateID = Utils.ParseInt(TemplateID, 0); mode.NodeName = Utils.HtmlEncode(txtNodeName.Text.Trim()); if (txtLink.Text.Length > 0) { mode.LinkURL = Utils.HtmlEncode(txtLink.Text.Trim()); } if (ddlModeID.SelectedValue != "0") { mode.ModuleID = new Guid(ddlModeID.SelectedValue.Trim()); } mode.NodeType = chkNodeType.Checked ? "1" : "0"; mode.IsValid = Utils.ParseBool(RBL_IsValid.SelectedValue); mode.NodelOrder = Utils.HtmlEncode(txtNodelOrder.Text.Trim()); mode.NodelDesc = Utils.HtmlEncode(txtNodelDesc.Text.Trim()); mode.NodelEngDesc = Utils.HtmlEncode(txtNodelEngDesc.Text.Trim()); mode.IsSystem = Utils.ParseBool(chkIsSystem.Checked); mode.IsContainWebContent = Utils.ParseBool(chkIsContainWebContent.Checked); mode.IsWeb = false; if (ddlReviewFlow.SelectedValue != "0") { mode.ReviewFlowID = this.ddlReviewFlow.SelectedValue; } if (this.Action == "EDIT") { #region 修改模块节点 if (IsHaveRightByOperCode("Edit")) { mode.NodeCode = Utils.HtmlEncode(hidNodeCode.Value); mode.ParentNode = NodeCode.Substring(0, NodeCode.Length - 3); if (mode.ParentNode == "") { mode.ParentNode = "0"; } //根据NodeCode得到子栏目下最大的NodeCode DataTable dtNodeCode = bll.GetList("MAXCODE", Utils.getOneParams(hidNodeCode.Value)); if (dtNodeCode.Rows[0]["NodeCode"].ToString() != "") { //如果没有子栏目,用户可随意修改[父级栏目]属性,如果有子栏目,则不给它赋值 mode.NodeType = chkNodeType.Checked ? "1" : "0"; } returnMsg = bll.Save("EDIT", mode); string logTitle = Request.Form["hidLogTitle"]; if (logTitle != txtNodeName.Text) { logTitle = logTitle + " => " + txtNodeName.Text; } try { if (Convert.ToInt32(returnMsg) > 0) { WriteLog("修改" + txtNodeName.Text + "模板节点成功", "", 2);// 写入操作日志 Utils.RunJavaScript(this, "type=1;title='" + txtNodeName.Text.Replace("'", "\\'") + "';"); } } catch { WriteLog("修改" + txtNodeName.Text + "模板节点失败", returnMsg, 2); Utils.RunJavaScript(this, "type=2;errmsg='" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + "';"); } } else { Utils.RunJavaScript(this, "alert({msg:'你没有编辑模板节点的权限,请联系站点管理员!',title:'提示信息'})"); } #endregion } else { #region 新增模块节点 if (IsHaveRightByOperCode("New")) { //根据IsParent判断它是不是父节点,如果不是则不能添加子节点 if (NodeType == "1") { //如果是子栏目,则必须要选择栏目类型 if (!chkNodeType.Checked && ddlModeID.SelectedValue == "0") { Utils.RunJavaScript(this, "alert({msg:'请选择所属模块!',title:'提示信息'})"); return; } if (ddlNodeCode.SelectedValue != "0") { mode.NodeCode = Utils.HtmlDecode(ddlNodeCode.SelectedValue); mode.ParentNode = "0";//顶级节点ParentNode="0" } else { //根据NodeCode得到子栏目下最大的NodeCode DataTable dtNodeCode = bll.GetList("MAXCODE", Utils.getOneParams(hidNodeCode.Value)); if (dtNodeCode.Rows[0]["NodeCode"].ToString() != "") { mode.NodeCode = Utils.HtmlDecode(dtNodeCode.Rows[0]["NodeCode"].ToString()); } else { mode.NodeCode = this.NodeCode + "001"; } mode.ParentNode = hidNodeCode.Value; } returnMsg = bll.Save("NEW", mode); string logTitle = Request.Form["hidLogTitle"]; if (logTitle != txtNodeName.Text) { logTitle = logTitle + " => " + txtNodeName.Text; } try { if (Convert.ToInt32(returnMsg) > 0) { WriteLog(GetLogValue(logTitle, "Update", "TemplateNodeEdit", true), "", 2); //写日志 Utils.RunJavaScript(this, "type=0;title='" + txtNodeName.Text.Replace("'", "\\'") + "';"); } } catch { WriteLog(GetLogValue(logTitle, "Update", "TemplateNodeEdit", false), returnMsg, 3); //写日志 Utils.RunJavaScript(this, "type=2;errmsg='" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + "';"); } } else//如果不是则不能添加子节点 { Utils.RunJavaScript(this, "alert({msg:'上级栏目不是父栏目,不能添加子栏目!',title:'提示信息'})"); } } else { Utils.RunJavaScript(this, "alert({msg:'你没有新增模板节点的权限,请联系站点管理员!',title:'提示信息'})"); } #endregion } }
protected void Edit(object sender, EventArgs e) { string msg; string listUrl; bool isValidate; // 权限验证 ctrManageEdit.SiteID = Utils.ParseInt(hdnSiteID.Value, 0); ctrManageEdit.NodeCode = hdnNodeID.Value; ctrManageEdit.FieldFromUrlParamValue = hdnFieldFromUrlParamValue.Value; listUrl = hdnTableName.Value.Replace("K_U_", "").Replace("K_F_", "") + "list.aspx?" + ctrManageEdit.KeepUrlParam; string msgTitle = string.IsNullOrEmpty(Request.Form["Title"]) ? "" : Request.Form["Title"].Replace("\"", "\\\""); if (!string.IsNullOrEmpty(this.ID)) { isValidate = IsHaveRightByOperCode("Edit"); // 修改权限认证 if (!isValidate) { jsMessage = "errmsg=\"对不起,您没有修改记录的操作权限,请与管理员联系!\";id=\"" + ID + "\""; this.hsFieldValue = ctrManageEdit.HsEditField; PageInit(); // 得新绑定数据 return; } else { msg = ctrManageEdit.Edit(false, this.ID); if (msg == "1") // 更新成功 { jsMessage = "type=1;title=\"" + msgTitle + " \";id=\"" + ctrManageEdit.RecordID + "\""; WriteLog("更新记录 " + Request.Form["Title"] + "(ID:" + ctrManageEdit.RecordID + ") 成功!", null, 2); } else // 失败 { jsMessage = "errmsg=\"对不起,操作失败。\";type=2;id=\"" + ctrManageEdit.RecordID + "\";"; WriteLog("对不起,更新记录 " + Request.Form["Title"] + "(ID:" + ctrManageEdit.RecordID + ") 失败!", msg, 3); } } } else { isValidate = IsHaveRightByOperCode("New"); // 添加权限认证 SetModelCookies("search", null); SetModelCookies("searchlink", null); SetModelCookies("ModelPage", null); if (!isValidate) { jsMessage = "errmsg=\"对不起,您没有添加记录的操作权限,请与管理员联系!\";id=\"" + ID + "\""; this.hsFieldValue = ctrManageEdit.HsEditField; PageInit(); // 得新绑定数据 return; } else { msg = ctrManageEdit.Edit(true, null); if (msg == "1") // 新增成功 { jsMessage = "type=0;title=\"" + msgTitle + " \";id=\"" + ctrManageEdit.RecordID + "\""; WriteLog("新增记录 " + Request.Form["Title"] + "(" + ctrManageEdit.RecordID + ") 成功!", null, 2); } else // 失败 { jsMessage = "errmsg=\"对不起,操作失败。\";type=2;id=\"" + ctrManageEdit.RecordID + "\";"; WriteLog("对不起,新增记录 " + Request.Form["Title"] + "(" + ctrManageEdit.RecordID + ") 失败!", msg, 3); } } } if (ctrManageEdit.HsEditField.Contains("IsHtml") && Utils.ParseBool(ctrManageEdit.HsEditField.Contains("IsHtml"))) // 公用字段,是否生成HTML { isValidate = IsHaveRightByOperCode("CreateHtml"); if (isValidate) { //模版方式生成静态页面 //string[] arrLog; //arrLog = ctrManageEdit.CreateHtml(ctrManageEdit.RecordID, this.SiteDir, GetUploadFileUrl(), GetUploadFileUrl(), GetUploadMediaUrl(), this.GetSiteDomain()); //if (!string.IsNullOrEmpty(arrLog[1])) //{ // jsMessage = "alert({msg:\"HTML页生成失败!\",title:\"操作提示\"});"; // WriteLog(arrLog[0], arrLog[1], 3); //} //else //{ // WriteLog(arrLog[0], null, 2); //} //动态转静态 KingTop.WEB.SysAdmin.SysManage.AspxToHtml_Publish publish = new KingTop.WEB.SysAdmin.SysManage.AspxToHtml_Publish(); string nodeList = "''"; List <string> lstMenu = new List <string>(); for (int i = 6; i <= NodeCode.Length; i = i + 3) { nodeList += ",'" + NodeCode.Substring(0, i) + "'"; lstMenu.Add(NodeCode.Substring(0, i)); } publish.IsBar = false; publish.IsContent = true; publish.IsIndex = true; publish.IsMenuList = true; publish.nodeCodeList = nodeList; publish.PublishType = 1; publish.TypeParam = new string[] { ctrManageEdit.RecordID }; publish.ListMenu = lstMenu; publish.siteDir = SiteDir; publish.siteID = SiteID; try { publish.Execute(); } catch { jsMessage = "alert({msg:\"HTML页生成失败!\",title:\"操作提示\"});"; } } else { jsMessage = "alert({msg:\"对不起,您没有 生成HTML 操作权限,请与管理员联系!\",title:\"操作提示\"});"; } } this.hsFieldValue = ctrManageEdit.HsEditField; PageInit(); // 得新绑定数据 }
/// <summary> /// 页面更新、删除 /// </summary> private void LinkClick() { string actionType; string idStr; bool isValidate; isValidate = false; if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["ID"])) // 单记录更新 { idStr = Request.QueryString["ID"]; } else { idStr = Request.Form["_chkID"]; // 批量更新 } actionType = ctrManageList.GetLinkType(); switch (actionType) { case "d": // 删除 isValidate = IsHaveRightByOperCode("Delete"); if (isValidate) { ctrManageList.LinkDelete(idStr); } else { jsMessage = "alert({msg:\"对不起,您没有 删除 操作权限,请与管理员联系!\",title:\"操作提示\"});"; } break; case "e": // 更新 isValidate = IsHaveRightByOperCode("Edit"); if (isValidate) { ctrManageList.LinkEdit(idStr); } else { jsMessage = "alert({msg:\"对不起,您没有 编辑 操作权限,请与管理员联系!\",title:\"操作提示\"});"; } break; case "HQB_PastFlowCheck": // 通过审核 //isValidate = IsHaveRightByOperCode("PastFlowCheck"); isValidate = IsHaveRightByOperCode("Check"); if (isValidate) { ctrManageList.FlowCheck(true); } else { jsMessage = "alert({msg:\"对不起,您没有 通过审核 操作权限,请与管理员联系!\",title:\"操作提示\"});"; } break; case "HQB_CancelFlowCheck": // 取消审核 //isValidate = IsHaveRightByOperCode("CancelFlowCheck"); isValidate = IsHaveRightByOperCode("CancelCheck"); if (isValidate) { ctrManageList.FlowCheck(false); } else { jsMessage = "alert({msg:\"对不起,您没有 取消审核 操作权限,请与管理员联系!\",title:\"操作提示\"});"; } break; case "h": // 生成HTML isValidate = IsHaveRightByOperCode("CreateHtml"); if (isValidate) { //模版方式生成静态页面 //ctrManageList.CreateHtml(idStr, this.SiteDir, GetUploadImgPath, GetUploadFileUrl(), GetUploadMediaUrl(), this.GetSiteDomain()); //if (string.IsNullOrEmpty(ctrManageList.LogException)) //{ // jsMessage = "alert({msg:\"HTML页生成成功!\",title:\"操作提示\"});"; //} //动态转静态 KingTop.WEB.SysAdmin.SysManage.AspxToHtml_Publish publish = new KingTop.WEB.SysAdmin.SysManage.AspxToHtml_Publish(); string nodeList = "''"; List <string> lstMenu = new List <string>(); for (int i = 6; i <= NodeCode.Length; i = i + 3) { nodeList += ",'" + NodeCode.Substring(0, i) + "'"; lstMenu.Add(NodeCode.Substring(0, i)); } publish.IsBar = false; publish.IsContent = true; publish.IsIndex = true; publish.IsMenuList = true; publish.nodeCodeList = nodeList; publish.PublishType = 1; publish.TypeParam = new string[] { idStr }; publish.ListMenu = lstMenu; publish.siteDir = SiteDir; publish.siteID = SiteID; try { publish.Execute(); } catch { jsMessage = "alert({msg:\"HTML页生成失败!\",title:\"操作提示\"});"; } } else { jsMessage = "alert({msg:\"对不起,您没有 生成HTML 操作权限,请与管理员联系!\",title:\"操作提示\"});"; } break; default: // 信息提示:参数传递不正确 break; } if (!string.IsNullOrEmpty(ctrManageList.LogContent)) { if (string.IsNullOrEmpty(ctrManageList.LogException)) // 失败 { WriteLog(ctrManageList.LogContent, ctrManageList.LogException, 3); } else // 成功 { WriteLog(ctrManageList.LogContent, string.Empty, 2); } } }
protected void btnEdit_Click(object sender, EventArgs e) { string returnMsg = ""; string editSelfMenuUrl = ""; DataTable dtNodeCode = null; #region 实体类赋值 mode.NodeID = new Guid(txtNodeID.Text); mode.NodeName = txtNodeName.Text.Trim(); mode.NodeDir = txtNodeDir.Text; mode.NodelIcon = txtNodelIcon.Text.Trim(); mode.CurrentImg = Utils.HtmlEncode(txtCurrentImg.Text.Trim()); mode.MouseOverImg = Utils.HtmlEncode(txtMouseOverImg.Text.Trim()); if (txtLinkURL.Text.Length > 0) { mode.LinkURL = txtLinkURL.Text.Trim(); } //if (ddlModel.SelectedValue != "0") //{ // mode.ModuleID = new Guid(ddlModel.SelectedValue.Trim()); //} mode.ModuleID = new Guid(Request.Form["ddlModel"]); mode.IsValid = Utils.ParseBool(RBL_IsValid.SelectedValue); mode.IsWeb = true; mode.NodelOrder = Utils.HtmlEncode(txtNodelOrder.Text.Trim()); mode.IsLeftDisplay = Utils.ParseBool(chkIsLeftDisplay.Checked); mode.IsTopMenuShow = Utils.ParseBool(chkIsTopMenuShow.Checked); mode.IsLeftMenuShow = Utils.ParseBool(chkIsLeftMenuShow.Checked); mode.NodelDesc = Editor1.Content; mode.NodelEngDesc = txtNodelEngDesc.Text.Trim(); mode.WebSiteID = Convert.ToInt32(this.SiteID); mode.Creater = base.GetLoginAccountId(); mode.Settings = ""; mode.Tips = Utils.HtmlEncode(txtTips.Text); mode.PageTitle = Utils.HtmlEncode(txtPageTitle.Text); mode.Meta_Keywords = Utils.HtmlEncode(txtKeyWords.Text); mode.Meta_Description = Utils.HtmlEncode(txtMetaDesc.Text); mode.SubDomain = txtSubDomain.Text; mode.CreateDate = DateTime.Now; mode.OpenType = radSelf.Checked ? 1 : 2; mode.ColumnType = 2; mode.DefaultTemplate = txtDefaultTemplate.Text; if (ddlListPagePostFix.SelectedValue != "") { mode.ListPagePostFix = this.ddlListPagePostFix.SelectedValue; } mode.IsCreateContentPage = radCreateContentPageTrue.Checked ? false : true; //自定义内容赋值 //取自定义数量 int CustomContentCount = Utils.ParseInt(ddlCustomContentCount.SelectedValue, 1); //自定义内容,初始化为第一个TextBox.Text string strCustomContent = txtCustomContent1.Text + "<hqb>" + Utils.ParseInt(Request.Form["chkIsHtmlEditor1"], 0); for (int i = 2; i <= CustomContentCount; i++) { string strTemp = Request.Form["txtCustomContent" + i.ToString()]; strCustomContent += "###" + strTemp + "<hqb>" + Utils.ParseInt(Request.Form["chkIsHtmlEditor" + i.ToString()], 0); } mode.Custom_Content = strCustomContent; mode.Banner = txtBanner.Text; #endregion if (Action == "EDIT") { #region 修改节点 // 权限验证,是否具有修改权限 if (IsHaveRightByOperCode("Edit")) { mode.NodeCode = Utils.HtmlEncode(txtNodeCode.Text.Trim()); mode.ParentNode = NCode.Substring(0, NCode.Length - 3); //根据NodeCode判断它下面是否有子栏目 dtNodeCode = bllModuleNode.GetList("ALLBY", Utils.getTwoParams(SiteID.ToString(), NCode)); if (dtNodeCode.Rows.Count == 0) { //如果没有子栏目,用户可随意修改[父级栏目]属性,如果有子栏目,则不给它赋值 mode.NodeType = (Utils.ParseBoolToInt(chkIsFolder.Checked)).ToString(); } else { mode.NodeType = "1"; } if (mode.ParentNode == "") { mode.ParentNode = "0"; } returnMsg = bllModuleNode.Save("EDIT", mode); string logTitle = Request.Form["hidLogTitle"]; if (logTitle != txtNodeName.Text) { logTitle = logTitle + " => " + txtNodeName.Text; } returnMsg = bllModuleNode.Save("EDIT", mode); if (Utils.ParseInt(returnMsg, 0) > 0) { DataTable parentDt = bllModuleNode.GetModeNodeFromCache(); string parentNodeCode; if (NCode.Length > 3) { parentNodeCode = NCode.Substring(0, NCode.Length - 3); } else { parentNodeCode = NCode; } DataRow[] parentdr = parentDt.Select("NodeCode='" + parentNodeCode + "'"); if (parentdr.Length > 0) { editSelfMenuUrl = "SingleColumn.aspx?Action=New&NodeID=" + parentdr[0]["NodeId"].ToString() + "&ID=" + parentdr[0]["NodeId"].ToString() + "&NCode=" + parentNodeCode + "&NodeCode=" + NodeCode + "&IsParent=1"; } //Utils.RunJavaScript(this, "alertClose({msg:'修改栏目成功!',title:'提示信息'},function(){location.href='ColumnManage.aspx?nodeid=" + NodeID + "'})"); WriteLog(GetLogValue(logTitle, "Update", "ModelNodeEdit", true), "", 2); //写日志 Utils.RunJavaScript(this, "type=1;title='" + txtNodeName.Text.Trim().Replace("'", "\\'") + "';editSelfMenuUrl='" + editSelfMenuUrl + "'"); } else { WriteLog(GetLogValue(logTitle, "Update", "ModelNodeEdit", false), returnMsg, 3); //写日志 Utils.RunJavaScript(this, "type=2;errmsg='" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + "'"); } } else { Utils.RunJavaScript(this, "alert({msg:'你没有修改栏目的权限,请联系站点管理员!',title:'提示信息'})"); } #endregion } else { #region 新增节点 //判断是否有新增权限 if (IsHaveRightByOperCode("New")) { //根据IsParent判断它是不是父节点,如果不是则不能添加子节点 if (IsParent == "1") { //如果是子栏目,则必须要选择栏目类型 //if (!chkIsFolder.Checked) //{ // Utils.RunJavaScript(this, "alert({msg:'请选择栏目类型!',title:'提示信息'})"); // return; //} //根据NodeCode得到子栏目下最大的NodeCode dtNodeCode = bllModuleNode.GetList("MAXCODE", Utils.getOneParams(this.NCode)); if (dtNodeCode != null && dtNodeCode.Rows.Count == 1) { if (dtNodeCode.Rows[0]["NodeCode"].ToString() != "") { mode.NodeCode = dtNodeCode.Rows[0]["NodeCode"].ToString(); } else //如果没有NodeCode后面三位从001开始 { mode.NodeCode = this.NCode + "001"; } } mode.NodeType = (Utils.ParseBoolToInt(chkIsFolder.Checked)).ToString(); mode.ParentNode = NCode; //如果是添加一级栏目,得到一级栏目最大的NodeCode+1 if (NCode == "0") { DataTable dt = bllModuleNode.GetList("MAXPCODE", Utils.getOneParams("")); if (dt.Rows.Count < 1) { mode.NodeCode = this.NCode; mode.ParentNode = "0"; } } returnMsg = bllModuleNode.Save("NEW", mode); editSelfMenuUrl = "SingleColumn.aspx?Action=Edit&NodeID=" + mode.NodeID + "&ID=" + mode.NodeID + "&NCode=" + mode.NodeCode + "&NodeCode=" + NodeCode + "&ColumnType=1"; if (Utils.ParseInt(returnMsg, 0) > 0) { WriteLog("新增栏目" + txtNodeName.Text + "成功!", "", 2);//写入操作日志 Utils.RunJavaScript(this, "type=0;title='" + txtNodeName.Text.Trim().Replace("'", "\\'") + "';editSelfMenuUrl='" + editSelfMenuUrl + "'"); } else { WriteLog("新增栏目" + txtNodeName.Text + "成功!", returnMsg, 2);//写入操作日志 Utils.RunJavaScript(this, "type=2;errmsg='" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + "'"); } } else//如果不是则不能添加子节点 { Utils.RunJavaScript(this, "alert({msg:'上级栏目不是父栏目,不能添加子栏目!',title:'提示信息'})"); } } else { Utils.RunJavaScript(this, "alert({msg:'你没有新增栏目的权限,请联系站点管理员!',title:'提示信息'})"); } #endregion } //判断是否生成静态页面 if (Utils.XmlRead(System.Web.HttpContext.Current.Server.MapPath("/config/SiteParam.config"), "SiteParamConfig/PublishType", "") == "2") { //动态转静态 KingTop.WEB.SysAdmin.SysManage.AspxToHtml_Publish publish = new KingTop.WEB.SysAdmin.SysManage.AspxToHtml_Publish(); string nodeList = "''"; List <string> lstMenu = new List <string>(); for (int i = 6; i <= NodeCode.Length; i = i + 3) { nodeList += ",'" + NodeCode.Substring(0, i) + "'"; lstMenu.Add(NodeCode.Substring(0, i)); } publish.IsBar = false; publish.IsContent = false; publish.IsIndex = true; publish.IsMenuList = true; publish.nodeCodeList = nodeList; publish.PublishType = 0; publish.ListMenu = lstMenu; publish.siteDir = SiteDir; publish.siteID = SiteID; try { publish.Execute(); } catch { Utils.RunJavaScript(this, "alert({msg:'HTML页生成失败!你可以到“内容发布”栏目中重新发布本栏目',title:'提示信息'})"); } } }