public void ProcessRequest(HttpContext context)
        {
            string code = context.Request.QueryString["term"];

            if (!string.IsNullOrEmpty(code))
            {
                var companydId     = -1;
                var formsPrincipal = FormsPrincipal <LoginUser> .GetAccount(HttpContext.Current);

                if (formsPrincipal != null)
                {
                    companydId = formsPrincipal.UserInfo.AccountComId;
                }

                var service = new ItemsService();

                var ja = new JArray();

                foreach (
                    var cate in service.Where(
                        p => p.FCompanyId == companydId &&
                        ((p.FCode.Contains(code) || p.FName.Contains(code)) ||
                         p.FSpell.Contains(code))).OrderBy(p => p.FName).Take(10))
                {
                    ja.Add(string.Format("{0}", cate.FName));
                }

                context.Response.ContentType = "text/plain";
                context.Response.Write(ja.ToString());
            }
        }
        /// <summary>
        /// 验证是否有用户id参数
        /// </summary>
        /// <returns></returns>
        protected virtual bool ValidationLoginUserId()
        {
            var sings = FormsPrincipal <CookUserInfo> .TryParsePrincipal(Request);

            if (null == sings)
            {
                return(false);
            }
            this.mCookUserInfo = sings.UserData;
            if (null != this.mCookUserInfo)
            {
                this.mloginUserId = this.mCookUserInfo.Id;
                var sessionitem = mSysUserSessionService.GetUserId(this.mCookUserInfo.Id);

                if (sessionitem == null || sessionitem.SessionId != mCookUserInfo.Sex)
                {
                    //清除cookie ,禁止登录,
                    FormsPrincipal <CookUserInfo> .SignOut();

                    AppGlobal.RenderResult(ApiCode.ExitLogin);
                    return(false);
                }
            }
            else
            {
                int.TryParse(this.Request.Params["loginUserId"], out mloginUserId);
            }

            return(mloginUserId > 0);
        }
Exemple #3
0
        public bool Login(string adminName, string password)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("AdminName", adminName);
            dic.Add("Password", password);
            dic.Add("Status", (1).ToString());
            Administrator admin = adminBLL.Get(dic);

            if (admin == null)
            {
                return(false);
            }
            else
            {
                //设置cookie信息
                CookiesModel ck = new CookiesModel
                {
                    AdminId   = admin.AdminId,
                    AdminName = admin.AdminName,
                    GroupId   = admin.GroupId
                };
                FormsPrincipal <CookiesModel> .SignIn(ck.AdminName, ck, 0);

                return(true);
            }
        }
        /// <summary>
        /// 缓存用户Cookie数据
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <returns></returns>
        private void CacheUserData(UserInfo userInfo)
        {
            _Session[LOGINERROR] = null;
            //客户端浏览器参数
            int w = _Request["w"].ObjToInt();
            int h = _Request["h"].ObjToInt();

            if (w > 0)
            {
                userInfo.ClientBrowserWidth = w;
            }
            if (h > 0)
            {
                userInfo.ClientBrowserHeight = h;
            }
            //获取客户端IP
            userInfo.ClientIP = WebHelper.GetClientIP(_Request);
            //缓存用户扩展信息
            UserInfo.CacheUserExtendInfo(userInfo.UserName, userInfo.ExtendUserObject);
            //用户票据保存
            FormsPrincipal.Login(userInfo.UserName, userInfo, UserInfo.ACCOUNT_EXPIRATION_TIME, GetHttpContext(_Request));
            //登录成功写cookie,保存客户端用户名
            var userNameCookie = new HttpCookie("UserName", userInfo.UserName);

            userNameCookie.Expires = DateTime.Now.AddDays(365);
            _Response.Cookies.Add(userNameCookie);
        }
Exemple #5
0
        /// <summary>
        /// 处理登陆
        /// </summary>
        /// <param name="context">HttpContext</param>
        /// <param name="action">请求动作</param>
        /// 时间:2016-05-10 17:28
        /// 备注:
        private void HanlderLogin(HttpContext context, string action)
        {
            if (string.Compare(action, "login", true) == 0)
            {
                string _userName     = context.Request["userName"],
                       _userPassword = context.Request["userPassword"],
                       _verifyCode   = context.Request["verifyCode"];
                if (CheckedVerifyCode(context, _verifyCode))
                {
                    try
                    {
                        Base_UserInfo userinfo = new Base_UserInfo();
                        userinfo.User_Name = _userName;
                        userinfo.User_Pwd  = _userPassword;
                        FormsPrincipal <Base_UserInfo> .SignIn(_userName, userinfo);

                        context.CreateResponse("登陆成功.", HttpStatusCode.OK);
                    }
                    catch (Exception ex)
                    {
                        HanlderErrorRequest(context, ex, "登陆失败,请稍后重试。");
                    }
                }
            }
        }
        /// <summary>
        /// 缓存用户Cookie数据
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <returns></returns>
        private void CacheUserData(UserInfo userInfo)
        {
            //客户端浏览器参数
            int w = _Request.QueryEx("w").ObjToInt();
            int h = _Request.QueryEx("h").ObjToInt();

            if (w > 0)
            {
                userInfo.ClientBrowserWidth = w;
            }
            if (h > 0)
            {
                userInfo.ClientBrowserHeight = h;
            }
            //获取客户端IP
            userInfo.ClientIP = WebHelper.GetClientIP(_Request);
            //缓存用户扩展信息
            UserInfo.CacheUserExtendInfo(userInfo.UserName, userInfo.ExtendUserObject);
            //用户票据保存
            int acount_expire_time = UserInfo.ACCOUNT_EXPIRATION_TIME;

            acount_expire_time = WebConfigHelper.GetAppSettingValue("ACCOUNT_EXPIRATION_TIME").ObjToInt();
            if (acount_expire_time <= 0)
            {
                acount_expire_time = UserInfo.ACCOUNT_EXPIRATION_TIME;
            }
            FormsPrincipal.Login(userInfo.UserName, userInfo, acount_expire_time, GetHttpContext(_Request));
        }
Exemple #7
0
        /// <summary>
        /// 退出登录
        /// </summary>
        /// <returns></returns>
        public ActionResult Logout()
        {
            //清除缓存
            AccountManager.Current.ClearCache();
            FormsPrincipal <UserInfo> .Logout();

            return(RedirectToAction("Login"));
        }
        /// <summary>
        /// 获取登录用户信息
        /// </summary>
        private void InititalLoginUser()
        {
            FormsPrincipal <CookUserInfo> source = FormsPrincipal <CookUserInfo> .TryParsePrincipal(this.Request);

            if (null != source)
            {
                this.LoginUser = source.UserData;
            }
        }
Exemple #9
0
        void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            if (app != null)
            {
                FormsPrincipal <CookiesModel> .SetFomrsIdentityUserData();
            }
        }
        public virtual bool ValidateLoginUser()
        {
            var cookUser = FormsPrincipal <CookUserInfo> .TryParsePrincipal(Request);

            if (null == cookUser || cookUser.UserData == null)
            {
                return(false);
            }
            this.CookUserInfo = cookUser.UserData;
            return(true);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserInfo userinfo = new UserInfo();

            userinfo.UserName = "******";
            userinfo.UserId   = 1;
            userinfo.GroupId  = 1;
            FormsPrincipal <UserInfo> .SignIn("yanzhiwei", userinfo, 1);

            FormsPrincipal <UserInfo> .RedirectDefaultPage("yanzhiwei");
        }
        /// <summary>
        /// 身份验证
        /// </summary>
        /// <returns></returns>
        protected virtual bool Validation()
        {
            //身份验证
            FormsPrincipal <CookUserInfo> source = FormsPrincipal <CookUserInfo> .TryParsePrincipal(this.Request);

            if (null == source || source.UserData == null)
            {
                AppGlobal.RenderResult(ApiCode.Security);
                return(false);
            }
            return(true);
        }
 /// <summary>
 /// 登出
 /// </summary>
 /// <returns></returns>
 public ActionResult Logout()
 {
     if (_Response == null)
     {
         _Response = Response;
     }
     if (_Session == null)
     {
         _Session = Session;
     }
     FormsPrincipal.Logout(_Response, _Session);
     return(RedirectToAction("Login"));
 }
Exemple #14
0
        protected void Session_End(object sender, EventArgs e)
        {
            Hashtable hOnline = (Hashtable)Application["Online"];

            if (hOnline == null)
            {
                return;
            }
            if (hOnline[Session.SessionID] != null)
            {
                hOnline.Remove(Session.SessionID);
                Application.Lock();
                Application["Online"] = hOnline;
                Application.UnLock();
                //移除cookie
                FormsPrincipal <CookUserInfo> .SignOut();
            }
        }
        /// <summary>
        /// 验证用户是否被禁用
        /// </summary>
        private void VerificationUser()
        {
            ValidationLoginUserId();
            var sings = FormsPrincipal <CookUserInfo> .TryParsePrincipal(Request);

            if (null == sings)
            {
                AppGlobal.RenderResult(ApiCode.Fail);
                return;
            }
            var loginuser = sings.UserData;

            if (null == loginuser)
            {
                AppGlobal.RenderResult(ApiCode.Fail);
                return;
            }


            if (loginuser != null)
            {
                //验证是否被禁用

                var item = mSysUserService.Get(loginuser.Id);
                if (null == item)
                {
                    AppGlobal.RenderResult(ApiCode.Fail);
                    return;
                }
                if (item.IsLockCards || item.IsDelete)
                {
                    AppGlobal.RenderResult(ApiCode.Success);
                    Logout();//注销
                }
                else
                {
                    AppGlobal.RenderResult(ApiCode.Fail);
                }
            }
            else
            {
                AppGlobal.RenderResult(ApiCode.Success);
            }
        }
        /// <summary>
        /// 应用程序认证请求
        /// </summary>
        /// <param name="sender">发送对象</param>
        /// <param name="e">事件参数</param>
        public void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpApplication app      = (HttpApplication)sender;
            string          username = string.Empty;

            if (app.Context.User != null && app.Context.User.Identity != null)
            {
                username = app.Context.User.Identity.Name;
            }
            int w = 0;
            int h = 0;

            if (app.Context.Request["nfm"].ObjToInt() == 1)
            {
                username = app.Context.Request["un"].ObjToStr(); //请求中自带的用户名
                w        = app.Context.Request["w"].ObjToInt();
                h        = app.Context.Request["h"].ObjToInt();
            }
            if (!string.IsNullOrEmpty(username))
            {
                UserInfo tempUserInfo = UserInfo.GetCurretnUser(app.Context);
                if (tempUserInfo == null || tempUserInfo.UserId == Guid.Empty || tempUserInfo.UserName.ToLower() != username.ToLower())
                {
                    Guid     userId   = UserOperate.GetUserIdByUserName(username);
                    UserInfo userInfo = UserOperate.GetUserInfo(userId);
                    if (w > 0 && h > 0)
                    {
                        userInfo.ClientBrowserWidth  = w;
                        userInfo.ClientBrowserHeight = h;
                    }
                    //缓存用户扩展信息
                    UserInfo.CacheUserExtendInfo(userInfo.UserName, userInfo.ExtendUserObject);
                    //保存票据
                    FormsPrincipal.Login(userInfo.UserName, userInfo, UserInfo.ACCOUNT_EXPIRATION_TIME, app.Context);
                }
                FormsPrincipal.TrySetUserInfo(app.Context);
            }
            else
            {
                FormsPrincipal.TrySetUserInfo(app.Context);
            }
        }
        private void LoginOper(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string userName = context.Request["userName"].ToString();
            string password = context.Request["password"].ToString();
            string strWhere = " and StaffName='" + userName + "' ";

            StaffsBLL bll   = new StaffsBLL();
            Staffs    model = bll.GetModel(strWhere);

            if (model != null)
            {
                if (model.UserPwd == password)
                {
                    FormsPrincipal.SignIn(model.UserName, model, 30);
                    LogHelper.Info(this.GetType(), model.UserName + "登录");

                    context.Response.Write(JsonConvert.SerializeObject(new
                    {
                        success = 0,
                        result  = "登录成功!"
                    }));
                }
                else
                {
                    context.Response.Write(JsonConvert.SerializeObject(new
                    {
                        success = 1,
                        result  = "密码输入不正确!"
                    }));
                }
            }
            else
            {
                context.Response.Write(JsonConvert.SerializeObject(new
                {
                    success = 2,
                    result  = "用户不存在!"
                }));
            }
            context.Response.End();
        }
Exemple #18
0
        public ActionResult MiniLogin(LoginVM loginModel)
        {
            SysUserVM sysUser = _accountBizProcess.Login(loginModel.SysUserName, loginModel.PasswordHash);

            if (sysUser != null)
            {
                UserInfo userInfo = sysUser.ToUserInfo();
                FormsPrincipal <UserInfo> .Login(sysUser.UserName, userInfo, 30);

                //登录成功写cookie
                var userNameCookie = new HttpCookie("username", sysUser.UserName);
                userNameCookie.Expires = DateTime.Now.AddDays(365);
                var rememberMeCookie = new HttpCookie("rememberme", loginModel.RememberMe.ToString().ToLower());
                userNameCookie.Expires = DateTime.Now.AddDays(365);

                Response.Cookies.Add(userNameCookie);

                return(DWZHelper.ReturnSuccAndClose("欢迎您回来!"));
            }
            else
            {
                return(DWZHelper.ReturnError("账号或密码输入错误"));
            }
        }
Exemple #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.Params["type"]))
            {
                //注销
                FormsPrincipal <CookUserInfo> .SignOut();

                Response.Redirect("/Login.aspx");
            }

            if (!IsPostBack)
            {
                if (Request["action"] == null)
                {
                    this.LoadMenu();
                }
            }

            //获取提现,充值人数
            if (Request["action"] != null)
            {
                GetBusinessCount();
            }
        }
        //玩家登陆
        private void Login(bool isfig = true)
        {
            var isLock = this.mLockIpInfoService.IsLockIp(Utils.GetIp());

            if (isLock)
            {
                //获取跳转地址
                AppGlobal.RenderResult(ApiCode.DisabledIp, this.GetRefDns());
                return;
            }

            //登陆名
            string loginCode = Request.Params["M_LOGINCODE"];
            //登陆密码
            string pwd = Request.Params["M_LOGINPWD"];
            //验证码
            string code = Request.Params["M_LOGINVIDACODE"];

            if (string.IsNullOrEmpty(loginCode) || string.IsNullOrEmpty(pwd))
            {
                AppGlobal.RenderResult(ApiCode.ParamEmpty);
                return;
            }
            if (string.IsNullOrEmpty(code) && isfig)
            {
                AppGlobal.RenderResult(ApiCode.ParamEmpty);
                return;
            }


            var item = this.mSysUserService.Get(loginCode, pwd);

            if (null == item)
            {
                AppGlobal.RenderResult(ApiCode.ValidationFails);
                return;
            }
            if (item.IsDelete)
            {
                AppGlobal.RenderResult(ApiCode.DisabledCode, this.GetRefDns());
                return;
            }


            string       sessionid = Guid.NewGuid().ToString();
            CookUserInfo info      = new CookUserInfo();

            info.Id         = item.Id;
            info.Code       = item.Code;
            info.NikeName   = item.NikeName;
            info.Sex        = sessionid;
            info.Head       = item.Head;
            info.Rebate     = item.Rebate;
            info.UserType   = item.UserType;
            info.IsRecharge = item.IsRecharge;
            info.PlayType   = item.PlayType;
            info.ProxyLevel = item.ProxyLevel;

            FormsPrincipal <CookUserInfo> .SignIn(loginCode, info, FormsAuthentication.Timeout.Minutes);

            //Ytg.ServerWeb.BootStrapper.SessionManager.AddOrUpdateSession(item.Id,new YtgSession()
            //{
            //    UserId = item.Id,
            //    SessionId = sessionid,
            //    OccDate = DateTime.Now,
            //    Code = item.Code
            //});


            string loginIpAddress = Ytg.Comm.Utils.GetIp();
            int    state          = this.mSysUserSessionService.UpdateInsertUserSession(new UserSession()
            {
                UserId      = item.Id,
                SessionId   = sessionid,
                LoginIp     = loginIpAddress,
                LoginClient = Ytg.Comm.Utils.GetLoginClientType(),
            });
            string loginCityName = "";//Utils.GetCityByIp(item.LastLoginIp);//获取所在城市
            string useSource     = System.Web.HttpContext.Current.Request.Params["usesource"];
            //判断是否为移动设备访问
            bool isMobile = Utils.IsMobile();

            if (isMobile)
            {
                useSource = "移动设备";
            }

            /**记录日志*/
            SysLog log = new SysLog()
            {
                Descript      = loginCityName,
                Ip            = loginIpAddress,
                OccDate       = DateTime.Now,
                ReferenceCode = info.Code,
                ServerSystem  = Ytg.Comm.Utils.GetUserSystem(),
                Type          = 0,
                UserId        = info.Id,
                UseSource     = useSource
            };

            /**记录日志 end*/

            //修改用户登录时间
            item.LastLoginTime = DateTime.Now;
            item.LastLoginIp   = loginIpAddress;
            item.IsLogin       = true;
            item.IsLineLogin   = true;
            item.LastCityName  = log.Descript;
            item.ServerSystem  = log.ServerSystem;
            item.UseSource     = log.UseSource;
            item.LoginCount++;//登录次数增加
            this.mSysUserService.Save();
            //单点登录
            // DanDianLogin(info.Id.ToString());

            //输出结果
            AppGlobal.RenderResult <CookUserInfo>(ApiCode.Success, info);
            //添加登录日志
            Ytg.Service.Logic.LogHelper.AddLog(log);
        }
Exemple #21
0
        public ActionResult Login(LoginVM loginModel)
        {
            ViewBag.IsShowValidateCode = false;

            if (ModelState.IsValid)
            {
                bool validatecode = true;
                if (Session["LoginError"] != null && Convert.ToInt32(Session["LoginError"]) >= 3)
                {
                    if (TempData.ContainsKey(SecurityController.VALIDATECODE))
                    {
                        string code = TempData[SecurityController.VALIDATECODE].ToString();
                        validatecode = loginModel.ValidateCode == code;
                    }
                    else
                    {
                        validatecode = false;
                    }
                }

                if (validatecode)
                {
                    SysUserVM sysUser = _accountBizProcess.Login(loginModel.SysUserName, loginModel.PasswordHash);
                    if (sysUser != null)
                    {
                        UserInfo userInfo = sysUser.ToUserInfo();
                        FormsPrincipal <UserInfo> .Login(sysUser.UserName, userInfo, 30);

                        Session["LoginError"] = null;

                        //登录成功写cookie
                        var userNameCookie = new HttpCookie("username", sysUser.UserName);
                        userNameCookie.Expires = DateTime.Now.AddDays(365);
                        var rememberMeCookie = new HttpCookie("rememberme", loginModel.RememberMe.ToString().ToLower());
                        userNameCookie.Expires = DateTime.Now.AddDays(365);

                        Response.Cookies.Add(userNameCookie);

                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "用户名或者密码输入错误!");
                    }
                }
                else
                {
                    ModelState.AddModelError("ValidateCode", "验证码输入错误!");
                }
            }

            Session["LoginError"] = Session["LoginError"] == null ? 0 : Convert.ToInt32(Session["LoginError"]) + 1;
            if (Convert.ToInt32(Session["LoginError"]) >= 3)
            {
                ViewBag.IsShowValidateCode = true;
            }

            //绑定错误信息
            ViewData.BindErrorMessage(ModelState);

            return(View(loginModel));
        }
Exemple #22
0
 /// <summary>
 /// 构造方法
 /// </summary>
 public ServerPushHandler(HttpContext context, ServerPushResult _IAsyncResult)
 {
     this.m_Context     = context;
     this._IAsyncResult = _IAsyncResult;
     m_CurrentUser      = (FormsPrincipal <UserInfo>)m_Context.User;
 }
 protected void Application_AuthenticateRequest(object sender, EventArgs e)
 {
     FormsPrincipal <UserInfo> .AddPermission(new string[2] {
         "admin", "user"
     });
 }
Exemple #24
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string code     = Request.Form["email"];
            string password = Request.Form["password"];

            if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(password))
            {
                Response.Write("<script>alert('请填写完整信息!');</script>");
                return;
            }

            //var userService = IoC.Resolve<ISysUserService>();
            //var userInfo = userService.GetAm(code, password);
            //if (userInfo == null || userInfo.UserType != Ytg.BasicModel.UserType.Manager)
            //{
            //    Response.Write("<script>alert('登录名不存在或密码错误!');</script>");
            //    return;
            //}

            var sysAccountService = IoC.Resolve <ISysAccountService>();

            var userInfo = sysAccountService.Login(code, password);

            if (userInfo == null)
            {
                Response.Write("<script>alert('登录名不存在或密码错误!');</script>");
                return;
            }
            else if (userInfo.IsEnabled == false)
            {
                Response.Write("<script>alert('当前账号已停用!');</script>");
                return;
            }
            else
            {
                //记录登录日志
                var sysAccountLogsService = IoC.Resolve <ISysAccountLogsService>();
                sysAccountLogsService.Create(new SysAccountLog()
                {
                    UserId       = userInfo.Id,
                    OccDate      = DateTime.Now,
                    Ip           = Ytg.Comm.Utils.GetIp(),
                    ServerSystem = Ytg.Comm.Utils.GetUserSystem(),
                    //   Descript = Utils.GetCityByIp(Ytg.Comm.Utils.GetIp())
                });
                sysAccountLogsService.Save();
            }

            string preLoginIp   = userInfo.LastLoginIp;
            string preLoginTime = userInfo.LastLoginTime != null?userInfo.LastLoginTime.Value.ToString("yyyy/MM/dd HH:mm:ss") : "";

            string curLoginIp = Utils.GetIp();//当前登录的Ip

            //修改登录IP和时间
            userInfo.PreLoginIp    = userInfo.LastLoginIp;
            userInfo.PreLoginTime  = userInfo.LastLoginTime;
            userInfo.LastLoginIp   = Utils.GetIp();
            userInfo.LastLoginTime = DateTime.Now;
            sysAccountService.Save();//保存信息

            //登录成功
            CookUserInfo cokUserInfo = new CookUserInfo()
            {
                Id       = userInfo.Id,
                Code     = userInfo.Code,
                NikeName = curLoginIp + "," + preLoginIp,
                Sex      = preLoginTime
            };

            FormsPrincipal <CookUserInfo> .SignIn(userInfo.Code, cokUserInfo, FormsAuthentication.Timeout.Minutes);

            //跳转至index.aspx
            Response.Redirect("/index.html");
        }
Exemple #25
0
        public void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            FormsPrincipal <UserInfo> .TrySetUserInfo(app.Context);
        }
Exemple #26
0
        /// <summary>
        /// 用户认证
        /// </summary>
        private void AjaxLogin(HttpContext context, string xname, string xpassword)
        {
            //var msg = new StringBuilder();
            var ip        = SingleQuery.Instance.Find(IpHelper.ClientIp);
            var ipAddress = string.Format("{0} {1}", new object[] { ip.Country, ip.Area });

            try
            {
                //msg.Append("000、======================>");
                var server = new AccountService();
                //msg.Append("001、======================>" + xpassword); ;
                //var password = EncryptUtil.Encrypt(xpassword);
                //msg.Append("002、======================>"+password);
                var accountNumber = xname.Trim();
                var account       = server.Where
                                        (p => (p.account_number == accountNumber || p.account_name == accountNumber) &&
                                        p.account_password == xpassword && p.deleteflag == 0)
                                    .FirstOrDefault();
                //msg.Append("1、读用户信息");

                if (account != null)
                {
                    // msg.Append("2、用户信息验证通过");
                    if (!account.account_flag.Equals(1))
                    {
                        _response = "{\"result\" :\"" + 0 + "\",\"returnval\" :\"" + "请所提供的帐号已被管理员禁用,请联系管理员。" + "\"}";
                        return;
                    }

                    //执行用户登录操作
                    int urlPort = context.Request.Url.Port;
                    //执行用户登录操作
                    FormsPrincipal <base_account> .SignIn(accountNumber,                                         //
                                                          new LoginUser(account.id,                              //
                                                                        account.account_name,                    //
                                                                        account.account_number,                  //
                                                                        account.account_number,                  //
                                                                        Convert.ToInt32(account.account_org_id), //
                                                                        Convert.ToInt32(account.FCompanyId),     //
                                                                        account.account_role_id,                 //
                                                                        urlPort),                                //
                                                          99999);

                    //最后一次登录时间
                    account.account_last_date = DateTime.Now;
                    account.account_ip        = IpHelper.ClientIp;
                    account.account_ip_addres = ipAddress;
                    server.SaveChanges();

                    //  msg.Append("3、记录用户本次登录信息");

                    var name = string.Format("{0}->{1}({2})", account.base_orgnization.org_name, //
                                             account.account_name, account.account_number);

                    //记录用户登录系统日志
                    var loginService = new LoginSevice();
                    var login        = new t_logins
                    {
                        account_name    = name,
                        account_ip      = IpHelper.ClientIp,
                        account_address = ipAddress,
                        account_id      = CurrentUser.Id,
                        action_on       = DateTime.Now,
                        action_desc     = "用户登录成功。"
                    };

                    loginService.Add(login);
                    //msg.Append("4、日志记录完毕");


                    //  msg.Append("5、调用友接口开始");
                    //接口
                    T6Account.Receiver    = "U8";
                    T6Account.Dynamicdate = DateTime.Now.ToString("MM/dd/yyyy");
                    T6Account.Sender      = "008";

                    // msg.Append("6、登录完成");
                    //context.Response.Redirect(FormsAuthentication.DefaultUrl);
                    _response = "{\"result\" :\"" + 1 + "\",\"returnval\" :\"" + "登录成功,正在转到主页..." + "\"}";
                }
                else
                {
                    _response = "{\"result\" :\"" + 0 + "\",\"returnval\" :\"" + "您所提供的用户名或者密码不正确,请联系管理员。" + "\"}";
                }
            }
            catch (Exception ex)
            {
                _response = "{\"result\" :\"" + 0 + "\",\"returnval\" :\"" + ex.Message + "\"}";//ex.Message
            }
        }
 /// <summary>
 /// 登出
 /// </summary>
 /// <returns></returns>
 public ActionResult Logout()
 {
     FormsPrincipal.Logout(GetHttpContext(_Request));
     return(RedirectToAction("Login"));
 }
        /// <summary>
        /// 注销登陆
        /// </summary>
        private void Logout()
        {
            FormsPrincipal <CookUserInfo> .SignOut();

            AppGlobal.RenderResult(ApiCode.Success);
        }
Exemple #29
0
        private void WinTTS()
        {
            var sings = FormsPrincipal <CookUserInfo> .TryParsePrincipal(Request);

            if (null == sings)
            {
                AppGlobal.RenderResult(ApiCode.ExitLogin);
                return;
            }
            var userdata = sings.UserData;

            if (null == userdata)
            {
                AppGlobal.RenderResult(ApiCode.ExitLogin);
                return;
            }

            //必须验证用户登录

            //真是中奖数据
            var result = mBetDetailService.GetRecentlyWin();

            if (null == result)
            {
                result = new List <RecentlyWinDTO>();
            }
            var wins = Ytg.ServerWeb.BootStrapper.SiteHelper.GetWinsMonery();

            if (wins != null)
            {
                int length   = wins.Count;//虚拟数据总条数
                var config   = SiteHelper.GetLotteryIdName();
                var keyArray = config.Keys.ToList();
                for (var i = 0; i < keyArray.Count; i++)
                {
                    var configIdStr = keyArray[i];
                    var opendIssue  = this.mLotteryIssueService.GetTop5OpendIssue(configIdStr);
                    if (opendIssue.Count < 1)
                    {
                        continue;
                    }

                    foreach (var tt in opendIssue)
                    {
                        if (wins.Count > 0)
                        {
                            var fs = wins[0];
                            result.Add(new RecentlyWinDTO()
                            {
                                Code        = fs.UserCode,
                                WinMoney    = fs.UserWinMonery,
                                IssueCode   = tt.IssueCode,
                                LotteryName = config[configIdStr]
                            });
                            wins.RemoveAt(0);
                        }
                    }
                }
            }

            result = result.OrderBy(x => x.Code).ToList();


            AppGlobal.RenderResult <List <RecentlyWinDTO> >(ApiCode.Success, result);
        }