Example #1
0
 public void RemoveUser(string userIndex, string userNames, LoginInfo info)
 {
     try
     {
         var arr         = userIndex.Split(',');
         var userNameArr = userNames.Split(',');
         for (var i = arr.Length - 1; i > -1; i--)
         {
             var userId = int.Parse(arr[i]);
             Dbop.Delete(userId);//litedb不起作用
             Dbop.DeleteHash(userNameArr[i]);
             ServerContext.logger.Info($"{info.username}删除了用户{userNameArr[i]}");
         }
     }
     catch (Exception ex)
     {
         throw new Exception("删除用户出错:" + ex.Message);
     }
 }
Example #2
0
        public void RemoveUser(string userIndex, string userNames)
        {
            try
            {
                var arr         = userIndex.Split(',');
                var userNameArr = userNames.Split(',');
                //for (var i = arr.Length - 1; i > -1; i--)
                //{
                //    Dbop.Delete(int.Parse(arr[i]));
                //    Dbop.DeleteHash(userNameArr[i]);
                //}

                //删除用户绑定
                lock (userLocker)
                {
                    if (ServerContext.ServerConfig.BoundConfig.UserPortBounds.ContainsKey(userIndex))
                    {
                        ServerContext.ServerConfig.BoundConfig.UserPortBounds.Remove(userIndex);
                    }
                }
                //刷新绑定列表
                ServerContext.UpdatePortMap();
                ServerContext.ServerConfig.SaveChanges(ServerContext.ServerConfigPath);
                for (var i = arr.Length - 1; i > -1; i--)
                {
                    var userId  = int.Parse(arr[i]);
                    var userDto = Dbop.Get(userNameArr[i]).ToObject <UserDTO>();
                    Dbop.Delete(userId);//litedb不起作用
                    Dbop.DeleteHash(userNameArr[i]);
                    ServerContext.CloseAllSourceByClient(int.Parse(userDto.userId));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("删除用户出错:" + ex.Message);
            }
        }