CheckEnvelopeStatus - C#

The best performing means of getting document or envelope status is to use DocumentTRAK to push notifications to your self hosted service.

Copy
// DocumentNOW V2 CheckEnvelopeStatus example
// assuming we set the namespace on the service proxy to DocNow ...

// force TLS 1.2 if .net < 4.6
ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

Guid accountContextID = new Guid(<fromYourAccount>);
Guid envelopeId = new Guid(<fromSubmission>);
Guid authToken = new Guid(<fromSubmission>);

DocNow.EnvelopeServiceClient client = new DocNow.EnvelopeServiceClient("BasicHttpBinding_IEnvelopeService1");
DocNow.CheckEnvelopeStatusRequest request = new DocNow.CheckEnvelopeStatusRequest();
request.ContextIdentifier = accountContextID;
request.EnvelopeId = envelopeId;
request.AuthToken = authToken;

DocNow.CheckEnvelopeStatusResult result = client.CheckEnvelopeStatus(request);

if(result.Exceptions != null)
{
    StringBuilder sb = new StringBuilder();
    foreach (DocNow.EnvelopeException exception in result.Exceptions)
    {
        sb.AppendFormat("{0}{1} : {2}", Environment.NewLine, exception.Severity.ToString(), exception.Value);
    }
    throw new Exception($"Errors occurred calling CheckEnvelopeStatus:{sb.ToString()}");
}
else
{
    Console.WriteLine($"{result.Status}");
    // envelope history
    foreach (DocNow.EnvelopeHistoryEvent evt in result.History)
    {
        Console.WriteLine($"{evt.Date} : {evt.Details}");
    }
    foreach (DocNow.EnvelopeDocument document in result.Documents)
    {
        Console.WriteLine($"{document.DocumentId}");
        Console.WriteLine($"{document.Name}");
        Console.WriteLine($"{document.Status}");
        // each document's history
        foreach (DocNow.EnvelopeDocumentHistoryEvent evt in document.History)
        {
            Console.WriteLine($"{evt.Date} : {evt.Details}");
        }
    }
}