mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
parent
429ed19967
commit
054f4989ea
1 changed files with 13 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ public class SnapshotDe
|
|||
private readonly EmailService emailService;
|
||||
private readonly FilterListViewUrlDto list;
|
||||
private readonly Data.Entities.Snapshot snapshot;
|
||||
private string httpStatusCodeBak;
|
||||
|
||||
public SnapshotDe(FilterListsDbContext dbContext, EmailService emailService, FilterListViewUrlDto list)
|
||||
{
|
||||
|
|
@ -57,6 +58,8 @@ public async Task SaveAsync()
|
|||
await SendExceptionEmail(e);
|
||||
}
|
||||
}
|
||||
|
||||
await EnsureHttpStatusCodeSaved();
|
||||
}
|
||||
|
||||
private async Task AddSnapshot()
|
||||
|
|
@ -93,6 +96,7 @@ private async Task<string> GetContent()
|
|||
using (var httpResponseMessage = await httpClient.GetAsync(list.ViewUrl))
|
||||
{
|
||||
snapshot.HttpStatusCode = ((int)httpResponseMessage.StatusCode).ToString();
|
||||
httpStatusCodeBak = snapshot.HttpStatusCode;
|
||||
if (httpResponseMessage.IsSuccessStatusCode)
|
||||
return await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
|
@ -102,6 +106,15 @@ private async Task<string> GetContent()
|
|||
return null;
|
||||
}
|
||||
|
||||
private async Task EnsureHttpStatusCodeSaved()
|
||||
{
|
||||
if (!snapshot.WasSuccessful)
|
||||
{
|
||||
snapshot.HttpStatusCode = httpStatusCodeBak;
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SendWebExceptionEmail()
|
||||
{
|
||||
var message = new StringBuilder();
|
||||
|
|
|
|||
Loading…
Reference in a new issue