private async Task Zap(long[] used)
        {
            await using var wfDb = _WorkflowDbContextFactory();

            var zap = wfDb.TemporaryExposureKeys
                      .Where(x => used.Contains(x.Id))
                      .ToList();

            _Index += used.Length;
            _Logger.LogInformation("Marking as Published - Count:{Count}, Running total:{RunningTotal}.", zap.Count, _Index);

            if (zap.Count == 0)
            {
                return;
            }

            foreach (var i in zap)
            {
                i.PublishingState = PublishingState.Published;
            }

            var bargs = new SubsetBulkArgs
            {
                PropertiesToInclude = new [] { nameof(TekEntity.PublishingState) }
            };

            await wfDb.BulkUpdateAsync2(zap, bargs); //TX
        }
Пример #2
0
        private async Task WriteNewEksToOutput()
        {
            _Logger.LogDebug("Build EKS.");

            var args = _Output.Select(Map).ToArray();

            var content = await _SetBuilder.BuildAsync(args);

            var e = new EksCreateJobOutputEntity
            {
                Region  = DefaultValues.Region,
                Release = _EksEngineResult.Started,
                CreatingJobQualifier = ++_EksCount,
                Content = content,
            };

            _Logger.LogInformation("Write EKS - Id:{CreatingJobQualifier}.", e.CreatingJobQualifier);


            await using (var dbc = _PublishingDbContextFac())
            {
                await using var tx = dbc.BeginTransaction();
                await dbc.AddAsync(e);

                dbc.SaveAndCommit();
            }

            _Logger.LogInformation("Mark TEKs as used.");

            foreach (var i in _Output)
            {
                i.Used = true;
            }

            //Could be 750k in this hit
            await using (var dbc2 = _PublishingDbContextFac())
            {
                var bargs = new SubsetBulkArgs
                {
                    PropertiesToInclude = new[] { nameof(EksCreateJobInputEntity.Used) }
                };
                await dbc2.BulkUpdateAsync2(_Output, bargs); //TX
            }

            _EksEngineResult.OutputCount += _Output.Count;

            var now = _DateTimeProvider.Now();

            _EksResults.Add(new EksInfo {
                TekCount = _Output.Count, TotalSeconds = (now - _StartEks).TotalSeconds
            });
            _Output.Clear();
            _StartEks = now;
        }
Пример #3
0
        public static async Task BulkInsertAsync2 <T>(this DbContext db, IList <T> page, SubsetBulkArgs args) where T : class
        {
            await using (db.BeginTransaction())
            {
                await db.BulkInsertAsync(page, args.ToBulkConfig());

                db.SaveAndCommit();
            }
        }