Click or drag to resize

Importing documents into a case

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().ConnectToExplore();

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

        // Create an import builder describing the data to import
        // (See IImportSetBuilder documentation for more info on the many 
        //  options for importing data)
        IImportSetBuilder builder = edaCase.Imports.ImportSets.GetNewBuilder();

        // Optionally create a new custodian for the data. 
        ICustodian cust = builder.AddCustodian("New Custodian 1");

        // Add a folder and some loose files for the custodian
        List<string> filesToAdd = new List<string>
        {
            @"\\NetworkDrive\Folder1\HiddenWorksheet.xlsx",
            @"\\NetworkDrive\Folder1\SlidesWithNotes.pptx",
            @"\\NetworkDrive\Folder1\PPT_2003_slides.ppt",
            @"\\NetworkDrive\Folder1\Folder2\Documents",
        };
        builder.AddSources(filesToAdd, cust);

        // Finally, commit the new sources and begin processing them.
        edaCase.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().ConnectToExplore();

        // Open the case
        ICase edaCase = 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 set, exception type or any combination of the above. This example demonstrates retrieving and printing out all exceptions that occurred during the import of 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().ConnectToExplore();

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

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

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