Ejemplo n.º 1
0
        public async Task ExecuteAsync()
        {
            var queryHelper      = new Query();
            var resourceGroupIds = GetResourceGroupIDs();
            IArtifactQueries  artifactQueries  = new ArtifactQueries();
            IImportFileParser importFileParser = new ImportFileParser();
            IWorkspaceQueries workspaceQueries = new WorkspaceQueries();
            IErrorQueries     errorQueries     = new ErrorQueries();
            IMarkupTypeHelper markupTypeHelper = new MarkupTypeHelper();
            var job = new ImportManagerJob(
                AgentID,
                Helper,
                queryHelper,
                DateTime.Now,
                resourceGroupIds,
                artifactQueries,
                importFileParser,
                workspaceQueries,
                errorQueries,
                markupTypeHelper);

            job.OnMessage += MessageRaised;

            try
            {
                RaiseMessage(string.Empty, 10);
                RaiseMessage("Enter Agent", 10);
                await job.ExecuteAsync();

                RaiseMessage("Exit Agent", 10);
                RaiseMessage(string.Empty, 10);
            }
            catch (Exception ex)
            {
                //Raise an error on the agents tab and event viewer
                RaiseError(ex.ToString(), ex.ToString());

                //Add the error to our custom Errors table
                queryHelper.InsertRowIntoImportErrorLogAsync(Helper.GetDBContext(-1), job.WorkspaceArtifactId, Constant.Tables.ImportManagerQueue, job.RecordId, job.AgentId, ex.ToString()).Wait();

                //Add the error to the Relativity Errors tab
                //this second try catch is in case we have a problem connecting to the RSAPI
                try
                {
                    errorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.System, job.WorkspaceArtifactId, ex);
                }
                catch (Exception rsapiException)
                {
                    RaiseError(rsapiException.ToString(), rsapiException.ToString());
                }

                //Set the status in the queue to error
                await queryHelper.UpdateStatusInImportManagerQueueAsync(Helper.GetDBContext(-1), Constant.Status.Queue.Error, job.RecordId);
            }
        }
Ejemplo n.º 2
0
        public async Task ExecuteAsync()
        {
            var sqlQueryHelper   = new SqlQueryHelper();
            var resourceGroupIds = GetResourceGroupIDs();

            _logger = Helper.GetLoggerFactory().GetLogger();
            var rsapiApiOptions = new APIOptions {
                WorkspaceID = -1
            };
            var rsapiClient = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.CurrentUser);

            rsapiClient.APIOptions = rsapiApiOptions;
            var rsapiGroupRepository = new RSAPIiRepositoryGroup(rsapiClient);
            var artifactQueries      = new ArtifactQueries();

            var job = new ImportWorkerJob(AgentID, Helper, sqlQueryHelper, artifactQueries, DateTime.Now, rsapiGroupRepository, resourceGroupIds, _logger, rsapiApiOptions, new SerializationHelper());

            job.OnMessage += MessageRaised;

            try
            {
                RaiseMessage("Enter Agent", 10);
                await job.ExecuteAsync();

                RaiseMessage("Exit Agent", 10);
            }
            catch (Exception ex)
            {
                //Raise an error on the agents tab and event viewer
                RaiseError(ex.ToString(), ex.ToString());
                _logger.LogError(ex, $"{Constant.Names.ApplicationName} - {ex}");

                //Add the error to our custom Errors table
                sqlQueryHelper.InsertRowIntoImportErrorLogAsync(Helper.GetDBContext(-1), job.WorkspaceArtifactId, Constant.Tables.ExportWorkerQueue, job.TableRowId, job.AgentId, ex.ToString()).Wait();

                //Add the error to the Relativity Errors tab
                //this second try catch is in case we have a problem connecting to the RSAPI
                try
                {
                    ErrorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.System, job.WorkspaceArtifactId, ex);
                }
                catch (Exception rsapiException)
                {
                    RaiseError(rsapiException.ToString(), rsapiException.ToString());
                    _logger.LogError(rsapiException, $"{Constant.Names.ApplicationName} - {rsapiException}");
                }
            }
            finally
            {
                rsapiClient.Dispose();
            }
        }
Ejemplo n.º 3
0
        private async Task LogErrorAsync(Exception ex)
        {
            //Add the error to our custom Errors table
            await QueryHelper.InsertRowIntoJobErrorLogAsync(
                AgentHelper.GetDBContext(-1),
                WorkspaceArtifactId,
                QueueTable,
                RecordId,
                AgentId,
                ex.ToString(), Constant.Tables.ReproduceErrorLog);

            //Add the error to the Relativity Errors tab
            ErrorQueries.WriteError(AgentHelper.GetServicesManager(), ExecutionIdentity.System, WorkspaceArtifactId, ex);
        }
Ejemplo n.º 4
0
        public override void Execute()
        {
            var sqlQueryHelper  = new SqlQueryHelper();
            var artifactQueries = new ArtifactQueries();

            var errorLogModel        = new ErrorLogModel(sqlQueryHelper, Helper.GetDBContext(-1), AgentID, Constant.Tables.WorkerQueue);
            var uniqueBatchTableName = "[" + Constant.Names.TablePrefix + "Worker_" + Guid.NewGuid() + "_" + AgentID + "]";
            var artifactFactory      = new ArtifactFactory(artifactQueries, Helper.GetServicesManager(), errorLogModel);

            var agentWorkerJob   = new WorkerJob(AgentID, Helper.GetServicesManager(), ExecutionIdentity.CurrentUser, new SqlQueryHelper(), new ArtifactQueries(), artifactFactory, Constant.AgentType.Worker, uniqueBatchTableName, Helper.GetDBContext(-1));
            var textExtractorLog = new TextExtractorLog();

            textExtractorLog.OnUpdate      += MessageRaised;
            agentWorkerJob.TextExtractorLog = textExtractorLog;

            try
            {
                RaiseMessage("Enter Agent", 10);
                agentWorkerJob.Execute();
                RaiseMessage("Exit Agent", 10);
            }
            catch (Exception ex)
            {
                //Raise an error on the agents tab and event viewer
                RaiseError(ex.ToString(), ex.ToString());
                //Add the error to our custom Errors table
                sqlQueryHelper.InsertRowIntoErrorLog(Helper.GetDBContext(-1), agentWorkerJob.WorkspaceArtifactId, Constant.Tables.WorkerQueue, agentWorkerJob.RecordId, agentWorkerJob.AgentId, ex.ToString());
                //Add the error to the Relativity Errors tab
                //this second try catch is in case we have a problem connecting to the RSAPI
                try
                {
                    ErrorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.CurrentUser, agentWorkerJob.WorkspaceArtifactId, ex);
                }
                catch (Exception rsapiException)
                {
                    RaiseError(rsapiException.ToString(), rsapiException.ToString());
                }
                //Set the status in the queue to error
                if (uniqueBatchTableName != string.Empty)
                {
                    sqlQueryHelper.UpdateStatusInWorkerQueue(Helper.GetDBContext(-1), Constant.QueueStatus.Error, uniqueBatchTableName);
                }
            }
            finally
            {
                textExtractorLog.RaiseUpdate("Dropping Worker Queue Batch table.");
                //drop temp table
                sqlQueryHelper.DropTable(Helper.GetDBContext(-1), uniqueBatchTableName);
            }
        }
Ejemplo n.º 5
0
        private async Task LogErrorAsync(Exception exception)
        {
            RaiseMessage($"Logging error. {_errorContext}");

            //Add the error to our custom Errors table
            await QueryHelper.InsertRowIntoImportErrorLogAsync(
                AgentHelper.GetDBContext(-1),
                WorkspaceArtifactId,
                Constant.Tables.ImportWorkerQueue,
                RecordId,
                AgentId,
                exception.ToString());

            //Add the error to the Relativity Errors tab
            ErrorQueries.WriteError(AgentHelper.GetServicesManager(), ExecutionIdentity.System, WorkspaceArtifactId, exception);
        }
Ejemplo n.º 6
0
        public async Task ExecuteAsync()
        {
            var queryHelper                  = new Query();
            var resourceGroupIds             = GetResourceGroupIDs();
            IArtifactQueries artifactQueries = new ArtifactQueries();
            IErrorQueries    errorQueries    = new ErrorQueries();

            var job = new ReproduceWorkerJob(AgentID, Helper, queryHelper, artifactQueries, resourceGroupIds, errorQueries);

            job.OnMessage += MessageRaised;

            try
            {
                RaiseMessage("Enter Agent", 10);
                await job.ExecuteAsync();

                RaiseMessage("Exit Agent", 10);
            }
            catch (Exception ex)
            {
                //Raise an error on the agents tab and event viewer
                RaiseError(ex.ToString(), ex.ToString());

                //Add the error to our custom Errors table
                queryHelper.InsertRowIntoJobErrorLogAsync(Helper.GetDBContext(-1), job.WorkspaceArtifactId, Constant.Tables.ReproduceWorkerQueue, job.RecordId, job.AgentId, ex.ToString(), Constant.Tables.ReproduceErrorLog).Wait();

                //Add the error to the Relativity Errors tab
                //this second try catch is in case we have a problem connecting to the RSAPI
                try
                {
                    errorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.System, job.WorkspaceArtifactId, ex);
                }
                catch (Exception rsapiException)
                {
                    RaiseError(rsapiException.ToString(), rsapiException.ToString());
                }
            }
        }
Ejemplo n.º 7
0
        public async Task ExecuteAsync()
        {
            ISqlQueryHelper     sqlQueryHelper   = new SqlQueryHelper();
            IEnumerable <Int32> resourceGroupIds = GetResourceGroupIDs();

            _logger = Helper.GetLoggerFactory().GetLogger();
            IArtifactQueries artifactQueries = new ArtifactQueries();

            //Setup RSAPI repositories
            APIOptions rsapiApiOptions = new APIOptions
            {
                WorkspaceID = -1
            };
            IRSAPIClient rsapiClient = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.CurrentUser);

            rsapiClient.APIOptions = rsapiApiOptions;
            IRsapiRepositoryGroup rsapiRepositoryGroup = new RSAPIiRepositoryGroup(rsapiClient);
            ILoginProfileManager  loginProfileManager  = Helper.GetServicesManager().CreateProxy <ILoginProfileManager>(ExecutionIdentity.CurrentUser);
            IAuthenticationHelper authenticationHelper = new AuthenticationHelper(loginProfileManager);
            ISerializationHelper  serializationHelper  = new SerializationHelper();

            ExportWorkerJob job = new ExportWorkerJob(
                agentId: AgentID,
                agentHelper: Helper,
                sqlQueryHelper: sqlQueryHelper,
                processedOnDateTime: DateTime.Now,
                resourceGroupIds: resourceGroupIds,
                logger: _logger,
                artifactQueries: artifactQueries,
                rsapiApiOptions: rsapiApiOptions,
                rsapiRepositoryGroup: rsapiRepositoryGroup,
                authenticationHelper: authenticationHelper,
                serializationHelper: serializationHelper);

            job.OnMessage += MessageRaised;

            try
            {
                RaiseMessage("Enter Agent", 10);
                await job.ExecuteAsync();

                RaiseMessage("Exit Agent", 10);
            }
            catch (Exception ex)
            {
                //Raise an error on the agents tab and event viewer
                RaiseError(ex.ToString(), ex.ToString());
                _logger.LogError(ex, $"{Constant.Names.ApplicationName} - {ex}");

                //Add the error to our custom Errors table
                sqlQueryHelper.InsertRowIntoExportErrorLogAsync(Helper.GetDBContext(-1), job.WorkspaceArtifactId, Constant.Tables.ExportWorkerQueue, job.TableRowId, job.AgentId, ex.ToString()).Wait();

                //Add the error to the Relativity Errors tab
                //this second try catch is in case we have a problem connecting to the RSAPI
                try
                {
                    ErrorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.System, job.WorkspaceArtifactId, ex);
                }
                catch (Exception rsapiException)
                {
                    RaiseError(rsapiException.ToString(), rsapiException.ToString());
                    _logger.LogError(rsapiException, $"{Constant.Names.ApplicationName} - {rsapiException}");
                }

                //Set the status in the queue to error
                sqlQueryHelper.UpdateStatusInExportWorkerQueueAsync(Helper.GetDBContext(-1), Constant.Status.Queue.ERROR, job.BatchTableName).Wait();
            }
            finally
            {
                rsapiClient.Dispose();
            }
        }