예제 #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();
    }
        public static void CreateDocumentsWithFolderArtifactID(Int32 workspaceID, int folderArtifactID, IDBContext workspaceDbContext, int documentCount = 5)
        {
            int identityFieldArtifactId = ArtifactHelpers.Fields.GetFieldArtifactID(Relativity.Test.Helpers.ArtifactHelpers.Document.GetDocumentIdentifierFieldName(workspaceDbContext, 10), workspaceDbContext);

            var iapi      = new ImportAPI(SharedTestHelpers.ConfigurationHelper.ADMIN_USERNAME, SharedTestHelpers.ConfigurationHelper.DEFAULT_PASSWORD, string.Format("{0}://{1}/Relativitywebapi/", SharedTestHelpers.ConfigurationHelper.SERVER_BINDING_TYPE, SharedTestHelpers.ConfigurationHelper.RSAPI_SERVER_ADDRESS));
            var importJob = iapi.NewNativeDocumentImportJob();

            importJob.Settings.CaseArtifactId = workspaceID;
            importJob.Settings.ExtractedTextFieldContainsFilePath = false;

            // Indicates file path for the native file.
            importJob.Settings.NativeFilePathSourceFieldName = Native_File;

            // Indicates the column containing the ID of the parent document.
            importJob.Settings.ParentObjectIdSourceFieldName = PARENT_OBJECT_ID_SOURCE_FIELD_NAME;

            // The name of the document identifier column must match the name of the document identifier field
            // in the workspace.
            importJob.Settings.SelectedIdentifierFieldName = control_Number;
            importJob.Settings.NativeFileCopyMode          = NativeFileCopyModeEnum.CopyFiles;
            importJob.Settings.OverwriteMode = OverwriteModeEnum.Append;

            // Specify the ArtifactID of the document identifier field, such as a control number.
            importJob.Settings.IdentityFieldId = identityFieldArtifactId;

            var documentDataTable = GetDocumentDataTable(folderArtifactID, workspaceID, documentCount, workspaceDbContext);

            importJob.SourceData.SourceData = documentDataTable.CreateDataReader();

            Console.WriteLine("Executing import...");

            importJob.Execute();

            // return artifact id's of documents
        }
예제 #3
0
        public static void ImportDocument(int workspaceId, string path)
        {
            int identifyFieldArtifactID = 1003667;    // 'Control Number' Field

            ImportAPI iapi = new ImportAPI(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD, IMPORT_API_ENDPOINT);

            var importJob = iapi.NewNativeDocumentImportJob();

            importJob.OnMessage              += ImportJobOnMessage;
            importJob.OnComplete             += ImportJobOnComplete;
            importJob.OnFatalException       += ImportJobOnFatalException;
            importJob.Settings.CaseArtifactId = workspaceId;
            importJob.Settings.ExtractedTextFieldContainsFilePath = false;

            importJob.Settings.NativeFilePathSourceFieldName = "Original Folder Path";
            importJob.Settings.NativeFileCopyMode            = NativeFileCopyModeEnum.CopyFiles; // NativeFileCopyModeEnum.CopyFiles; NativeFileCopyModeEnum.DoNotImportNativeFiles
            importJob.Settings.OverwriteMode = OverwriteModeEnum.AppendOverlay;

            importJob.Settings.IdentityFieldId = identifyFieldArtifactID;
            importJob.SourceData.SourceData    = GetDocumentDataTable(path).CreateDataReader();

            Console.WriteLine("=======>>>>> Executing import...");

            importJob.Execute();
        }
        public static void CreateDocumentswithFolderName(int WorkspaceArtifactId, int numberofDocuments, bool UploadNative, string folderName, IDBContext workspaceDbContext)
        {
            try
            {
                int identityFieldArtifactId = ArtifactHelpers.Fields.GetFieldArtifactID(Relativity.Test.Helpers.ArtifactHelpers.Document.GetDocumentIdentifierFieldName(workspaceDbContext, 10), workspaceDbContext);
                var iapi      = new ImportAPI(SharedTestHelpers.ConfigurationHelper.ADMIN_USERNAME, SharedTestHelpers.ConfigurationHelper.DEFAULT_PASSWORD, string.Format("{0}://{1}/Relativitywebapi/", SharedTestHelpers.ConfigurationHelper.SERVER_BINDING_TYPE, SharedTestHelpers.ConfigurationHelper.RSAPI_SERVER_ADDRESS));
                var importJob = iapi.NewNativeDocumentImportJob();

                importJob.Settings.CaseArtifactId = WorkspaceArtifactId;
                importJob.Settings.ExtractedTextFieldContainsFilePath = false;

                // Indicates file path for the native file.
                importJob.Settings.NativeFilePathSourceFieldName = Native_File;

                // Indicates the column containing the ID of the parent document.
                importJob.Settings.ParentObjectIdSourceFieldName = PARENT_OBJECT_ID_SOURCE_FIELD_NAME;

                // The name of the document identifier column must match the name of the document identifier field
                // in the workspace.
                importJob.Settings.SelectedIdentifierFieldName = control_Number;
                importJob.Settings.NativeFileCopyMode          = NativeFileCopyModeEnum.CopyFiles;
                importJob.Settings.OverwriteMode = OverwriteModeEnum.Append;

                // Specify the ArtifactID of the document identifier field, such as a control number.
                importJob.Settings.IdentityFieldId = identityFieldArtifactId;

                importJob.SourceData.SourceData = GetDocumentDataTable(numberofDocuments, UploadNative, folderName).CreateDataReader();

                importJob.OnComplete += report =>
                {
                    Console.WriteLine("Native Import Finished");
                    Console.WriteLine(report.FatalException);
                };

                importJob.OnComplete += report =>
                {
                    Console.WriteLine("Native Import Finished");
                    Console.WriteLine(report.FatalException);
                };

                importJob.OnFatalException += report =>
                {
                    Console.WriteLine("Native Import Failed");
                    Console.WriteLine(report.FatalException);
                };

                Console.WriteLine("Executing import...");

                importJob.Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
예제 #5
0
        public override void Execute()
        {
            DataTable table = new DataTable();

            table.Columns.Add("Control Number", typeof(string));
            table.Columns.Add("File Path", typeof(string));
            var filenames = new List <string>
            {
                SampleDocPdfFileName,
                SampleDocWordFileName,
                SampleDocExcelFileName,
                SampleDocMsgFileName,
                SampleDocHtmFileName,
                SampleDocEmfFileName,
                SampleDocPptFileName,
                SampleDocTxtFileName
            };

            int    index         = random.Next(1, filenames.Count);
            string fileName      = filenames[index - 1];
            string controlNumber = GenerateControlNumber(fileName);

            table.Rows.Add(controlNumber, System.IO.Path.Combine(@"S:\Samples - Relativity\IntAuthIAPIAgent - Sample\ImportAPI-Agent-Plugin\Dataset\Docs", fileName));

            ImportAPI iapi      = new ImportAPI(this.configuration.UserName, this.configuration.Password, this.configuration.WebServiceUrl);
            var       importJob = iapi.NewNativeDocumentImportJob();

            importJob.OnMessage += status =>
            {
                // Handle messages here or raise some event.
                System.Diagnostics.Trace.TraceInformation($"Message: {status.Message}");
            };

            importJob.OnComplete += report =>
            {
                // Handle completion here or raise some event.
                System.Diagnostics.Trace.TraceInformation($"Job finished with {report.ErrorRowCount} errors.");
            };

            importJob.OnFatalException += report =>
            {
                // Handle fatal exceptions here or raise some event.
                System.Diagnostics.Trace.TraceError($"Job fatal error: {report.FatalException}.");
            };

            importJob.Settings.CaseArtifactId = this.configuration.WorkspaceId;
            importJob.Settings.ExtractedTextFieldContainsFilePath = false;
            importJob.Settings.NativeFileCopyMode            = NativeFileCopyModeEnum.CopyFiles;
            importJob.Settings.NativeFilePathSourceFieldName = "File Path";
            importJob.Settings.OverwriteMode   = OverwriteModeEnum.Append;
            importJob.Settings.IdentityFieldId = this.configuration.IdentifyFieldArtifactId;
            importJob.SourceData.SourceData    = table.CreateDataReader();
            importJob.Execute();
        }
        public bool ImportDocument(IAgentHelper helper, int workspaceID, List <WikitivityUploadsAgent.DataObtainedSingleRequestObject> batchedArticleList, AgentBase aB)
        {
            var success = false;

            Int32  workspaceArtifactID     = workspaceID;
            Int32  identifyFieldArtifactID = 1003667;               // 'Control Number' Field
            String relativityWebAPIUrl     = GetWebApiUrl(helper, aB);

            aB.RaiseMessage("Obtained RelativityWebAPI: " + relativityWebAPIUrl, 1);
            String    relativityFolderName = "Name of the Destination Folder";
            var       url  = relativityWebAPIUrl;
            ImportAPI iapi = ImportAPI.CreateByRsaBearerToken(url);

            try
            {
                var importJob = iapi.NewNativeDocumentImportJob();
                importJob.OnMessage              += ImportJobOnMessage;
                importJob.OnComplete             += ImportJobOnComplete;
                importJob.OnFatalException       += ImportJobOnFatalException;
                importJob.Settings.CaseArtifactId = workspaceArtifactID;
                importJob.Settings.ExtractedTextFieldContainsFilePath = false;

                // Utilize these fields to set up native import
                // importJob.Settings.DisableNativeLocationValidation = true; Use these two lines for disabling native import & validation.
                // importJob.Settings.DisableNativeValidation = true;
                // importJob.Settings.NativeFilePathSourceFieldName = "Original Folder Path";
                importJob.Settings.NativeFileCopyMode = NativeFileCopyModeEnum.DoNotImportNativeFiles;                 // NativeFileCopyModeEnum.CopyFiles; NativeFileCopyModeEnum.DoNotImportNativeFiles
                importJob.Settings.OverwriteMode      = OverwriteModeEnum.Append;
                importJob.Settings.IdentityFieldId    = identifyFieldArtifactID;
                importJob.SourceData.SourceData       = GetDocumentDataTable(batchedArticleList, aB).CreateDataReader();

                importJob.Execute();

                success = true;
            }
            catch (Exception ex)
            {
                aB.RaiseMessage(ex.ToString(), 1);
            }
            return(success);
        }
예제 #7
0
        public static ImportBulkArtifactJob GetImportApi(int workspaceId)
        {
            var iapi   = new ImportAPI(SharedTestHelpers.ConfigurationHelper.ADMIN_USERNAME, SharedTestHelpers.ConfigurationHelper.DEFAULT_PASSWORD, string.Format("{0}://{1}/Relativitywebapi/", SharedTestHelpers.ConfigurationHelper.SERVER_BINDING_TYPE, SharedTestHelpers.ConfigurationHelper.RSAPI_SERVER_ADDRESS));
            var fields = iapi.GetWorkspaceFields(workspaceId, 10);

            var identifier = fields.FirstOrDefault(x => x.FieldCategory == kCura.Relativity.ImportAPI.Enumeration.FieldCategoryEnum.Identifier);

            if (identifier == null)
            {
                throw new ApplicationException($"No identifier field found for workspace id {workspaceId}");
            }
            // job.Settings.IdentityFieldId = identifier.ArtifactID;

            var importJob = iapi.NewNativeDocumentImportJob();

            importJob.Settings.CaseArtifactId = workspaceId;
            importJob.Settings.ExtractedTextFieldContainsFilePath = false;

            // Indicates file path for the native file.
            importJob.Settings.NativeFilePathSourceFieldName = Native_File;

            // Indicates the column containing the ID of the parent document.
            importJob.Settings.ParentObjectIdSourceFieldName = PARENT_OBJECT_ID_SOURCE_FIELD_NAME;

            // The name of the document identifier column must match the name of the document identifier field
            // in the workspace.
            importJob.Settings.SelectedIdentifierFieldName = Control_Number;
            importJob.Settings.NativeFileCopyMode          = NativeFileCopyModeEnum.CopyFiles;
            importJob.Settings.OverwriteMode = OverwriteModeEnum.Append;

            // Specify the ArtifactID of the document identifier field, such as a control number.
            importJob.Settings.IdentityFieldId = identifier.ArtifactID;


            return(importJob);
        }
        public static void CreateDocuments(Int32 workspaceID, int folderArtifactID, DataTable sourceDataTable)
        {
            var iapi = new ImportAPI(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD,
                                     string.Format("https://{0}/Relativitywebapi/", ConfigurationHelper.RSAPI_SERVER_ADDRESS));

            var importJob = iapi.NewNativeDocumentImportJob();

            importJob.OnMessage              += ImportJobOnMessage;
            importJob.OnComplete             += ImportJobOnComplete;
            importJob.OnFatalException       += ImportJobOnFatalException;
            importJob.Settings.CaseArtifactId = workspaceID;
            importJob.Settings.ExtractedTextFieldContainsFilePath = false;

            importJob.Settings.NativeFilePathSourceFieldName = "Native File";
            importJob.Settings.NativeFileCopyMode            = NativeFileCopyModeEnum.CopyFiles;
            importJob.Settings.OverwriteMode = OverwriteModeEnum.Append;

            importJob.Settings.IdentityFieldId = _IDENTITY_FIELD_ARTIFACT_ID;

            var documentDataTable = sourceDataTable;

            importJob.SourceData.SourceData = documentDataTable.CreateDataReader();
            importJob.Execute();
        }
예제 #9
0
        private void runImportJob()
        {
            var eventHandler = new EventHandler();
            var importApi    = new ImportAPI(settings.RelativitySettings.Username, password, settings.RelativitySettings.WebServiceUrl);
            var importJob    = importApi.NewNativeDocumentImportJob();

            importJob.OnMessage        += new ImportBulkArtifactJob.OnMessageEventHandler(eventHandler.ImportJobOnMessage);
            importJob.OnError          += new ImportBulkArtifactJob.OnErrorEventHandler(eventHandler.ImportJobOnError);
            importJob.OnFatalException += new IImportNotifier.OnFatalExceptionEventHandler(eventHandler.ImportJobOnFatalException);

            importJob.Settings.ArtifactTypeId = 10;
            importJob.Settings.CaseArtifactId = workspaceId;

            if (folderId > 0)
            {
                importJob.Settings.DestinationFolderArtifactID = folderId;
            }
            importJob.Settings.ExtractedTextEncoding = Encoding.UTF8;
            importJob.Settings.ExtractedTextFieldContainsFilePath = true;
            importJob.Settings.MaximumErrorCount  = int.MaxValue - 1;
            importJob.Settings.NativeFileCopyMode = settings.UploadSettings.NativeCopyMode;

            if (!settings.UploadSettings.NativeCopyMode.Equals(NativeFileCopyModeEnum.DoNotImportNativeFiles))
            {
                importJob.Settings.NativeFilePathSourceFieldName = "NativeFilePathSourceFieldName";
                settings.FieldsSettings.FieldsMapping.Add(
                    new Field()
                {
                    LoadfileColumn  = "ITEMPATH",
                    WorkspaceColumn = "NativeFilePathSourceFieldName"
                });
            }

            if (settings.FieldsSettings.FolderPathSourceFieldName != null && settings.FieldsSettings.FolderPathSourceFieldName.Length > 0)
            {
                importJob.Settings.FolderPathSourceFieldName = "FolderPathSourceFieldName";
                settings.FieldsSettings.FieldsMapping.Add(
                    new Field()
                {
                    LoadfileColumn  = settings.FieldsSettings.FolderPathSourceFieldName,
                    WorkspaceColumn = "FolderPathSourceFieldName"
                });
            }

            var dataTable = readLoadfile(loadfileFileInfo);

            importJob.SourceData.SourceData = dataTable.CreateDataReader();

            importJob.Settings.OverwriteMode      = settings.UploadSettings.OverwriteMode;
            importJob.Settings.RelativityUsername = settings.RelativitySettings.Username;
            importJob.Settings.RelativityPassword = password;
            importJob.Settings.WebServiceURL      = settings.RelativitySettings.WebServiceUrl;

            bool identifierSet = false;

            foreach (var field in settings.FieldsSettings.FieldsMapping)
            {
                if (!identifierSet && field.Identifier)
                {
                    importJob.Settings.SelectedIdentifierFieldName = field.WorkspaceColumn;
                    identifierSet = true;
                    Console.WriteLine("Using identifier loadfile field " + field.LoadfileColumn);
                }
            }
            importJob.Execute();
        }