private void GetAll(IWebClient client) { var request = new GetAllServicesRequest(); try { var response = client.GetResponse(request); Console.WriteLine("==========================Result=========================="); Console.WriteLine("Response: \r\n{0}", response.ResponseJsonString); Console.WriteLine("==========================Result=========================="); } catch (ServerException ex) { Console.WriteLine("ServerException happened: \r\n\tErrorCode: {0}\r\n\tErrorMessage: {1}", ex.ErrorCode, ex.ErrorMessage); } catch (ClientException ex) { Console.WriteLine("ClientException happened: \r\n\tRequestId: {0}\r\n\tErrorCode: {1}\r\n\tErrorMessage: {2}", ex.RequestId, ex.ErrorCode, ex.ErrorMessage); } catch (Exception ex) { Console.WriteLine("Unknown Exception happened: {0}\r\n{1}", ex.Message, ex.StackTrace); } }
/// <summary> /// 获得所有服务 /// </summary> /// <param name="serverID"></param> /// <returns></returns> public List <WindowsService> GetAllServices(string serverID) { List <WindowsService> list = new List <WindowsService>(); GetAllServicesRequest request = new GetAllServicesRequest(); var server = serverbll.GetServer(serverID); Client client = new Client(); string url = client.GetRealUrl(request, server.Url); var response = SDKFactory.Client.Execute(request, url: url); if (response.IsError) { throw new Exception(response?.ErrorMessage); } return(response.Services); }