Example #1
0
 public ActionResult Index(FormCollection collection)
 {
     RoadFlow.Platform.OnlineUsers onlineUsers = new RoadFlow.Platform.OnlineUsers();
     if (!base.Request.Form["ClearAll"].IsNullOrEmpty())
     {
         onlineUsers.RemoveAll();
     }
     if (!base.Request.Form["ClearSelect"].IsNullOrEmpty())
     {
         string text = base.Request.Form["checkbox_app"];
         if (!text.IsNullOrEmpty())
         {
             string[] array = text.Split(',');
             for (int i = 0; i < array.Length; i++)
             {
                 Guid test;
                 if (array[i].IsGuid(out test))
                 {
                     onlineUsers.Remove(test);
                 }
             }
         }
     }
     return(query(collection));
 }
Example #2
0
        public string CheckLogin()
        {
            string name  = Keys.SessionKeys.IsValidateCode.ToString();
            string name2 = Keys.SessionKeys.ValidateCode.ToString();
            string text  = base.Request.Form["Account"];
            string text2 = base.Request.Form["Password"];
            string text3 = base.Request.Form["VCode"];
            string b     = base.Request.Form["Force"];
            string str   = "(帐号:" + text + " 密码:" + text2 + " 验证码:" + text3 + ")";

            if (text.IsNullOrEmpty() || text2.IsNullOrEmpty())
            {
                RoadFlow.Platform.Log.Add("用户登录失败(帐号或密码为空)" + str, "", RoadFlow.Platform.Log.Types.用户登录);
                return("{\"status\":0,\"msg\":\"帐号或密码不能为空!\"}");
            }
            if (base.Session[name] != null && "1" == base.Session[name].ToString() && (base.Session[name2] == null || string.Compare(base.Session[name2].ToString(), text3.Trim1(), true) != 0))
            {
                RoadFlow.Platform.Log.Add("用户登录失败(验证码错误)" + str, "", RoadFlow.Platform.Log.Types.用户登录);
                return("{\"status\":0,\"msg\":\"验证码错误!\"}");
            }
            RoadFlow.Platform.Users   users     = new RoadFlow.Platform.Users();
            RoadFlow.Data.Model.Users byAccount = users.GetByAccount(text.Trim());
            if (byAccount == null || string.Compare(byAccount.Password, users.GetUserEncryptionPassword(byAccount.ID.ToString(), text2.Trim()), false) != 0)
            {
                base.Session[name] = "1";
                RoadFlow.Platform.Log.Add("用户登录失败(帐号或密码错误)" + str, "", RoadFlow.Platform.Log.Types.用户登录);
                return("{\"status\":0,\"msg\":\"帐号或密码错误!\"}");
            }
            if (byAccount.Status == 1)
            {
                base.Session[name] = "1";
                RoadFlow.Platform.Log.Add("用户登录失败(帐号已被冻结)" + str, "", RoadFlow.Platform.Log.Types.用户登录);
                return("{\"status\":0,\"msg\":\"帐号已被冻结!\"}");
            }
            RoadFlow.Platform.OnlineUsers   onlineUsers  = new RoadFlow.Platform.OnlineUsers();
            RoadFlow.Data.Model.OnlineUsers onlineUsers2 = onlineUsers.Get(byAccount.ID);
            if (onlineUsers2 != null && "1" != b)
            {
                string iP = onlineUsers2.IP;
                base.Session.Remove(name);
                return("{\"status\":2,\"msg\":\"当前帐号已经在" + iP + "登录,您要强行登录吗?\"}");
            }
            Guid guid = Guid.NewGuid();

            base.Session[Keys.SessionKeys.UserID.ToString()]       = byAccount.ID;
            base.Session[Keys.SessionKeys.UserUniqueID.ToString()] = guid;
            base.Session[Keys.SessionKeys.BaseUrl.ToString()]      = base.Url.Content("~/");
            base.Session[Keys.SessionKeys.UserName.ToString()]     = byAccount.Name;
            base.Response.Cookies.Add(new HttpCookie(Keys.SessionKeys.UserID.ToString(), byAccount.ID.ToString())
            {
                Expires = MyController.CurrentDateTime.AddDays(7.0)
            });
            onlineUsers.Add(byAccount, guid);
            base.Session.Remove(name);
            RoadFlow.Platform.Log.Add("用户登录成功(帐号:" + text + ")", "", RoadFlow.Platform.Log.Types.用户登录);
            return("{\"status\":1,\"msg\":\"成功!\"}");
        }
Example #3
0
        private ActionResult query(FormCollection collection)
        {
            RoadFlow.Platform.OnlineUsers onlineUsers = new RoadFlow.Platform.OnlineUsers();
            string name = string.Empty;

            if (collection != null)
            {
                name = base.Request.Form["Name"];
            }
            else
            {
                name = base.Request.QueryString["Name"];
            }
            base.ViewBag.Name = name;
            List <RoadFlow.Data.Model.OnlineUsers> list = onlineUsers.GetAll();

            if (!name.IsNullOrEmpty())
            {
                list = (from p in list
                        where p.UserName.IndexOf(name) >= 0
                        select p).ToList();
            }
            return(View(list));
        }