Ejemplo n.º 1
0
        public void Execute()
        {
            try
            {
                switch (ButtonName)
                {
                case Constant.Names.Console.SUBMIT:
                    //verify all necessary fields are provided
                    if (SavedSearchArtifactId == null || ExtractorProfileArtifactId == null || SourceLongTextFieldArtifactId == null)
                    {
                        throw new CustomExceptions.TextExtractorSetMissingFieldsException(Constant.ErrorMessages.EXTRACTION_SET_MISSING_FIELDS);
                    }

                    var dataRow = SqlQueryHelper.RetrieveSingleInManagerQueueByArtifactId(EddsDbContext, ActiveArtifactId, WorkspaceArtifactId);

                    if (dataRow == null)
                    {
                        //Insert record into Text Extractor Manager table
                        SqlQueryHelper.InsertRowIntoManagerQueue(EddsDbContext, WorkspaceArtifactId, SavedSearchArtifactId, ActiveArtifactId, ExtractorProfileArtifactId, SourceLongTextFieldArtifactId);

                        //Call RSAPI and update Status of Job to Submitted
                        ArtifactQueries.UpdateRdoStringFieldValue(SvcMgr, ExecutionCurrentUserIdentity, WorkspaceArtifactId, Constant.Guids.ObjectType.ExtractorSet, Constant.Guids.Fields.ExtractorSet.Status, ActiveArtifactId, Constant.ExtractorSetStatus.SUBMITTED);
                    }
                    break;

                case Constant.Names.Console.CANCEL:
                    //Check if status of Extractor Set is not Complete
                    var extractorSetStatus = ArtifactQueries.GetExtractorSetStatus(SvcMgr, ExecutionCurrentUserIdentity, WorkspaceArtifactId, ActiveArtifactId);

                    if (extractorSetStatus != Constant.ExtractorSetStatus.COMPLETE)
                    {
                        //Update status of Extractor Set to Cancelled
                        ArtifactQueries.UpdateRdoStringFieldValue(SvcMgr, ExecutionCurrentUserIdentity, WorkspaceArtifactId, Constant.Guids.ObjectType.ExtractorSet, Constant.Guids.Fields.ExtractorSet.Status, ActiveArtifactId, Constant.ExtractorSetStatus.CANCELLED);
                    }
                    else
                    {
                        throw new CustomExceptions.TextExtractorSetConsoleCancelException(Constant.ErrorMessages.EXTRACTION_SET_RECORD_COMPLETE);
                    }
                    break;
                }
            }
            catch (CustomExceptions.TextExtractorSetConsoleCancelException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0}, Error Message: {1}", Constant.ErrorMessages.DEFAULT_ERROR_PREPEND, ex));
            }
        }