Example #1
0
        /// <summary>
        /// 更改工作台位置信息
        /// </summary>
        /// <param name="position"></param>
        protected void UpdatePosition(string position)
        {
            string strMessage = "";

            //先判断是不是超级用户
            if (userID == "0")
            {
                try
                {
                    string xml = Server.MapPath("~/SysAdmin/Configuraion/adminLoginInfo.config");
                    Utils.XmlUpdate(xml, "/root/Position", "", position);
                    strMessage = "1";
                }
                catch (Exception exp)
                {
                    strMessage = exp.ToString();
                }
            }
            else
            {
                KingTop.Model.SysManage.AccountSite modelAccountSite = new KingTop.Model.SysManage.AccountSite();
                AccountSite bllAccountSite = new AccountSite();
                modelAccountSite.UserID    = int.Parse(userID);
                modelAccountSite.LoginDate = DateTime.Now; //无实际作用
                modelAccountSite.SiteID    = SiteID;
                modelAccountSite.PoSition  = position;
                strMessage = bllAccountSite.Save("UPDATEPOSITION", modelAccountSite);
            }
            WriteLog(GetLogValue("", "EDIT", "WorkStation", true), "", 2);
        }
Example #2
0
        /// <summary>
        /// 获取用户登陆信息
        /// </summary>
        protected void GetLoginInfo()
        {
            if (userID == "0")
            {
                //admin
                string xml = Server.MapPath("~/SysAdmin/Configuraion/adminLoginInfo.config");
                strLastLoginDate = Utils.XmlRead(xml, "/root/LastLoginDate", "");
                strLastLoginIP   = Utils.XmlRead(xml, "/root/LastLoginIp", "");
                strLoginCount    = Utils.XmlRead(xml, "/root/LoginCount", "");
            }
            else
            {
                AccountSite bllAccountSite = new AccountSite();
                DataTable   dt             = bllAccountSite.GetList("USERID", Utils.getTwoParams(userID, SiteID.ToString()));
                if (dt.Rows.Count > 0)
                {
                    strLastLoginDate = dt.Rows[0]["LastLoginDate"].ToString();
                    strLastLoginIP   = dt.Rows[0]["LastLoginIP"].ToString();
                    strLoginCount    = dt.Rows[0]["LoginCount"].ToString();
                }
            }
            List <string> dbInfo = new Top().GetDataBaseInfo();

            DataBaseVersion = dbInfo[0];
            DataBaseSize    = dbInfo[1];
            LogSize         = dbInfo[2];
        }
Example #3
0
 //更新登录信息
 protected void UpdateLoginInfo(int UserID, int SiteID)
 {
     if (SiteID != 0)
     {
         //admin登陆
         if (UserID == 0)
         {
             string xml = Server.MapPath("~/sysadmin/Configuraion/adminLoginInfo.config");
             //更新上次登陆信息
             string strLoginDate = Utils.XmlRead(xml, "/root/LoginDate", "");
             string strLoginIp   = Utils.XmlRead(xml, "/root/Ip", "");
             Utils.XmlUpdate(xml, "/root/LastLoginDate", "", strLoginDate);
             Utils.XmlUpdate(xml, "/root/LastLoginIp", "", strLoginIp);
             //更新本次登陆信息
             Utils.XmlUpdate(xml, "/root/LoginDate", "", DateTime.Now.ToString());
             Utils.XmlUpdate(xml, "/root/Ip", "", Utils.GetIP());
             int intLoginCount = Utils.ParseInt(Utils.XmlRead(xml, "/root/LoginCount", ""), 0) + 1;
             Utils.XmlUpdate(xml, "/root/LoginCount", "", intLoginCount.ToString());
         }
         else
         {
             AccountSite modelAccountSite = new AccountSite();
             KingTop.BLL.SysManage.AccountSite bllAccountSite = new KingTop.BLL.SysManage.AccountSite();
             modelAccountSite.UserID    = UserID;
             modelAccountSite.SiteID    = SiteID;
             modelAccountSite.IP        = Utils.GetIP();
             modelAccountSite.LoginDate = DateTime.Now;
             bllAccountSite.Save("UpdateLoginInfo", modelAccountSite);
         }
     }
 }
        public static string CheckName(string UserName, string SiteID)
        {
            string strResult = string.Empty;

            KingTop.BLL.SysManage.AccountSite objAccountSite = new AccountSite();
            DataTable dt = objAccountSite.GetList("ISHAVESITE", Utils.getTwoParams(UserName, SiteID));

            if (dt.Rows.Count > 0)
            {
                strResult = "1";
            }
            else
            {
                strResult = isExist(UserName) ? "2" : "3";
            }
            return(strResult);
        }
Example #5
0
        /// <summary>
        /// 获取工作台的位置信息
        /// </summary>
        /// <returns></returns>
        protected string GetPosition()
        {
            string position = "";

            //先判断是不是超级用户
            if (userID == "0")
            {
                string xml = Server.MapPath("~/SysAdmin/Configuraion/adminLoginInfo.config");
                position = Utils.XmlRead(xml, "/root/Position", "");
            }
            else
            {
                AccountSite bllAccountSite = new AccountSite();
                DataTable   dt             = bllAccountSite.GetList("USERID", Utils.getTwoParams(userID, SiteID.ToString()));
                //数据库若没位置信息,则默认为"c1:1@2@3|c2:4@5@6"
                position = (dt.Rows.Count > 0 && dt.Rows[0]["POSITION"].ToString().Trim() != "") ? dt.Rows[0]["POSITION"].ToString() : "c1:1@3@5@7@|c2:2@4@6@8@|";
            }

            return(position);
        }
Example #6
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);
            }
        }
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            if (this.ddlUserGroup.SelectedValue == "0")
            {
                Utils.RunJavaScript(this, "alert({msg:'请选择所属用户组!',title:'提示信息'})");
                return;
            }
            KingTop.BLL.SysManage.UserRole      bllUserRole  = new UserRole();
            KingTop.Model.SysManage.UserRole    modeUserRole = new KingTop.Model.SysManage.UserRole();
            KingTop.Model.SysManage.AccountSite ModeSite     = new KingTop.Model.SysManage.AccountSite();
            string returnMsg = "";

            //把页面的值传给账户属性

            MAccount.Orders  = Convert.ToInt32(this.txtAccountOrder.Text);
            MAccount.IsValid = Utils.ParseBool(RBL_IsValid.SelectedValue);

            //根据ID得到用户信息
            DataTable DTAccount = BllAccount.GetList("ONE", Utils.getOneParams(this.UserID));

            if (this.Action == "EDIT")
            {
                #region 修改用户信息
                //判断是否有权限

                if (IsHaveRightByOperCode("Edit"))
                {
                    //得到传过来的userid
                    MAccount.UserID = Convert.ToInt32(this.UserID);
                    //编辑用户
                    returnMsg = BllAccount.Save("EDIT", MAccount);
                    if (Utils.ParseInt(returnMsg, 0) > 0)
                    {
                        //修改该账号用户组
                        modeUserRole.UserId        = UserID;
                        modeUserRole.UserGroupCode = new Guid(ddlUserGroup.SelectedValue.ToString());
                        modeUserRole.ExtentValue   = this.hdUserGropOld.Value.ToString();
                        bllUserRole.Save("EDIT", modeUserRole);
                        Utils.RunJavaScript(this, "type=1;userName='******'", "\\'") + "';userid=" + UserID + ";");
                        WriteLog("帐户" + txtAccountName.Value + "编辑成功!", "", 2);
                    }
                    else
                    {
                        Utils.RunJavaScript(this, "type=2;errmsg=" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + ";");
                        WriteLog("帐户" + txtAccountName.Value + "编辑失败!", returnMsg, 2);
                    }
                }
                else
                {
                    Utils.RunJavaScript(this, "alert({msg:'你没有编辑用户的权限,请联系站点管理员!',title:'提示信息'})");
                }
                #endregion
            }
            if (this.Action == "NEW")
            {
                #region 新增用户信息
                string accountName = txtAccountName.Value;
                string admin       = ConfigurationManager.AppSettings[SystemConst.CONFIG_SUPERUSER];
                if (admin != null && admin.Equals(accountName))
                {
                    Utils.RunJavaScript(this, "type=2;userName='******'", "\\'") + "';errmsg='该用户已存在,请填写其他用户名'");
                    return;
                }
                MAccount.UserName = accountName;
                MAccount.PassWord = SecurityHelper.MD5(txtAccountPwd.Text).ToString();
                if (IsHaveRightByOperCode("New"))
                {
                    try
                    {
                        if (KingTop.Common.AppCache.IsExist("UserID"))
                        {
                            UserID = (string)KingTop.Common.AppCache.Get("UserID");
                        }
                        if (!isExist(MAccount.UserName))
                        {
                            //如果用户表里不存在该用户,向用户表添加记录

                            UserID = BllAccount.Save("NEW", MAccount).ToString();
                        }

                        //为该用户加入当前站点
                        AccountSite objAccSite = new AccountSite();

                        ModeSite.UserID    = Utils.ParseInt(UserID, 1);
                        ModeSite.SiteID    = SiteID;
                        ModeSite.IsValid   = true;
                        ModeSite.LoginDate = DateTime.Now;
                        ModeSite.IP        = Utils.GetIP();
                        objAccSite.Save("NEW", ModeSite);
                        //为该用户加入用户组


                        modeUserRole.UserGroupCode = new Guid(ddlUserGroup.SelectedValue.ToString());
                        modeUserRole.UserId        = UserID;
                        returnMsg = bllUserRole.Save("NEW", modeUserRole);
                        if (Utils.ParseInt(returnMsg, 0) > 0)
                        {
                            //Utils.RunJavaScript(this, "alert({msg:'新增用户成功!',title:'提示信息'})");
                            WriteLog("新增" + txtAccountName.Value + "用户成功!", "", 2);
                            Utils.RunJavaScript(this, "type=0;userName='******'", "\\'") + "';userid=" + UserID + ";");
                        }
                    }
                    catch
                    {
                        //Utils.RunJavaScript(this, "alert({msg:" + returnMsg + ",title:'提示信息'})");
                        Utils.RunJavaScript(this, "type=2;userName='******'", "\\'") + "';errmsg='" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + "'");
                        WriteLog("新增" + txtAccountName.Value + "用户失败!", returnMsg, 2);
                    }
                }
                else
                {
                    Utils.RunJavaScript(this, "alert({msg:'你没有新增用户的权限,请联系站点管理员!',title:'提示信息'})");
                }
                #endregion
            }
        }