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