//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);
            }
        }
        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);
            }
        }
Exemplo n.º 4
0
        public static async Task BuildDtSearchIndexAsync(HttpClient httpClient, int workspaceId, int dtSearchIndexId)
        {
            try
            {
                string url = $"Relativity.Rest/API/Relativity.DtSearchIndexes/workspace/{workspaceId}/dtsearchindexes/{dtSearchIndexId}/fullBuildIndex";
                BuilddtSearchIndexRequest buildDtSearchIndexRequest = new BuilddtSearchIndexRequest
                {
                    isActive = true
                };
                string request = JsonConvert.SerializeObject(buildDtSearchIndexRequest);

                Console2.WriteDisplayStartLine("Building 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 Build dtSearch Index");
                }

                Console2.WriteDisplayEndLine("Built DtSearch Index!");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when building DtSearch Index", ex);
            }
        }
Exemplo n.º 5
0
        public static async Task RunImagingJobAsync(HttpClient httpClient, int imagingSetId, int workspaceArtifactId)
        {
            try
            {
                string url = "Relativity.REST/api/Relativity.Imaging.Services.Interfaces.IImagingModule/Imaging Job Service/RunImagingSetAsync";
                RunImagingJobRequest runImagingJobRequest = new RunImagingJobRequest
                {
                    imagingJob = new Imagingjob
                    {
                        imagingSetId = imagingSetId,
                        workspaceId  = workspaceArtifactId
                    }
                };
                string request = JsonConvert.SerializeObject(runImagingJobRequest);

                Console2.WriteDisplayStartLine("Creating Imaging Job");
                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 Run Imaging Job");
                }

                Console2.WriteDisplayEndLine("Created Imaging Job!");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when running Imaging Job", 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);
            }
        }
Exemplo n.º 7
0
        public static async Task RunProductionAsync(HttpClient httpClient, int productionId, int workspaceId)
        {
            try
            {
                Console2.WriteDisplayStartLine("Running Production");

                string url = $"/Relativity.REST/api/Relativity.Productions.Services.IProductionModule/Production%20Manager/RunProductionAsync";
                ProductionRunRequest runProductionRequest = new ProductionRunRequest()
                {
                    workspaceArtifactID  = workspaceId,
                    overrideConflicts    = true,
                    productionArtifactID = productionId,
                    suppressWarnings     = true
                };
                string request = JsonConvert.SerializeObject(runProductionRequest);

                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 run production set.");
                }

                Console2.WriteDisplayEndLine("Ran Production!");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when Running Production", ex);
            }
        }
        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);
            }
        }
Exemplo n.º 9
0
        public static async Task StageProductionAsync(HttpClient httpClient, int productionId, int workspaceId)
        {
            try
            {
                string url = $"/Relativity.REST/api/Relativity.Productions.Services.IProductionModule/Production%20Manager/StageProductionAsync";
                ProductionStageRequest productionStageRequest =
                    new ProductionStageRequest()
                {
                    productionArtifactId = productionId, workspaceArtifactId = workspaceId
                };
                string request = JsonConvert.SerializeObject(productionStageRequest);

                Console2.WriteDisplayStartLine("Staging Production");
                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 stage production set.");
                }

                Console2.WriteDisplayEndLine("Staged Production!");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when Staging Production", ex);
            }
        }
        public async Task <List <int> > WorkspaceQueryAsync(string workspaceName)
        {
            Console2.WriteDisplayStartLine($"Querying for Workspaces [Name: {workspaceName}]");

            try
            {
                RsapiClient.APIOptions.WorkspaceID = -1;

                TextCondition     textCondition  = new TextCondition(WorkspaceFieldNames.Name, TextConditionEnum.EqualTo, workspaceName);
                Query <Workspace> workspaceQuery = new Query <Workspace>
                {
                    Fields    = FieldValue.AllFields,
                    Condition = textCondition
                };

                QueryResultSet <Workspace> workspaceQueryResultSet = await Task.Run(() => RsapiClient.Repositories.Workspace.Query(workspaceQuery));

                if (!workspaceQueryResultSet.Success || workspaceQueryResultSet.Results == null)
                {
                    throw new Exception("Failed to query Workspaces");
                }

                List <int> workspaceArtifactIds = workspaceQueryResultSet.Results.Select(x => x.Artifact.ArtifactID).ToList();

                Console2.WriteDisplayEndLine($"Queried for Workspaces! [Count: {workspaceArtifactIds.Count}]");

                return(workspaceArtifactIds);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when querying Workspaces", ex);
            }
        }
        public static async Task PublishJobAsync(HttpClient httpClient, int processingSetId, int workspaceId)
        {
            try
            {
                string            url = "Relativity.REST/api/Relativity.Processing.Services.IProcessingModule/Processing Job Manager/SubmitPublishJobsAsync";
                PublishJobRequest publishJobRequest = new PublishJobRequest
                {
                    PublishJob = new Publishjob
                    {
                        ProcessingSetId     = processingSetId,
                        WorkspaceArtifactId = workspaceId
                    }
                };
                string request = JsonConvert.SerializeObject(publishJobRequest);

                Console2.WriteDisplayStartLine("Starting Publish Job");
                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 Start Publish Job");
                }

                Console2.WriteDisplayEndLine("Started Publish Job!");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when staring Processing Publish Job", 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);
            }
        }
Exemplo n.º 13
0
        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);
            }
        }
        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);
            }
        }
        public static async Task WaitForDiscoveryJobToCompleteAsync(HttpClient httpClient, int workspaceId, int processingSetId)
        {
            Console2.WriteDisplayStartLine("Waiting for Discovery Job to finish...");
            bool discoveryComplete = await JobCompletedSuccessfullyAsync(httpClient, workspaceId, processingSetId, Constants.ProcessingJobType.Discover);

            if (!discoveryComplete)
            {
                throw new Exception("Discovery Job failed to Complete.");
            }
            Console2.WriteDisplayEndLine("Discovery Job Complete!");
        }
Exemplo n.º 16
0
        public static async Task WaitForImagingJobToCompleteAsync(HttpClient httpClient, int workspaceId, int imagingSetId)
        {
            Console2.WriteDisplayStartLine("Waiting for Imaging Job to finish");
            bool publishComplete = await JobCompletedSuccessfullyAsync(httpClient, workspaceId, imagingSetId);

            if (!publishComplete)
            {
                throw new Exception("Imaging Job failed to Complete.");
            }
            Console2.WriteDisplayEndLine("Imaging Job Complete!");
        }
        public async Task WaitForProductionJobToCompleteAsync(int workspaceArtifactId, int productionSetArtifactId)
        {
            Console2.WriteDisplayStartLine("Waiting for Production Job to finish");
            bool publishComplete = await JobCompletedSuccessfullyAsync(workspaceArtifactId, productionSetArtifactId, 5);

            if (!publishComplete)
            {
                throw new Exception("Production Job failed to Complete");
            }
            Console2.WriteDisplayEndLine("Production Job Complete!");
        }
        public async Task WaitForImagingJobToCompleteAsync(int workspaceArtifactId, int imagingSetArtifactId)
        {
            RsapiClient.APIOptions.WorkspaceID = workspaceArtifactId;
            Console2.WriteDisplayStartLine("Waiting for Imaging Job to finish");
            bool publishComplete = await JobCompletedSuccessfullyAsync(workspaceArtifactId, imagingSetArtifactId);

            if (!publishComplete)
            {
                throw new Exception("Imaging Job failed to Complete");
            }
            Console2.WriteDisplayEndLine("Imaging Job Complete!");
        }
        public async Task WaitForPublishJobToCompleteAsync(int workspaceArtifactId, int processingSetArtifactId)
        {
            RsapiClient.APIOptions.WorkspaceID = workspaceArtifactId;
            Console2.WriteDisplayStartLine("Waiting for Publish Job to finish...");
            bool publishComplete = await IsJobCompletedSuccessfullyAsync(workspaceArtifactId, processingSetArtifactId, Constants.ProcessingJobType.Publish);

            if (!publishComplete)
            {
                throw new Exception("Publish Job failed to Complete.");
            }
            Console2.WriteDisplayEndLine("Publish Job Complete!");
        }
Exemplo n.º 20
0
        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);
            }
        }
        public async Task CleanupWorkspacesAsync()
        {
            List <int> workspaceArtifactIds = await WorkspaceQueryAsync(Constants.Workspace.NAME);

            if (workspaceArtifactIds.Count > 0)
            {
                Console2.WriteDisplayEndLine("Cleaning up previous Workspaces");
                foreach (int workspaceArtifactId in workspaceArtifactIds)
                {
                    await DeleteWorkspaceAsync(workspaceArtifactId);
                }
                Console2.WriteDisplayEndLine("Cleaned up previous Workspaces!");
            }
        }
        // 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);
            }
        }
Exemplo n.º 23
0
        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);
            }
        }
Exemplo n.º 24
0
        public async Task UploadDocumentsToBlobAsync()
        {
            try
            {
                Console2.WriteDisplayStartLine("Transferring Documents");
                string sourceFolderPath = GetLocalDocumentsFolderPath();
                await UploadAllDocumentsFromFolderAsync(sourceFolderPath);

                Console2.WriteDisplayEndLine("Transferred Documents!");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when writing documents to Blob storage", ex);
            }
        }
        public async Task DeleteWorkspaceAsync(int workspaceArtifactId)
        {
            Console2.WriteDisplayStartLine("Deleting Workspace ");

            try
            {
                await Task.Run(() => RsapiClient.Repositories.Workspace.DeleteSingle(workspaceArtifactId));

                Console2.WriteDisplayEndLine("Deleted Workspace!");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when deleting Workspace", 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);
            }
        }
Exemplo n.º 27
0
        public async Task BuildDtSearchIndexAsync(int workspaceArtifactId, int dtSearchIndexArtifactId)
        {
            try
            {
                Console2.WriteDisplayStartLine("Building DtSearch Index");

                await DtSearchIndexManager.FullBuildIndexAsync(workspaceArtifactId, dtSearchIndexArtifactId, true);

                Console2.WriteDisplayEndLine("Built DtSearch Index!");
                // we will probably need to do some sort of status check. Any larger batch of documents probably would not build fast enough to just move on?
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when building DtSearch Index", 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);
            }
        }
Exemplo n.º 30
0
        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);
            }
        }