We 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,
April 28Created
January 21Last Updated
8 years agoLast Reply
1Replies
17Views
2Users
0Likes
0Links
harishaidary | Posts: 1812
Reply to: Download signed documents with a date range
Thursday, April 28, 2016 at 04:50am
0
votes
Hey,
Here's an example code on how you would download signed documents within a date range:
using 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!");
}
}
}
Reply to: Download signed documents with a date range
Thursday, April 28, 2016 at 04:50am