예제 #1
0
        public void addUserOnline(string userName, string Ip, string timeLogin, int company)
        {
            bool            isExist  = false;
            UserOnlineModel model    = new UserOnlineModel();
            DateTime        date     = Convert.ToDateTime(timeLogin);
            string          clientId = GetClientID();
            int             count    = listUserName.Where(m => m.UserName.Trim() == userName.Trim() && m.Date == date && m.Company == company).Count <UserOnlineModel>();

            foreach (var item in listUserName)
            {
                if (item.ClientID.Trim() == clientId.Trim() || count > 0)
                {
                    isExist = true;
                    break;
                }
            }
            if (!isExist)
            {
                model.ClientID = clientId;
                model.Date     = Convert.ToDateTime(timeLogin);
                model.UserName = userName;
                model.IP       = Ip;
                model.IsOnline = true;
                model.Company  = company;
                listUserName.Add(model);
            }

            //else
            //{
            //    listUserName[index].ClientID = clientId;
            //    listUserName[index].Date= DateTime.Now;
            //}
        }
예제 #2
0
        public void removeUserOnline(string clientId)
        {
            bool            isExist = false;
            UserOnlineModel model   = new UserOnlineModel();

            foreach (var item in listUserName)
            {
                if (item.ClientID.Trim() == clientId.Trim())
                {
                    model   = item;
                    isExist = true;
                    break;
                }
            }
            if (isExist)
            {
                listUserName.Remove(model);
            }
        }