Esempio n. 1
0
 void GetLoginer(HttpContext context)
 {
     if (context.Session["LoginCompanyOperator"] == null)
     {
         try
         {
             string   webCookie = context.Session.SessionID.ToString();
             Olb_User dCLoginer = null;
             dCLoginer = LoginerManageService.GetInstance().GetLoginerByMd5Cookie(Md5.GetMd5(webCookie));
             if (dCLoginer != null)
             {
                 dCLoginer.PassWord = string.Empty;
                 context.Session["LoginCompanyOperator"] = dCLoginer;
             }
             else
             {
                 if (context.Request.Form["NO_COOKIE_SessionId"] != null && context.Request.Form["NO_COOKIE_SessionId"].ToString() != string.Empty)
                 {
                     webCookie = context.Request.Form["NO_COOKIE_SessionId"].ToString();
                     dCLoginer = LoginerManageService.GetInstance().GetLoginerByMd5Cookie(webCookie);
                     if (dCLoginer != null)
                     {
                         dCLoginer.PassWord = string.Empty;
                         context.Session["LoginCompanyOperator"] = dCLoginer;
                     }
                 }
             }
         }
         catch
         { }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 编辑用户
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public Message Edit(Olb_User info)
        {
            Message m;

            try
            {
                DataContext dd     = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);
                Olb_User    dbinfo = dd.GetTable <Olb_User>().Where(p => p.ID == info.ID).SingleOrDefault();

                info.PassWord = dbinfo.PassWord;
                ConvertHelper.Copy <Olb_User>(dbinfo, info);

                dd.SubmitChanges();
                m = new Message()
                {
                    Result     = true,
                    TxtMessage = JSon.TToJson <Olb_User>(dbinfo)
                };
            }
            catch (Exception e)
            {
                m = new Message()
                {
                    Result     = false,
                    TxtMessage = "修改用户信息失败!" + e.Message
                };
            }
            return(m);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public Message Add(Olb_User info)
        {
            Message m;

            try
            {
                //需要为每个方法创建一个DataContext实例 原因在于DataContext的缓存机制
                DataContext      dd  = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);
                Table <Olb_User> tbl = dd.GetTable <Olb_User>();

                string guid = Guid.NewGuid().ToString();
                info.ID = guid;

                tbl.InsertOnSubmit(info);
                dd.SubmitChanges();

                m = new Message()
                {
                    Result     = true,
                    TxtMessage = JSon.TToJson <Olb_User>(info)
                };
            }
            catch (Exception e)
            {
                m = new Message()
                {
                    Result     = false,
                    TxtMessage = "注册用户失败!" + e.Message
                };
            }
            return(m);
        }
Esempio n. 4
0
        public Olb_User GetLoginerByMd5Cookie(string md5Cookie)
        {
            Olb_User    dbinfo = null;
            LoginerInfo info   = LoginerManageHelper.getInstance().List.Where(p => p.Md5Key == md5Cookie).SingleOrDefault();

            if (info != null && info.OperID != null && info.OperID != string.Empty)
            {
                DataContext dd = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);
                dbinfo = dd.GetTable <Olb_User>().Where(p => p.Account == info.OperID).SingleOrDefault();
            }
            return(dbinfo);
        }
Esempio n. 5
0
        /// <summary>
        /// 获取用户
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public Olb_User GetUserByAccount(string account)
        {
            Olb_User dbinfo = null;

            try
            {
                DataContext dd = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);
                dbinfo = dd.GetTable <Olb_User>().Where(p => p.Account == account).SingleOrDefault();
            }
            catch (Exception e)
            {
                //记录日志
            }
            return(dbinfo);
        }
Esempio n. 6
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     if (context.Session["LoginCompanyOperator"] == null)
     {
         GetLoginer(context);
     }
     if (context.Session["LoginCompanyOperator"] != null)
     {
         isLoginOn     = true;
         loginOperator = (Olb_User)context.Session["LoginCompanyOperator"];
         DoLoginedHandlerWork(context);
     }
     else
     {
         isLoginOn     = false;
         loginOperator = null;
         DoNoLoginHandlerWork(context);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="oldPwd"></param>
        /// <param name="newPwd"></param>
        /// <param name="account"></param>
        /// <returns></returns>
        public Message UpdatePwd(string oldPwd, string newPwd, string account)
        {
            Message m;

            try
            {
                DataContext dd     = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);
                Olb_User    dbinfo = dd.GetTable <Olb_User>().Where(p => p.Account == account).SingleOrDefault();

                if (oldPwd == dbinfo.PassWord)
                {
                    dbinfo.PassWord = newPwd;
                    dd.SubmitChanges();
                    m = new Message()
                    {
                        Result     = true,
                        TxtMessage = JSon.TToJson <Olb_User>(dbinfo)
                    };
                }
                else
                {
                    m = new Message()
                    {
                        Result     = false,
                        TxtMessage = "原密码错误!"
                    };
                }
            }
            catch (Exception e)
            {
                m = new Message()
                {
                    Result     = false,
                    TxtMessage = "修改密码失败!" + e.Message
                };
            }
            return(m);
        }
Esempio n. 8
0
        public override void DoLoginedHandlerWork(HttpContext context)
        {
            Message jsonMessage;

            jsonMessage = new Message()
            {
                Result     = false,
                TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。"
            };
            string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper();

            try
            {
                switch (AjaxType)
                {
                case "LOADLOGINER":
                    jsonMessage = new Message()
                    {
                        Result     = true,
                        TxtMessage = JSon.TToJson <Olb_User>(base.loginOperator)
                    };
                    break;

                case "USEREDIT":
                    Olb_User user = base.loginOperator;
                    if (context.Request.Form["Name"] != null && context.Request.Form["Name"].ToString().Trim() != string.Empty)
                    {
                        user.Name = context.Request.Form["Name"].ToString().Trim();
                    }
                    if (context.Request.Form["IdentityCard"] != null && context.Request.Form["IdentityCard"].ToString().Trim() != string.Empty)
                    {
                        user.IdentityCard = context.Request.Form["IdentityCard"].ToString().Trim();
                    }
                    if (context.Request.Form["Address"] != null && context.Request.Form["Address"].ToString().Trim() != string.Empty)
                    {
                        user.Address = context.Request.Form["Address"].ToString().Trim();
                    }

                    jsonMessage = UserManageService.GetInstance().Edit(user);
                    break;

                case "UPDATEPWD":
                    string oldPwd = "", newPwd = "", account = "";
                    if (context.Request.Form["oldPwd"] != null && context.Request.Form["oldPwd"].ToString().Trim() != string.Empty)
                    {
                        oldPwd = context.Request.Form["oldPwd"].ToString().Trim();
                    }
                    if (context.Request.Form["newPwd"] != null && context.Request.Form["newPwd"].ToString().Trim() != string.Empty)
                    {
                        newPwd = context.Request.Form["newPwd"].ToString().Trim();
                    }
                    if (oldPwd != "" && newPwd != "" && account != "")
                    {
                        account     = base.loginOperator.Account;
                        oldPwd      = Md5.GetMd5(oldPwd);
                        newPwd      = Md5.GetMd5(newPwd);
                        jsonMessage = UserManageService.GetInstance().UpdatePwd(oldPwd, newPwd, account);
                    }
                    break;

                default:
                    jsonMessage = new Message()
                    {
                        Result     = false,
                        TxtMessage = "操作未定义。"
                    };
                    break;
                }
            }
            catch (Exception ex)
            {
                jsonMessage = new Message()
                {
                    Result     = false,
                    TxtMessage = ex.Message
                };
            }
            finally
            {
            }
            context.Response.Write(JSon.TToJson <Message>(jsonMessage));
        }
Esempio n. 9
0
        public override void DoNoLoginHandlerWork(HttpContext context)
        {
            Message jsonMessage = new Message();
            //获取操作类型AType:ADD,EDIT,DELETE,QUERY

            string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper();

            switch (AjaxType)
            {
            case "USERLOGIN":
                jsonMessage = UserLogin(context);
                break;

            case "USERLOGINOUT":
                if (context.Session["LoginCompanyOperator"] != null)
                {
                    context.Session.Remove("LoginCompanyOperator");
                }
                string webCookie = context.Session.SessionID.ToString();
                jsonMessage = LoginerManageService.GetInstance().UnLRegisterClientByMd5Cookie(Md5.GetMd5(webCookie));
                break;

            case "USERREGISTER":
                try
                {
                    string name = "", pwd = "";
                    if (context.Request.Form["Name"] != null && context.Request.Form["Name"].ToString().Trim() != string.Empty)
                    {
                        name = context.Request.Form["Name"].ToString().Trim();
                    }
                    if (context.Request.Form["Password"] != null && context.Request.Form["Password"].ToString().Trim() != string.Empty)
                    {
                        pwd = context.Request.Form["Password"].ToString().Trim();
                    }
                    if (name != "" && pwd != "")
                    {
                        Olb_User user = new Olb_User();
                        user.Account  = name;
                        user.PassWord = Md5.GetMd5(pwd);
                        jsonMessage   = UserManageService.GetInstance().Add(user);
                        if (jsonMessage.Result)
                        {
                            Olb_User Loginer = UserManageService.GetInstance().GetUserByAccount(name);
                            webCookie = context.Session.SessionID.ToString();
                            LoginerManageService.GetInstance().UserLogin(Md5.GetMd5(webCookie), Loginer.Account);

                            Loginer.PassWord = string.Empty;
                            context.Session["LoginCompanyOperator"] = Loginer;
                        }
                    }
                }
                catch (Exception e) { }
                break;

            case "CHECKCODE":
                string code = "";
                if (context.Request.Form["Code"] != null && context.Request.Form["Code"].ToString().Trim() != string.Empty)
                {
                    code = context.Request.Form["Code"].ToString().Trim();
                }
                string validCode = context.Session["CheckCode"] as String;      //获取系统生成的验证码
                if (!string.IsNullOrEmpty(validCode) && !string.IsNullOrEmpty(code))
                {
                    if (code.ToLower() == validCode.ToLower())
                    {
                        jsonMessage = new Message()
                        {
                            Result     = true,
                            TxtMessage = "ok"
                        };
                    }
                    else
                    {
                        jsonMessage = new Message()
                        {
                            Result     = false,
                            TxtMessage = "验证码错误"
                        };
                    }
                }
                break;

            default:
                jsonMessage = new Message()
                {
                    Result     = false,
                    TxtMessage = "操作未定义。"
                };
                break;
            }
            context.Response.Write(JSon.TToJson <Message>(jsonMessage));
        }
Esempio n. 10
0
        private Message UserLogin(HttpContext context)
        {
            Message jMessage = new Message();
            string  LoginID  = string.Empty;
            string  LoginPsw = string.Empty;

            if (context.Request.Form["Name"] != null && context.Request.Form["Name"].ToString().Trim() != string.Empty)
            {
                LoginID = context.Request.Form["Name"].ToString().Trim();
            }
            if (context.Request.Form["Password"] != null)
            {
                LoginPsw = context.Request.Form["Password"].ToString().Trim();
            }
            if (LoginID == string.Empty)
            {
                jMessage = new Message()
                {
                    Result     = false,
                    TxtMessage = "登录账号格式不正确。"
                };
            }
            else
            {
                Olb_User Loginer = UserManageService.GetInstance().GetUserByAccount(LoginID);

                if (Loginer != null && Loginer.Account != string.Empty)
                {
                    if (Loginer.PassWord == Md5.GetMd5(LoginPsw))
                    {
                        jMessage = new Message()
                        {
                            Result     = true,
                            TxtMessage = "登录成功。"
                        };
                        string webCookie = context.Session.SessionID.ToString();
                        LoginerManageService.GetInstance().UserLogin(Md5.GetMd5(webCookie), Loginer.Account);

                        Loginer.PassWord = string.Empty;
                        context.Session["LoginCompanyOperator"] = Loginer;
                    }
                    else
                    {
                        jMessage = new Message()
                        {
                            Result     = false,
                            TxtMessage = "密码错误。"
                        };
                    }
                }
                else
                {
                    jMessage = new Message()
                    {
                        Result     = false,
                        TxtMessage = "登录账号不存在。"
                    };
                }
            }
            return(jMessage);
        }