Exemplo n.º 1
0
 public void ReportStatus(CancellationToken cancellationToken)
 {
     try
     {
         var failureRate = (Uris.Count() - ProcessedDicomFiles.Count) / Uris.Count();
         if (failureRate > FailureThreshold)
         {
             var retry = Retries < MaxRetry;
             resultsService.ReportFailure(TaskId, retry, cancellationToken);
             Logger.LogInformation(
                 "Task marked as failed with failure rate={0}, total={1}, failed={2}, processed={3}, retry={4}",
                 failureRate,
                 Uris.Count(),
                 FailedDicomFiles.Count + FailedFiles.Count,
                 ProcessedDicomFiles.Count,
                 retry);
         }
         else
         {
             resultsService.ReportSuccess(TaskId, cancellationToken);
             Logger.LogInformation("Task marked as successful");
         }
     }
     catch (System.Exception ex)
     {
         Logger.LogError("Failed to report status back to Results Service: {0}", ex);
     }
 }
Exemplo n.º 2
0
 private void ReportFailures(List <TaskResponse> invalidTasks, CancellationToken cancellationToken)
 {
     foreach (var task in invalidTasks)
     {
         try
         {
             _resultsService.ReportFailure(task.TaskId, false, cancellationToken);
             _logger.LogWarning("Task {0} marked as failrue and will not be retried.", task.TaskId);
         }
         catch (System.Exception ex)
         {
             _logger.LogWarning("Failed to mark task {0} as failure: {1}", task.TaskId, ex);
         }
     }
 }