Click or drag to resize

Importing documents using Turbo Import

Demonstrates
Example - Start Import Processing

This example creates a new custodian, assigns it the source document locations to import, and then schedules the import processing

Note 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.

C#
using Law.EdaIntegration;
using Law.EdaIntegration.Case;
using Law.EdaIntegration.Import;

class Sample
{
    public static void Main()
    {
        // Initialize the environment
        EdaIntegration edaIntegration = EdaIntegration.ConnectToLawTurboImport();

        // Select the case where the new documents belong.
        string caseName = "My Case";
        Case tiCase = edaIntegration.Cases.OpenCaseByName(caseName);

        // Create an import builder that will be used to describe the data to import
        ImportSetBuilder builder = tiCase.Imports.ImportSets.GetNewBuilder();

        // Add some files and/or folders
        List<string> filesToAdd = new List<string>
        {
            @"\\NetworkDrive\Folder1\HiddenWorksheet.xlsx",
            @"\\NetworkDrive\Folder1\SlidesWithNotes.pptx",
            @"\\NetworkDrive\Folder1\Office_Memorandum.doc",
            @"\\NetworkDrive\Folder2",
        };
        builder.AddSources(filesToAdd, true);

        // Queue up the import set for processing
        tiCase.Imports.ImportSets.StartImport(builder);
    }
}
Example - Checking the Status of Import Processing

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.

C#
using System;
using System.Threading;
using Law.EdaIntegration;
using Law.EdaIntegration.Case;
using Law.EdaIntegration.Process;

class Sample
{
    public static void Main()
    {
        // Initialize the environment
        EdaIntegration edaIntegration = EdaIntegration.ConnectToLawTurboImport();

        // Open the case
        Case tiCase = edaIntegration.Cases.OpenCaseByName("My Case");

        bool check = true;
        while (check)
        {
            // Refresh the case status
            ProcessingStatus stat = tiCase.ProcessingStatus;

            Console.Write("\r The processing state of the case is: ");

            // Check the status of the export
            switch (stat)
            {
                case ProcessingStatus.Pending:
                    Console.Write("Pending");;
                    break;

                case ProcessingStatus.Working:
                    Console.Write("Active ");

                    // You can also optionally view the queue of work to be done for a case
                    /*
                      foreach(ProcessInfo proc in edaIntegration.Cases.GetProcessInfo(tiCase.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.Write("Halted ");
                    check = false;
                    break;
                case ProcessingStatus.Complete:
                    Console.Write("Complete");
                    check = false;
                    break;
            }
            // Import processing may take some time to complete so choose a time interval 
            // appropriate to the number of documents being imported.
            Thread.Sleep(10000);

        }
    }
}
Example - Retrieving any exceptions that occurred during import processing

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 Sets, exception type, or any combination of the above. This example demonstrates retrieving and display all exceptions that occurred for the above import set.

C#
 using Law.EdaIntegration;
 using Law.EdaIntegration.Case;
 using Law.EdaIntegration.Exception;

class Sample
{
    public static void Main()
    {
        // Initialize the environment
        EdaIntegration edaIntegration = EdaIntegration.ConnectToLawTurboImport();

        // Open the case
        Case tiCase = edaIntegration.Cases.OpenCaseByName("My Case");

        // Create an exception filter to limit the exceptions returned to only one Import Set
        ImportSet importSet = theCase.Imports.ImportSets.ByLabel("Import Set 001");
        var filter = new ExceptionFilter { ImportSetIds = new List<int> {importSet.Id} };

        // Get all the exceptions
        ExceptionItem[] exceptions = tiCase.Exceptions.All(filter).ToArray();

        // 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
                );
        }
    }
}
See Also