Exporting documents from a case |
This set of examples shows how to perform the following:
This example creates a new export, configures it, and begins the export process.
Note |
---|
LAW Direct exports from Explore to LAW are supported only if LAW has been configured in the Explore environment and the LAW case already exists. LAW Direct exports using the Integration Library will not create the LAW case if it does not already exist. |
using EdaIntegrationContract; using EdaIntegrationContract.Case; using EdaIntegrationContract.Exports; class Sample { public static void Main() { // Initialize the environment var edaIntegration = new EdaIntegration().ConnectToExplore(); // Select the case where the new documents belong. ICase edaCase = edaIntegration.Cases.OpenCaseByName("My Case"); // Create a new export for the case. IExport export = edaCase.Exports.Create("My Native Export", ExportType.Native); // Configure it to export all filtered documents export.Config.Scope = ExportScope.Filtered; /* // Alternatively you could export only documents that have been // tagged with one or more tags. export.Config.Scope = ExportScope.Tagged; export.Config.TagsToInclude = new List<ITag> { edaCase.Tags.ByName("Relevant"), edaCase.Tags.ByName("FurtherReview") }; export.Config.TagsToExclude = new List<ITag> { edaCase.Tags.ByName("Privileged") }; */ // Set the properties of the export export.Config.AlphaNumericNumbering = true; export.Config.NumberingSeed = "Exp-1A"; export.Config.IncludeNativeFiles = true; export.Config.ExportTextToFile = false; export.Config.GeneratedLoadFileFormat = LoadFileFormat.None; edaCase.Exports.Update(export); // Start the export processing. edaCase.Exports.Start(export.Id); } }
You can check the status of the export processing in several ways. One possible way to do this is to continuously check the state of the export itself. This example opens the export in question and continuously loops checking the status.
using System; using System.Threading; using EdaIntegrationContract; using EdaIntegrationContract.Case; using EdaIntegrationContract.Exports; class Sample { public static void Main() { // Initialize the environment var edaIntegration = new EdaIntegration().ConnectToExplore(); // Open the case ICase edaCase = edaIntegration.Cases.OpenCaseByName("My Case"); bool check = true; while (check) { // Export processing may take some time to complete so choose a time interval // appropriate to the number of documents being exported. Thread.Sleep(10000); // Refresh the export data IExport export = edaCase.Exports.ByName("My Native Export"); // Check the status of the export switch (export.State) { case ExportState.ExceptionOccurred: // Print out the exception info Console.WriteLine("Exception occurred: {0}", export.Exception.ToString()); check = false; break; case ExportState.Complete: Console.WriteLine("Total Documents: {0}", export.TotalDocuments); Console.WriteLine("Total Exported: {0}", export.NumExported); Console.WriteLine("Error Count: {0}", export.NumErrors); check = false; break; } } } }
This example shows how to view any errors that occurred during the export processing.
using System; using EdaIntegrationContract; using EdaIntegrationContract.Case; using EdaIntegrationContract.Exports; class Sample { public static void Main() { // Initialize the environment var edaIntegration = new EdaIntegration().ConnectToExplore(); // Get the export ICase edaCase = edaIntegration.Cases.OpenCaseByName("My Case"); IExport export = edaCase.Exports.ByName("Export-001"); // Display the errors on the console foreach (IExportError err in export.Errors.All()) { Console.WriteLine("{0}: {1}", err.DocumentId, err.Message); } } }
This example shows how to retrieve the documents and/or metadata that have been exported.
Additionally, this example demonstrates calling MarkAsReceived to indicate which documents have been successfully processed through the Integration Library. By default, ExportDocumentManager.All returns only those that have not been marked as received. Calling MarkAsReceived is optional but provides the benefit that should your processing halt for any reason then the next call to ExportDocumentManager.All will pick up where it left off with minimal overlap. If this is not a concern then eliminating the call to MarkAsReceived may reduce your overall processing time.
Note |
---|
When ExportDocumentManager.All is called it takes as snapshot of all the documents ids that are currently available for export. If this method is called while the export processing is still occurring then the list may not include all documents. Repeating the call after the export processing has completed will include the remaining documents. |
using System; using System.Collections.Generic; using EdaIntegrationContract; using EdaIntegrationContract.Case; using EdaIntegrationContract.Exports; class Sample { public static void Main() { // Initialize the environment var edaIntegration = new EdaIntegration().ConnectToExplore(); // Get the export ICase edaCase = edaIntegration.Cases.OpenCaseByName("My Case"); IExport export = edaCase.Exports.ByName("Export-001"); // Create a list to hold the ids of the documents that are received from the // export. This list will ensure that if our processing is aborted for any // reason that we can pick up where we left off. List<int> docsReceived = new List<int>(); // Set the number of document to process before we update their received state const int batchSize = 10; // Retrieve the list of documents that were exported IExportDocumentManager mgr = export.Documents; // Loop through each document and display the export number and file // name on the system console foreach (IExportDocument doc in mgr.All()) { Console.WriteLine("{0}: {1}", doc.ExportNumber, doc.FileName); // Accumulate the document ids so we can mark them as received docsReceived.Add(doc.InventoryId); if (docsReceived.Count >= batchSize) { // Mark items as received mgr.MarkAsReceived(docsReceived); // Clear the received list docsReceived.Clear(); } } } }