void LogBatchCompleted(object sender, LogBatchCompletedEventArgs e) { if (e.Error == null) { try { logAgent.IncrementTotalLogsSent(e.Batch.Logs.Count()); logAgent.IncrementTotalBatchesSent(1); if (e.Result != null) { if (e.Result.IsEnabled.HasValue) { logAgent.State = e.Result.IsEnabled.Value ? BatchingLogAgent.BatchingLogAgentStates.Enabled : BatchingLogAgent.BatchingLogAgentStates.Disabled; } if (e.Result.QueuePollingInterval.HasValue && !IsThrottled) { QueuePollingInterval = e.Result.QueuePollingInterval.Value; } if (e.Result.ServerTime.HasValue) { if (!logAgent.ServerTimeOffset.HasValue && e.Batch.TimeStamp.HasValue) { logAgent.ServerTimeOffset = TimeSpan.FromTicks(e.Result.ServerTime.Value.Ticks - e.Batch.TimeStamp.Value); } } } // decrement the FailedSendCount FailedSendCount = Math.Max(FailedSendCount - 1, 0); try { if (BatchSendSuccess != null) { BatchSendSuccess(this, new BatchEventArgs(e.Batch)); } } catch { /* swollow */ } } catch (Exception ex) { LogBatchFailed(e.Batch, ex); } finally { // ALWAYS reset this! state = QueueManagerStates.Polling; } } else { LogBatchFailed(e.Batch, e.Error); } }
void LogBatchCompleted(object sender, LogBatchCompletedEventArgs e) { if (e.Error == null) { try { logAgent.IncrementTotalLogsSent(e.Batch.Logs.Count()); logAgent.IncrementTotalBatchesSent(1); if (e.Result != null) { if (e.Result.IsEnabled.HasValue) logAgent.State = e.Result.IsEnabled.Value ? BatchingLogAgent.BatchingLogAgentStates.Enabled : BatchingLogAgent.BatchingLogAgentStates.Disabled; if (e.Result.QueuePollingInterval.HasValue && !IsThrottled) QueuePollingInterval = e.Result.QueuePollingInterval.Value; if (e.Result.ServerTime.HasValue) { if (!logAgent.ServerTimeOffset.HasValue && e.Batch.TimeStamp.HasValue) { logAgent.ServerTimeOffset = TimeSpan.FromTicks(e.Result.ServerTime.Value.Ticks - e.Batch.TimeStamp.Value); } } } // decrement the FailedSendCount FailedSendCount = Math.Max(FailedSendCount - 1, 0); try { if (BatchSendSuccess != null) BatchSendSuccess(this, new BatchEventArgs(e.Batch)); } catch { /* swollow */ } } catch (Exception ex) { LogBatchFailed(e.Batch, ex); } finally { // ALWAYS reset this! state = QueueManagerStates.Polling; } } else { LogBatchFailed(e.Batch, e.Error); } }