update DiscontinuedDate during snaps, temp disable seeding of DiscontinuedDate

closes #427
opens #544
This commit is contained in:
Collin M. Barrett 2018-10-01 12:24:50 -05:00
parent a41b547177
commit 0acdfc4539
2 changed files with 10 additions and 1 deletions

View file

@ -102,7 +102,8 @@ private static async Task InsertOnDuplicateKeyUpdate<TEntity>(DbContext dbContex
private static List<IProperty> GetPropertiesLessValueGeneratedTimestamps(IEntityType entityType) =>
entityType.GetProperties()
.Where(x => !new List<string> {"CreatedDateUtc", "ModifiedDateUtc"}.Contains(x.Name))
.Where(x =>
!new List<string> {"CreatedDateUtc", "ModifiedDateUtc", "DiscontinuedDate"}.Contains(x.Name))
.ToList();
private static string CreateValues<TEntity>(IEnumerable<TEntity> seed,

View file

@ -123,6 +123,7 @@ private async Task GetLinesFromSource(HttpResponseMessage response)
await SetWasUpdated();
if (SnapEntity.WasUpdated)
{
await UpdateDiscontinuedDate();
memoryStream.Position = 0;
if (ListUrl.EndsWith(".7z"))
await GetLinesFrom7Zip(memoryStream);
@ -152,6 +153,13 @@ await dbContext.Snapshots
.Select(s => s.Md5Checksum)
.FirstOrDefaultAsync() ?? Array.Empty<byte>();
private async Task UpdateDiscontinuedDate()
{
var list = await dbContext.FilterLists.FirstOrDefaultAsync(l => l.Id == List.Id);
if (!(list.DiscontinuedDate is null) && DateTime.Now > list.DiscontinuedDate)
list.DiscontinuedDate = null;
}
private async Task GetLinesFrom7Zip(Stream stream)
{
using (var archive = SevenZipArchive.Open(stream))