Beispiel #1
0
        /// <summary>
        /// 进行登陆操作
        /// </summary>
        /// <param name="sLoginName">用户名</param>
        /// <param name="sLoginPass">密码</param>
        /// <param name="sCode_op">验证码</param>
        /// <param name="UserKey">用户key</param>
        private void LoginUser(string sLoginName, string sLoginPass, string sCode_op, string UserKey)
        {
            MessageBox MBx = new MessageBox();

            MBx.M_Type     = 2;
            MBx.M_Title    = "登陆出错!";
            MBx.M_IconType = Icon_Type.Error;
            MBx.M_Body     = "验证码无效,请确认您输入的验证码有效!";

            if (DispCode && (Session["CheckCode"] == null || sCode_op != Session["CheckCode"].ToString()))
            {
                MBx.M_WriteToDB = false;
                MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮重新输入验证码!", UrlType.Href, true));
            }
            else if (!FrameWorkLogin.CheckDisableLoginUser(UserKey))
            {
                MBx.M_Body = string.Format("当前IP:{0}登陆出错次数({1})超过系统允许,已经禁止登陆.请联系管理员!", Common.GetIPAddress(), FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData.C_LoginErrorMaxNum);
                MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮返回!", UrlType.Href, true));
            }
            else if (new FrameWorkLogin().CheckLogin(sLoginName, sLoginPass, UserKey))
            {
                MBx.M_IconType  = Icon_Type.OK;
                MBx.M_Title     = "登陆成功!";
                MBx.M_Body      = string.Format("欢迎您{0},成功登入。您的IP为:{1}!", sLoginName, Common.GetIPAddress());
                MBx.M_WriteToDB = false;
                MBx.M_ButtonList.Add(new sys_NavigationUrl("确定", "default.aspx", "点击按钮登陆!", UrlType.Href, true));
                FrameWorkLogin.MoveErrorLoginUser(UserKey);
                //写登入日志
                EventMessage.EventWriteDB(2, MBx.M_Body, UserData.Get_sys_UserTable(sLoginName).UserID);
            }
            else
            {
                MBx.M_Body = string.Format("用户名/密码({0}/{1})错误!", sLoginName, sLoginPass);
                MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮重新输入!", UrlType.Href, true));
            }
            Session["CheckCode"] = Common.RndNum(4);
            EventMessage.MessageBox(MBx);
        }
Beispiel #2
0
        /// <summary>
        /// 进行登陆操作
        /// </summary>
        /// <param name="sLoginName">用户名</param>
        /// <param name="sLoginPass">密码</param>
        /// <param name="sCode_op">验证码</param>
        /// <param name="UserKey">用户key</param>
        private void LoginUser(string sLoginName, string sLoginPass, string sCode_op, string UserKey)
        {
            MessageBox MBx = new MessageBox();

            MBx.M_Type     = 2;
            MBx.M_Title    = "登陆出错!";
            MBx.M_IconType = Icon_Type.Error;
            MBx.M_Body     = "验证码无效,请确认您输入的验证码有效!";



            //判断当前MAC是否允许登录
            string flag = ConfigurationManager.AppSettings["LoginValidate"].ToString();

            if (flag == "true")
            {
                //判断是否是超级用户

                if (SuperUser(sLoginName) == "1")
                {
                    if (DispCode && (Session["CheckCode"] == null || sCode_op != Session["CheckCode"].ToString()))
                    {
                        MBx.M_WriteToDB = false;
                        MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮重新输入验证码!", UrlType.Href, true));
                    }
                    else if (!FrameWorkLogin.CheckDisableLoginUser(UserKey))
                    {
                        MBx.M_Body = string.Format("当前IP:{0}登陆出错次数({1})超过系统允许,已经禁止登陆.请联系管理员!", Common.GetIPAddress(), FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData.C_LoginErrorMaxNum);
                        MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮返回!", UrlType.Href, true));
                    }
                    else if (new FrameWorkLogin().CheckLogin(sLoginName, sLoginPass, UserKey))
                    {
                        MBx.M_IconType  = Icon_Type.OK;
                        MBx.M_Title     = "登陆成功!";
                        MBx.M_Body      = string.Format("欢迎您{0},成功登入。您的IP为:{1}!", sLoginName, Common.GetIPAddress());
                        MBx.M_WriteToDB = false;
                        MBx.M_ButtonList.Add(new sys_NavigationUrl("确定", "default.aspx", "点击按钮登陆!", UrlType.Href, true));
                        FrameWorkLogin.MoveErrorLoginUser(UserKey);
                        //写登入日志
                        EventMessage.EventWriteDB(2, MBx.M_Body, UserData.Get_sys_UserTable(sLoginName).UserID);
                    }
                    else
                    {
                        MBx.M_Body = string.Format("用户名/密码({0}/{1})错误!", sLoginName, sLoginPass);
                        MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮重新输入!", UrlType.Href, true));
                    }
                }
                else
                {
                    //获取当前登录人的IP地址
                    string ip = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

                    QueryParam qp = new QueryParam();
                    qp.Where     = " where 1=1 and L_Status=1 and L_MAC='" + ip.Trim() + "' and getdate()>L_StartDate and getdate()<L_EndDate";
                    qp.PageIndex = 1;
                    qp.PageSize  = 1;
                    int RecordCount = 0;
                    List <sys_LoginAuthorizeEntity> lst = BusinessFacadeDLT.sys_LoginAuthorizeList(qp, out RecordCount);
                    if (RecordCount > 0)
                    {
                        if (DispCode && (Session["CheckCode"] == null || sCode_op != Session["CheckCode"].ToString()))
                        {
                            MBx.M_WriteToDB = false;
                            MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮重新输入验证码!", UrlType.Href, true));
                        }
                        else if (!FrameWorkLogin.CheckDisableLoginUser(UserKey))
                        {
                            MBx.M_Body = string.Format("当前IP:{0}登陆出错次数({1})超过系统允许,已经禁止登陆.请联系管理员!", Common.GetIPAddress(), FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData.C_LoginErrorMaxNum);
                            MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮返回!", UrlType.Href, true));
                        }
                        else if (new FrameWorkLogin().CheckLogin(sLoginName, sLoginPass, UserKey))
                        {
                            MBx.M_IconType  = Icon_Type.OK;
                            MBx.M_Title     = "登陆成功!";
                            MBx.M_Body      = string.Format("欢迎您{0},成功登入。您的IP为:{1}!", sLoginName, Common.GetIPAddress());
                            MBx.M_WriteToDB = false;
                            MBx.M_ButtonList.Add(new sys_NavigationUrl("确定", "default.aspx", "点击按钮登陆!", UrlType.Href, true));
                            FrameWorkLogin.MoveErrorLoginUser(UserKey);
                            //写登入日志
                            EventMessage.EventWriteDB(2, MBx.M_Body, UserData.Get_sys_UserTable(sLoginName).UserID);
                        }
                        else
                        {
                            MBx.M_Body = string.Format("用户名/密码({0}/{1})错误!", sLoginName, sLoginPass);
                            MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮重新输入!", UrlType.Href, true));
                        }
                    }
                    else
                    {
                        MBx.M_WriteToDB = false;
                        MBx.M_Body      = string.Format("对不起{0},您的IP为:{1},此IP无授权或授权过期,请申请授权此IP后重新登录!", sLoginName, Common.GetIPAddress());
                        MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "此IP无授权或授权过期,请申请授权此IP后重新登录!", UrlType.Href, true));
                    }
                }
            }
            else
            {
                if (DispCode && (Session["CheckCode"] == null || sCode_op != Session["CheckCode"].ToString()))
                {
                    MBx.M_WriteToDB = false;
                    MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮重新输入验证码!", UrlType.Href, true));
                }
                else if (!FrameWorkLogin.CheckDisableLoginUser(UserKey))
                {
                    MBx.M_Body = string.Format("当前IP:{0}登陆出错次数({1})超过系统允许,已经禁止登陆.请联系管理员!", Common.GetIPAddress(), FrameSystemInfo.GetSystemInfoTable.S_SystemConfigData.C_LoginErrorMaxNum);
                    MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮返回!", UrlType.Href, true));
                }
                else if (new FrameWorkLogin().CheckLogin(sLoginName, sLoginPass, UserKey))
                {
                    MBx.M_IconType  = Icon_Type.OK;
                    MBx.M_Title     = "登陆成功!";
                    MBx.M_Body      = string.Format("欢迎您{0},成功登入。您的IP为:{1}!", sLoginName, Common.GetIPAddress());
                    MBx.M_WriteToDB = false;
                    MBx.M_ButtonList.Add(new sys_NavigationUrl("确定", "default.aspx", "点击按钮登陆!", UrlType.Href, true));
                    FrameWorkLogin.MoveErrorLoginUser(UserKey);
                    //写登入日志
                    EventMessage.EventWriteDB(2, MBx.M_Body, UserData.Get_sys_UserTable(sLoginName).UserID);
                }
                else
                {
                    MBx.M_Body = string.Format("用户名/密码({0}/{1})错误!", sLoginName, sLoginPass);
                    MBx.M_ButtonList.Add(new sys_NavigationUrl("返回", "login.aspx", "点击按钮重新输入!", UrlType.Href, true));
                }
            }
            Session["CheckCode"] = Common.RndNum(4);
            EventMessage.MessageBox(MBx);
        }