public async Task <int> CreateImagingSetAsync(int workspaceArtifactId, int savedSearchArtifactId, int imagingProfileArtifactId) { Console2.WriteDisplayStartLine($"Creating Imaging Set [Name: {Constants.Imaging.Set.NAME}]"); try { ImagingSet imagingSet = new ImagingSet { DataSource = savedSearchArtifactId, Name = Constants.Imaging.Set.NAME, ImagingProfile = new ImagingProfileRef { ArtifactID = imagingProfileArtifactId }, EmailNotificationRecipients = Constants.Imaging.Set.EMAIL_NOTIFICATION_RECIPIENTS }; // Save the ImagingSet. Successful saves return the ArtifactID of the ImagingSet. int imagingSetArtifactId = await ImagingSetManager.SaveAsync(imagingSet, workspaceArtifactId); Console2.WriteDebugLine($"Imaging Set ArtifactId: {imagingSetArtifactId}"); Console2.WriteDisplayEndLine("Created Imaging Set!"); return(imagingSetArtifactId); } catch (ServiceException ex) { //The service throws an exception of type ServiceException, performs logging and rethrows the exception. throw new Exception("An error occured when creating Imaging Set", ex); } }
public async Task RunImagingJobAsync(int workspaceArtifactId, int imagingSetArtifactId) { Console2.WriteDisplayStartLine("Creating Imaging Job"); try { ImagingJob imagingJob = new ImagingJob { ImagingSetId = imagingSetArtifactId, WorkspaceId = workspaceArtifactId, QcEnabled = Constants.Imaging.Job.QC_ENABLED }; //Run an ImagingSet job. Console2.WriteDebugLine($"[{nameof(imagingSetArtifactId)}: {imagingSetArtifactId}, {nameof(workspaceArtifactId)}: {workspaceArtifactId}]"); Guid?jobGuid = (await ImagingJobManager.RunImagingSetAsync(imagingJob)).ImagingJobId; Console2.WriteDebugLine($"Imaging Job Guid: {jobGuid.ToString()}"); Console2.WriteDisplayEndLine("Created Imaging Job!"); } catch (ServiceException ex) { //The service throws an exception of type ServiceException, performs logging and rethrows the exception. throw new Exception("An error occured when running Imaging Job", ex); } }
//Handles imaging operations (create profile and set, run job) #region Create Imaging Profile / Set public async Task <int> CreateImagingProfileAsync(int workspaceArtifactId) { Console2.WriteDisplayStartLine($"Creating Imaging Profile [Name: {Constants.Imaging.Profile.NAME}]"); try { ImagingProfile basicImagingProfile = new ImagingProfile { BasicOptions = new BasicImagingEngineOptions { ImageOutputDpi = Constants.Imaging.Profile.IMAGE_OUTPUT_DPI, BasicImageFormat = Constants.Imaging.Profile.BASIC_IMAGE_FORMAT, ImageSize = Constants.Imaging.Profile.IMAGE_SIZE }, Name = Constants.Imaging.Profile.NAME, ImagingMethod = Constants.Imaging.Profile.IMAGING_METHOD }; // Save the ImagingProfile. Successful saves returns the ArtifactID of the ImagingProfile. int imagingProfileArtifactId = await ImagingProfileManager.SaveAsync(basicImagingProfile, workspaceArtifactId); Console2.WriteDebugLine($"Imaging Profile ArtifactId: {imagingProfileArtifactId}"); Console2.WriteDisplayEndLine("Created Imaging Profile!"); return(imagingProfileArtifactId); } catch (ServiceException ex) { //The service throws an exception of type ServiceException, performs logging and rethrows the exception. throw new Exception("An error occured when creating Imaging Profile", ex); } }
private static async Task <ITransferClient> CreateClientAsync(IRelativityTransferHost relativityTransferHost, ClientConfiguration clientConfiguration, CancellationToken cancellationToken) { Console2.WriteTapiStartHeader("Create Client"); ITransferClient client; if (clientConfiguration.Client == WellKnownTransferClient.Unassigned) { // The CreateClientAsync method chooses the best client at runtime. Console2.WriteDebugLine("TAPI is choosing the best transfer client..."); client = await relativityTransferHost.CreateClientAsync(clientConfiguration, cancellationToken).ConfigureAwait(false); } else { // The CreateClient method creates the specified client. Console2.WriteDebugLine("The API caller specified the {0} transfer client.", clientConfiguration.Client); client = relativityTransferHost.CreateClient(clientConfiguration); } if (client == null) { throw new InvalidOperationException("This operation cannot be performed because a transfer client could not be created."); } Console2.WriteDebugLine("TAPI created the {0} transfer client.", client.DisplayName); Console2.WriteTapiEndHeader(); return(client); }
private static void DisplayTransferResult(ITransferResult transferResult) { // The original request can be accessed within the transfer result. Console2.WriteDebugLine(); Console2.WriteDebugLine("Transfer Summary"); Console2.WriteDebugLine("Name: {0}", transferResult.Request.Name); Console2.WriteDebugLine("Direction: {0}", transferResult.Request.Direction); if (transferResult.Status == TransferStatus.Successful || transferResult.Status == TransferStatus.Canceled) { Console2.WriteDebugLine("Result: {0}", transferResult.Status); } else { Console2.WriteDebugLine(ConsoleColor.Red, "Result: {0}", transferResult.Status); if (transferResult.TransferError != null) { Console2.WriteDebugLine(ConsoleColor.Red, "Error: {0}", transferResult.TransferError.Message); } else { Console2.WriteDebugLine(ConsoleColor.Red, "Error: Check the error log for more details."); } } // Display useful transfer metrics. Console2.WriteDebugLine("Elapsed time: {0:hh\\:mm\\:ss}", transferResult.Elapsed); Console2.WriteDebugLine("Total files: Files: {0:n0}", transferResult.TotalTransferredFiles); Console2.WriteDebugLine("Total bytes: Files: {0:n0}", transferResult.TotalTransferredBytes); Console2.WriteDebugLine("Total files not found: {0:n0}", transferResult.TotalFilesNotFound); Console2.WriteDebugLine("Total bad path errors: {0:n0}", transferResult.TotalBadPathErrors); Console2.WriteDebugLine("Data rate: {0:#.##} Mbps", transferResult.TransferRateMbps); Console2.WriteDebugLine("Retry count: {0}", transferResult.RetryCount); }
public async Task <int> CreateCustodianAsync(int workspaceArtifactId) { try { Console2.WriteDisplayStartLine($"Creating Custodian [FirstName: {Constants.Processing.Custodian.FIRST_NAME}, LastName: {Constants.Processing.Custodian.LAST_NAME}]"); //Build the ProcessingCustodian object. ProcessingCustodian processingCustodian = new ProcessingCustodian { ArtifactID = Constants.Processing.Custodian.ARTIFACT_ID, DocumentNumberingPrefix = Constants.Processing.Custodian.DOCUMENT_NUMBERING_PREFIX, FirstName = Constants.Processing.Custodian.FIRST_NAME, LastName = Constants.Processing.Custodian.LAST_NAME }; int custodianArtifactId = await ProcessingCustodianManager.SaveAsync(processingCustodian, workspaceArtifactId); if (custodianArtifactId == 0) { throw new Exception("Failed to Create Custodian"); } Console2.WriteDebugLine($"Custodian ArtifactId: {custodianArtifactId}"); Console2.WriteDisplayEndLine("Created Custodian!"); return(custodianArtifactId); } catch (Exception ex) { throw new Exception("An error occured when creating Custodian", ex); } }
// Add a data source to the production public async Task CreateDataSourceAsync(int workspaceArtifactId, int productionArtifactId, int savedSearchArtifactId) { Console2.WriteDisplayStartLine($"Creating Production Data Source [Name: {Constants.Production.DataSource.Name}]"); try { ProductionDataSource dataSource = new ProductionDataSource() { Name = Constants.Production.DataSource.Name, SavedSearch = new SavedSearchRef(savedSearchArtifactId), ProductionType = Constants.Production.DataSource.PRODUCTION_TYPE, UseImagePlaceholder = Constants.Production.DataSource.USE_IMAGE_PLACEHOLDER, Placeholder = new ProductionPlaceholderRef(), BurnRedactions = Constants.Production.DataSource.BURN_REDACTIONS, MarkupSet = new MarkupSetRef() }; int dataSourceArtifactId = await ProductionDataSourceManager.CreateSingleAsync(workspaceArtifactId, productionArtifactId, dataSource); if (dataSourceArtifactId != 0) { Console2.WriteDebugLine($"Production Data Source ArtifactId: {dataSourceArtifactId}"); Console2.WriteDisplayEndLine("Created Production Data Source!"); } else { throw new Exception("Failed to create Production Data Source"); } } catch (Exception ex) { throw new Exception("An error occured when creating Production Data Source", ex); } }
// Create a production with page level numbering public async Task <int> CreatePageLevelProductionAsync(int workspaceArtifactId) { Console2.WriteDisplayStartLine($"Creating Production [Name: {Constants.Production.NAME}]"); try { // Construct the production object that you want to create Production production = new Production { Name = Constants.Production.NAME, Details = new ProductionDetails { DateProduced = Constants.Production.DateProduced, EmailRecipients = Constants.Production.EMAIL_RECIPIENTS, ScaleBrandingFont = Constants.Production.SCALE_BRANDING_FONT, BrandingFontSize = Constants.Production.BRANDING_FONT_SIZE, PlaceholderImageFormat = Constants.Production.PLACEHOLDER_IMAGE_FORMAT }, Numbering = new PageLevelNumbering { BatesPrefix = Constants.Production.BATES_PREFIX, BatesSuffix = Constants.Production.BATES_SUFFIX, BatesStartNumber = Constants.Production.BATES_START_NUMBER, NumberOfDigitsForDocumentNumbering = Constants.Production.NUMBER_OF_DIGITS_FOR_DOCUMENT_NUMBERING }, Footers = new ProductionFooters { LeftFooter = new HeaderFooter(Constants.Production.HEADER_FOOTER_FRIENDLY_NAME) { Type = Constants.Production.HEADER_FOOTER_TYPE, FreeText = Constants.Production.HEADER_FOOTER_FREE_TEXT } }, Keywords = Constants.Production.KEYWORDS, Notes = Constants.Production.NAME }; // Save the production into the specified workspace int productionArtifactId = await ProductionManager.CreateSingleAsync(workspaceArtifactId, production); Console2.WriteDebugLine($"Production ArtifactId: {productionArtifactId}"); Console2.WriteDisplayEndLine("Created Production!"); return(productionArtifactId); } catch (ValidationException validationException) { throw new Exception("There are validation errors when creating Production", validationException); } catch (Exception ex) { throw new Exception("An error occured when creating Production", ex); } }
public static async Task CreateResponsiveFieldAsync(HttpClient httpClient, int workspaceId) { try { string url = $"Relativity.REST/Workspace/{workspaceId}/Field"; CreateResponsiveFieldRequest createResponsiveFieldRequest = new CreateResponsiveFieldRequest { ArtifactTypeName = "Field", Name = Constants.Workspace.ResponsiveField.Name, ParentArtifact = new ParentArtifact { ArtifactID = workspaceId }, ObjectType = new ObjectType { DescriptorArtifactTypeID = Constants.DOCUMENT_ARTIFACT_TYPE }, FieldTypeID = (int)Constants.Workspace.ResponsiveField.FIELD_TYPE_ID, IsRequired = Constants.Workspace.ResponsiveField.IS_REQUIRED, OpenToAssociations = Constants.Workspace.ResponsiveField.OPEN_TO_ASSOCIATIONS, Linked = Constants.Workspace.ResponsiveField.LINKED, AllowSortTally = Constants.Workspace.ResponsiveField.ALLOW_SORT_TALLY, Wrapping = Constants.Workspace.ResponsiveField.WRAPPING, AllowGroupBy = Constants.Workspace.ResponsiveField.ALLOW_GROUP_BY, AllowPivot = Constants.Workspace.ResponsiveField.ALLOW_PIVOT, Width = 123, IgnoreWarnings = Constants.Workspace.ResponsiveField.IGNORE_WARNINGS, NoValue = Constants.Workspace.ResponsiveField.NO_VALUE, YesValue = Constants.Workspace.ResponsiveField.YES_VALUE }; string request = JsonConvert.SerializeObject(createResponsiveFieldRequest); Console2.WriteDisplayStartLine($"Creating Responsive Field"); HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request); string result = await response.Content.ReadAsStringAsync(); bool success = (HttpStatusCode.OK == response.StatusCode) || (HttpStatusCode.Created == response.StatusCode); if (!success) { throw new Exception("Failed to Create Responsive field"); } JObject resultObject = JObject.Parse(result); if (!resultObject["Results"][0]["Success"].Value <bool>()) { throw new Exception("Failed to Create Responsive field"); } int responsiveFieldArtifactId = resultObject["Results"][0]["ArtifactID"].Value <int>(); Console2.WriteDebugLine($"Responsive Field ArtifactId: {responsiveFieldArtifactId}"); Console2.WriteDisplayEndLine("Created Responsive Field!"); } catch (Exception ex) { throw new Exception("An error occurred when creating the Responsive field", ex); } }
private static async Task ChangeDataRateAsync(ITransferJob transferJob, CancellationToken cancellationToken) { if (transferJob.IsDataRateChangeSupported) { Console2.WriteDebugLine("Changing the transfer data rate..."); await transferJob.ChangeDataRateAsync(0, 10, cancellationToken).ConfigureAwait(false); Console2.WriteDebugLine("Changed the transfer data rate."); } }
public async Task <int> CreateWorkspaceAsync(int templateArtifactId) { Console2.WriteDisplayStartLine("Creating new Workspace"); try { const string workspaceCreationFailErrorMessage = "Failed to create new workspace"; RsapiClient.APIOptions.WorkspaceID = -1; //Create the workspace object and apply any desired properties. Workspace newWorkspace = new Workspace { Name = Constants.Workspace.NAME, Accessible = Constants.Workspace.ACCESSIBLE, DatabaseLocation = Constants.Workspace.DATABASE_LOCATION }; ProcessOperationResult processOperationResult = await Task.Run(() => RsapiClient.Repositories.Workspace.CreateAsync(templateArtifactId, newWorkspace)); if (!processOperationResult.Success) { throw new Exception(workspaceCreationFailErrorMessage); } ProcessInformation processInformation = await Task.Run(() => RsapiClient.GetProcessState(RsapiClient.APIOptions, processOperationResult.ProcessID)); const int maxTimeInMilliseconds = (Constants.Waiting.MAX_WAIT_TIME_IN_MINUTES * 60 * 1000); const int sleepTimeInMilliSeconds = Constants.Waiting.SLEEP_TIME_IN_SECONDS * 1000; int currentWaitTimeInMilliseconds = 0; while ((currentWaitTimeInMilliseconds < maxTimeInMilliseconds) && (processInformation.State != ProcessStateValue.Completed)) { Thread.Sleep(sleepTimeInMilliSeconds); processInformation = await Task.Run(() => RsapiClient.GetProcessState(RsapiClient.APIOptions, processOperationResult.ProcessID)); currentWaitTimeInMilliseconds += sleepTimeInMilliSeconds; } int?workspaceArtifactId = processInformation.OperationArtifactIDs.FirstOrDefault(); if (workspaceArtifactId == null) { throw new Exception(workspaceCreationFailErrorMessage); } Console2.WriteDebugLine($"Workspace ArtifactId: {workspaceArtifactId.Value}"); Console2.WriteDisplayEndLine("Created new Workspace!"); return(workspaceArtifactId.Value); } catch (Exception ex) { throw new Exception("An error occured when creating Workspace", ex); } }
private static void DisplayFileShare(RelativityFileShare relativityFileShare) { Console2.WriteDebugLine("Artifact ID: {0}", relativityFileShare.ArtifactId); Console2.WriteDebugLine("Name: {0}", relativityFileShare.Name); Console2.WriteDebugLine("UNC Path: {0}", relativityFileShare.Url); Console2.WriteDebugLine("Cloud Instance: {0}", relativityFileShare.CloudInstance); // RelativityOne specific properties. Console2.WriteDebugLine("Number: {0}", relativityFileShare.Number); Console2.WriteDebugLine("Tenant ID: {0}", relativityFileShare.TenantId); }
public static async Task AddProductionDataSourceAsync(HttpClient httpClient, int productionId, int workspaceId, int savedSearchArtifactId) { try { string url = $"/Relativity.REST/api/Relativity.Productions.Services.IProductionModule/Production%20Data%20Source%20Manager/CreateSingleAsync"; ProductionDataSourceObject productionDataSourceObject = new ProductionDataSourceObject { dataSource = new Datasource() { ProductionType = Constants.Production.DataSource.PRODUCTION_TYPE_AS_STRING, SavedSearch = new Savedsearch() { ArtifactID = savedSearchArtifactId }, Name = Constants.Production.DataSource.Name, MarkupSet = new Markupset(), BurnRedactions = Constants.Production.DataSource.BURN_REDACTIONS, UseImagePlaceholder = Constants.Production.DataSource.USE_IMAGE_PLACEHOLDER_AS_STRING, PlaceHolder = new ProductionPlaceholderRef() }, workspaceArtifactID = workspaceId, productionID = productionId, }; string request = JsonConvert.SerializeObject(productionDataSourceObject); Console2.WriteDisplayStartLine($"Creating Production Data Source [Name: {Constants.Production.DataSource.Name}]"); HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request); string result = await response.Content.ReadAsStringAsync(); bool success = HttpStatusCode.OK == response.StatusCode; if (!success) { throw new Exception("Failed to create production data source."); } int dataSourceArtifactId = Int32.Parse(result); if (dataSourceArtifactId != 0) { Console2.WriteDebugLine($"Production Data Source ArtifactId: {dataSourceArtifactId}"); Console2.WriteDisplayEndLine("Created Production Data Source!"); } else { throw new Exception("Failed to create Production Data Source"); } } catch (Exception ex) { throw new Exception("An error occured when creating Production Data Source", ex); } }
// Run the Production public async Task RunProductionAsync(int workspaceArtifactId, int productionArtifactId) { Console2.WriteDisplayStartLine("Running Production"); try { ProductionJobResult productionJobResult = await ProductionManager.RunProductionAsync(workspaceArtifactId, productionArtifactId, true); bool wasJobCreated = productionJobResult.WasJobCreated; const int maxTimeInMilliseconds = (Constants.Waiting.MAX_WAIT_TIME_IN_MINUTES * 60 * 1000); const int sleepTimeInMilliSeconds = Constants.Waiting.SLEEP_TIME_IN_SECONDS * 1000; int currentWaitTimeInMilliseconds = 0; while (currentWaitTimeInMilliseconds < maxTimeInMilliseconds && wasJobCreated == false) { Thread.Sleep(sleepTimeInMilliSeconds); string errors = productionJobResult.Errors.FirstOrDefault(); Console2.WriteDebugLine($"Errors: {errors}"); List <string> warnings = productionJobResult.Warnings; Console2.WriteDebugLine($"Warnings: {string.Join("; ", warnings)}"); List <string> messages = productionJobResult.Messages; Console2.WriteDebugLine($"Message: {string.Join("; ", messages)}"); // Okay, so maybe you've looked at the errors and found some document conflicts // and you want to override it anyway. //bool overrideConflicts = true; //bool suppressWarnings = false; productionJobResult = await ProductionManager.RunProductionAsync(workspaceArtifactId, productionArtifactId, true); wasJobCreated = productionJobResult.WasJobCreated; currentWaitTimeInMilliseconds += sleepTimeInMilliSeconds; } Console2.WriteDisplayEndLine("Ran Production!"); } catch (ValidationException validationException) { throw new Exception("There are validation errors when Running Production", validationException); } catch (Exception ex) { throw new Exception("An error occured when Running Production", ex); } }
public static async Task <int> CreateDtSearchIndexAsync(HttpClient httpClient, int workspaceId, int keywordSearchArtifactId) { try { int indexShareLocationId = await GetIndexShareLocationIdAsync(httpClient, workspaceId); string url = $"Relativity.REST/api/Relativity.DtSearchIndexes/workspace/{workspaceId}/dtsearchindexes/"; DtSearchIndexSaveRequest dtSearchIndexSaveRequest = new DtSearchIndexSaveRequest { dtSearchIndexRequest = new DtSearchIndexRequest { Name = Constants.Search.DtSearchIndex.NAME, Order = Constants.Search.DtSearchIndex.ORDER, SearchSearchID = keywordSearchArtifactId, RecognizeDates = Constants.Search.DtSearchIndex.RECOGNIZE_DATES, SkipNumericValues = Constants.Search.DtSearchIndex.SKIP_NUMERIC_VALUES, IndexShareCodeArtifactID = indexShareLocationId, EmailAddress = Constants.Search.DtSearchIndex.EMAIL_ADDRESS, NoiseWords = Constants.Search.DtSearchIndex.NOISE_WORDS, AlphabetText = Constants.Search.DtSearchIndex.ALPHABET_TEXT, DirtySettings = Constants.Search.DtSearchIndex.DIRTY_SETTINGS, SubIndexSize = Constants.Search.DtSearchIndex.SUB_INDEX_SIZE, FragmentationThreshold = Constants.Search.DtSearchIndex.FRAGMENTATION_THRESHOLD, Priority = Constants.Search.DtSearchIndex.PRIORITY } }; string request = JsonConvert.SerializeObject(dtSearchIndexSaveRequest); Console2.WriteDisplayStartLine("Creating DtSearch Index"); HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request); string result = await response.Content.ReadAsStringAsync(); bool success = HttpStatusCode.OK == response.StatusCode; if (!success) { throw new Exception("Failed to Create dtSearch Index"); } int dtSearchIndexArtifactId = Int32.Parse(result); Console2.WriteDebugLine($"DtSearch Index ArtifactId: {dtSearchIndexArtifactId}"); Console2.WriteDisplayEndLine("Created DtSearch Index!"); return(dtSearchIndexArtifactId); } catch (Exception ex) { throw new Exception("An error occured when creating DtSearch Index", ex); } }
// Stage the production public async Task StageProductionAsync(int workspaceArtifactId, int productionArtifactId) { Console2.WriteDisplayStartLine("Staging Production"); try { ProductionJobResult productionJobResult = await ProductionManager.StageProductionAsync(workspaceArtifactId, productionArtifactId); ProductionStatusDetailsResult productionStatusDetailsResult = await ProductionManager.GetProductionStatusDetails(workspaceArtifactId, productionArtifactId); const int maxTimeInMilliseconds = (Constants.Waiting.MAX_WAIT_TIME_IN_MINUTES * 60 * 1000); const int sleepTimeInMilliSeconds = Constants.Waiting.SLEEP_TIME_IN_SECONDS * 1000; int currentWaitTimeInMilliseconds = 0; while (currentWaitTimeInMilliseconds < maxTimeInMilliseconds && (string)productionStatusDetailsResult.StatusDetails.FirstOrDefault().Value != "Staged") { Thread.Sleep(sleepTimeInMilliSeconds); productionStatusDetailsResult = await ProductionManager.GetProductionStatusDetails(workspaceArtifactId, productionArtifactId); currentWaitTimeInMilliseconds += sleepTimeInMilliSeconds; } if (productionJobResult.Errors.Count != 0) { const string errorMessage = "There was an error when Staging Production"; Console2.WriteDebugLine(errorMessage); foreach (string item in productionJobResult.Errors) { Console2.WriteDebugLine(item); } throw new Exception(errorMessage); } foreach (string item in productionJobResult.Messages) { Console2.WriteDebugLine(item); } Console2.WriteDebugLine(productionStatusDetailsResult.StatusDetails.Last() + "\r\n"); Console2.WriteDisplayEndLine("Staged Production!"); } catch (Exception ex) { throw new Exception("An error occured when Staging Production", ex); } }
public static async Task CreateProcessingDataSourceAsync(HttpClient httpClient, int processingSetArtifactId, int custodianArtifactId, int timeZoneArtifactId, int destinationFolderArtifactId, int workspaceId) { try { string url = "Relativity.REST/api/Relativity.Processing.Services.IProcessingModule/Processing Data Source Manager/SaveAsync"; ProcessingDataSourceSaveRequest processingDataSourceSaveRequest = new ProcessingDataSourceSaveRequest { processingDataSource = new Processingdatasource { ProcessingSet = new ProcessingSet { ArtifactID = processingSetArtifactId }, Custodian = custodianArtifactId, DestinationFolder = destinationFolderArtifactId, DocumentNumberingPrefix = Constants.Processing.DataSource.DOCUMENT_NUMBERING_PREFIX, InputPath = Constants.Processing.DataSource.INPUT_PATH, Name = Constants.Processing.DataSource.NAME, OcrLanguages = new[] { "English" }, Order = Constants.Processing.DataSource.ORDER, TimeZone = timeZoneArtifactId, StartNumber = Constants.Processing.DataSource.START_NUMBER, IsStartNumberVisible = Constants.Processing.DataSource.IS_START_NUMBER_VISIBLE }, workspaceArtifactId = workspaceId }; string request = JsonConvert.SerializeObject(processingDataSourceSaveRequest); Console2.WriteDisplayStartLine($"Creating Processing Data Source [Name: {Constants.Processing.DataSource.NAME}]"); HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request); string result = await response.Content.ReadAsStringAsync(); bool success = HttpStatusCode.OK == response.StatusCode; if (!success) { throw new Exception("Failed to Create Processing Data Source"); } int processingDataSourceArtifactId = Int32.Parse(result); Console2.WriteDebugLine($"Processing Data Source ArtifactId: {processingDataSourceArtifactId}"); Console2.WriteDisplayEndLine("Created Processing Data Source!"); } catch (Exception ex) { throw new Exception("An error occured when creating Processing Data Source", ex); } }
public async Task <int> CreateResponsiveFieldAsync(int workspaceArtifactId) { Console2.WriteDisplayStartLine("Creating Responsive Field"); try { RsapiClient.APIOptions.WorkspaceID = workspaceArtifactId; kCura.Relativity.Client.DTOs.Field responsiveField = new kCura.Relativity.Client.DTOs.Field { ObjectType = new ObjectType { DescriptorArtifactTypeID = Constants.DOCUMENT_ARTIFACT_TYPE }, Name = Constants.Workspace.ResponsiveField.Name, FieldTypeID = Constants.Workspace.ResponsiveField.FIELD_TYPE_ID, IsRequired = Constants.Workspace.ResponsiveField.IS_REQUIRED, OpenToAssociations = Constants.Workspace.ResponsiveField.OPEN_TO_ASSOCIATIONS, Linked = Constants.Workspace.ResponsiveField.LINKED, AllowSortTally = Constants.Workspace.ResponsiveField.ALLOW_SORT_TALLY, Wrapping = Constants.Workspace.ResponsiveField.WRAPPING, AllowGroupBy = Constants.Workspace.ResponsiveField.ALLOW_GROUP_BY, AllowPivot = Constants.Workspace.ResponsiveField.ALLOW_PIVOT, IgnoreWarnings = Constants.Workspace.ResponsiveField.IGNORE_WARNINGS, Width = Constants.Workspace.ResponsiveField.WIDTH, NoValue = Constants.Workspace.ResponsiveField.NO_VALUE, YesValue = Constants.Workspace.ResponsiveField.YES_VALUE }; int responsiveFieldArtifactId = await Task.Run(() => RsapiClient.Repositories.Field.CreateSingle(responsiveField)); if (responsiveFieldArtifactId == 0) { throw new Exception("Failed to create Responsive Field"); } Console2.WriteDebugLine($"Responsive Field ArtifactId: {responsiveFieldArtifactId}"); Console2.WriteDisplayEndLine("Created Responsive Field!"); return(responsiveFieldArtifactId); } catch (Exception ex) { throw new Exception("An error occured when creating Responsive field", ex); } }
public static async Task TagDocumentsAsync(HttpClient httpClient, int workspaceId, List <int> documentsToTag) { try { Console2.WriteDisplayStartLine("Tagging all documents as Responsive"); foreach (var document in documentsToTag) { try { string url = $"Relativity.REST/Workspace/{workspaceId}/Document/{document}"; TaggingDoc newRequestForTagging = new TaggingDoc() { ArtifactId = document, TypeName = "Document", FieldValue = Constants.Workspace.ResponsiveField.VALUE }; string request = JsonConvert.SerializeObject(newRequestForTagging); HttpResponseMessage response = RESTConnectionManager.MakePut(httpClient, url, request); string result = await response.Content.ReadAsStringAsync(); bool success = HttpStatusCode.OK == response.StatusCode; if (!success) { throw new Exception("Failed to tag documents."); } // result = result.Substring(1, result.Length - 2); // JObject resultObject = JObject.Parse(result); Console2.WriteDebugLine($"Tagged document as Responsive! [Id: {document}]"); } catch (Exception ex) { throw new Exception($@"Failed to tag documents {ex.ToString()}"); } } Console2.WriteDisplayEndLine("Tagged all documents as Responsive!"); } catch (Exception ex) { throw new Exception("An error occurred tagging documents as responsive", ex); } }
public static async Task <int> CreateImagingProfileAsync(HttpClient httpClient, int workspaceArtifactId) { try { string url = "Relativity.REST/api/Relativity.Imaging.Services.Interfaces.IImagingModule/Imaging Profile Service/SaveAsync"; ImagingProfileSaveRequest imagingProfileSaveRequest = new ImagingProfileSaveRequest { imagingProfile = new Imagingprofile { BasicOptions = new Basicoptions { ImageOutputDpi = Constants.Imaging.Profile.IMAGE_OUTPUT_DPI, BasicImageFormat = Constants.Imaging.Profile.BASIC_IMAGE_FORMAT_AS_STRING, ImageSize = Constants.Imaging.Profile.IMAGE_SIZE_AS_STRING }, Name = Constants.Imaging.Profile.NAME, ImagingMethod = Constants.Imaging.Profile.IMAGING_METHOD_AS_STRING }, workspaceId = workspaceArtifactId }; string request = JsonConvert.SerializeObject(imagingProfileSaveRequest); Console2.WriteDisplayStartLine($"Creating Imaging Profile [Name: {Constants.Imaging.Profile.NAME}]"); HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request); string result = await response.Content.ReadAsStringAsync(); bool success = HttpStatusCode.OK == response.StatusCode; if (!success) { throw new Exception("Failed to Create Imaging Profile"); } int imagingProfileArtifactId = Int32.Parse(result); Console2.WriteDebugLine($"Imaging Profile ArtifactId: {imagingProfileArtifactId}"); Console2.WriteDisplayEndLine("Created Imaging Profile!"); return(imagingProfileArtifactId); } catch (Exception ex) { throw new Exception("An error occured when creating Imaging Profile", ex); } }
public async Task TransferDocumentsAsync() { Console2.WriteDisplayStartLine("Transferring Documents"); try { InitializeGlobalSettings(); using (ITransferLog transferLog = CreateTransferLog()) { using (IRelativityTransferHost relativityTransferHost = CreateRelativityTransferHost(transferLog)) { using (CancellationTokenSource cancellationTokenSource = new CancellationTokenSource()) { CancellationToken cancellationToken = cancellationTokenSource.Token; await UploadMultipleDocumentsAsync(relativityTransferHost, cancellationToken).ConfigureAwait(false); } } } Console2.WriteDisplayEndLine("Transferred Documents!"); } catch (TransferException e) { if (e.Fatal) { Console2.WriteDebugLine(ConsoleColor.Red, "A fatal transfer failure has occurred. Error: " + e); } else { Console2.WriteDebugLine(ConsoleColor.Red, "A non-fatal transfer failure has occurred. Error: " + e); } } catch (ApplicationException e) { // No need to include the stacktrace. Console2.WriteDebugLine(ConsoleColor.Red, e.Message); } catch (Exception e) { Console2.WriteDebugLine(ConsoleColor.Red, "An unexpected error has occurred. Error: " + e); } }
private async Task <IList <TransferPath> > SearchLocalSourcePathsAsync(ITransferClient transferClient, string uploadTargetPath, CancellationToken cancellationToken) { Console2.WriteTapiStartHeader("Search Paths"); string searchLocalPath = GetLocalDocumentsFolderPath(); const bool local = true; PathEnumeratorContext pathEnumeratorContext = new PathEnumeratorContext(transferClient.Configuration, new[] { searchLocalPath }, uploadTargetPath) { PreserveFolders = false }; IPathEnumerator pathEnumerator = transferClient.CreatePathEnumerator(local); EnumeratedPathsResult result = await pathEnumerator.EnumerateAsync(pathEnumeratorContext, cancellationToken).ConfigureAwait(false); Console2.WriteDebugLine("Local Paths: {0}", result.LocalPaths); Console2.WriteDebugLine("Elapsed time: {0:hh\\:mm\\:ss}", result.Elapsed); Console2.WriteDebugLine("Total files: {0:n0}", result.TotalFileCount); Console2.WriteDebugLine("Total bytes: {0:n0}", result.TotalByteCount); Console2.WriteTapiEndHeader(); return(result.Paths.ToList()); }
public async Task <int> CreateDtSearchIndexAsync(int workspaceArtifactId, int keywordSearchArtifactId) { Console2.WriteDisplayStartLine("Creating DtSearch Index"); try { int indexShareCodeArtifactId = DtSearchIndexManager.GetIndexShareLocationAsync(workspaceArtifactId).Result[0].ID; DtSearchIndexRequest dtSearchIndexRequest = new DtSearchIndexRequest { Name = Constants.Search.DtSearchIndex.NAME, Order = Constants.Search.DtSearchIndex.ORDER, SearchSearchID = keywordSearchArtifactId, RecognizeDates = Constants.Search.DtSearchIndex.RECOGNIZE_DATES, SkipNumericValues = Constants.Search.DtSearchIndex.SKIP_NUMERIC_VALUES, IndexShareCodeArtifactID = indexShareCodeArtifactId, EmailAddress = Constants.Search.DtSearchIndex.EMAIL_ADDRESS, NoiseWords = Constants.Search.DtSearchIndex.NOISE_WORDS, AlphabetText = Constants.Search.DtSearchIndex.ALPHABET_TEXT, DirtySettings = Constants.Search.DtSearchIndex.DIRTY_SETTINGS, SubIndexSize = Constants.Search.DtSearchIndex.SUB_INDEX_SIZE, FragmentationThreshold = Constants.Search.DtSearchIndex.FRAGMENTATION_THRESHOLD, Priority = Constants.Search.DtSearchIndex.PRIORITY }; int dtSearchIndexArtifactId = await DtSearchIndexManager.CreateAsync(workspaceArtifactId, dtSearchIndexRequest); if (dtSearchIndexArtifactId == 0) { throw new Exception("Failed to create the DtSearch Index"); } Console2.WriteDebugLine($"DtSearch Index ArtifactId: {dtSearchIndexArtifactId}"); Console2.WriteDisplayEndLine("Created DtSearch Index!"); return(dtSearchIndexArtifactId); } catch (Exception ex) { throw new Exception("An error occured when creating DtSearch Index", ex); } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"> /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources. /// </param> private void Dispose(bool disposing) { if (this.disposed) { return; } if (disposing) { if (!string.IsNullOrEmpty(this.Path) && Directory.Exists(this.Path)) { try { string[] files = Directory.GetFiles(this.Path, "*", SearchOption.AllDirectories); foreach (string file in files) { FileAttributes attributes = File.GetAttributes(file); File.SetAttributes(file, attributes & ~FileAttributes.ReadOnly); File.Delete(file); } Directory.Delete(this.Path, true); } catch (IOException e) { Console2.WriteDebugLine( ConsoleColor.Red, $"Failed to tear down the '{this.Path}' temp directory due to an I/O issue. Exception: " + e); } catch (UnauthorizedAccessException e) { Console2.WriteDebugLine( ConsoleColor.Red, $"Failed to tear down the '{this.Path}' temp directory due to unauthorized access. Exception: " + e); } } } this.disposed = true; }
private static TransferContext CreateTransferContext() { // The context object is used to decouple operations such as progress from other TAPI objects. TransferContext context = new TransferContext { StatisticsRateSeconds = 0.5, StatisticsEnabled = true }; context.TransferPathIssue += (sender, args) => { Console2.WriteDebugLine("Event=TransferPathIssue, Attributes={0}", args.Issue.Attributes); }; context.TransferRequest += (sender, args) => { Console2.WriteDebugLine("Event=TransferRequest, Status={0}", args.Status); }; context.TransferPathProgress += (sender, args) => { Console2.WriteDebugLine( "Event=TransferPathProgress, Filename={0}, Status={1}", Path.GetFileName(args.Path.SourcePath), args.Status); }; context.TransferJobRetry += (sender, args) => { Console2.WriteDebugLine("Event=TransferJobRetry, Retry={0}", args.Count); }; context.TransferStatistics += (sender, args) => { // Progress has already factored in file-level vs byte-level progress. Console2.WriteDebugLine( "Event=TransferStatistics, Progress: {0:00.00}%, Transfer rate: {1:00.00} Mbps, Remaining: {2:hh\\:mm\\:ss}", args.Statistics.Progress, args.Statistics.TransferRateMbps, args.Statistics.RemainingTime); }; return(context); }
public async Task CreateProcessingDataSourceAsync(int processingSetArtifactId, int custodianArtifactId, int timeZoneArtifactId, int destinationFolderArtifactId, int workspaceArtifactId) { try { Console2.WriteDisplayStartLine($"Creating Processing Data Source [Name: {Constants.Processing.DataSource.NAME}]"); //Build the processing ProcessingDataSource object. ProcessingDataSource processingDataSource = new ProcessingDataSource { ArtifactID = Constants.Processing.DataSource.ARTIFACT_ID, ProcessingSet = new ProcessingSetRef { ArtifactID = processingSetArtifactId }, Custodian = custodianArtifactId, DestinationFolder = destinationFolderArtifactId, DocumentNumberingPrefix = Constants.Processing.DataSource.DOCUMENT_NUMBERING_PREFIX, InputPath = Constants.Processing.DataSource.INPUT_PATH, Name = Constants.Processing.DataSource.NAME, OcrLanguages = Constants.Processing.DataSource.OcrLanguages, Order = Constants.Processing.DataSource.ORDER, TimeZone = timeZoneArtifactId, StartNumber = Constants.Processing.DataSource.START_NUMBER, IsStartNumberVisible = Constants.Processing.DataSource.IS_START_NUMBER_VISIBLE }; //Create the ProcessingDataSource object. The service returns the Artifact ID for the object. int processingDataSourceArtifactId = await ProcessingDataSourceManager.SaveAsync(processingDataSource, workspaceArtifactId); if (processingDataSourceArtifactId == 0) { throw new Exception("Failed to Create Processing Data Source"); } Console2.WriteDebugLine($"Processing Data Source ArtifactId: {processingDataSourceArtifactId}"); Console2.WriteDisplayEndLine("Created Processing Data Source!"); } catch (Exception ex) { throw new Exception("An error occured when creating Processing Data Source", ex); } }
public static async Task <int> CreateImagingSetAsync(HttpClient httpClient, int savedSearchArtifactId, int imagingProfileId, int workspaceArtifactId) { try { string url = "Relativity.REST/api/Relativity.Imaging.Services.Interfaces.IImagingModule/Imaging Set Service/SaveAsync"; ImagingSetSaveRequest imagingSetSaveRequest = new ImagingSetSaveRequest { imagingSet = new Imagingset { DataSource = savedSearchArtifactId, Name = Constants.Imaging.Set.NAME, ImagingProfile = new ImagingProfile { ArtifactID = imagingProfileId }, EmailNotificationRecipients = Constants.Imaging.Set.EMAIL_NOTIFICATION_RECIPIENTS }, workspaceId = workspaceArtifactId }; string request = JsonConvert.SerializeObject(imagingSetSaveRequest); Console2.WriteDisplayStartLine($"Creating Imaging Set [Name: {Constants.Imaging.Set.NAME}]"); HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request); string result = await response.Content.ReadAsStringAsync(); bool success = HttpStatusCode.OK == response.StatusCode; if (!success) { throw new Exception("Failed to Create Imaging Set"); } int imagingSetArtifactId = Int32.Parse(result); Console2.WriteDebugLine($"Imaging Set ArtifactId: {imagingSetArtifactId}"); Console2.WriteDisplayEndLine("Created Imaging Set!"); return(imagingSetArtifactId); } catch (Exception ex) { throw new Exception("An error occured when creating Imaging Set", ex); } }
private static void InitializeGlobalSettings() { Console2.WriteTapiStartHeader("Initialize GlobalSettings"); // A meaningful application name is encoded within monitoring data. GlobalSettings.Instance.ApplicationName = "sample-app"; // Configure for a console-based application. GlobalSettings.Instance.CommandLineModeEnabled = true; Console2.WriteDebugLine("Configured console settings."); // This will automatically write real-time entries into the transfer log. GlobalSettings.Instance.StatisticsLogEnabled = true; GlobalSettings.Instance.StatisticsLogIntervalSeconds = .5; Console2.WriteDebugLine("Configured statistics settings."); // Limit the max target rate and throw exceptions when invalid paths are specified. GlobalSettings.Instance.MaxAllowedTargetDataRateMbps = 10; Console2.WriteDebugLine("Configured miscellaneous settings."); Console2.WriteTapiEndHeader(); }
public static async Task <int> CreateProcessingSetAsync(HttpClient httpClient, int processingProfileArtifactId, int workspaceId) { try { string url = "Relativity.REST/api/Relativity.Processing.Services.IProcessingModule/Processing Set Manager/SaveAsync"; ProcessingSetSaveRequest processingSetSaveRequest = new ProcessingSetSaveRequest { ProcessingSet = new Processingset { Name = Constants.Processing.Set.NAME, Profile = new Profile { ArtifactID = processingProfileArtifactId } }, workspaceArtifactId = workspaceId }; string request = JsonConvert.SerializeObject(processingSetSaveRequest); Console2.WriteDisplayStartLine($"Creating Processing Set [Name: {Constants.Processing.Set.NAME}]"); HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request); string result = await response.Content.ReadAsStringAsync(); bool success = HttpStatusCode.OK == response.StatusCode; if (!success) { throw new Exception("Failed to Create Processing Set"); } int processingSetArtifactId = Int32.Parse(result); Console2.WriteDebugLine($"Processing Set ArtifactId: {processingSetArtifactId}"); Console2.WriteDisplayEndLine("Created Processing Set!"); return(processingSetArtifactId); } catch (Exception ex) { throw new Exception("An error occured when creating Processing Set", ex); } }
public async Task TagDocumentsResponsiveAsync(int workspaceId, List <int> documentsToTag) { Console2.WriteDisplayStartLine("Tagging all documents as Responsive"); RsapiClient.APIOptions.WorkspaceID = workspaceId; foreach (int currentDocumentArtifactId in documentsToTag) { // Read the document Document currentDocumentRdo = await Task.Run(() => RsapiClient.Repositories.Document.ReadSingle(currentDocumentArtifactId)); // Code the document as Responsive currentDocumentRdo.Fields.Add(new FieldValue { Name = Constants.Workspace.ResponsiveField.Name, Value = Constants.Workspace.ResponsiveField.VALUE }); try { // Perform the document update WriteResultSet <Document> documentWriteResultSet = await Task.Run(() => RsapiClient.Repositories.Document.Update(currentDocumentRdo)); if (!documentWriteResultSet.Success) { Console2.WriteDebugLine($"Error: {documentWriteResultSet.Message} \r\n {documentWriteResultSet.Results[0].Message}"); Console2.WriteDebugLine(string.Join(";", documentWriteResultSet.Results)); throw new Exception("Failed to tag document as Responsive"); } Console2.WriteDebugLine($"Tagged document as Responsive! [Name: {currentDocumentRdo.TextIdentifier}]"); } catch (Exception ex) { throw new Exception("An error occured when tagging document as Responsive", ex); } } Console2.WriteDisplayEndLine("Tagged all documents as Responsive!"); }