Пример #1
0
        private void GetLoginOn(HttpContext context)
        {
            UsersBLL    bll         = new UsersBLL();
            ReturnModel ReturnModel = new ReturnModel();
            //int IsManager = 0;

            int result = 0;

            try
            {
                string LoginName = context.Request.Params["LoginName"];
                string Password  = context.Request.Params["Password"];
                string CardID    = context.Request.Params["CardID"];
                //string IsRemember = context.Request.Params["IsRemember"];

                if (!string.IsNullOrEmpty(LoginName) && !string.IsNullOrEmpty(Password) && !string.IsNullOrEmpty(CardID))
                {
                    Users  users  = new Users();
                    string PwdKey = LinkFun.getPwdKey();
                    Password    = DESEncrypt.Encrypt(PwdKey, Password);//旧密码加密
                    ReturnModel = bll.VerificationPassword(LoginName, Password, CardID);
                    if (ReturnModel.IsSuccess)
                    {
                        int UserID = (int)ReturnModel.Data;
                        result = UserID;

                        MerchantFrontCookieBLL.SetMerchantFrontCookie(UserID, LoginName);

                        #region 改造前端登录方法存储到缓存
                        UsersBLL bllUsers = new UsersBLL();
                        Users    model    = bllUsers.GetModel(UserID);
                        if (model != null)
                        {
                            string key = ComPage.memberModelCacheDependency + model.UserID;
                            ComPage.SetBWJSCache(key, Guid.NewGuid(), null, DateTime.Now.AddMinutes(ComPage.SafeToDouble(LinkFun.ConfigString("FrontEndCookieExpires", "120"))), TimeSpan.Zero);

                            HttpCookie cookie = new HttpCookie(LinkFun.ConfigString("FrontEndCookieName", "BWJSFrontEnd20180108"));
                            cookie.Expires = DateTime.Now.AddMinutes(ComPage.SafeToDouble(LinkFun.ConfigString("FrontEndCookieExpires", "120")));
                            cookie.Values.Add("Id", HttpContext.Current.Server.UrlEncode(model.UserID.ToString()));

                            System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                            System.Web.HttpContext.Current.Response.AppendCookie(cookie);

                            model.LastAccessIP     = HttpContext.Current.Request.UserHostAddress;
                            model.LoginTimes       = ComPage.SafeToInt(model.LoginTimes) + 1;
                            model.RecordUpdateTime = DateTime.Now;
                            model.IsLogined        = 1;
                            bllUsers.Update(model);
                        }
                        #endregion
                    }
                }
                context.Response.Write(ObjectToJson(ReturnModel));
            }
            catch (Exception ex)
            {
                context.Response.Write(ex);
            }
        }
Пример #2
0
        public void AddUser(HttpContext context)
        {
            string PwdKey = LinkFun.getPwdKey();
            int    UserID = 0;

            if (!string.IsNullOrEmpty(context.Request.QueryString["UserID"].ToString()))
            {
                UserID = Convert.ToInt32(context.Request.QueryString["UserID"].ToString());
            }


            string   objOrder = GetParam("UsersModel", context);
            Users    users    = JsonConvert.DeserializeObject <Users>(objOrder);
            UsersBLL usersbll = new UsersBLL();


            int result = 0;

            //编辑
            if (UserID > 0)
            {
                if (users.LoginName != "" && users.Password != "")
                {
                    result = usersbll.Update(users) ? 1 : 0;
                    if (result > 0)
                    {
                        #region 通知风控系统

                        #endregion
                    }
                }
            }
            else
            {
                string pwd = DESEncrypt.Encrypt(PwdKey, users.Password);//加密密码
                users.Password = pwd;
                //添加
                if (users.LoginName != "" && users.Password != "")
                {
                    result = usersbll.Add(users);
                    if (result > 0)
                    {
                        #region 通知风控系统

                        #endregion
                    }
                }
            }
            context.Response.Write(result);
        }