private async Task <DMResponse> SendRequestAsync(string command, bool readOnly, bool logResponseContent = true) { traceType.WriteInfo("Sending {0} command: {1}", readOnly ? "read" : "write", command); var watch = Stopwatch.StartNew(); DMResponse response = await dmClient.SendRequestAsync(command, null, readOnly); string message = string.Format( "DM response to command '{0}': HTTP {1}, status {2}, elapsed {3} msec\n{4}", command, response.HttpResponseCode, response.Status, watch.ElapsedMilliseconds, logResponseContent ? response.Response : $"(response content omitted; length = {response.Response?.Length})"); if (response.Status == DMServerResponseCode.Ok) { traceType.WriteInfo("{0}", message); } else { traceType.WriteWarning("{0}", message); } return(response); }
private void VerifyResponse(DMResponse response) { if (response.Status != DMServerResponseCode.Ok) { throw new DMClientException(response); } }
public void DMResponseObjectTest() { DMResponse sample = new DMResponse(); sample.rc = "1"; sample.reqId = "id"; Assert.AreEqual("1", sample.rc); Assert.AreEqual("id", sample.reqId); }
public DMClientException(DMResponse response) : base($"DM returned response with status {response.Validate("response").Status}") { this.Response = response; }