public ManifestEntity Execute() { var now = _DateTimeProvider.Now(); var releaseCutoff = now - TimeSpan.FromHours(_AgConfig.ManifestLifeTimeHours); var e = _DbContext.Current.ManifestContent .Where(x => x.Release > releaseCutoff) .OrderByDescending(x => x.Release) .Take(1) .SingleOrDefault(); if (e != null) { return(e); } _DbContext.Current.BulkDelete(_DbContext.Current.ManifestContent.ToList()); //TODO execute sql. var content = JsonConvert.SerializeObject(_ManifestBuilder.Execute()); var bytes = Encoding.UTF8.GetBytes(content); e = new ManifestEntity { Release = now, ContentTypeName = ContentHeaderValues.Json, Content = bytes, Region = DefaultValues.Region, }; e.PublishingId = _PublishingIdCreator.Create(e); _DbContext.Current.ManifestContent.Add(e); _DbContext.SaveAndCommit(); return(e); }
public async Task <ExposureKeySetContentEntity> Execute(ExposureKeySetContentEntity e) { e.PublishingId = _PublishingIdCreator.Create(e); await _DbConfig.Current.AddAsync(e); return(e); }
public async Task Execute(RiskCalculationConfigArgs args) { var e = args.ToEntity(); e.PublishingId = _PublishingIdCreator.Create(e); _DbContextProvider.Current.Add(e); }
public async Task Execute(MobileDeviceRivmAdviceArgs args) { var e = args.ToEntity(); e.PublishingId = _PublishingIdCreator.Create(e); await _DbConfig.Current.AddAsync(e); }
public void Write(ExposureKeySetEntity[] things) { var entities = things.Select(x => new ExposureKeySetContentEntity { Content = x.AgContent, CreatingJobName = x.CreatingJobName, CreatingJobQualifier = x.CreatingJobQualifier, Region = x.Region, Release = x.Created, }); foreach (var i in entities) { i.PublishingId = _PublishingIdCreator.Create(i); } using (_DbContext.BeginTransaction()) { _DbContext.Current.BulkInsertAsync(entities.ToList()); _DbContext.SaveAndCommit(); } }
public async Task Execute() { _DbContextProvider.Current.Database.EnsureCreated(); using var tx = _DbContextProvider.Current.Database.BeginTransaction(); var e0 = new MobileDeviceRivmAdviceArgs { Release = new DateTime(2020, 1, 1), Text = new[] { new LocalizableTextArgs { Locale = "en-GB", IsolationAdviceShort = "1st", IsolationAdviceLong = "First", }, new LocalizableTextArgs { Locale = "nl-nl", IsolationAdviceShort = "1e", IsolationAdviceLong = "Eerste", } } }.ToEntity(); e0.PublishingId = _PublishingIdCreator.Create(e0); await _DbContextProvider.Current.AddAsync(e0); var e1 = new MobileDeviceRivmAdviceArgs { Release = new DateTime(2020, 5, 1), IsolationPeriodDays = 10, ObservedTemporaryExposureKeyRetentionDays = 14, TemporaryExposureKeyRetentionDays = 15, Text = new[] { new LocalizableTextArgs { Locale = "en-GB", IsolationAdviceShort = "Stay the hell indoors for {0} day!!!", IsolationAdviceLong = "Something hmtl, zipped", }, new LocalizableTextArgs { Locale = "nl-nl", IsolationAdviceShort = "Verklaar de hel binnenshuis", IsolationAdviceLong = "Verklaar de hel binnenshuis but longer.", } } }.ToEntity(); e1.PublishingId = _PublishingIdCreator.Create(e1); await _DbContextProvider.Current.AddAsync(e1); var e2 = new MobileDeviceRivmAdviceArgs { Release = new DateTime(2021, 1, 1), Text = new LocalizableTextArgs[0] }.ToEntity(); e2.PublishingId = _PublishingIdCreator.Create(e2); await _DbContextProvider.Current.AddAsync(e2); //TODO something more realistic var e4 = new RiskCalculationConfigArgs { Release = new DateTime(2020, 5, 1), MinimumRiskScore = 4, Attenuation = new WeightingArgs { Weight = 30, LevelValues = new[] { 1 } }, DaysSinceLastExposure = new WeightingArgs { Weight = 40, LevelValues = new[] { 1, 2, 3, 4 } }, DurationLevelValues = new WeightingArgs { Weight = 50, LevelValues = new[] { 10, 2, 3, 4, 5 } }, TransmissionRisk = new WeightingArgs { Weight = 60, LevelValues = new[] { 10, 100, 1000 } }, }.ToEntity(); e4.PublishingId = _PublishingIdCreator.Create(e4); await _DbContextProvider.Current.AddAsync(e4); tx.Commit(); }