예제 #1
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));
        }
예제 #2
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));
        }
예제 #3
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);
        }