public async Task Create(ISystemProcessOperationRuleRun entity) { if (entity == null) { return; } lock (this._lock) { try { this._logger.LogInformation($"SystemProcessOperationRuleRunRepository SAVING {entity}"); using (var dbConnection = this._dbConnectionFactory.BuildConn()) using (var conn = dbConnection.QuerySingleAsync <int>(CreateSql, entity)) { entity.Id = conn.Result; } } catch (Exception e) { this._logger.LogError( $"System Process Operation Rule Run Repository Create Method For {entity.Id} {entity.SystemProcessOperationId}. {e.Message}"); } } }
private void RescheduleRuleRun(ISystemProcessOperationRuleRun ruleRun) { if (ruleRun == null // ReSharper disable once MergeSequentialChecks || ruleRun.ScheduleRuleStart == null || ruleRun.ScheduleRuleEnd == null || string.IsNullOrWhiteSpace(ruleRun.RuleParameterId)) { this._logger?.LogWarning( $"{nameof(ScheduleRulePublisher)} received a badly formed rule run. Skipping."); return; } var scheduledExecution = new ScheduledExecution { Rules = new List <RuleIdentifier> { new RuleIdentifier { Ids = new[] { ruleRun.RuleParameterId }, Rule = (Rules)ruleRun.RuleTypeId } }, TimeSeriesInitiation = ruleRun.ScheduleRuleStart.GetValueOrDefault(), TimeSeriesTermination = ruleRun.ScheduleRuleEnd.Value, CorrelationId = ruleRun.CorrelationId, IsBackTest = ruleRun.IsBackTest, IsForceRerun = true }; var cts = new CancellationTokenSource(); var serialisedMessage = this._messageBusSerialiser.SerialiseScheduledExecution(scheduledExecution); this._logger?.LogWarning( $"{nameof(ScheduleRulePublisher)} about to submit {serialisedMessage} to {this._awsConfiguration.ScheduleRuleDistributedWorkQueueName}"); var sendToQueue = this._awsQueueClient.SendToQueue( this._awsConfiguration.ScheduleRuleDistributedWorkQueueName, serialisedMessage, cts.Token); sendToQueue.Wait(TimeSpan.FromMinutes(30)); if (sendToQueue.IsCanceled) { this._logger?.LogError( $"{nameof(ScheduleRulePublisher)} timed out communicating with queue for {serialisedMessage} to {this._awsConfiguration.ScheduleRuleDistributedWorkQueueName}"); } this._logger?.LogWarning( $"{nameof(ScheduleRulePublisher)} completed submitting {serialisedMessage} to {this._awsConfiguration.ScheduleRuleDistributedWorkQueueName}"); }
public async Task Update(ISystemProcessOperationRuleRun entity) { if (entity == null) { return; } try { using (var dbConnection = this._dbConnectionFactory.BuildConn()) using (var conn = dbConnection.ExecuteAsync(UpdateSql, entity)) { await conn; } } catch (Exception e) { this._logger.LogError(e, $"System Process Operation Rule Run Repository Update Method For {entity.Id} {entity.SystemProcessOperationId}."); } }
public void Log(Exception e, ISystemProcessOperationRuleRun ruleRun) { if (ruleRun == null) { this.Log(e); return; } var dto = new ExceptionDto { ExceptionMessage = e.Message, InnerExceptionMessage = e.InnerException?.Message, StackTrace = e.StackTrace, SystemProcessOperationRuleRunId = ruleRun.Id, SystemProcessOperationId = ruleRun.SystemProcessOperationId, SystemProcessId = ruleRun.SystemProcessId }; this._exceptionRepository.Save(dto); }