public async Task GetNetTotals() { Network network = new Network(); NetTotalsOM result = await network.GetNetTotals(); Assert.IsNotNull(result); }
public static async Task <ApiResponse> GetNetTotals() { ApiResponse response = new ApiResponse(); try { Network network = new Network(); NetTotals totals = new NetTotals(); NetTotalsOM result = await network.GetNetTotals(); if (result != null) { totals.TimeMillis = result.TimeMillis; totals.TotalBytesRecv = result.TotalBytesRecv; totals.TotalBytesSent = result.TotalBytesSent; response.Result = Newtonsoft.Json.Linq.JToken.FromObject(totals); } 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); }
public async Task <NetTotalsOM> GetNetTotals() { AuthenticationHeaderValue authHeaderValue = null; RpcClient client = new RpcClient(new Uri("http://localhost:5006"), authHeaderValue, null, null, "application/json"); RpcRequest request = RpcRequest.WithNoParameters("GetNetTotals", 1); RpcResponse response = await client.SendRequestAsync(request); if (response.HasError) { throw new ApiCustomException(response.Error.Code, response.Error.Message); } NetTotalsOM responseValue = response.GetResult <NetTotalsOM>(); return(responseValue); }