Exemplo n.º 1
0
        public static Int32 JobQueueDepth(Relativity.API.IDBContext eddsDBContext)
        {
            string sql = @"
                SELECT COUNT(*) 
                FROM [EDDS].[eddsdbo].[ExtensionFixerQueue]";

            return(Int32.Parse(eddsDBContext.ExecuteSqlStatementAsScalar(sql).ToString()));
        }
Exemplo n.º 2
0
        public static Boolean DoesAgentHaveJob(Relativity.API.IDBContext eddsDBContext, Int32 agentArtifactID)
        {
            string sql      = String.Format(@"
                SELECT COUNT(*) 
                FROM [EDDS].[eddsdbo].[ExtensionFixerQueue] 
                WHERE [AgentArtifactID] = {0}", agentArtifactID.ToString());
            Int32  jobCount = Int32.Parse(eddsDBContext.ExecuteSqlStatementAsScalar(sql).ToString());

            if (jobCount > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private async Task SubmitDocuments(ConsoleButton consoleButton)
        {
            try
            {
                switch (consoleButton.Name)
                {
                //Handle each Button's functionality
                case "Submit Documents":
                    int   workspaceId = this.Helper.GetActiveCaseID();
                    int   modelId     = this.ActiveArtifact.ArtifactID;
                    Model model       = new Model();

                    //Get Documents In SavedSearch
                    int savedSearchId = (int)this.ActiveArtifact.Fields[Guids.Model.SAVED_SEARCH_FIELD.ToString()].Value.Value;
                    await model.ReadDocumentsInSavedSeach(Helper.GetServicesManager(), workspaceId, savedSearchId);

                    //Could have made function shared with the other event handler but left here for demo
                    Relativity.API.IDBContext workspaceContext = Helper.GetDBContext(workspaceId);
                    string        documentLocation             = string.Empty;
                    List <string> documentLocations            = new List <string>();
                    foreach (int documentArtifactId in model.DocsInSearch)
                    {
                        string       sql = @"SELECT [Location] FROM [file] WITH(NOLOCK) WHERE [DocumentArtifactId] = @documentArtifactID AND [Type] = 0";
                        SqlParameter documentArtifactIdParam = new SqlParameter("@documentArtifactID", SqlDbType.Int);
                        documentArtifactIdParam.Value = documentArtifactId;
                        documentLocation = workspaceContext.ExecuteSqlStatementAsScalar <String>(sql, new SqlParameter[] { documentArtifactIdParam });
                        documentLocations.Add(documentLocation);
                    }

                    //get secrets
                    AzureSettings azureSettings = new AzureSettings();

                    ISecretStore secretStore                = this.Helper.GetSecretStore();
                    Secret       secret                     = secretStore.Get(azureSettings.SecretPath);
                    string       congnitiveServicesKey      = secret.Data[azureSettings.CognitiveServicesKeySecretName];
                    string       congnitiveServicesEndPoint = secret.Data[azureSettings.CognitiveServicesEndpointSecretName];
                    string       storageAccountKey          = secret.Data[azureSettings.StorageAccountKeySecretName];
                    string       storageAccountName         = secret.Data[azureSettings.StorageAccountNameSecretName];


                    //upload documents to New Container
                    AzureStorageService azureStorageService             = new FormRecognition.AzureStorageService(storageAccountKey, storageAccountName);
                    Microsoft.Azure.Storage.Blob.CloudBlobClient client = azureStorageService.GetClient();
                    string containerPrefix = workspaceId.ToString() + "-" + modelId.ToString();
                    string sasUrl          = azureStorageService.UploadFiles(client, documentLocations, containerPrefix);
                    string containerName   = azureStorageService.ContainerName;

                    //Train model
                    AzureFormRecognitionService azureFormRecognitionService = new FormRecognition.AzureFormRecognitionService(congnitiveServicesKey, congnitiveServicesEndPoint, Helper);
                    Guid modeld = await azureFormRecognitionService.TrainModelAsync(azureFormRecognitionService.GetClient(), sasUrl);

                    model.ModelGuid = modeld;
                    model.SasUrl    = sasUrl;

                    //Update Relativity with data returned
                    await model.UpdateRelativity(Helper.GetServicesManager(), workspaceId, modelId);

                    break;
                }
            }
            catch (Exception e)
            {
                Helper.GetLoggerFactory().GetLogger().LogError(e, "Submit Documents Error");
                throw;
            }
        }