예제 #1
0
    /// <summary>
    /// Generates a large number of documents
    /// </summary>
    public static void Generate(ImportAPI iapi, int workspaceId, int numDocs)
    {
        ImportBulkArtifactJob importJob = iapi.NewNativeDocumentImportJob();

        iapi.ExecutionSource = ExecutionSourceEnum.ImportAPI;

        const int    controlNumFieldArtifactId = 1003667;
        const string idFieldName     = "Control Number";
        const string nativeFileField = "FILE_PATH";

        importJob.OnMessage        += ImportJobOnMessage;
        importJob.OnComplete       += ImportJobOnComplete;
        importJob.OnFatalException += ImportJobOnFatalException;

        importJob.Settings.CaseArtifactId = workspaceId;
        importJob.Settings.ExtractedTextFieldContainsFilePath = true;
        importJob.Settings.ExtractedTextEncoding = Encoding.UTF8;
        importJob.Settings.NativeFileCopyMode    = NativeFileCopyModeEnum.CopyFiles;
        importJob.Settings.OverwriteMode         = OverwriteModeEnum.AppendOverlay;
        importJob.Settings.DisableControlNumberCompatibilityMode = true;
        importJob.Settings.SelectedIdentifierFieldName           = idFieldName;
        importJob.Settings.NativeFilePathSourceFieldName         = nativeFileField;
        importJob.Settings.IdentityFieldId = controlNumFieldArtifactId;

        const string file = @"S:\Data\Hamlet.docx";

        importJob.SourceData.SourceData =
            GenerateLoadTable(numDocs, file, idFieldName, nativeFileField)
            .CreateDataReader();
        Console.WriteLine("Executing import...");
        importJob.Execute();
    }
예제 #2
0
        public static void Import(ImportBulkArtifactJob importJob, DataTable data)
        {
            var errors = new List <Exception>();

            try
            {
                importJob.SourceData.SourceData = data.CreateDataReader();
                Console.WriteLine("Executing import...");

                importJob.OnError += report =>
                {
                    foreach (var key in report.Keys)
                    {
                        var value = report[key];
                        errors.Add(new Exception($"{key} : {value}"));
                    }
                };

                importJob.OnFatalException += report =>
                {
                    errors.Add(report.FatalException);
                };

                importJob.Execute();
                if (errors.Any())
                {
                    throw new AggregateException(errors);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
                throw;
            }
        }
예제 #3
0
 public BulkArtifactImportJob(
     ImportBulkArtifactJob job,
     ImportConnectionInfo connectionInfo,
     ImportContext context)
     : base(connectionInfo, context)
 {
     this.job      = job ?? throw new ArgumentNullException(nameof(job));
     this.Settings = new BulkArtifactImportSettings(this.job.Settings)
     {
         WorkspaceId = this.ConnectionInfo.WorkspaceId
     };
 }
 public void HydrateImportJob(ImportBulkArtifactJob importJob)
 {
     importJob.Settings.CaseArtifactId = WorkspaceID;
     importJob.Settings.ExtractedTextFieldContainsFilePath         = ExtractedTextFieldContainsFilePath;
     importJob.Settings.DisableExtractedTextEncodingCheck          = DisableExtractedTextEncodingCheck;
     importJob.Settings.DisableExtractedTextFileLocationValidation = DisableExtractedTextFileLocationValidation;
     importJob.Settings.NativeFilePathSourceFieldName   = NATIVE_FILE;
     importJob.Settings.DisableNativeLocationValidation = DisableNativeLocationValidation;
     importJob.Settings.DisableNativeValidation         = DisableNativeValidation;
     importJob.Settings.NativeFileCopyMode    = NativeFileCopyMode;
     importJob.Settings.OverwriteMode         = OverwriteMode;
     importJob.Settings.ExtractedTextEncoding = ExtractedTextEncoding;
     if (!string.IsNullOrEmpty(ParentObjectIdSourceFieldName))
     {
         importJob.Settings.ParentObjectIdSourceFieldName = ParentObjectIdSourceFieldName;
     }
 }