Skip to content

Commit

Permalink
continue processing on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mlapaglia committed Jul 1, 2021
1 parent a340aa9 commit 9b540a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
25 changes: 17 additions & 8 deletions OpenAlprWebhookProcessor/Alerts/AlertService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,29 @@ private async Task ProcessAlertsAsync()
plateGroups = plateGroups.Where(x => x.Id == job.LicensePlateId);
}

var result = await plateGroups.FirstOrDefaultAsync();
var result = await plateGroups.FirstOrDefaultAsync(_cancellationTokenSource.Token);

if (result != null)
{
_logger.LogInformation($"alerting for: {result.Id}");
await _processorHub.Clients.All.LicensePlateAlerted(result.Id.ToString());
await _alertClient.SendAlertAsync(new Alert()

try
{
await _alertClient.SendAlertAsync(new Alert()
{
Description = result.AlertDescription.ToString(),
Id = result.Id,
PlateNumber = result.BestNumber.ToString(),
},
result.Jpeg,
_cancellationTokenSource.Token);
}
catch (Exception ex)
{
Description = result.AlertDescription.ToString(),
Id = result.Id,
PlateNumber = result.BestNumber.ToString(),
},
result.Jpeg,
_cancellationTokenSource.Token);
_logger.LogError(ex, $"failed to send alert to {nameof(_alertClient)}");
}

}
}
}
Expand Down
3 changes: 1 addition & 2 deletions OpenAlprWebhookProcessor/Alerts/Pushover/PushoverClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -45,7 +44,7 @@ public async Task SendAlertAsync(
content.Add(new StringContent(alert.PlateNumber + " " + alert.Description), "message");
content.Add(new StringContent("openalpr alert"), "title");

if(clientSettings.SendPlatePreview)
if (clientSettings.SendPlatePreview)
{
content.Add(new ByteArrayContent(Convert.FromBase64String(base64PreviewJpeg)), "attachment", "attachment.jpg");
}
Expand Down

0 comments on commit 9b540a2

Please sign in to comment.