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 |
---|
Native exports are the only type of export currently supported by the Integration Library. |
using Law.EdaIntegration; using Law.EdaIntegration.Case; using Law.EdaIntegration.Exports; class Sample { public static void Main() { // Initialize the environment string connectionString = @"Data Source=localhost;Initial Catalog=EDA_Management;Integrated Security=False;User ID=myUserId;Password=myPassword"; EdaIntegration edaIntegration = new EdaIntegration(); edaIntegration.InitializeEnvironment(connectionString); // Select the case where the new documents belong. string caseName = @"My Case"; Case edaCase = edaIntegration.Cases.ByName(caseName); // Create an new export for the case. Export export = edaCase.Exports.Create("Export-001"); // Set the properties of the export // 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<Tag> { edaCase.Tags.ByName("Relevant"), edaCase.Tags.ByName("FurtherReview") }; export.Config.TagsToExclude = new List<Tag> { edaCase.Tags.ByName("Privileged") }; */ 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 Law.EdaIntegration; using Law.EdaIntegration.Case; using Law.EdaIntegration.Exports; class Sample { public static void Main() { // Initialize the environment string connectionString = @"Data Source=localhost;Initial Catalog=EDA_Management;Integrated Security=False;User ID=myUserId;Password=myPassword"; EdaIntegration edaIntegration = new EdaIntegration(); edaIntegration.InitializeEnvironment(connectionString); // Open the case Case edaCase = edaIntegration.Cases.ByName(@"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 Export export = edaCase.Exports.ByName("Export-001"); // 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 Law.EdaIntegration; using Law.EdaIntegration.Case; using Law.EdaIntegration.Exports; class Sample { public static void Main() { // Initialize the environment string connectionString = @"Data Source=localhost;Initial Catalog=EDA_Management;Integrated Security=False;User ID=myUserId;Password=myPassword"; EdaIntegration edaIntegration = new EdaIntegration(); edaIntegration.InitializeEnvironment(connectionString); // Get the export Case edaCase = edaIntegration.Cases.ByName(@"My Case"); Export export = edaCase.Exports.ByName("Export-001"); // Display the errors on the console foreach (ExportError 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 Law.EdaIntegration; using Law.EdaIntegration.Case; using Law.EdaIntegration.Exports; class Sample { public static void Main() { // Initialize the environment string connectionString = @"Data Source=localhost;Initial Catalog=EDA_Management;Integrated Security=False;User ID=myUserId;Password=myPassword"; EdaIntegration edaIntegration = new EdaIntegration(); edaIntegration.InitializeEnvironment(connectionString); // Get the export Case edaCase = edaIntegration.Cases.ByName(@"My Case"); Export 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 ExportDocumentManager 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.Id); if (docsReceived.Count >= batchSize) { // Mark items as received mgr.MarkAsReceived(docsReceived); // Clear the received list docsReceived.Clear(); } } } }