Пример #1
0
        private static async Task DeleteWorkspaceAsync()
        {
            Console2.WriteStartHeader("Delete Workspace");
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            Console.WriteLine("Would you like to delete the created workspace (type 'y' or 'n'):");
            string response = Console.ReadLine();

            if (response == null || response.ToLower().Equals("y"))
            {
                WorkspaceHelper workspaceHelper = new WorkspaceHelper(_connectionManager.RsapiClient);

                // Delete workspace
                await workspaceHelper.DeleteWorkspaceAsync(_workspaceArtifactId);
            }

            stopwatch.Stop();
            DisplayTimeElapsed(stopwatch.Elapsed);
        }
Пример #2
0
            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!");
        }
Пример #5
0
        private static async Task CreateAndBuildDtSearch()
        {
            Console2.WriteStartHeader("Create Search");
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            // Create Keyword Search
            int seedSearchId = await RESTSearchHelper.CreateKeywordSearchAsync(_httpClient, _workspaceArtifactId);

            // Create dtSearch Index
            _dtSearchIndexId = await RESTSearchHelper.CreateDtSearchIndexAsync(_httpClient, _workspaceArtifactId, seedSearchId);

            // Build dtSearch Index
            await RESTSearchHelper.BuildDtSearchIndexAsync(_httpClient, _workspaceArtifactId, _dtSearchIndexId);

            // Create dtSearch
            _dtSearchArtifactId = await RESTSearchHelper.CreateDtSearchAsync(_httpClient, _workspaceArtifactId, _dtSearchIndexId, Constants.Workspace.EXTRACTED_TEXT_FIELD_NAME);

            stopwatch.Stop();
            DisplayTimeElapsed(stopwatch.Elapsed);
        }
Пример #6
0
        public override async Task Execute()
        {
            Console2.White("Seeding Users... ");

            _db.Users.AddIfNotExists(m => m.Name == "Admin", new User
            {
                Name           = "Admin",
                Email          = "*****@*****.**",
                HashedPassword = Hash.Create("admin"),
                IsAdmin        = true,
                ConfirmedAt    = DateTime.Now
            });

            Console2.GreenLine("✅");

            Console2.White($"Seeding Providers... ");

            _db.Providers.AddIfNotExists(m => m.Name == "Four", new Provider
            {
                Name    = "Four",
                Amounts = "10,20,30,50"
            });

            _db.Providers.AddIfNotExists(m => m.Name == "Lemon", new Provider
            {
                Name    = "Lemon",
                Amounts = "15,25,50"
            });

            _db.Providers.AddIfNotExists(m => m.Name == "G-Mobile", new Provider
            {
                Name    = "G-Mobile",
                Amounts = "10,15,20,30"
            });

            Console2.GreenLine("✅");

            await _db.SaveChangesAsync();
        }
        public static async Task <int> CreateCustodianAsync(HttpClient httpClient, int workspaceId)
        {
            try
            {
                string url = "Relativity.REST/api/Relativity.Processing.Services.IProcessingModule/Processing Custodian Manager/SaveAsync";
                CustodianSaveRequest custodianSaveRequest = new CustodianSaveRequest
                {
                    Custodian = new Custodian
                    {
                        DocumentNumberingPrefix = Constants.Processing.Custodian.DOCUMENT_NUMBERING_PREFIX,
                        FirstName     = Constants.Processing.Custodian.FIRST_NAME,
                        LastName      = Constants.Processing.Custodian.LAST_NAME,
                        CustodianType = "Person"
                    },
                    workspaceArtifactId = workspaceId
                };
                string request = JsonConvert.SerializeObject(custodianSaveRequest);

                Console2.WriteDisplayStartLine($"Creating Custodian [FirstName: {Constants.Processing.Custodian.FIRST_NAME}, LastName: {Constants.Processing.Custodian.LAST_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 Custodian");
                }

                int custodianArtifactId = Int32.Parse(result);
                Console2.WriteDebugLine($"Custodian ArtifactId: {custodianArtifactId}");
                Console2.WriteDisplayEndLine("Created Custodian!");

                return(custodianArtifactId);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when creating Custodian", ex);
            }
        }
Пример #8
0
        public static async Task <List <int> > GetDocumentsToTagAsync(HttpClient httpClient, int searchID, int workspaceID)
        {
            try
            {
                List <int> DocsToTag = new List <int>();
                string     url       = $"/Relativity.REST/Workspace/{workspaceID}/Document/QueryResult";
                string     fields    = "*";
                GetDocs    docsToTag = new GetDocs()
                {
                    Condition = $"'ArtifactId' IN SAVEDSEARCH {searchID}",
                    Fields    = new string[] { fields }
                };
                string request = JsonConvert.SerializeObject(docsToTag);

                Console2.WriteDisplayStartLine("Querying documents to Tag");
                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 obtain documents.");
                }

                JObject resultObject = JObject.Parse(result);
                foreach (JToken token in resultObject["Results"])
                {
                    DocsToTag.Add(token["Artifact ID"].Value <int>());
                }
                Console2.WriteDisplayEndLine($"Queried documents to Tag [Count: {DocsToTag.Count}]");

                return(DocsToTag);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occurred when Querying for documents to tag", ex);
            }
        }
Пример #9
0
            private async Task <RelativityFileShare> GetFileShareAsync(IRelativityTransferHost relativityTransferHost, int number, CancellationToken cancellationToken)
            {
                Console2.WriteTapiStartHeader("Get Specified File Share");
                IFileStorageSearch fileStorageSearch = relativityTransferHost.CreateFileStorageSearch();

                // Admin rights are required but this allows searching for all possible file shares within the instance.
                FileStorageSearchContext context = new FileStorageSearchContext {
                    WorkspaceId = Workspace.AdminWorkspaceId
                };
                FileStorageSearchResults results = await fileStorageSearch.SearchAsync(context, cancellationToken).ConfigureAwait(false);

                // Specify the cloud-based logical file share number - or just the 1st file share when all else fails.
                RelativityFileShare fileShare = results.GetRelativityFileShare(number) ?? results.FileShares.FirstOrDefault();

                if (fileShare == null)
                {
                    throw new InvalidOperationException("This operation cannot be performed because there are no file shares available.");
                }

                DisplayFileShare(fileShare);
                Console2.WriteTapiEndHeader();
                return(fileShare);
            }
Пример #10
0
        private static async Task CreateAndRunImagingSetAsync()
        {
            Console2.WriteStartHeader("Imaging");
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            //	Perform another search for documents where responsive = yes
            int savedSearchId = await RESTSearchHelper.CreateDtSearchAsync(_httpClient, _workspaceArtifactId, _dtSearchIndexId, Constants.Workspace.ResponsiveField.Name);

            // Create Imaging Profile and Set
            int imagingProfileId = await RESTImagingHelper.CreateImagingProfileAsync(_httpClient, _workspaceArtifactId);

            int imagingSetId = await RESTImagingHelper.CreateImagingSetAsync(_httpClient, savedSearchId, imagingProfileId, _workspaceArtifactId);

            // Run Imaging Job
            await RESTImagingHelper.RunImagingJobAsync(_httpClient, imagingSetId, _workspaceArtifactId);

            await RESTImagingHelper.WaitForImagingJobToCompleteAsync(_httpClient, _workspaceArtifactId, imagingSetId);

            stopwatch.Stop();
            DisplayTimeElapsed(stopwatch.Elapsed);
        }
Пример #11
0
        public override bool Execute(Input input)
        {
            var make = new Maker(_solution);

            Console2.BreakLine();

            if (input.Template.IsEmpty())
            {
                Console2.YellowLine("Choose one of the templates passing the flag:");
                Console2.WhiteLine("--new");
                Console2.WhiteLine("--show");
                Console2.WhiteLine("--list");
                Console2.WhiteLine("--edit");

                return(false);
            }

            make.Feature(input.In, input.Name, input.Action, input.Template);

            Console2.BreakLine();

            return(true);
        }
        public async Task StartPublishJobAsync(int processingSetArtifactId, int workspaceArtifactId)
        {
            try
            {
                Console2.WriteDisplayStartLine("Starting Publish Job");

                // Create a publish job object.
                PublishJob publishJob = new PublishJob
                {
                    ProcessingSetId     = processingSetArtifactId,
                    WorkspaceArtifactId = workspaceArtifactId
                };

                // Submit the job for publish.
                await ProcessingJobManager.SubmitPublishJobsAsync(publishJob);

                Console2.WriteDisplayEndLine("Started Publish Job!");
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when staring Processing Publish Job", ex);
            }
        }
Пример #13
0
        public static async Task CheckProductionStatusAsync(HttpClient httpClient, int productionId, int workspaceId)
        {
            try
            {
                string url = $"/Relativity.REST/api/Relativity.Productions.Services.IProductionModule/Production%20Manager/ReadSingleAsync";
                string productionStatus = "Staged";
                ReadProductionRequest readProductionRequest = new ReadProductionRequest()
                {
                    DataSourceReadMode   = 0,
                    productionArtifactID = productionId,
                    workspaceArtifactID  = workspaceId
                };
                string request = JsonConvert.SerializeObject(readProductionRequest);

                Console2.WriteDisplayStartLine("Waiting for Production Job to finish");
                while (productionStatus != "Produced")
                {
                    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 read production set.");
                    }
                    JToken productionReadResults = JToken.Parse(result);
                    var    test2 = productionReadResults["ProductionMetadata"];
                    productionStatus = test2["Status"].Value <string>();
                }

                Console2.WriteDisplayEndLine("Production Job Complete!");
            }
            catch (Exception ex)
            {
                throw new Exception("Production Job failed to Complete", ex);
            }
        }
        public async Task <int> CreateProcessingSetAsync(int processingProfileArtifactId, int workspaceArtifactId)
        {
            try
            {
                Console2.WriteDisplayStartLine($"Creating Processing Set [Name: {Constants.Processing.Set.NAME}]");

                //Build the ProcessingSet object.
                ProcessingSet processingSet = new ProcessingSet
                {
                    ArtifactID = Constants.Processing.Set.ARTIFACT_ID,
                    Name       = Constants.Processing.Set.NAME,
                    Profile    = new ProcessingProfileRef(processingProfileArtifactId)
                };

                if (Constants.Processing.Set.EmailNotificationRecipients.Length > 0)
                {
                    processingSet.EmailNotificationRecipients = Constants.Processing.Set.EmailNotificationRecipients;
                }

                //Create the ProcessingSet object. The service returns the Artifact ID of the object.
                int processingSetArtifactId = await ProcessingSetManager.SaveAsync(processingSet, workspaceArtifactId);

                if (processingSetArtifactId == 0)
                {
                    throw new Exception("Failed to Create Processing Set");
                }

                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);
            }
        }
Пример #15
0
        private static async Task CreateAndBuildDtSearch()
        {
            Console2.WriteStartHeader("Create Search");
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            SearchHelper searchHelper = new SearchHelper(_connectionManager.KeywordSearchManager, _connectionManager.DtSearchManager, _connectionManager.DtSearchIndexManager, _connectionManager.RsapiClient);

            // Create Keyword Search
            int keywordSearchArtifactId = await searchHelper.CreateKeywordSearchAsync(_workspaceArtifactId);

            // Create dtSearch Index
            int dtSearchIndexArtifactId = await searchHelper.CreateDtSearchIndexAsync(_workspaceArtifactId, keywordSearchArtifactId);

            // Build dtSearch index
            await searchHelper.BuildDtSearchIndexAsync(_workspaceArtifactId, dtSearchIndexArtifactId);

            // Create dtSearch
            _dtSearchArtifactId = await searchHelper.CreateDtSearchAsync(_workspaceArtifactId, Constants.Workspace.EXTRACTED_TEXT_FIELD_NAME);

            stopwatch.Stop();
            DisplayTimeElapsed(stopwatch.Elapsed);
        }
Пример #16
0
            public Task Execute()
            {
                var services = _services.Where(x =>
                                               !x.ServiceType.Namespace.StartsWith("Microsoft") &&
                                               !x.ServiceType.Namespace.StartsWith("System"));

                // if (input.Namespace.NotEmpty())
                services = services.Where(x =>
                                          x.ServiceType.Namespace.StartsWith("Mediat") ||
                                          x.ServiceType.Namespace.StartsWith("Miru") ||
                                          x.ServiceType.Namespace.StartsWith("Intanext"))
                           .OrderBy(x => x.ServiceType.FullName);

                foreach (var service in services)
                {
                    Console2.WhiteLine(service.ServiceType.FullName);
                    Console2.White("\t");
                    Console2.WhiteLine(service.Lifetime.ToString());
                    Console2.White("\t");
                    Console2.WhiteLine(service.ImplementationType?.FullName ?? "None");
                }

                return(Task.CompletedTask);
            }
Пример #17
0
        public async Task <List <int> > GetDocumentsToTagAsync(int searchArtifactId, int workspaceArtifactId)
        {
            Console2.WriteDisplayStartLine("Querying documents to Tag");

            RsapiClient.APIOptions.WorkspaceID = workspaceArtifactId;
            List <int> documentsToTag = new List <int>();

            Query <Document> documentQuery = new Query <Document>
            {
                Condition = new SavedSearchCondition(searchArtifactId),
                Fields    = FieldValue.AllFields
            };

            ResultSet <Document> docResults = await Task.Run(() => RsapiClient.Repositories.Document.Query(documentQuery));

            foreach (Result <Document> singleDoc in docResults.Results)
            {
                // This loop will add the artifactID of each document that met our search Criteria and as such should be tagged responsive or w/e
                documentsToTag.Add(singleDoc.Artifact.ArtifactID);
            }

            Console2.WriteDisplayEndLine($"Queried documents to Tag [Count: {documentsToTag.Count}]");
            return(documentsToTag);
        }
        //This should cover profile, custodians, processing sets, inventory job, discovery, publish
        public async Task <int> CreateProcessingProfileAsync(int timeZoneArtifactId, int destinationFolderArtifactId, int workspaceArtifactId)
        {
            try
            {
                Console2.WriteDisplayStartLine($"Creating Processing Profile [Name: {Constants.Processing.Profile.NAME}]");

                // Build Basic Processing Profile
                ProcessingProfile processingProfile = BuildBasicProfile(timeZoneArtifactId, destinationFolderArtifactId);

                //Build the ProcessingProfileSaveRequest
                ProcessingProfileSaveRequest processingProfileSaveRequest = new ProcessingProfileSaveRequest
                {
                    ProcessingProfile = processingProfile,
                    WorkspaceId       = workspaceArtifactId
                };

                //Create the ProcessingProfile object. The service returns a ProcessingProfileSaveResponse object.
                ProcessingProfileSaveResponse saveResponse = await ProcessingProfileManager.SaveAsync(processingProfileSaveRequest);

                int processingProfileArtifactId = saveResponse.ProcessingProfileId;
                if (processingProfileArtifactId == 0)
                {
                    throw new Exception("Failed to Create Processing Profile");
                }

                Console2.WriteDebugLine($"Processing Profile ArtifactId: {processingProfileArtifactId}");
                Console2.WriteDisplayEndLine("Created Processing Profile!");

                return(processingProfileArtifactId);
            }
            catch (Exception ex)
            {
                // Error Creating Processing Profile
                throw new Exception("An error occured when creating Processing Profile", ex);
            }
        }
Пример #19
0
        public static async Task MainAsync(string[] args)
        {
            try
            {
                _httpClient        = RESTConnectionManager.GetHttpClient();
                _connectionManager = new ConnectionManager();

                await CleanupWorkspacesAsync();

                await CreateWorkspaceAsync();

                await TransferDocumentsAsync();

                await CreateAndRunProcessingSetAsync();

                await CreateAndBuildDtSearch();

                await TagDocumentsAsResponsiveAsync();

                await CreateAndRunImagingSetAsync();

                await CreateAndRunProductionAsync();

                await DownloadProductionAsync();
            }
            catch (Exception ex)
            {
                string errorMessage = $"An error occured in the {nameof(MainAsync)} method.";
                Console2.WriteErrorLine(errorMessage);
                throw new Exception(errorMessage, ex);
            }
            finally
            {
                await DeleteWorkspaceAsync();
            }
        }
        public static async Task <int> CreateProcessingProfileAsync(HttpClient httpClient, int timeZoneArtifactId, int destinationFolderArtifactId, int workspaceId)
        {
            try
            {
                string url = "Relativity.REST/api/Relativity.Processing.Services.IProcessingModule/Processing Profile Manager/SaveAsync";
                ProcessingProfileSaveRequestStructure processingProfileSaveRequestStructure = new ProcessingProfileSaveRequestStructure
                {
                    ProcessingProfileSaveRequest = new ProcessingProfileSaveRequest
                    {
                        ProcessingProfile = new ProcessingProfile
                        {
                            Name = Constants.Processing.Profile.NAME,
                            NumberingSettings = new NumberingSettings
                            {
                                DefaultDocumentNumberingPrefix = Constants.Processing.Profile.DEFAULT_DOCUMENT_NUMBERING_PREFIX,
                                NumberofDigits       = Constants.Processing.Profile.NUMBER_OF_DIGITS4_AS_STRING,
                                NumberingType        = Constants.Processing.Profile.NUMBERING_TYPE_AS_STRING,
                                ParentChildNumbering = Constants.Processing.Profile.PARENT_CHILD_NUMBERING_AS_STRING,
                                Delimiter            = Constants.Processing.Profile.DELIMITER,
                            },
                            DeduplicationSettings = new DeduplicationSettings
                            {
                                DeduplicationMethod        = Constants.Processing.Profile.DE_DUPLICATION_METHOD_AS_STRING,
                                PropagateDeduplicationData = Constants.Processing.Profile.PROPAGATE_DE_DUPLICATION_DATA
                            },
                            ExtractionSettings = new ExtractionSettings
                            {
                                Extractchildren                = Constants.Processing.Profile.EXTRACT_CHILDREN,
                                EmailOutput                    = Constants.Processing.Profile.EMAIL_OUTPUT_AS_STRING,
                                ExcelTextExtractionMethod      = Constants.Processing.Profile.EXCEL_TEXT_EXTRACTION_METHOD_AS_STRING,
                                ExcelHeaderFooterExtraction    = Constants.Processing.Profile.EXCEL_HEADER_FOOTER_EXTRACTION_AS_STRING,
                                PowerPointTextExtractionMethod = Constants.Processing.Profile.POWER_POINT_TEXT_EXTRACTION_METHOD_AS_STRING,
                                WordTextExtractionMethod       = Constants.Processing.Profile.WORD_TEXT_EXTRACTION_METHOD_AS_STRING,
                                OCR              = Constants.Processing.Profile.OCR,
                                OCRAccuracy      = Constants.Processing.Profile.OCR_ACCURACY_AS_STRING,
                                OCRTextSeparator = Constants.Processing.Profile.OCR_TEXT_SEPARATOR
                            },
                            InventoryDiscoverSettings = new InventoryDiscoverSettings
                            {
                                DeNIST              = Constants.Processing.Profile.DE_NIST,
                                DefaultTimeZoneID   = timeZoneArtifactId,
                                DefaultOCRlanguages = Constants.Processing.Profile.DEFAULT_OCR_LANGUAGES
                            },
                            PublishSettings = new PublishSettings
                            {
                                AutopublishSet           = Constants.Processing.Profile.AUTO_PUBLISH_SET,
                                DefaultDestinationFolder = new DefaultDestinationFolder
                                {
                                    ArtifactID = destinationFolderArtifactId
                                },
                                UseSourceFolderStructure = Constants.Processing.Profile.USE_SOURCE_FOLDER_STRUCTURE
                            }
                        },
                        WorkspaceId = workspaceId
                    }
                };
                string request = JsonConvert.SerializeObject(processingProfileSaveRequestStructure);

                Console2.WriteDisplayStartLine($"Creating Processing Profile [Name: {Constants.Processing.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 Processing Profile");
                }

                JObject resultObject = JObject.Parse(result);
                int     processingProfileArtifactId = resultObject["ProcessingProfileId"].Value <int>();
                Console2.WriteDebugLine($"Processing Profile ArtifactId: {processingProfileArtifactId}");
                Console2.WriteDisplayEndLine("Created Processing Profile!");

                return(processingProfileArtifactId);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when creating Processing Profile", ex);
            }
        }
Пример #21
0
        public override Task <bool> Handle(ConsoleCommandEvent <LogoConsoleCommand> request, CancellationToken cancellationToken)
        {
            Console2.WriteTextLogo();

            return(Task.FromResult(true));
        }
Пример #22
0
 public void PrintConsole(string line)
 {
     Console2.Invoke(new TreeViewUpdateDelegate(delegate(string line1) { Console2.Nodes.Add(line1).EnsureVisible(); }), new object[] { line });
 }
Пример #23
0
        public static async Task <int> CreateProductionAsync(HttpClient httpClient, int workspaceId)
        {
            try
            {
                string     url          = $"/Relativity.REST/api/Relativity.Productions.Services.IProductionModule/Production%20Manager/CreateSingleAsync";
                Production prodSettings = new Production()
                {
                    Details = new Details()
                    {
                        BrandingFontSize = Constants.Production.BRANDING_FONT_SIZE, EmailRecipients = "", ScaleBrandingFont = false
                    },
                    Footers = new Footers()
                    {
                        LeftFooter = new Leftfooter()
                        {
                            Type = "None", Field = new Field1()
                            {
                                ArtifactID = 0, Name = "", ViewFieldID = 0
                            }, FreeText = "", FriendlyName = "Left Header"
                        }
                    },
                    Headers = new Headers()
                    {
                        LeftHeader = new Leftheader()
                        {
                            Type = "None", Field = new Field()
                            {
                                ArtifactID = 0, Name = "", ViewFieldID = 0
                            }, FreeText = "", FriendlyName = "Left Header"
                        }
                    },
                    Name      = Constants.Production.NAME,
                    Numbering = new Numbering()
                    {
                        AttachmentRelationalField = new Attachmentrelationalfield()
                        {
                            ArtifactID = 0, Name = "", ViewFieldID = 0
                        }, BatesPrefix = Constants.Production.BATES_PREFIX, BatesStartNumber = Constants.Production.BATES_START_NUMBER, BatesSuffix = Constants.Production.BATES_SUFFIX, NumberOfDigitsForDocumentNumbering = Constants.Production.NUMBER_OF_DIGITS_FOR_DOCUMENT_NUMBERING, NumberingType = "PageLevel"
                    },
                    ShouldCopyInstanceOnWorkspaceCreate = false,
                    SortOrder = ""
                };
                ProductionObject newProduction = new ProductionObject()
                {
                    Production          = prodSettings,
                    workspaceArtifactID = workspaceId
                };
                string request = JsonConvert.SerializeObject(newProduction);

                Console2.WriteDisplayStartLine($"Creating Production [Name: {Constants.Production.NAME}]");
                HttpResponseMessage response = RESTConnectionManager.MakePost(httpClient, url, request);
                string result  = response.Content.ReadAsStringAsync().Result;
                bool   success = HttpStatusCode.OK == response.StatusCode;
                if (!success)
                {
                    throw new Exception("Failed to create production set.");
                }

                int productionArtifactId = Convert.ToInt32(result);
                Console2.WriteDebugLine($"Production ArtifactId: {productionArtifactId}");
                Console2.WriteDisplayEndLine("Created Production!");

                return(productionArtifactId);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when creating Production", ex);
            }
        }
Пример #24
0
        public async Task <int> CreateKeywordSearchAsync(int workspaceArtifactId)
        {
            Console2.WriteDisplayStartLine("Creating Keyword search for DtSearch Index");

            try
            {
                SearchContainerRef searchFolder = new SearchContainerRef();

                KeywordSearch keywordSearch = new KeywordSearch
                {
                    Name            = Constants.Search.KeywordSearch.NAME,
                    SearchContainer = searchFolder
                };

                // Get all the query fields available to the current user.
                SearchResultViewFields searchResultViewFields = await KeywordSearchManager.GetFieldsForSearchResultViewAsync(workspaceArtifactId, Constants.DOCUMENT_ARTIFACT_TYPE);

                // Set the owner to the current user, in this case "Admin, Relativity," or "0" for public.
                List <UserRef> searchOwners = await KeywordSearchManager.GetSearchOwnersAsync(workspaceArtifactId);

                keywordSearch.Owner = searchOwners.First(o => o.Name == Constants.Search.KeywordSearch.OWNER);

                // Add the fields to the Fields collection.
                // If a field Name, ArtifactID, Guid, or ViewFieldID is known, a field can be set with that information as well.

                FieldRef fieldRef = searchResultViewFields.FieldsNotIncluded.First(f => f.Name == Constants.Search.KeywordSearch.FIELD_EDIT);
                keywordSearch.Fields.Add(fieldRef);

                fieldRef = searchResultViewFields.FieldsNotIncluded.First(f => f.Name == Constants.Search.KeywordSearch.FIELD_FILE_ICON);
                keywordSearch.Fields.Add(fieldRef);

                fieldRef = searchResultViewFields.FieldsNotIncluded.First(f => f.Name == Constants.Search.KeywordSearch.FIELD_CONTROL_NUMBER);
                keywordSearch.Fields.Add(fieldRef);

                // Create a Criteria for the field named "Extracted Text" where the value is set

                Criteria criteria = new Criteria
                {
                    Condition = new CriteriaCondition(
                        new FieldRef
                    {
                        Name = Constants.Search.KeywordSearch.CONDITION_FIELD_EXTRACTED_TEXT
                    }, CriteriaConditionEnum.IsSet)
                };

                // Add the search condition criteria to the collection.
                keywordSearch.SearchCriteria.Conditions.Add(criteria);

                // Add a note.

                keywordSearch.Notes          = Constants.Search.KeywordSearch.NOTES;
                keywordSearch.ArtifactTypeID = Constants.DOCUMENT_ARTIFACT_TYPE;

                // Create the search.
                int keywordSearchArtifactId = await KeywordSearchManager.CreateSingleAsync(workspaceArtifactId, keywordSearch);

                if (keywordSearchArtifactId == 0)
                {
                    throw new Exception("Failed to create the Keyword Search");
                }

                Console2.WriteDebugLine($"Keyword Search ArtifactId: {keywordSearchArtifactId}");
                Console2.WriteDisplayEndLine("Created Keyword search for DtSearch Index!");

                return(keywordSearchArtifactId);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when creating Keyword Search", ex);
            }
        }
Пример #25
0
        public async Task <int> CreateDtSearchAsync(int workspaceArtifactId, string fieldName)
        {
            Console2.WriteDisplayStartLine($"Creating DtSearch for Field [Name: {fieldName}]");

            try
            {
                string searchName = Constants.Search.DtSearch.NAME;
                if (fieldName == Constants.Workspace.EXTRACTED_TEXT_FIELD_NAME)
                {
                    searchName = Constants.Search.DtSearch.NAME_EXTRACTED_TEXT;
                }
                SearchContainerRef searchContainerRef = new SearchContainerRef();
                dtSearch           dtSearch           = new dtSearch
                {
                    Name            = searchName,
                    SearchContainer = searchContainerRef
                };

                // Get all the query fields available to the current user.
                SearchResultViewFields searchResultViewFields = await DtSearchManager.GetFieldsForSearchResultViewAsync(workspaceArtifactId, Constants.DOCUMENT_ARTIFACT_TYPE);

                // Get a dtSearch SearchIndex and set it.
                List <SearchIndexRef> searchIndexes = await DtSearchManager.GetSearchIndexesAsync(workspaceArtifactId);

                dtSearch.SearchIndex = searchIndexes.FirstOrDefault();

                // Set the owner to "Public".
                List <UserRef> searchOwners = await DtSearchManager.GetSearchOwnersAsync(workspaceArtifactId);

                dtSearch.Owner = searchOwners.First(o => o.Name == Constants.Search.DtSearch.OWNER);

                // Add the fields to the Fields collection.
                // If a field Name, ArtifactID, Guid, or ViewFieldID is known, a field can be set with that information as well.

                FieldRef field = searchResultViewFields.FieldsNotIncluded.First(f => f.Name == Constants.Search.DtSearch.FIELD_EDIT);
                dtSearch.Fields.Add(field);

                field = searchResultViewFields.FieldsNotIncluded.First(f => f.Name == Constants.Search.DtSearch.FIELD_FILE_ICON);
                dtSearch.Fields.Add(field);

                field = searchResultViewFields.FieldsNotIncluded.First(f => f.Name == Constants.Search.DtSearch.FIELD_CONTROL_NUMBER);
                dtSearch.Fields.Add(field);

                // Create a Criteria for the field named "Extracted Text" where the value is set

                Criteria criteria = new Criteria
                {
                    Condition = new CriteriaCondition(new FieldRef
                    {
                        Name = fieldName
                    }, CriteriaConditionEnum.IsSet)
                };

                // Add the search condition criteria to the collection.
                dtSearch.SearchCriteria.Conditions.Add(criteria);

                // Search for the text string "John" with a fuzziness level of 5 and stemming enabled.
                //search.SearchText = "John";
                //search.FuzzinessLevel = 5;
                //search.EnableStemming = true;

                // Add a note.
                dtSearch.Notes          = Constants.Search.DtSearch.NOTES;
                dtSearch.ArtifactTypeID = Constants.DOCUMENT_ARTIFACT_TYPE;

                // Create the search.
                int dtSearchArtifactId = await DtSearchManager.CreateSingleAsync(workspaceArtifactId, dtSearch);

                if (dtSearchArtifactId == 0)
                {
                    throw new Exception("Failed to create the DtSearch");
                }

                Console2.WriteDebugLine($"DtSearch ArtifactId: {dtSearchArtifactId}");
                Console2.WriteDisplayEndLine("Created DtSearch!");

                return(dtSearchArtifactId);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when creating DtSearch", ex);
            }
        }
Пример #26
0
        public static async Task <int> CreateKeywordSearchAsync(HttpClient httpClient, int workspaceId)
        {
            try
            {
                string url = "Relativity.REST/api/Relativity.Services.Search.ISearchModule/Keyword Search Manager/CreateSingleAsync";
                KeywordSearchCreateRequest keywordSearchCreateRequest = new KeywordSearchCreateRequest
                {
                    workspaceArtifactID = workspaceId,
                    searchDTO           = new Searchdto
                    {
                        ArtifactTypeID = 10,
                        Name           = Constants.Search.KeywordSearch.NAME,
                        SearchCriteria = new Searchcriteria
                        {
                            Conditions = new []
                            {
                                new Condition
                                {
                                    condition = new Condition1
                                    {
                                        Operator        = "Is Set",
                                        ConditionType   = "Criteria",
                                        FieldIdentifier = new Fieldidentifier
                                        {
                                            Name = Constants.Search.KeywordSearch.CONDITION_FIELD_EXTRACTED_TEXT
                                        }
                                    }
                                }
                            }
                        },
                        Fields = new []
                        {
                            new Field
                            {
                                Name = "Edit"
                            },
                            new Field
                            {
                                Name = "File Icon"
                            },
                            new Field
                            {
                                Name = "Control Number"
                            }
                        }
                    }
                };
                string request = JsonConvert.SerializeObject(keywordSearchCreateRequest);

                Console2.WriteDisplayStartLine("Creating Keyword search for 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 Keyword Search");
                }

                int keywordSearchArtifactId = Int32.Parse(result);
                Console2.WriteDebugLine($"Keyword Search ArtifactId: {keywordSearchArtifactId}");
                Console2.WriteDisplayEndLine("Created Keyword search for DtSearch Index!");

                return(keywordSearchArtifactId);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when creating Keyword Search", ex);
            }
        }
Пример #27
0
        public static async Task <int> CreateDtSearchAsync(HttpClient httpClient, int workspaceId, int dtSearchIndexId, string fieldName)
        {
            try
            {
                string url        = "Relativity.REST/api/Relativity.Services.Search.ISearchModule/dtSearch Manager/CreateSingleAsync";
                string searchName = Constants.Search.DtSearch.NAME;
                if (fieldName == Constants.Workspace.EXTRACTED_TEXT_FIELD_NAME)
                {
                    searchName = Constants.Search.DtSearch.NAME_EXTRACTED_TEXT;
                }
                DtSearchSaveRequest dtSearchSaveRequest = new DtSearchSaveRequest
                {
                    workspaceArtifactID = workspaceId,
                    searchDTO           = new searchdto
                    {
                        ArtifactTypeID = 10,
                        Name           = searchName,
                        SearchIndex    = new searchindex
                        {
                            ArtifactID = dtSearchIndexId,
                            Name       = Constants.Search.DtSearchIndex.NAME
                        },
                        SearchCriteria = new searchcriteria
                        {
                            Conditions = new []
                            {
                                new condition
                                {
                                    condition1 = new condition1
                                    {
                                        Operator        = "Is Set",
                                        ConditionType   = "Criteria",
                                        FieldIdentifier = new fieldidentifier
                                        {
                                            Name = fieldName
                                        }
                                    }
                                },
                            }
                        },
                        Fields = new []
                        {
                            new Fields
                            {
                                Name = "Edit"
                            },
                            new Fields
                            {
                                Name = "File Icon"
                            },
                            new Fields
                            {
                                Name = "Control Number"
                            }
                        }
                    }
                };
                string request = JsonConvert.SerializeObject(dtSearchSaveRequest);

                Console2.WriteDisplayStartLine($"Creating DtSearch for Field [Name: {fieldName}]");
                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");
                }

                int dtSearchArtifactId = Int32.Parse(result);
                Console2.WriteDebugLine($"DtSearch ArtifactId: {dtSearchArtifactId}");
                Console2.WriteDisplayEndLine("Created DtSearch!");

                return(dtSearchArtifactId);
            }
            catch (Exception ex)
            {
                throw new Exception("An error occured when creating DtSearch", ex);
            }
        }
Пример #28
0
            private async Task UploadMultipleDocumentsAsync(IRelativityTransferHost relativityTransferHost, CancellationToken cancellationToken)
            {
                // Search for the first logical file share.
                const int           logicalFileShareNumber = 1;
                RelativityFileShare fileShare = await GetFileShareAsync(relativityTransferHost, logicalFileShareNumber, cancellationToken).ConfigureAwait(false);

                // Configure an Aspera specific transfer.
                AsperaClientConfiguration configuration = CreateAsperaClientConfiguration();

                // Assigning the file share bypasses auto-configuration that will normally use the default workspace repository.
                configuration.TargetFileShare = fileShare;
                using (ITransferClient client = await CreateClientAsync(relativityTransferHost, configuration, cancellationToken).ConfigureAwait(false))
                    using (AutoDeleteDirectory directory = new AutoDeleteDirectory())
                    {
                        // Create a job-based upload transfer request.
                        Console2.WriteTapiStartHeader("Advanced Transfer - Upload");
                        string uploadTargetPath = GetUniqueRemoteTargetPath(fileShare);
                        IList <TransferPath> localSourcePaths = await SearchLocalSourcePathsAsync(client, uploadTargetPath, cancellationToken).ConfigureAwait(false);

                        TransferContext context          = CreateTransferContext();
                        TransferRequest uploadJobRequest = TransferRequest.ForUploadJob(uploadTargetPath, context);
                        uploadJobRequest.Application = "Github Sample";
                        uploadJobRequest.Name        = "Advanced Upload Sample";

                        // Create a transfer job to upload the local sample data set to the target remote path.
                        using (ITransferJob job = await client.CreateJobAsync(uploadJobRequest, cancellationToken).ConfigureAwait(false))
                        {
                            Console2.WriteDebugLine("Advanced upload started.");

                            // Paths added to the async job are transferred immediately.
                            await job.AddPathsAsync(localSourcePaths, cancellationToken).ConfigureAwait(false);

                            // Await completion of the job.
                            ITransferResult result = await job.CompleteAsync(cancellationToken).ConfigureAwait(false);

                            Console2.WriteDebugLine("Advanced upload completed.");
                            DisplayTransferResult(result);
                            Console2.WriteTapiEndHeader();
                        }

                        // Create a job-based download transfer request.
                        Console2.WriteTapiStartHeader("Advanced Transfer - Download");
                        string          downloadTargetPath = directory.Path;
                        TransferRequest downloadJobRequest = TransferRequest.ForDownloadJob(downloadTargetPath, context);
                        downloadJobRequest.Application = "Github Sample";
                        downloadJobRequest.Name        = "Advanced Download Sample";
                        Console2.WriteDebugLine("Advanced download started.");

                        // Create a transfer job to download the sample data set to the target local path.
                        using (ITransferJob job = await client.CreateJobAsync(downloadJobRequest, cancellationToken).ConfigureAwait(false))
                        {
                            IEnumerable <TransferPath> remotePaths = localSourcePaths.Select(localPath => new TransferPath
                            {
                                SourcePath     = uploadTargetPath + "\\" + Path.GetFileName(localPath.SourcePath),
                                PathAttributes = TransferPathAttributes.File,
                                TargetPath     = downloadTargetPath
                            });

                            await job.AddPathsAsync(remotePaths, cancellationToken).ConfigureAwait(false);
                            await ChangeDataRateAsync(job, cancellationToken).ConfigureAwait(false);

                            // Await completion of the job.
                            ITransferResult result = await job.CompleteAsync(cancellationToken).ConfigureAwait(false);

                            Console2.WriteDebugLine("Advanced download completed.");
                            DisplayTransferResult(result);
                            Console2.WriteTapiEndHeader();
                        }
                    }
            }
Пример #29
0
 private static void DisplayTimeElapsed(TimeSpan stopwatchElapsed, string prefix = null)
 {
     Console2.WriteDisplayStartLine($"{prefix ?? string.Empty}Time elapsed: {stopwatchElapsed:hh\\:mm\\:ss}");
     Console2.WriteDisplayEmptyLine();
 }
Пример #30
0
 public void CleanConsole()
 {
     Console2.Invoke(new TreeViewCleanDelegate(delegate { Console2.Nodes.Clear(); }));
 }