Example #1
0
        private string GetUserStatus(MyRabbit.Entity.User user)
        {
            if (SingleLogin)
            {
                Application.Lock();
                IList <MyRabbit.Entity.User> users = Application[GlobalKeys.TotalLogonUsers] as List <MyRabbit.Entity.User>;
                Application.UnLock();

                bool online = users.Contains(user);
                if (online && user.IsLogon == 1)
                {
                    return("在线");
                }
                else if (!online && user.IsLogon == 1)
                {
                    return("锁定");
                }
                else
                {
                    return("离线");
                }
            }
            else
            {
                if (user.IsLogon == 1)
                {
                    return("在线");
                }
                else
                {
                    return("离线");
                }
            }
        }
Example #2
0
        protected void gvwUser_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            try
            {
                if (gvwUser.Rows[e.NewSelectedIndex].Cells[4].Text.Equals("离线"))
                {
                    ShowMessage("当前用户无需进行此操作!");
                    return;
                }

                IList <MyRabbit.Entity.User> users = Session[USERS] as List <MyRabbit.Entity.User>;
                MyRabbit.Entity.User         user  = users[e.NewSelectedIndex];
                if (user.Id.Equals(LogonUser.Id))
                {
                    ShowMessage("当前用户不能进行此操作!");
                    return;
                }

                Application.Lock();
                IList <MyRabbit.Entity.User> totalLogonUsers = Application[GlobalKeys.TotalLogonUsers] as List <MyRabbit.Entity.User>;

                user.IsLogon = 0;
                userService.Update(user);
                totalLogonUsers.Remove(user);
                Application[GlobalKeys.TotalLogonUsers] = totalLogonUsers;
                Application.UnLock();

                ShowMessage("操作成功!");
            }
            catch (Exception ex)
            {
                SysLog.Error(ex);
                GoToErrorPage();
            }
        }