//根据ModeNode实体得到插入K_SysModeNode的sql protected string GetInsertModeNodeSql(KingTop.Model.SysManage.ModuleNode mode) { string ReturnSql = string.Empty; ReturnSql = "INSERT INTO K_SysModuleNode("; ReturnSql += "NodeID,NodeCode,NodeName,NodeType,LinkURL,ParentNode,ModuleID,IsValid,"; ReturnSql += "NodelOrder,NodelDesc,NodelEngDesc,NodelIcon,IsSystem,IsWeb,WebSiteID,"; ReturnSql += "ReviewFlowID,IsContainWebContent,IsLeftDisplay)"; ReturnSql += "VALUES('"; ReturnSql += mode.NodeID + "','" + mode.NodeCode + "','" + mode.NodeName + "','" + mode.NodeType + "','" + mode.LinkURL + "','" + mode.ParentNode + "','" + mode.ModuleID + "','" + mode.IsValid + "','"; ReturnSql += mode.NodelOrder + "','" + mode.NodelDesc + "','" + mode.NodelEngDesc + "','" + mode.NodelIcon + "','" + mode.IsSystem + "','" + mode.IsWeb + "','" + mode.WebSiteID + "','"; ReturnSql += mode.ReviewFlowID + "','" + mode.IsContainWebContent + "','" + mode.IsLeftDisplay + "')"; return(ReturnSql); }
/// <summary> /// 增、改K_SysModuleNode表 /// </summary> /// <param name="tranType">操作类型,NEW=增,EDIT=改</param> /// <param name="AutModel"></param> /// <returns>返回大于0的数字操作正常,返回非数字表示操作错误,返回的是系统错误说明</returns> public string Save(string trantype, KingTop.Model.SysManage.ModuleNode ModuleNodeModel) { string re = dal.Save(trantype, ModuleNodeModel); //更新缓存 AppCache.Remove("ModeNodeAndModuleCache"); GetModeNodeFromCache(); AppCache.Remove("PublishNodeCache"); AppCache.Remove("SiteMenuNodeCache"); Publish_GetNodeFromCache(); return(re); }
protected void btnSave_Click(object sender, EventArgs e) { strTemplateID = this.hiddenTemplateID.Value; string returnMsg = string.Empty; string strSiteID = string.Empty; string strUserGropCode = string.Empty; string siteDir = txtDir.Text.ToString().ToLower().Trim(); StringBuilder sbsql = new StringBuilder(); #region 保存站点信息 //得到站点设置 if (Directory.Exists(Server.MapPath("/" + siteDir)) || siteDir == "main") { Utils.RunJavaScript(this, "alert({msg:'保存站点失败:文件夹名称已存在,请重新填写文件夹名称!',title:'提示信息'})"); return; } if (chkIsDomain.Checked && txtSiteURL.Text.Trim() == "") { Utils.RunJavaScript(this, "alert({msg:'保存站点失败:网站域名必须填写!',title:'提示信息'})"); return; } try { //在根目录下建立站点文件夹 Directory.CreateDirectory(Server.MapPath("/" + siteDir)); } catch (Exception ex) { Utils.RunJavaScript(this, "alert({msg:'保存站点失败:" + ex.Message.Replace("'", "\'").Replace("\r\n", "<br>").Replace("\r", "<br>") + "',title:'提示信息'})"); return; } mode.SiteName = Utils.HtmlDecode(txtSiteName.Text.ToString()); mode.Directory = Utils.HtmlDecode(siteDir); mode.IsMainSite = rdoMain.Checked ? true : false; StringBuilder sb = new StringBuilder(); sb.Append("TemlateID=").Append(strTemplateID);//模板ID //if (ddlSiteCode.SelectedValue != "0") //{ // sb.Append("&CharSet=").Append(ddlSiteCode.SelectedValue);//站点编码 //} if (chkIsImportNode.Checked) { sb.Append("&IsImprotNode=").Append("True");//是否导入节点信息 } else { sb.Append("&IsImprotNode=").Append("False"); } //if (chkImportFormStyle.Checked) //{ // sb.Append("&IsImportFormStyle=").Append("True");//是否导入表单样式 //} //else //{ sb.Append("&IsImportFormStyle=").Append("False"); //} if (chkIsDomain.Checked) { mode.SiteUrl = Utils.HtmlDecode(txtSiteURL.Text.ToString()); sb.Append("&IsDomain=").Append("True"); } else { mode.SiteUrl = ""; sb.Append("&IsDomain=").Append("False"); } mode.SettingsXML = sb.ToString(); if (!SetSiteXML(siteDir)) { return; } //保存站点设置 strSiteID = bll.Save("NEW", mode); if (strSiteID.IndexOf("Error") != -1) { Utils.RunJavaScript(this, "alert({msg:'保存站点失败:" + strSiteID.Replace("'", "\'").Replace("\r\n", "<br>").Replace("\r", "<br>").Replace("Error:", "") + "',title:'提示信息'})"); DeleteDir(Server.MapPath("/" + siteDir)); return; } //判断SiteID是否有值 UpdateSiteId(siteDir, strSiteID); int intSiteid = Utils.ParseInt(strSiteID, 0); #endregion #region 新增一个用户组(strSiteID+"站点管理员"),该用户组属于站点管理员角色 KingTop.BLL.SysManage.UserGroup UserGropBll = new UserGroup(); KingTop.Model.SysManage.UserGroup UserGropMode = new KingTop.Model.SysManage.UserGroup(); UserGropMode.UserGroupCode = Guid.NewGuid(); UserGropMode.UserGroupName = strSiteID + "站点管理员"; UserGropMode.SiteID = intSiteid; UserGropMode.IsParent = true; UserGropMode.NumCode = UserGropBll.GetList("GETMAXPNUMCODE", Utils.getOneParams("0")).Tables[0].Rows[0]["MaxCode"].ToString(); UserGropMode.ParentNumCode = "0"; UserGropMode.UserGroupOrder = 0; UserGropMode.InputDate = System.DateTime.Now; try { UserGropBll.Save("new", UserGropMode); } catch { } strUserGropCode = UserGropMode.UserGroupCode.ToString(); #endregion #region 导入栏目节点设置 导入用户组权限 //根据strTemplateID得到该模板下所有栏目 KingTop.BLL.SysManage.WebSiteTemplateNode bllTmpNode = new WebSiteTemplateNode(); KingTop.Model.SysManage.WebSiteTemplateNode modeTmpNode = new KingTop.Model.SysManage.WebSiteTemplateNode(); KingTop.BLL.SysManage.ModuleNode bllModeNode = new ModuleNode(); KingTop.Model.SysManage.ModuleNode modeNode = new KingTop.Model.SysManage.ModuleNode(); DataTable dtTmpNode = bllTmpNode.GetList("WEBSITE", Utils.getOneParams(strTemplateID)); if (dtTmpNode.Rows.Count > 0) { //当前ModelNode的最大NodeCode string strMaxNodeCode = string.Empty; //MaxNodeCode和100的差量 int intSubNodeCode = 0; DataTable dtNodeCode = bllModeNode.GetList("MAXCODE", Utils.getOneParams("0")); if (dtNodeCode != null && dtNodeCode.Rows.Count == 1) { strMaxNodeCode = dtNodeCode.Rows[0]["NodeCode"].ToString(); } try { intSubNodeCode = Convert.ToInt32(strMaxNodeCode) - 100 + 1; } catch { throw new Exception("获取当前最大节点数失败!"); } foreach (DataRow dr in dtTmpNode.Rows) { modeNode.WebSiteID = intSiteid; modeNode.NodeID = Guid.NewGuid(); modeNode.NodeCode = dr["NodeCode"].ToString(); modeNode.NodeName = dr["NodeName"].ToString(); modeNode.NodeType = dr["NodeType"].ToString(); modeNode.LinkURL = dr["LinkURL"].ToString(); modeNode.ParentNode = dr["ParentNode"].ToString(); modeNode.IsValid = Utils.ParseBool(dr["IsValid"].ToString()); modeNode.ModuleID = new Guid(dr["ModuleID"].ToString()); modeNode.NodelOrder = dr["NodelOrder"].ToString(); modeNode.NodelDesc = dr["NodelDesc"].ToString(); modeNode.NodelEngDesc = dr["NodelEngDesc"].ToString(); modeNode.IsSystem = Utils.ParseBool(dr["IsSystem"].ToString()); modeNode.IsWeb = Utils.ParseBool(dr["IsWeb"].ToString()); modeNode.ReviewFlowID = dr["ReviewFlowID"].ToString(); modeNode.IsContainWebContent = Utils.ParseBool(dr["IsContainWebContent"].ToString()); modeNode.IsLeftDisplay = Utils.ParseBool(dr["IsLeftDisplay"].ToString()); //NodeCode唯一 if (modeNode.NodeCode.Length > 3) { modeNode.NodeCode = (Utils.ParseInt(modeNode.NodeCode.Substring(0, 3), 0) + intSubNodeCode).ToString() + modeNode.NodeCode.Substring(3, modeNode.NodeCode.Length - 3); } else { modeNode.NodeCode = (Utils.ParseInt(modeNode.NodeCode.Substring(0, 3), 0) + intSubNodeCode).ToString(); } if (modeNode.ParentNode != "0") { if (modeNode.ParentNode.Length > 3) { modeNode.ParentNode = (Utils.ParseInt(modeNode.ParentNode.Substring(0, 3), 0) + intSubNodeCode).ToString() + modeNode.ParentNode.Substring(3, modeNode.ParentNode.Length - 3); } else { modeNode.ParentNode = (Utils.ParseInt(modeNode.ParentNode.Substring(0, 3), 0) + intSubNodeCode).ToString(); } } //插入ModeNode表sql sbsql.Append(GetInsertModeNodeSql(modeNode)); //得到插入用户组权限表的sql(根据modeNode.NodeID) sbsql.Append(GetInsertUserGroupPermitSql(strUserGropCode, dr["ID"].ToString(), modeNode.NodeID.ToString())); } } //执行生成的sql try { SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction, CommandType.Text, sbsql.ToString()); } catch (System.Exception exp) { throw new Exception(exp.Message); } #endregion #region 最后把生成的站点赋给当前账户 //admin拥有所有站点的所有权限,不用新增数据 if (GetLoginAccountId().ToString() != "0") { KingTop.BLL.SysManage.AccountSite AccountSiteBll = new AccountSite(); KingTop.Model.SysManage.AccountSite AccountSiteModel = new KingTop.Model.SysManage.AccountSite(); AccountSiteModel.UserID = Utils.ParseInt(base.GetLoginAccountId().ToString(), 0); AccountSiteModel.SiteID = intSiteid; AccountSiteModel.IsValid = true; try { AccountSiteBll.Save("new", AccountSiteModel); } catch (System.Exception exp) { throw new Exception(exp.Message); } } #endregion #region 最后把用户填的账户插入账户表并把生成的用户组赋给该账户(这里直接给当前登陆账户赋该网站管理员用户组) //admin拥有所有站点的所有权限,不用新增数据 if (GetLoginAccountId().ToString() != "0") { KingTop.BLL.SysManage.UserRole UserRoleBll = new UserRole(); KingTop.Model.SysManage.UserRole UserRoleModel = new KingTop.Model.SysManage.UserRole(); UserRoleModel.UserGroupCode = new Guid(strUserGropCode); UserRoleModel.UserId = base.GetLoginAccountId(); try { UserRoleBll.Save("new", UserRoleModel); } catch (System.Exception exp) { throw new Exception(exp.Message); } } //更新栏目缓存 AppCache.Remove("ModeNodeAndModuleCache"); ModuleNode objmodulenode = new ModuleNode(); objmodulenode.GetModeNodeFromCache(); AppCache.Remove("PublishNodeCache"); objmodulenode.Publish_GetNodeFromCache(); #region 创建一个系统默认的方案 //创建默认方案 bllProject.CreateDefaultProject(mode.Directory, NodeCode, modeNode.WebSiteID); #endregion #endregion #region 导入栏目 string[] parSite = ddlSiteTemplate.SelectedValue.Split('|'); returnMsg = InsertSiteMenu(parSite[0], intSiteid.ToString(), siteDir, parSite[1]); #endregion #region 制文件 bool IsMenu = false; if (string.IsNullOrEmpty(returnMsg)) { IsMenu = true; returnMsg = CopySiteFile(Server.MapPath("/" + parSite[1]), Server.MapPath("/" + siteDir), parSite[1], siteDir); } else { returnMsg += "<br>" + CopySiteFile(Server.MapPath("/" + parSite[1]), Server.MapPath("/" + siteDir), parSite[1], siteDir); } #endregion if (chkIsImportNode.Checked && IsMenu) { Response.Redirect("NewWebSetMenuEdit.aspx?NodeCode=" + NodeCode + "&parentNodeCode=" + RootNodeCode); } else { Utils.RunJavaScript(this, "alert({msg:'" + returnMsg + "',title:'提示信息'});NewSiteName='" + mode.SiteName.Replace("'", "\\'") + "';NewSiteID=" + modeNode.WebSiteID); } }
/// <summary> /// 增、改K_SysModuleNode表 /// </summary> /// <param Name="tranType">操作类型,NEW=增,EDIT=改</param> /// <param Name="paramsModel"></param> /// <returns>返回大于0的数字操作正常,返回非数字表示操作错误,返回的是系统错误说明</returns> public string Save(string tranType, KingTop.Model.SysManage.ModuleNode paramsModel) { string isOk = ""; try { SqlParameter returnValue = new SqlParameter("@ReturnValue", SqlDbType.Int, 4); returnValue.Direction = ParameterDirection.Output; string cmdText = "proc_K_SysModuleNodeSave"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("tranType", tranType), new SqlParameter("NodeID", paramsModel.NodeID), new SqlParameter("NodeCode", paramsModel.NodeCode), new SqlParameter("NodeName", paramsModel.NodeName), new SqlParameter("NodeType", paramsModel.NodeType), new SqlParameter("LinkURL", paramsModel.LinkURL), new SqlParameter("ParentNode", paramsModel.ParentNode), new SqlParameter("ModuleID", paramsModel.ModuleID), new SqlParameter("IsLeftDisplay", paramsModel.IsLeftDisplay), new SqlParameter("IsValid", paramsModel.IsValid), new SqlParameter("NodelOrder", paramsModel.NodelOrder), new SqlParameter("NodelDesc", paramsModel.NodelDesc), new SqlParameter("NodelEngDesc", paramsModel.NodelEngDesc), new SqlParameter("NodelIcon", paramsModel.NodelIcon), new SqlParameter("MouseOverImg", paramsModel.MouseOverImg), new SqlParameter("CurrentImg", paramsModel.CurrentImg), new SqlParameter("IsSystem", paramsModel.IsSystem), new SqlParameter("IsWeb", paramsModel.IsWeb), new SqlParameter("WebSiteID", paramsModel.WebSiteID), new SqlParameter("NodeDir", paramsModel.NodeDir), new SqlParameter("Tips", paramsModel.Tips), new SqlParameter("Meta_Keywords", paramsModel.Meta_Keywords), new SqlParameter("Meta_Description", paramsModel.Meta_Description), new SqlParameter("PageTitle", paramsModel.PageTitle), new SqlParameter("Custom_Content", paramsModel.Custom_Content), new SqlParameter("DefaultTemplate", paramsModel.DefaultTemplate), new SqlParameter("ListPageTemplate", paramsModel.ListPageTemplate), new SqlParameter("ContentTemplate", paramsModel.ContentTemplate), new SqlParameter("EnableSubDomain", paramsModel.EnableSubDomain), new SqlParameter("SubDomain", paramsModel.SubDomain), new SqlParameter("Settings", paramsModel.Settings), new SqlParameter("Creater", paramsModel.Creater), new SqlParameter("CreateDate", paramsModel.CreateDate), new SqlParameter("ReviewFlowID", paramsModel.ReviewFlowID), new SqlParameter("OpenType", paramsModel.OpenType), new SqlParameter("PurviewType", paramsModel.PurviewType), new SqlParameter("IsEnableComment", paramsModel.IsEnableComment), new SqlParameter("IsCreateListPage", paramsModel.IsCreateListPage), new SqlParameter("IncrementalUpdatePages", paramsModel.IncrementalUpdatePages), new SqlParameter("IsEnableIndexCache", paramsModel.IsEnableIndexCache), new SqlParameter("ListPageSavePathType", paramsModel.ListPageSavePathType), new SqlParameter("ListPagePostFix", paramsModel.ListPagePostFix), new SqlParameter("IsCreateContentPage", paramsModel.IsCreateContentPage), new SqlParameter("ContentPageHtmlRule", paramsModel.ContentPageHtmlRule), new SqlParameter("AutoCreateHtmlType", paramsModel.AutoCreateHtmlType), new SqlParameter("Custom_Images", paramsModel.Custom_Images), new SqlParameter("IsContainWebContent", paramsModel.IsContainWebContent), new SqlParameter("ColumnType", paramsModel.ColumnType), new SqlParameter("CustomManageLink", paramsModel.CustomManageLink), new SqlParameter("Banner", paramsModel.Banner), new SqlParameter("IsTopMenuShow", paramsModel.IsTopMenuShow), new SqlParameter("IsLeftMenuShow", paramsModel.IsLeftMenuShow), returnValue }; SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, cmdText, paras); isOk = returnValue.Value.ToString(); } catch (Exception ex) { isOk = ex.Message; } return(isOk); }