Exemple #1
0
 public ActionResult LoginOut(string uid)
 {
     var guid = new Guid(uid);
     UsersBLL uBll=new UsersBLL();
     var user = uBll.GetPartUserByUidAndPwd(guid);
     if (user != null)
     {
         user.IsOnline = 0;
         uBll.Update(user, null);
     }
     return Content("");
 }
        /// <summary>
        /// 说明:初始化调用构造函数后可能不可用的数据。
        /// </summary>
        /// <param name="requestContext"></param>
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);
            SpeechInfoBLL bll = new SpeechInfoBLL();
            citys = bll.GetCitys();

            WorkContext.IsHttpAjax = WebHelper.IsAjax();
            WorkContext.Url = WebHelper.GetUrl();
            WorkContext.UrlReferrer = WebHelper.GetUrlReferrer();
            WorkContext.IP = WebHelper.GetIP();
            // WebHelper.GetIP();

            if (string.IsNullOrWhiteSpace(WorkContext.IP) || WorkContext.IP == "127.0.0.1")
            {
                WorkContext.CityName = "重庆市";
            }
            else
            {
                //测试地址搜索#region 测试地址搜索
                IPScaner objScan = new IPScaner();
                string ip = Request.UserHostAddress.ToString();
                objScan.DataPath = Server.MapPath("/App_data/qqwry.Dat");
                objScan.IP = WorkContext.IP;
                //"113.200.29.90";
                string addre = objScan.IPLocation();
                int IndexofA = addre.IndexOf("省") + 1;
                WorkContext.CityName = addre.Substring(IndexofA);
            }
            UsersEntity userInfo = new UsersEntity();
            Guid uid = ShopUtils.GetUidCookie();
            //获得保存在cookie中的密码
            string encryptPwd = ShopUtils.GetCookiePassword();
            UsersBLL userBll = new UsersBLL();
            if (Session["User"] != null)
            {
                CurrentUser = Session["User"] as UsersEntity;
                userInfo = CurrentUser;
            }
            else
            {

                userInfo = userBll.GetPartUserByUidAndPwd(uid);
              //  requestContext.HttpContext.Response.Write("<script>alert('登录超时!');window.location.reload();</script>");
            }

            if (userInfo != null && !Guid.Empty.Equals(userInfo.Id))
            {
                WorkContext.Uid = userInfo.Id;
                WorkContext.Password = userInfo.Password;
                WorkContext.UserEmail = userInfo.Email;
                WorkContext.NickName = string.IsNullOrWhiteSpace(userInfo.NickName) ? userInfo.Email : userInfo.NickName;
            }

            //从cookie中获取用户的基本信息
        }