コード例 #1
0
        public Dictionary <string, object> Login(BaseUser model)
        {
            string         Msg       = "";
            IPScanerHelper objScan   = new IPScanerHelper();
            string         IPAddress = NetHelper.GetIPAddress();

            objScan.IP       = IPAddress;
            objScan.DataPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Resource/IPScaner/QQWry.Dat");
            string   IPAddressName = objScan.IPLocation();
            int      msg           = 0;
            BaseUser base_user     = UserBll.UserLogin(model.Account, model.UserPassword, out msg);

            switch (msg)
            {
            case 0:
                Msg = "账号不存在";
                SysLogBll.WriteLog(model.Account, OperationType.Login, LogSatus.fail, "账号不存在、IP所在城市" + IPAddressName);
                break;

            case 1:
                RoleBll RoleBll = new RoleBll();
                Role    role    = RoleBll.GetModelByUserId(base_user.UserId);

                IManageUser mangeuser = new IManageUser();
                mangeuser.UserId        = base_user.UserId;
                mangeuser.Account       = base_user.Account;
                mangeuser.IPAddress     = IPAddress;
                mangeuser.IPAddressName = IPAddressName;
                if (role != null)
                {
                    mangeuser.RoleName = role.RoleName;
                    mangeuser.RoleId   = role.RoleId;
                }
                else
                {
                    mangeuser.RoleName = "";
                    mangeuser.RoleId   = 0;
                }
                ManageProvider.Provider.AddCurrent(mangeuser);
                SysLogBll.WriteLog(model.Account, OperationType.Login, LogSatus.Success, "登陆成功、IP所在城市" + IPAddressName);
                break;

            case 2:
                Msg = "账户锁定";
                SysLogBll.WriteLog(model.Account, OperationType.Login, LogSatus.fail, "账户锁定、IP所在城市" + IPAddressName);
                break;

            case 3:
                Msg = "密码错误";
                SysLogBll.WriteLog(model.Account, OperationType.Login, LogSatus.fail, "密码错误、IP所在城市" + IPAddressName);
                break;
            }

            return(new Dictionary <string, object>
            {
                { "code", msg },
                { "msg", Msg }
            });
        }
コード例 #2
0
        /// <summary>
        /// 密码登录
        /// </summary>
        /// <param name="context"></param>
        private void PwdLogin(HttpContext context)
        {
            RM_UserInfo_IDAO user_idao    = new RM_UserInfo_Dal();
            RM_System_IDAO   sys_idao     = new RM_System_Dal();
            IPScanerHelper   objScan      = new IPScanerHelper();
            string           user_Account = context.Request["user_Account"]; //账户
            string           userPwd      = context.Request["userPwd"];      //密码
            string           jizhu        = context.Request["jizhu"];
            DataTable        dtlogin      = user_idao.UserLogin(user_Account.Trim(), userPwd.Trim());

            if (dtlogin != null)
            {
                objScan.DataPath = context.Server.MapPath("/Themes/IPScaner/QQWry.Dat");
                objScan.IP       = RequestHelper.GetIP();
                string OWNER_address = objScan.IPLocation();
                if (dtlogin.Rows.Count != 0)
                {
                    string AdminHotelid = dtlogin.Rows[0]["AdminHotelid"].ToString();
                    LoginInfo(context, dtlogin, OWNER_address);

                    #region ** 记住密码cookie **
                    HttpCookie cookie = context.Request.Cookies["USER_COOKIE"];
                    if (cookie == null)
                    {
                        cookie = new HttpCookie("USER_COOKIE");
                    }
                    cookie.Values.Clear();
                    cookie.Expires = DateTime.Now.AddDays(30);
                    if (jizhu == "1")
                    {
                        cookie.Values.Add("UserName", user_Account);
                        cookie.Values.Add("PassWord", userPwd);
                        cookie.Values.Add("DLAdminHotelid", AdminHotelid);
                        context.Response.AppendCookie(cookie);
                    }
                    else
                    {
                        TimeSpan ts = new TimeSpan(-1, 0, 0, 0);
                        cookie.Expires = DateTime.Now.Add(ts);//删除整个Cookie,只要把过期时间设置为现在
                        context.Response.AppendCookie(cookie);
                    }
                    #endregion

                    context.Response.Write("3");//验证成功
                    return;
                }
                else
                {
                    user_idao.SysLoginLog(1, 1, user_Account, "0", OWNER_address, "", "");
                    context.Response.Write("4");//账户或者密码有错误!
                    return;
                }
            }
            else
            {
                context.Response.Write("5");//服务连接不上!
            }
        }
コード例 #3
0
ファイル: SyncWhois.cs プロジェクト: mukeshrebari/MVC5Ext
        public void CheckWhois()
        {
            try
            {
                IPScanerHelper ipModel = new IPScanerHelper();
                string         localIp = ConfigHelper.AppSettings("IP");
                string         currIp  = ipModel.IPLocation(); //System.Web.HttpContext.Current.Request.UserHostAddress;// Request.ServerVariables["LOCAl_ADDR"];
                string         text    = string.Format("time:{0},localHost:{1},currIP:{1}", DateTime.Now, localIp, currIp);

                if (localIp != currIp)
                {
                    UpWhois(currIp);
                    ConfigHelper.SetValue("IP", currIp);
                }
            }
            catch (Exception ex)
            {
                log.Debug("this is not !", ex);
            }
        }
コード例 #4
0
        /// <summary>
        /// 手机 验证码登录
        /// </summary>
        /// <param name="context"></param>
        private void CodeLogin(HttpContext context)
        {
            RM_UserInfo_IDAO user_idao = new RM_UserInfo_Dal();
            RM_System_IDAO   sys_idao  = new RM_System_Dal();
            IPScanerHelper   objScan   = new IPScanerHelper();
            string           phone     = context.Request["phone"]; //账户
            string           code      = context.Request["code"];  //验证码

            StringBuilder sql_code = new StringBuilder();

            sql_code.Append("SELECT TOP 1 Code FROM SendRecord WHERE PhoneSubmit = @Phone AND Code = @Code AND CreateTime > DATEADD(mi,-5,GETDATE())");
            SqlParam[] param_code = new SqlParam[] {
                new SqlParam("@Phone", phone),
                new SqlParam("@Code", code)
            };
            DataTable dt_code = DataFactory.SqlDataBase().GetDataTableBySQL(sql_code, param_code);

            if (dt_code != null && dt_code.Rows.Count > 0)
            {
                DataTable dtlogin = user_idao.PhoneLogin(phone.Trim());
                if (dtlogin != null && dtlogin.Rows.Count > 0)
                {
                    objScan.DataPath = context.Server.MapPath("/Themes/IPScaner/QQWry.Dat");
                    objScan.IP       = RequestHelper.GetIP();
                    string OWNER_address = objScan.IPLocation();
                    LoginInfo(context, dtlogin, OWNER_address);
                    context.Response.Write("1");//验证成功
                    return;
                }
                else
                {
                    context.Response.Write("10012");//手机号不存在!
                }
            }
            else
            {
                context.Response.Write("10011");//验证码错误或超时!
            }
        }
コード例 #5
0
        public void login(HttpContext context)
        {
            string user_Account = context.Request["user_Account"]; //账户
            string userPwd      = context.Request["userPwd"];      //密码
            string jizhu        = context.Request["jizhu"];        //是否记住密码
            string fhz          = "5";
            string sql          = string.Format(@"SELECT User_Account,User_Pwd,User_Name,User_ID FROM dbo.Agent_UserInfo WHERE IsDelete=1 and User_Account=@User_Account and  User_Pwd=@User_Pwd");

            SqlParam[] pamm = new SqlParam[] {
                new SqlParam("@User_Account", user_Account),
                new SqlParam("@User_Pwd", Md5Helper.MD5(userPwd, 32))
            };
            DataTable ds = DataFactory.SqlDataBase().GetDataTableBySQL(new StringBuilder(sql), pamm);

            if (ds != null)
            {
                if (ds.Rows.Count > 0)
                {
                    //RequestSession.ClearAllSession();
                    IPScanerHelper objScan = new IPScanerHelper();
                    objScan.DataPath = context.Server.MapPath("/Themes/IPScaner/QQWry.Dat");
                    objScan.IP       = RequestHelper.GetIP();
                    Hashtable hs = new Hashtable();
                    hs["SYS_LOGINLOG_IP"]     = RequestHelper.GetIP();
                    hs["SYS_LOGINLOG_TIME"]   = DateTime.Now;
                    hs["User_Account"]        = user_Account;
                    hs["SYS_LOGINLOG_STATUS"] = 1;
                    hs["OWNER_address"]       = objScan.IPLocation();
                    hs["Base_UserInfo_ID"]    = ds.Rows[0]["User_ID"].ToString();
                    DataFactory.SqlDataBase().InsertByHashtable("Agent_SysLoginlog", hs);

                    HttpCookie cookie = new HttpCookie("agent_cookie");
                    cookie.Expires = DateTime.Now.AddDays(30);
                    if (jizhu == "1")
                    {
                        cookie.Values.Add("UserName", user_Account);
                        cookie.Values.Add("PassWord", userPwd);
                        context.Response.AppendCookie(cookie);
                    }
                    else
                    {
                        cookie.Values.Clear();
                    }

                    HttpCookie cookies = new HttpCookie("dlagent_COOKIE");
                    cookies.Expires = DateTime.Now.AddDays(1);
                    cookies.Values.Add("User_ID", ds.Rows[0]["User_ID"].ToString());
                    cookies.Values.Add("User_Account", user_Account);
                    cookies.Values.Add("User_Name", ds.Rows[0]["User_Name"].ToString());
                    cookies.Values.Add("User_Pwd", ds.Rows[0]["User_Pwd"].ToString());
                    context.Response.AppendCookie(cookies);
                    fhz = "3";
                }
                else
                {
                    fhz = "4";//账户或者密码有错误!
                }
            }
            else
            {
                fhz = "5";
            }

            context.Response.Write(fhz);//服务连接不上!
        }
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType     = "text/plain";
            context.Response.Buffer          = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1.0);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";
            string           Action       = context.Request["action"];
            string           user_Account = context.Request["user_Account"];
            string           userPwd      = context.Request["userPwd"];
            string           code         = context.Request["code"];
            RM_UserInfo_IDAO user_idao    = new RM_UserInfo_Dal();
            RM_System_IDAO   sys_idao     = new RM_System_Dal();
            IPScanerHelper   objScan      = new IPScanerHelper();
            SR_Tickets_IDal  ticket_idao  = new SR_Tickets_Dal();
            string           text         = Action;

            if (text != null)
            {
                if (text == "Menu")
                {
                    string UserId   = RequestSession.GetSessionUser().UserId.ToString();
                    string strMenus = JsonHelper.DataTableToJson(sys_idao.GetMenuHtml(UserId), "MENU");
                    context.Response.Write(strMenus);
                    context.Response.End();
                }
                else if (text == "login")
                {
                    //if (code.ToLower() != context.Session["dt_session_code"].ToString().ToLower())
                    //{
                    //    context.Response.Write("1");
                    //    context.Response.End();
                    //}
                    DataTable dtlogin = user_idao.UserLogin(user_Account.Trim(), userPwd.Trim());
                    if (dtlogin != null)
                    {
                        objScan.DataPath = context.Server.MapPath("/Themes/IPScaner/QQWry.Dat");
                        objScan.IP       = RequestHelper.GetIP();
                        string OWNER_address = objScan.IPLocation();
                        // string OWNER_address = RequestHelper.GetIP();
                        if (dtlogin.Rows.Count != 0)
                        {
                            user_idao.SysLoginLog(user_Account, "1", OWNER_address);
                            if (dtlogin.Rows[0]["DeleteMark"].ToString() == "1")
                            {
                                if (this.Islogin(context, user_Account))
                                {
                                    RequestSession.AddSessionUser(new SessionUser
                                    {
                                        UserId           = dtlogin.Rows[0]["User_ID"].ToString(),
                                        UserAccount      = dtlogin.Rows[0]["User_Account"].ToString(),
                                        UserName         = dtlogin.Rows[0]["User_Name"].ToString(),
                                        User_Account     = dtlogin.Rows[0]["User_Account"].ToString(),
                                        UserPwd          = dtlogin.Rows[0]["User_Pwd"].ToString(),
                                        Organization_IDs = dtlogin.Rows[0]["Organization_Name"].ToString(),
                                        OrganizationID   = dtlogin.Rows[0]["Organization_ID"].ToString(),
                                        Organization_Fax = dtlogin.Rows[0]["Organization_Fax"].ToString(),
                                        DESKey           = CommonHelper.GetRandomString(9)
                                    });

                                    //ConfigHelper.GetAppSettings("SqlServer_RM_DB")

                                    context.Response.Write("3");
                                    context.Response.End();
                                }
                                else
                                {
                                    context.Response.Write("6");
                                    context.Response.End();
                                }
                            }
                            else
                            {
                                user_idao.SysLoginLog(user_Account, "2", OWNER_address);
                                context.Response.Write("2");
                                context.Response.End();
                            }
                        }
                        else
                        {
                            user_idao.SysLoginLog(user_Account, "0", OWNER_address);
                            context.Response.Write("4");
                            context.Response.End();
                        }
                    }
                    else
                    {
                        context.Response.Write("5");
                        context.Response.End();
                    }
                }
            }
        }
コード例 #7
0
        public override void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType     = "text/plain";
            context.Response.Buffer          = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";
            base.ProcessRequest(context);
            string           Action       = context.Request["action"];       //提交动作
            string           user_Account = context.Request["user_Account"]; //账户
            string           userPwd      = context.Request["userPwd"];      //密码
            string           code         = context.Request["code"];         //验证码
            YR_UserInfo_IDAO user_idao    = new YR_UserInfo_Dal();
            YR_System_IDAO   sys_idao     = new YR_System_Dal();
            IPScanerHelper   objScan      = new IPScanerHelper();

            switch (Action)
            {
            case "login":
                if (code.ToLower() != context.Session["dt_session_code"].ToString().ToLower())
                {
                    context.Response.Write("1");    //验证码输入不正确!
                    context.Response.End();
                }
                DataTable dtlogin = user_idao.UserLogin(user_Account.Trim(), userPwd.Trim());
                if (dtlogin != null)
                {
                    objScan.DataPath = context.Server.MapPath("/Themes/IPScaner/QQWry.Dat");
                    objScan.IP       = RequestHelper.GetIP();
                    string OWNER_address = objScan.IPLocation().Replace("CZ88.NET", "");;
                    if (dtlogin.Rows.Count != 0)
                    {
                        user_idao.SysLoginLog(user_Account, "1", OWNER_address);
                        if (dtlogin.Rows[0]["DeleteMark"].ToString() == "1")
                        {
                            if (Islogin(context, user_Account))
                            {
                                SessionUser user = new SessionUser();
                                user.UserId      = dtlogin.Rows[0]["User_ID"].ToString();
                                user.UserAccount = dtlogin.Rows[0]["User_Account"].ToString();
                                user.UserName    = dtlogin.Rows[0]["User_Name"].ToString() + "(" + dtlogin.Rows[0]["User_Account"].ToString() + ")";
                                user.UserPwd     = dtlogin.Rows[0]["User_Pwd"].ToString();
                                user.RoleName    = dtlogin.Rows[0]["Roles_Name"].ToString();
                                RequestSession.AddSessionUser(user);
                                context.Response.Write("3");    //验证成功
                                context.Response.End();
                            }
                            else
                            {
                                context.Response.Write("6");    //该用户已经登录,不允许重复登录
                                context.Response.End();
                            }
                        }
                        else
                        {
                            user_idao.SysLoginLog(user_Account, "2", OWNER_address);    //账户被锁,联系管理员!
                            context.Response.Write("2");
                            context.Response.End();
                        }
                    }
                    else
                    {
                        user_idao.SysLoginLog(user_Account, "0", OWNER_address);
                        context.Response.Write("4");    //账户或者密码有错误!
                        context.Response.End();
                    }
                }
                else
                {
                    context.Response.Write("5");    //服务连接不上!
                    context.Response.End();
                }
                break;

            case "Menu":
                string UserId   = RequestSession.GetSessionUser().UserId.ToString();  //用户ID
                string strMenus = JsonHelper.DataTableToJson(sys_idao.GetMenuHtml(UserId), "MENU");
                context.Response.Write(strMenus);
                context.Response.End();
                break;

            default:
                break;
            }
        }
コード例 #8
0
ファイル: LoginController.cs プロジェクト: gxlbang/yoga
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="Account">账户</param>
        /// <param name="Password">密码</param>
        /// <returns></returns>
        public ActionResult CheckLogin(string Account, string Password, string Token)
        {
            string Msg = "";

            try
            {
                IPScanerHelper objScan   = new IPScanerHelper();
                string         IPAddress = NetHelper.GetIPAddress();
                objScan.IP       = IPAddress;
                objScan.DataPath = Server.MapPath("~/Resource/IPScaner/QQWry.Dat");
                string IPAddressName = objScan.IPLocation();
                string outmsg        = "";
                VerifyIPAddress(Account, IPAddress, IPAddressName, Token);
                //系统管理
                if (Account == ConfigHelper.AppSettings("CurrentUserName"))
                {
                    if (ConfigHelper.AppSettings("CurrentPassword") == Password)
                    {
                        IManageUser imanageuser = new IManageUser();
                        imanageuser.UserId        = "System";
                        imanageuser.Account       = "System";
                        imanageuser.UserName      = "******";
                        imanageuser.Gender        = "男";
                        imanageuser.InnerUser     = 1;
                        imanageuser.Code          = "System";
                        imanageuser.LogTime       = DateTime.Now;
                        imanageuser.CompanyId     = "系统";
                        imanageuser.DepartmentId  = "系统";
                        imanageuser.IPAddress     = IPAddress;
                        imanageuser.IPAddressName = IPAddressName;
                        imanageuser.IsSystem      = true;
                        ManageProvider.Provider.AddCurrent(imanageuser);
                        //对在线人数全局变量进行加1处理
                        HttpContext rq = System.Web.HttpContext.Current;
                        rq.Application["OnLineCount"] = (int)rq.Application["OnLineCount"] + 1;
                        Msg = "3";//验证成功
                        Base_SysLogBll.Instance.WriteLog(Account, OperationType.Login, "1", "登陆成功、IP所在城市:" + IPAddressName);
                    }
                    else
                    {
                        return(Content("4"));
                    }
                }
                else
                {
                    Base_User base_user = base_userbll.UserLogin(Account, Password, out outmsg);
                    switch (outmsg)
                    {
                    case "-1":          //账户不存在
                        Msg = "-1";
                        Base_SysLogBll.Instance.WriteLog(Account, OperationType.Login, "-1", "账户不存在、IP所在城市:" + IPAddressName);
                        break;

                    case "lock":        //账户锁定
                        Msg = "2";
                        Base_SysLogBll.Instance.WriteLog(Account, OperationType.Login, "-1", "账户锁定、IP所在城市:" + IPAddressName);
                        break;

                    case "error":       //密码错误
                        Msg = "4";
                        Base_SysLogBll.Instance.WriteLog(Account, OperationType.Login, "-1", "密码错误、IP所在城市:" + IPAddressName);
                        break;

                    case "succeed":     //验证成功
                        IManageUser imanageuser = new IManageUser();
                        imanageuser.UserId        = base_user.UserId;
                        imanageuser.InnerUser     = base_user.InnerUser ?? 1;
                        imanageuser.Account       = base_user.Account;
                        imanageuser.UserName      = base_user.RealName;
                        imanageuser.Gender        = base_user.Gender;
                        imanageuser.Password      = base_user.Password;
                        imanageuser.Code          = base_user.Code;
                        imanageuser.Secretkey     = base_user.Secretkey;
                        imanageuser.LogTime       = DateTime.Now;
                        imanageuser.CompanyId     = base_user.CompanyId;
                        imanageuser.DepartmentId  = base_user.DepartmentId;
                        imanageuser.ObjectId      = base_objectuserrelationbll.GetObjectId(imanageuser.UserId);
                        imanageuser.IPAddress     = IPAddress;
                        imanageuser.IPAddressName = IPAddressName;
                        imanageuser.IsSystem      = false;
                        ManageProvider.Provider.AddCurrent(imanageuser);
                        //对在线人数全局变量进行加1处理
                        HttpContext rq = System.Web.HttpContext.Current;
                        rq.Application["OnLineCount"] = (int)rq.Application["OnLineCount"] + 1;
                        Msg = "3";    //验证成功
                        Base_SysLogBll.Instance.WriteLog(Account, OperationType.Login, "1", "登陆成功、IP所在城市:" + IPAddressName);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Msg = ex.Message;
            }
            return(Content(Msg));
        }
コード例 #9
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="account">账户</param>
        /// <param name="password">密码</param>
        /// <param name="pwd"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public ActionResult CheckLogin(string account, string password, string pwd, string token)
        {
            account = HttpUtility.UrlDecode(account, Encoding.UTF8);

            string msg = "";

            try
            {
                IPScanerHelper objScan   = new IPScanerHelper();
                string         ipAddress = Net.GetIPAddress();
                objScan.IP       = ipAddress;
                objScan.DataPath = Server.MapPath("~/Resource/IPScaner/QQWry.Dat");
                string ipAddressName = objScan.IPLocation();
                VerifyIPAddress(account, ipAddress, ipAddressName, token);
                //系统管理
                if (account == Config.GetValue("CurrentUserName"))
                {
                    if (Config.GetValue("CurrentPassword") == password)
                    {
                        var us = DataFactory.Database().FindEntity <BaseUser>("1109001");

                        IManageUser imanageuser = new IManageUser
                        {
                            UserId        = us.UserId,
                            Account       = us.Account,
                            UserName      = "******",
                            Gender        = "男",
                            Code          = "System",
                            LogTime       = DateTime.Now,
                            CompanyId     = us.CompanyId,
                            DepartmentId  = us.DepartmentId,
                            IPAddress     = ipAddress,
                            IPAddressName = ipAddressName,
                            IsSystem      = true
                        };
                        ManageProvider.Provider.AddCurrent(imanageuser);
                        //对在线人数全局变量进行加1处理
                        HttpContext rq = System.Web.HttpContext.Current;
                        rq.Application["OnLineCount"] = (int)rq.Application["OnLineCount"] + 1;
                        msg = "3";//验证成功
                        BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "1", "登陆成功、IP所在城市:" + ipAddressName);
                    }
                    else
                    {
                        return(Content("4"));
                    }
                }
                else
                {
                    var      outmsg   = "";
                    BaseUser baseUser = _baseUserbll.UserLogin(account, password, pwd, out outmsg);
                    switch (outmsg)
                    {
                    case "-1":          //账户不存在
                        msg = "-1";
                        BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "账户不存在、IP所在城市:" + ipAddressName);
                        break;

                    case "lock":        //账户锁定
                        msg = "2";
                        BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "账户锁定、IP所在城市:" + ipAddressName);
                        break;

                    case "error":       //密码错误
                        msg = "4";
                        BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "-1", "密码错误、IP所在城市:" + ipAddressName);
                        break;

                    case "succeed":     //验证成功
                        CheckOnLine(account);

                        IManageUser imanageuser = new IManageUser
                        {
                            UserId       = baseUser.UserId,
                            Account      = baseUser.Account,
                            UserName     = baseUser.RealName,
                            Gender       = baseUser.Gender,
                            Password     = baseUser.Password,
                            Code         = baseUser.Code,
                            Secretkey    = baseUser.Secretkey,
                            LogTime      = DateTime.Now,
                            CompanyId    = baseUser.CompanyId,
                            DepartmentId = baseUser.DepartmentId
                        };
                        imanageuser.ObjectId      = _baseObjectuserrelationbll.GetObjectId(imanageuser.UserId);
                        imanageuser.IPAddress     = ipAddress;
                        imanageuser.IPAddressName = ipAddressName;
                        imanageuser.IsSystem      = false;
                        ManageProvider.Provider.AddCurrent(imanageuser);
                        //对在线人数全局变量进行加1处理
                        HttpContext rq = System.Web.HttpContext.Current;
                        rq.Application["OnLineCount"] = (int)rq.Application["OnLineCount"] + 1;
                        msg = "3";    //验证成功
                        BaseSysLogBll.Instance.WriteLog(account, OperationType.Login, "1", "登陆成功、IP所在城市:" + ipAddressName);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            return(Content(msg));
        }
コード例 #10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType     = "text/plain";
            context.Response.Buffer          = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";
            string                active                = HttpContext.Current.Request["action"];
            string                Account               = context.Request["Account"]; //账户
            string                Pwd                   = context.Request["Pwd"];     //密码
            string                code                  = context.Request["code"];    //验证码
            BPMS_UserIBLL         bpms_useribll         = new BPMS_UserBLL();
            BPMS_User             bpms_user             = new BPMS_User();
            BPMS_OrganizationIBLL bpms_organizationibll = new BPMS_OrganizationBLL();
            BPMS_Organization     bpms_organization     = new BPMS_Organization();
            BPMS_SysLogIBLL       bpms_syslogibll       = new BPMS_SysLogBLL();
            BPMS_IPBlacklistIBLL  bpms_ipblacklistibll  = new BPMS_IPBlacklistBLL();
            IPScanerHelper        objScan               = new IPScanerHelper();
            string                Msg                   = "";
            string                UserId                = "";

            switch (active)
            {
            case "login":    //登录
                #region 登录
                try
                {
                    string IPAddress = RequestHelper.GetIPAddress();
                    objScan.IP       = IPAddress;
                    objScan.DataPath = context.Server.MapPath("/Themes/IPScaner/QQWry.Dat");
                    string IPAddressName = objScan.IPLocation();
                    if (code.ToLower() != context.Session["dt_session_code"].ToString().ToLower())
                    {
                        Msg = "1";    //验证码输入不正确
                    }
                    else
                    {
                        //系统管理
                        if (Account == ConfigHelper.GetValue("CurrentUserName") && Md5Helper.MD5(Pwd, 32) == ConfigHelper.GetValue("CurrentPassword"))
                        {
                            SessionUser user = new SessionUser();
                            user.UserId         = "System";
                            user.Account        = "System";
                            user.UserName       = "******";
                            user.Gender         = "男";
                            user.Password       = bpms_user.Password;
                            user.Code           = "System";
                            user.DepartmentId   = "超级管理员";
                            user.DepartmentName = "超级管理员";
                            RequestSession.AddSessionUser(user);
                            Msg = "3";    //验证成功
                            bpms_syslogibll.AddSysLoginLog(bpms_user.Account, "登录成功", IPAddress, IPAddressName);
                        }
                        else
                        {
                            #region 验证
                            bpms_ipblacklistibll.TheIpIsRange(IPAddress);
                            string outmsg;
                            bpms_user = bpms_useribll.UserLogin(Account.Trim(), Pwd.Trim(), out outmsg);
                            if (outmsg != "-1")
                            {
                                if (outmsg == "succeed")
                                {
                                    if (bpms_user.Enabled == 1)
                                    {
                                        if (Islogin(context, Account.Trim()))
                                        {
                                            string DepartmentName = "";
                                            bpms_organization = bpms_organizationibll.GetEntity(bpms_user.DepartmentId);
                                            if (bpms_organization != null)
                                            {
                                                DepartmentName = bpms_organization.FullName;
                                            }
                                            SessionUser user = new SessionUser();
                                            user.UserId         = bpms_user.UserId;
                                            user.Account        = bpms_user.Account;
                                            user.UserName       = bpms_user.RealName;
                                            user.Gender         = bpms_user.Gender;
                                            user.Password       = bpms_user.Password;
                                            user.Code           = bpms_user.Code;
                                            user.Secretkey      = bpms_user.Secretkey;
                                            user.DepartmentId   = bpms_user.DepartmentId;
                                            user.DepartmentName = DepartmentName;
                                            user.RoleId         = bpms_user.RoleId;
                                            RequestSession.AddSessionUser(user);
                                            Msg = "3";    //验证成功
                                            bpms_syslogibll.AddSysLoginLog(bpms_user.Account, "登录成功", IPAddress, IPAddressName);
                                        }
                                        else
                                        {
                                            context.Response.Write("6");    //该用户已经登录,不允许重复登录
                                            context.Response.End();
                                        }
                                    }
                                    else
                                    {
                                        Msg = "2";    //账户锁定
                                        bpms_syslogibll.AddSysLoginLog(bpms_user.Account, "账户锁定", IPAddress, IPAddressName);
                                    }
                                }
                                else
                                {
                                    Msg = "4";    //账户或者密码有错误
                                    bpms_syslogibll.AddSysLoginLog(bpms_user.Account, "登录失败", IPAddress, IPAddressName);
                                }
                            }
                            else
                            {
                                Msg = DbErrorMsg.ReturnMsg;    //服务连接不上
                            }
                            #endregion
                        }
                    }
                }
                catch (Exception ex)
                {
                    Msg = ex.Message;
                }
                context.Response.Write(Msg);
                context.Response.End();
                #endregion
                break;

            case "Outlogin":    //安全退出
                UserId = RequestSession.GetSessionUser().UserId;
                CacheHelper.RemoveAllCache("Module" + UserId);
                CacheHelper.RemoveAllCache("Button" + UserId);
                CacheHelper.RemoveAllCache("Data" + UserId);
                context.Session.Abandon();      //取消当前会话
                context.Session.Clear();        //清除当前浏览器所以Session
                context.Response.Write("1");
                context.Response.End();
                break;

            case "LoadFirstMenu":
                UserId = RequestSession.GetSessionUser().UserId;
                IList list = (IList)StorePermission.Instance.GetModulePermission(UserId);
                context.Response.Write(JsonHelper.DropToJson <BPMS_ModulePermission>(list, "JSON"));
                context.Response.End();
                break;

            case "SetSystemId":                                //模块ID、访问模块
                UserId = RequestSession.GetSessionUser().UserId;
                string SystemId = context.Request["SystemId"]; //模块ID
                List <BPMS_ModulePermission> Modulelist = IListHelper.IListToList <BPMS_ModulePermission>((IList)StorePermission.Instance.GetModulePermission(UserId)).FindAll(t => t.MenuId == SystemId);
                foreach (BPMS_ModulePermission entity in Modulelist)
                {
                    BPMS_SysLogDAL.Instance.AddVisitLog(UserId, RequestSession.GetSessionUser().UserName, entity.FullName, "URL:" + entity.NavigateUrl);
                    break;
                }
                //写入Session
                context.Session["SystemId"] = SystemId;
                context.Response.Write(SystemId);
                context.Response.End();
                break;

            case "LeaveModule":    //离开模块
                break;

            default:
                break;
            }
        }
コード例 #11
0
ファイル: Frame.ashx.cs プロジェクト: Andy-Yin/MY_OA_RM
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     context.Response.Buffer = true;
     context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
     context.Response.AddHeader("pragma", "no-cache");
     context.Response.AddHeader("cache-control", "");
     context.Response.CacheControl = "no-cache";
     string Action = context.Request["action"];                      //提交动作
     string user_Account = context.Request["user_Account"];          //账户
     string userPwd = context.Request["userPwd"];                    //密码
     string code = context.Request["code"];                          //验证码
     RM_UserInfo_IDAO user_idao = new RM_UserInfo_Dal();
     RM_System_IDAO sys_idao = new RM_System_Dal();
     IPScanerHelper objScan = new IPScanerHelper();
     switch (Action)
     {
         case "login":
             if (code.ToLower() != context.Session["dt_session_code"].ToString().ToLower())
             {
                 context.Response.Write("1");//验证码输入不正确!
                 context.Response.End();
             }
             DataTable dtlogin = user_idao.UserLogin(user_Account.Trim(), userPwd.Trim());
             if (dtlogin != null)
             {
                 objScan.DataPath = context.Server.MapPath("/Themes/IPScaner/QQWry.Dat");
                 objScan.IP = RequestHelper.GetIP();
                 string OWNER_address = objScan.IPLocation();
                 if (dtlogin.Rows.Count != 0)
                 {
                     user_idao.SysLoginLog(user_Account, "1", OWNER_address);
                     if (dtlogin.Rows[0]["DeleteMark"].ToString() == "1")
                     {
                         if (Islogin(context, user_Account))
                         {
                             SessionUser user = new SessionUser();
                             user.UserId = dtlogin.Rows[0]["User_ID"].ToString();
                             user.UserAccount = dtlogin.Rows[0]["User_Account"].ToString();
                             user.UserName = dtlogin.Rows[0]["User_Name"].ToString() + "(" + dtlogin.Rows[0]["User_Account"].ToString() + ")";
                             user.UserPwd = dtlogin.Rows[0]["User_Pwd"].ToString();
                             RequestSession.AddSessionUser(user);
                             context.Response.Write("3");//验证成功
                             context.Response.End();
                         }
                         else
                         {
                             context.Response.Write("6");//该用户已经登录,不允许重复登录
                             context.Response.End();
                         }
                     }
                     else
                     {
                         user_idao.SysLoginLog(user_Account, "2", OWNER_address);//账户被锁,联系管理员!
                         context.Response.Write("2");
                         context.Response.End();
                     }
                 }
                 else
                 {
                     user_idao.SysLoginLog(user_Account, "0", OWNER_address);
                     context.Response.Write("4");//账户或者密码有错误!
                     context.Response.End();
                 }
             }
             else
             {
                 context.Response.Write("5");//服务连接不上!
                 context.Response.End();
             }
             break;
         case "Menu":
             string UserId = RequestSession.GetSessionUser().UserId.ToString();//用户ID
             string strMenus = JsonHelper.DataTableToJson(sys_idao.GetMenuHtml(UserId), "MENU");
             context.Response.Write(strMenus);
             context.Response.End();
             break;
         default:
             break;
     }
 }
コード例 #12
0
ファイル: SwitchHotel.aspx.cs プロジェクト: radtek/zhkqxt
        private void SwitchLogin(string user_Account, string userPwd, string AdminHotelid)
        {
            RM_UserInfo_IDAO user_idao = new RM_UserInfo_Dal();



            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"select top 1 * from V_Login where ");
            strSql.Append("User_Account=@User_Account ");
            strSql.Append("and User_Pwd=@User_Pwd ");
            strSql.Append("and AdminHotelid=@AdminHotelid ");
            SqlParam[] para =
            {
                new SqlParam("@AdminHotelid", AdminHotelid),
                new SqlParam("@User_Account", user_Account),
                new SqlParam("@User_Pwd",     userPwd)
            };
            DataTable dtlogin = DataFactory.SqlDataBase().GetDataTableBySQL(strSql, para);

            if (dtlogin != null)
            {
                IPScanerHelper objScan = new IPScanerHelper();
                objScan.DataPath = Server.MapPath("/Themes/IPScaner/QQWry.Dat");
                objScan.IP       = RequestHelper.GetIP();
                string OWNER_address = objScan.IPLocation();
                if (dtlogin.Rows.Count != 0)
                {
                    if (dtlogin.Rows[0]["DeleteMark"].ToString() == "1")
                    {
                        user_idao.SysLoginLog(1, 10, user_Account, "1", OWNER_address, dtlogin.Rows[0]["User_ID"].ToString(), AdminHotelid);
                        SessionUser user = new SessionUser();
                        user.UserId       = dtlogin.Rows[0]["User_ID"].ToString();
                        user.UserAccount  = dtlogin.Rows[0]["User_Account"].ToString();
                        user.UserName     = dtlogin.Rows[0]["User_Name"].ToString() + "(" + dtlogin.Rows[0]["User_Account"].ToString() + ")";
                        user.UserPwd      = dtlogin.Rows[0]["User_Pwd"].ToString();
                        user.AdminHotelid = dtlogin.Rows[0]["AdminHotelid"].ToString();
                        user.Hotelid      = dtlogin.Rows[0]["Hotelid"].ToString();
                        user.HotelListId  = dtlogin.Rows[0]["HotelListId"].ToString();
                        user.IsAdmin      = dtlogin.Rows[0]["IsAdmin"].ToString();
                        RequestSession.AddSessionUser(user);

                        HttpCookie cookies = new HttpCookie("LoginUser_CK");
                        cookies.Values.Clear();
                        cookies.Expires = DateTime.Now.AddDays(1);
                        cookies.Values.Add("User_ID", user.UserId.ToString());
                        cookies.Values.Add("User_Account", user.UserAccount.ToString());
                        cookies.Values.Add("AdminHotelid", user.AdminHotelid.ToString());
                        cookies.Values.Add("Hotelid", user.Hotelid.ToString());
                        cookies.Values.Add("User_Name", user.UserName.ToString());
                        cookies.Values.Add("UserPwd", user.UserPwd.ToString());
                        cookies.Values.Add("HotelListId", user.HotelListId.ToString());
                        cookies.Values.Add("IsAdmin", user.IsAdmin.ToString());
                        Response.AppendCookie(cookies);

                        this.Response.Write("<script lanuage=javascript>top.location='/Frame/MainDefault.aspx'</script>");
                    }
                    else
                    {
                        user_idao.SysLoginLog(1, 10, user_Account, "2", OWNER_address, "", dtlogin.Rows[0]["AdminHotelid"].ToString());//账户被锁,联系管理员!
                    }
                }
                else
                {
                    user_idao.SysLoginLog(1, 10, user_Account, "0", OWNER_address, "", "");
                }
            }
        }