public async Task Execute(IksWriteArgs args)
        {
            var e = new IksInEntity
            {
                BatchTag = args.BatchTag,
                Content  = args.Content,
                Created  = _DateTimeProvider.Snapshot
                           //Received = ? Not sure we need this cos its just a log.
            };

            await _DbContext.Received.AddAsync(e);

            await _DbContext.SaveChangesAsync();
        }
Beispiel #2
0
        public async Task Execute(IksInEntity entity)
        {
            if (!TryParse(entity.Content, out var batch))
            {
                entity.Error = true;
                return;
            }

            if (batch?.Keys == null || batch.Keys.Count == 0)
            {
                //TODO log.
                entity.Error = true;
                return;
            }

            var items = batch.Keys
                        .Where(Valid)
                        .Select(x => (DkProcessingItem) new DkProcessingItem
            {
                DiagnosisKey = new DiagnosisKeyEntity
                {
                    DailyKey        = new DailyKey(x.KeyData.ToByteArray(), (int)x.RollingStartIntervalNumber, (int)x.RollingPeriod),
                    Origin          = TekOrigin.Efgs,
                    PublishedToEfgs = true,     //Do not send back to EFGS
                    Efgs            = new EfgsTekInfo
                    {
                        CountryOfOrigin        = x.Origin,
                        CountriesOfInterest    = string.Join(",", x.VisitedCountries),
                        DaysSinceSymptomsOnset = x.DaysSinceOnsetOfSymptoms,
                        ReportType             = (ReportType)x.ReportType,
                    },
                    Local = new LocalTekInfo
                    {
                        //Filled in by filters
                    }
                },
                Metadata = new Dictionary <string, object>
                {
                    { "Countries", x.VisitedCountries.ToArray() },
                    { "TRL", x.TransmissionRiskLevel },
                    { "ReportType", x.ReportType }
                }
            }).ToArray();

            items = _importProcessors.Execute(items);
            var result = items.Select(x => x.DiagnosisKey).ToList(); //Can't get rid of compiler warning.
            await _dkSourceDbContext.BulkInsertAsync2(result, new SubsetBulkArgs());
        }
Beispiel #3
0
        private async Task Process(IksInEntity item)
        {
            try
            {
                var processor = _InboundIksReaderFunc();
                await processor.Execute(item);

                if (!item.Error)
                {
                    item.Accepted = _DateTimeProvider.Snapshot;
                }

                _IksInDbContext.Update(item);
                _IksInDbContext.SaveChanges();
            }
            catch (Exception e)
            {
                //TODO mark as having issues - retry x times? Don't want to repeat
                //TODO log...
                throw;
            }
        }