示例#1
0
        /// <summary>
        /// 实例化用户类并获取用户信息
        /// </summary>
        public LoginAgentUser(System.Web.HttpContext context, string moduleCode)
        {
            try
            {
                LoginAgentUser user = (LoginAgentUser)context.Session["clientUser"];
                this.userId  = user.userId;
                this.roleIds = user.roleIds;
                string roleTypeById = new  TSAgentRoleDAO().Get(user.roleIds).type;
                this.roleType = roleTypeById;
                if (roleTypeById == "0")//代理商
                {
                    this.userName  = new  TBAgentDAO().Get(user.userId).agentName;
                    this.agentId   = user.userId;
                    this.agentName = userName;
                    this.siteId    = "无";
                    this.siteName  = "无";
                }
                else //员工
                {
                    TBStaff tbStaff = new TBStaffDAO().Get(user.userId);
                    this.userName = tbStaff.staffName;
                    this.siteId   = tbStaff.siteId;
                    TBSite tbSite = new TBSiteDAO().Get(tbStaff.siteId);
                    this.siteName  = tbSite.siteName;
                    this.agentId   = tbSite.agentId;
                    this.agentName = new TBAgentDAO().Get(tbSite.agentId).agentName;
                }
                this.moduleRight = user.moduleRight;
            }
            catch
            {
                Message.right(context, "登录已过期,请重新登录");
                this.pass = false;
                return;
            }

            if (this.userId == null)
            {
                Message.right(context, "登录已过期,请重新登录");
                this.pass = false;
                return;
            }
            else if (moduleCode != null && !moduleCode.Equals(""))
            {
                if (this.moduleRight.ContainsKey(moduleCode))
                {
                    this.moduleName = (string)this.moduleRight[moduleCode];
                }
                else
                {
                    Message.right(context, "对不起,您无此模块使用权限");
                    this.pass = false;
                    return;
                }
            }
            else
            {
                this.moduleName = "系统主界面";
            }
            this.pass = true;
        }
示例#2
0
        ///<summary>
        ///登录系统
        ///</summary>
        /// <param name="context">HTTP请求上下文</param>
        /// <param name="userCode">用户名称</param>
        /// <param name="userPwd">用户密码</param>
        public void Login(System.Web.HttpContext context, string userCode, string userPwd)
        {
            //获取用户信息
            List <TSAgentUser> tsAgentUserList = new TSAgentUserDAO().GetList("userCode", userCode);

            if (tsAgentUserList.Count != 1)
            {
                Message.error(context, "帐号错误");
                return;
            }

            TSAgentUser tsAgentUser = tsAgentUserList[0];

            if (!tsAgentUser.userPwd.Equals(Encrypt.ConvertPwd(tsAgentUser.userId, userPwd)))
            {
                Message.error(context, "密码错误");
                return;
            }
            //获取代理商和执法文书类型信息
            string roleType = new TSAgentRoleDAO().Get(tsAgentUser.roleId).type;

            if (roleType == "0")
            {
                TBAgent tbAgent = new TBAgentDAO().Get(tsAgentUser.userId);
                if (tbAgent.auditStatus != ((int)AuditStauts.AuditSucces).ToString())
                {
                    Message.error(context, "代理商未审核或审核失败");
                    return;
                }
                if (!tbAgent.status.Equals("1"))
                {
                    Message.error(context, "代理商停用");
                    return;
                }
            }
            else
            {
                TBStaff tbStaff = new TBStaffDAO().Get(tsAgentUser.userId);
                TBAgent tbAgent = new TBAgentDAO().Get(tbStaff.agentId);
                if (tbAgent.auditStatus != ((int)AuditStauts.AuditSucces).ToString())
                {
                    Message.error(context, "代理商未审核或审核失败");
                    return;
                }
                if (!tbAgent.status.Equals("1"))
                {
                    Message.error(context, "代理商停用");
                    return;
                }
                TBSite tbSite = new TBSiteDAO().Get(tbStaff.siteId);
                if (tbSite.auditStatus != ((int)AuditStauts.AuditSucces).ToString())
                {
                    Message.error(context, "执法文书类型未审核或审核失败");
                    return;
                }
                if (!tbSite.status.Equals("1"))
                {
                    Message.error(context, "执法文书类型停用");
                    return;
                }
            }

            //设置登录信息
            this.userId  = tsAgentUser.userId;
            this.roleIds = tsAgentUser.roleId;
            if (roleType == "0")//代理商
            {
                this.userName = new TBAgentDAO().Get(tsAgentUser.userId).agentName;
            }
            else //员工
            {
                this.userName = new TBStaffDAO().Get(tsAgentUser.userId).staffName;
            }
            //会话保存登录用户信息
            context.Session["clientUser"] = this;
            Message.success(context, "success");//成功返回
        }