예제 #1
0
        /// <summary>
        /// 添加一个用户到在线用户表
        /// </summary>
        public bool Add(RoadFlow.Data.Model.Users user, Guid uniqueID)
        {
            if (user == null)
            {
                return(false);
            }
            var  onList = GetAll();
            bool isadd  = false;
            var  onUser = onList.Find(p => p.ID == user.ID);

            if (onUser == null)
            {
                isadd  = true;
                onUser = new RoadFlow.Data.Model.OnlineUsers();
                var station = new UsersRelation().GetMainByUserID(user.ID);
                if (station != null)
                {
                    onUser.OrgName = new Organize().GetAllParentNames(station.OrganizeID);
                }
            }
            onUser.ID         = user.ID;
            onUser.ClientInfo = string.Concat("操作系统:", RoadFlow.Utility.Tools.GetOSName(), "  浏览器:", RoadFlow.Utility.Tools.GetBrowse());
            onUser.IP         = RoadFlow.Utility.Tools.GetIPAddress();
            onUser.LastPage   = "";
            onUser.LoginTime  = RoadFlow.Utility.DateTimeNew.Now;
            onUser.UniqueID   = uniqueID;
            onUser.UserName   = user.Name;
            if (isadd)
            {
                onList.Add(onUser);
            }
            set(onList);
            return(true);
        }
예제 #2
0
        public bool Add(RoadFlow.Data.Model.Users user, Guid uniqueID)
        {
            if (user == null)
            {
                return(false);
            }
            List <RoadFlow.Data.Model.OnlineUsers> all = this.GetAll();
            bool flag = false;

            RoadFlow.Data.Model.OnlineUsers onlineUsers = all.Find((Predicate <RoadFlow.Data.Model.OnlineUsers>)(p => p.ID == user.ID));
            if (onlineUsers == null)
            {
                flag        = true;
                onlineUsers = new RoadFlow.Data.Model.OnlineUsers();
                RoadFlow.Data.Model.UsersRelation mainByUserId = new UsersRelation().GetMainByUserID(user.ID);
                if (mainByUserId != null)
                {
                    onlineUsers.OrgName = new Organize().GetAllParentNames(mainByUserId.OrganizeID, false, " / ");
                }
            }
            onlineUsers.ID         = user.ID;
            onlineUsers.ClientInfo = "操作系统:" + Tools.GetOSName() + "  浏览器:" + Tools.GetBrowse();
            onlineUsers.IP         = Tools.GetIPAddress();
            onlineUsers.LastPage   = "";
            onlineUsers.LoginTime  = DateTimeNew.Now;
            onlineUsers.UniqueID   = uniqueID;
            onlineUsers.UserName   = user.Name;
            if (flag)
            {
                all.Add(onlineUsers);
            }
            this.set(all);
            return(true);
        }
예제 #3
0
        public bool Remove(Guid userID)
        {
            List <RoadFlow.Data.Model.OnlineUsers> all = this.GetAll();

            RoadFlow.Data.Model.OnlineUsers onlineUsers = all.Find((Predicate <RoadFlow.Data.Model.OnlineUsers>)(p => p.ID == userID));
            if (onlineUsers != null)
            {
                all.Remove(onlineUsers);
            }
            this.set(all);
            return(true);
        }
예제 #4
0
        public string CheckLogin()
        {
            string name1  = Keys.SessionKeys.IsValidateCode.ToString();
            string index1 = Keys.SessionKeys.ValidateCode.ToString();
            string str1   = this.Request.Form["Account"];
            string str2   = this.Request.Form["Password"];
            string str3   = this.Request.Form["VCode"];
            string str4   = this.Request.Form["Force"];
            string str5   = "(帐号:" + str1 + " 密码:" + str2 + " 验证码:" + str3 + ")";

            if (str1.IsNullOrEmpty() || str2.IsNullOrEmpty())
            {
                RoadFlow.Platform.Log.Add("用户登录失败(帐号或密码为空)" + str5, "", RoadFlow.Platform.Log.Types.用户登录, "", "", (RoadFlow.Data.Model.Users)null);
                return("{\"status\":0,\"msg\":\"帐号或密码不能为空!\"}");
            }
            if (this.Session[name1] != null && "1" == this.Session[name1].ToString() && (this.Session[index1] == null || string.Compare(this.Session[index1].ToString(), str3.Trim1(), true) != 0))
            {
                RoadFlow.Platform.Log.Add("用户登录失败(验证码错误)" + str5, "", RoadFlow.Platform.Log.Types.用户登录, "", "", (RoadFlow.Data.Model.Users)null);
                return("{\"status\":0,\"msg\":\"验证码错误!\"}");
            }
            RoadFlow.Platform.Users   users     = new RoadFlow.Platform.Users();
            RoadFlow.Data.Model.Users byAccount = users.GetByAccount(str1.Trim());
            if (byAccount == null || string.Compare(byAccount.Password, users.GetUserEncryptionPassword(byAccount.ID.ToString(), str2.Trim()), false) != 0)
            {
                this.Session[name1] = (object)"1";
                RoadFlow.Platform.Log.Add("用户登录失败(帐号或密码错误)" + str5, "", RoadFlow.Platform.Log.Types.用户登录, "", "", (RoadFlow.Data.Model.Users)null);
                return("{\"status\":0,\"msg\":\"帐号或密码错误!\"}");
            }
            if (byAccount.Status == 1)
            {
                this.Session[name1] = (object)"1";
                RoadFlow.Platform.Log.Add("用户登录失败(帐号已被冻结)" + str5, "", RoadFlow.Platform.Log.Types.用户登录, "", "", (RoadFlow.Data.Model.Users)null);
                return("{\"status\":0,\"msg\":\"帐号已被冻结!\"}");
            }
            RoadFlow.Platform.OnlineUsers   onlineUsers1 = new RoadFlow.Platform.OnlineUsers();
            RoadFlow.Data.Model.OnlineUsers onlineUsers2 = onlineUsers1.Get(byAccount.ID);
            if (onlineUsers2 != null && "1" != str4)
            {
                string ip = onlineUsers2.IP;
                this.Session.Remove(name1);
                return("{\"status\":2,\"msg\":\"当前帐号已经在" + ip + "登录,您要强行登录吗?\"}");
            }
            Guid uniqueID = Guid.NewGuid();

            this.Session[Keys.SessionKeys.UserID.ToString()] = (object)byAccount.ID;
            HttpSessionStateBase session1 = this.Session;

            Keys.SessionKeys sessionKeys = Keys.SessionKeys.UserUniqueID;
            string           index2      = sessionKeys.ToString();
            // ISSUE: variable of a boxed type
            __Boxed <Guid> local = (ValueType)uniqueID;

            session1[index2] = (object)local;
            HttpSessionStateBase session2 = this.Session;

            sessionKeys = Keys.SessionKeys.BaseUrl;
            string index3 = sessionKeys.ToString();
            string str6   = this.Url.Content("~/");

            session2[index3] = (object)str6;
            HttpSessionStateBase session3 = this.Session;

            sessionKeys = Keys.SessionKeys.UserName;
            string index4 = sessionKeys.ToString();
            string name2  = byAccount.Name;

            session3[index4] = (object)name2;
            HttpCookieCollection cookies = this.Response.Cookies;

            sessionKeys = Keys.SessionKeys.UserID;
            cookies.Add(new HttpCookie(sessionKeys.ToString(), byAccount.ID.ToString())
            {
                Expires = MyController.CurrentDateTime.AddDays(7.0)
            });
            onlineUsers1.Add(byAccount, uniqueID);
            this.Session.Remove(name1);
            RoadFlow.Platform.Log.Add("用户登录成功(帐号:" + str1 + ")", "", RoadFlow.Platform.Log.Types.用户登录, "", "", (RoadFlow.Data.Model.Users)null);
            return("{\"status\":1,\"msg\":\"成功!\"}");
        }