Download signed documents with a date range
Thursday, April 28, 2016 at 04:16amWe have a user that would like to download all signed documents for the past week under his account. Would anyone have a sample code on how to do that?
Thanks,
OneSpan Introduces DigipassONE, Bringing a Unified Platform Approach to Authentication Modernization
A new authentication platform helps financial institutions support diverse customer authentication preferences while modernizing at their own pace Learn More
Reply to: Download signed documents with a date range
Thursday, April 28, 2016 at 04:50amusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using Silanis.ESL.SDK; using Silanis.ESL.SDK.Builder; using System.Diagnostics; using System.IO; namespace DownloadDocumentsDateRange { class DownloadDocuments { //replace apiKey placeholder with your own value private static String apiUrl = "https://sandbox.e-signlive.com/api"; private static String apiKey = "your_api_key"; public static void Main(string[] args) { EslClient eslClient = new EslClient(apiKey, apiUrl); //starting point to retrieve completed packages int index = 1; //Retrieve first 50 completed packages. Packages are returned as a page from eSignLive. Page completed_packages = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, new PageRequest(index, 50), DateTime.Today.AddDays(-7), DateTime.Now);
while (index = completed_packages.TotalElements)
{
foreach (DocumentPackage package in completed_packages)
{
//for each completed package, get the package id to download signed documents.
Debug.WriteLine("Downloading package: " + package.Id + "...");
byte[] zipContent = eslClient.DownloadZippedDocuments(package.Id);
File.WriteAllBytes(Directory.GetCurrentDirectory() + "/package-documents-" + package.Id.ToString() + ".zip", zipContent);
index++;
Thread.Sleep(1000);
}
//Retrieve next 50 packages
completed_packages = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, new PageRequest(index, 50), DateTime.Today.AddDays(-7), DateTime.Now);
}
Debug.WriteLine("Downloaded All File!");
}
}
} Let me know if anything is unclear :)