Follow

CheckStatus - C#

Last updated 2017-08-15 13:49:20 UTC

The best performing means of getting document status is to use DocumentTRAK to push notifications to your self hosted service.   In this example, we call CheckStatus on 3 documents at once.

Given the following local class to hold document metadata ...


private class aDocumentClass
{
    public Guid documentID { get; set; }
    public Guid authToken { get; set; }
    public string status{ get; set; }
    public aDocumentClass(Guid docID, Guid authT)
    {
        this.authToken = authT;
        this.documentID = docID;
    }
}

... the following calls CheckStatus on 3 documents at once ...


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

List<aDocumentClass> documents = new List<aDocumentClass>();
// 3 different documents, with their authtokens documents.Add(new aDocumentClass(new Guid("691EC525-1F67-418C-9E05-A7CA01269A52"), new Guid("AF38B382-21F8-4A26-BE43-531F29498DE3"))); documents.Add(new aDocumentClass(new Guid("E070DCDC-4CF2-46B7-A659-A7CA0126F422"), new Guid("852AD083-2093-4A03-9A75-C829213F02C2"))); documents.Add(new aDocumentClass(new Guid("55135265-ABE3-48DD-9911-A7CF00FE4459"), new Guid("152D5DDE-01BF-4BCE-99BF-F3F35F4E4E79"))); Guid ContextIdentifier = new Guid(<fromYourAccount>); DocNow.CheckStatusServiceClient client = new DocNow.CheckStatusServiceClient(); DocNow.DocumentStatusCheck[] checks = new DocNow.DocumentStatusCheck[documents.Count]; int i = 0; foreach (aDocumentClass doc in documents) { checks[i] = new DocNow.DocumentStatusCheck(); checks[i].Id = doc.documentID; checks[i].AuthToken = doc.authToken; checks[i].ContextIdentifier = ContextIdentifier; i++; } DocNow.DocumentStatusCheckResult[] results = client.CheckStatus(checks); if(results.Length>0) { foreach(DocNow.DocumentStatusCheckResult result in results) { if(result.Exceptions != null) { StringBuilder sb = new StringBuilder(); foreach (DocNow.StatusCheckException exception in result.Exceptions) { sb.AppendFormat("{0} : {1}{2}", exception.Severity.ToString(), exception.Value, Environment.NewLine); } Console.WriteLine(sb.ToString()); } else { var document = documents.Find(x => x.documentID.Equals(result.Id)); if(document != null) { document.status = result.StatusType.ToString(); } } } // now go do something with your documents List }
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.