public void LoadClients(List <Guid> clientIds, Action <LoadClientsResponse> callback)
            {
                Guid messageId = Guid.NewGuid();

                Task.Factory.StartNew(() => {
                    try {
                        using (var service = CreateService()) {
                            LoadClientsRequest request = new LoadClientsRequest {
                                MessageId = messageId,
                                LoginName = LoginName,
                                ClientIds = clientIds,
                                Timestamp = DateTime.Now
                            };
                            request.SignIt(Password);
                            LoadClientsResponse response = service.LoadClients(request);
                            callback?.Invoke(response);
                        }
                    }
                    catch (CommunicationException e) {
                        Global.DebugLine(e.Message, ConsoleColor.Red);
                        callback?.Invoke(LoadClientsResponse.ClientError(messageId, e.Message));
                    }
                    catch (Exception e) {
                        Global.Logger.Error(e.Message, e);
                        callback?.Invoke(LoadClientsResponse.ClientError(messageId, e.Message));
                    }
                });
            }
 public LoadClientsResponse LoadClients(LoadClientsRequest request)
 {
     if (request == null)
     {
         return(LoadClientsResponse.InvalidInput(Guid.Empty, "参数错误"));
     }
     try {
         if (string.IsNullOrEmpty(request.LoginName))
         {
             return(LoadClientsResponse.InvalidInput(request.MessageId, "登录名不能为空"));
         }
         if (!HostRoot.Current.UserSet.TryGetKey(request.LoginName, out IUser key))
         {
             return(LoadClientsResponse.Forbidden(request.MessageId));
         }
         if (!request.Timestamp.IsInTime())
         {
             return(LoadClientsResponse.Expired(request.MessageId));
         }
         if (request.ClientIds == null || request.ClientIds.Count == 0)
         {
             return(LoadClientsResponse.InvalidInput(request.MessageId, "clientIds为空"));
         }
         if (request.Sign != request.GetSign(key.Password))
         {
             return(LoadClientsResponse.Forbidden(request.MessageId, "签名验证未通过"));
         }
         var data = HostRoot.Current.ClientSet.LoadClients(request.ClientIds) ?? new List <ClientData>();
         return(new LoadClientsResponse(data));
     }
     catch (Exception e) {
         Global.Logger.ErrorDebugLine(e.Message, e);
         return(LoadClientsResponse.ServerError(request.MessageId, e.Message));
     }
 }