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 EdaIntegrationContract;
using EdaIntegrationContract.Case;
using EdaIntegrationContract.Import;

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

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

        // Create an import builder that will be used to describe the data to import
        IImportSetBuilder 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 EdaIntegrationContract;
using EdaIntegrationContract.Case;
using EdaIntegrationContract.Process;

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

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

        bool check = true;
        ProcessingStatus stat = edaCase.ProcessingStatus;
        while (check)
        {
            Console.Write("\r The processing state of the case is ... ");

            // Check the status of the export
            switch (stat)
            {
                case ProcessingStatus.Pending:
                    Console.Write("Pending".PadRight(20, ' '));
                    break;
                case ProcessingStatus.Working:
                    Console.Write("Active".PadRight(20, ' '));
                    break;
                case ProcessingStatus.Suspended:
                case ProcessingStatus.Blacklisted:
                    Console.Write("Halted".PadRight(20, ' '));
                    check = false;
                    break;
                case ProcessingStatus.Complete:
                    Console.Write("Complete".PadRight(20, ' '));
                    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(2000);

            // Refresh the case status
            stat = edaCase.ProcessingStatus;
        }
    }
}
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 IExceptionManager 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 EdaIntegrationContract;
using EdaIntegrationContract.Case;
using EdaIntegrationContract.Import;
using EdaIntegrationContract.Exceptions;

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

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

        // Create an exception filter to limit the exceptions returned to only one Import Set
        IImportSet importSet = tiCase.Imports.ImportSets.ByLabel("Import Set 001");
        IExceptionFilter filter = tiCase.Exceptions.NewExceptionFilter();
        filter.ImportSetIds = new List<int> {importSet.Id};

        // Get all the exceptions
        IExceptionItem[] 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 (IExceptionItem 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