Importing documents into a case |
This set of examples shows how to perform the following:
This example creates a new custodian, assigns it the source document locations to import, and then schedules the import processing
Note |
---|
When importing data, any number or combination of files and folders can be assigned to a custodian. When adding a folder, the folder tree will be crawled and add all the files found within the folder tree (it does not crawl the folder structure until after the import processing begins). If you are adding sources to an existing custodian, you can select the custodian from the case and use its id when adding the source folder/files. Only the newly added sources will be processed. |
using Law.EdaIntegration; using Law.EdaIntegration.Case; using Law.EdaIntegration.Import; class Sample { public static void Main() { // Initialize the environment EdaIntegration edaIntegration = EdaIntegration.ConnectToExplore(); // Select the case where the new documents belong. string caseName = "My Case"; Case edaCase = edaIntegration.Cases.OpenCaseByName(caseName); // Create a new custodian Custodian custodian = edaCase.Custodians.Create("New Custodian 1"); // Add a folder source string folder = @"\\NetworkDrive\Folder1\Folder2\Documents"; edaCase.Sources.AddFolder(folder, custodian.Id); // Add a file source List<string> filesToAdd = new List<string> { @"\\NetworkDrive\Folder1\HiddenWorksheet.xlsx", @"\\NetworkDrive\Folder1\SlidesWithNotes.pptx", @"\\NetworkDrive\Folder1\PPT_2003_slides.ppt", }; edaCase.Sources.AddFiles(filesToAdd, custodian.Id); // Create a new import session and begin processing any new document sources. You may // supply a session label or allow the system to create a default label. ImportSession session = edaCase.Imports.ImportSessions.Create("Session1"); // Finally, commit the new sources and begin processing them. edaCase.Imports.ImportSessions.StartImport(session.Id); } }
You can check the status of the import processing in several ways. One possible way to do this is to continuously check the processing status for the case.
using System; using System.Threading; using Law.EdaIntegration; using Law.EdaIntegration.Case; using Law.EdaIntegration.Processing; class Sample { public static void Main() { // Initialize the environment EdaIntegration edaIntegration = EdaIntegration.ConnectToExplore(); // Open the case Case edaCase = edaIntegration.Cases.OpenCaseByName("My Case"); bool check = true; while (check) { // Import processing may take some time to complete so choose a time interval // appropriate to the number of documents being imported. Thread.Sleep(10000); // Refresh the case status ProcessingStatus stat = edaCase.ProcessingStatus; // Check the status of the export switch (stat) { case ProcessingStatus.Pending: case ProcessingStatus.Working: // Work is in queue or in progress // You can also optionally view the queue of work to be done for a case /* foreach(ProcessInfo proc in edaIntegration.Cases.GetProcessInfo(edaCase.Id)) { Console.WriteLine("Activity: {0}", proc.Activity); Console.WriteLine(" Status: {0}", proc.Status); Console.WriteLine(" Num Agents Running: {0}", proc.RunningCount); Console.WriteLine(" Agent List: {0}", String.Join(",", proc.ServiceAgentList)); } */ break; case ProcessingStatus.Suspended: case ProcessingStatus.Blacklisted: Console.WriteLine("The processing for the case has been suspended or blacklisted!"); check = false; break; case ProcessingStatus.Complete: Console.WriteLine("Import processing complete."); check = false; break; } } } }
There are many ways that the list of exceptions that occurred during the import processing can be retrieved. The ExceptionManager allows exceptions to be retrieved by custodian, file type, import session, exception type or any combination of the above. This example demonstrates retrieving and printing out all exceptions that occurred during the above import session.
using Law.EdaIntegration; using Law.EdaIntegration.Case; using Law.EdaIntegration.Exceptions; class Sample { public static void Main() { // Initialize the environment EdaIntegration edaIntegration = EdaIntegration.ConnectToExplore(); // Open the case Case edaCase = edaIntegration.Cases.OpenCaseByName("My Case"); // Create the exception filter to limit the exceptions returned to only the current session ImportSession session = edaCase.Imports.ImportSessions.ByLabel("Session1"); ExceptionFilter filter = new ExceptionFilter(); filter.SessionIds = new List<int> { session.Id }; // Get all the exceptions ExceptionItem[] exceptions = edaCase.Exceptions.All(filter).ToArray(); // Output the results in tabular form // Output the results in tabular form const string outputFormat = "{0, 6} {1, 6} {2, -38} {3, -60}"; Console.WriteLine(outputFormat, "Exc Id", "Doc Id", "File Ref", "Message"); Console.WriteLine(outputFormat, "======", "======", "======================================", "============================================================"); foreach (ExceptionItem exception in exceptions) { Console.WriteLine(outputFormat, exception.Id.ToString(), exception.DocumentId.ToString(), exception.FileReference.Length > 38 ? string.Concat("...", exception.FileReference?.Substring(exception.FileReference.Length - 35)) : exception.FileReference, exception.Message.Length > 60 ? string.Concat( exception.FileReference.Substring(0, 57), "...") : exception.Message ); } } }