コード例 #1
0
        //绑定导航节点编码
        private void BindNodeCode()
        {
            ModuleNode bllModuleNode = new ModuleNode();
            //得到系统站点下所有ParentNode=0的顶级导航列表

            DataTable dt = bllModuleNode.GetList("GETPARENTNODE", Utils.getTwoParams("0", "1"));

            if (dt.Rows.Count > 0)
            {
                this.ddlNodeCode.DataSource     = dt.DefaultView;
                this.ddlNodeCode.DataTextField  = "NodeName";
                this.ddlNodeCode.DataValueField = "NodeCode";
                this.ddlNodeCode.DataBind();
            }
            ListItem ls = new ListItem("请选择", "0");//追加一项

            this.ddlNodeCode.Items.Insert(0, ls);
        }
コード例 #2
0
 private void OnDel()
 {
     if (Request.QueryString["Action"] == "Del")
     {
         string ID = Request.QueryString["NodeID"];
         //判断权限
         if (IsHaveRightByOperCode("Delete"))
         {
             DataTable dt       = BllModuleNode.GetList("ONE", Utils.getOneParams(ID));
             string    nodeName = string.Empty;
             if (dt.Rows.Count > 0)
             {
                 nodeName = dt.Rows[0]["NodeName"].ToString().Replace("'", "\\'");
             }
             string returnMsg = BllModuleNode.ModuleNodeSet("DELONE", "", ID);
             try
             {
                 if (Convert.ToInt32(returnMsg) == -1)
                 {
                     Utils.RunJavaScript(this, "alert({msg:'该栏目包含子栏目,不能直接删除,请先删除其子栏目!',title:'提示信息'})");
                 }
                 else
                 {
                     WriteLog("删除" + nodeName + "节点成功!", "", 2);//写入操作日志
                 }
             }
             catch
             {
                 WriteLog("删除" + nodeName + "节点失败!", returnMsg, 2);//写入操作日志
                 Utils.RunJavaScript(this, "alert({msg:'" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + "',title:'提示信息'})");
             }
         }
         else
         {
             Utils.RunJavaScript(this, "alert({msg:'你没有删除栏目的权限,请联系站点管理员!',title:'提示信息'})");
         }
     }
 }
コード例 #3
0
        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);
            }
        }