public async Task GetNetworkInfo() { Network network = new Network(); NetworkInfoOM result = await network.GetNetworkInfo(); Assert.IsNotNull(result); }
public async Task <NetworkInfoOM> GetNetworkInfo() { AuthenticationHeaderValue authHeaderValue = null; RpcClient client = new RpcClient(new Uri("http://localhost:5006"), authHeaderValue, null, null, "application/json"); RpcRequest request = RpcRequest.WithNoParameters("GetNetworkInfo", 1); RpcResponse response = await client.SendRequestAsync(request); if (response.HasError) { throw new ApiCustomException(response.Error.Code, response.Error.Message); } NetworkInfoOM responseValue = response.GetResult <NetworkInfoOM>(); return(responseValue); }
public static async Task <ApiResponse> GetNetworkInfo() { ApiResponse response = new ApiResponse(); try { Network network = new Network(); NetworkInfo list = new NetworkInfo(); NetworkInfoOM result = await network.GetNetworkInfo(); if (result != null) { list.Connections = result.Connections; list.IsRunning = result.IsRunning; list.MinimumSupportedVersion = result.MinimumSupportedVersion; list.ProtocolVersion = result.ProtocolVersion; list.Version = result.Version; response.Result = Newtonsoft.Json.Linq.JToken.FromObject(list); } else { response.Result = null; } } catch (ApiCustomException ex) { Logger.Singleton.Error(ex.Message); response.Error = new ApiError(ex.ErrorCode, ex.Message); } catch (Exception ex) { Logger.Singleton.Error(ex.Message); response.Error = new ApiError(ex.HResult, ex.Message); } return(response); }