public async Task Create(UserModel user) { var key = _keys.Next(); user.JumpConsistentSeed = await _sequence.GetNextAsync(key, key.InitialValue, _keys.Increment); var r = await _db.User.CreateItemAsync(user, new PartitionKey(user.PartitionKey)); _logger.LogInformation($"{nameof(Create)} RequestCharge:{r.RequestCharge}"); }
public async Task <TemporaryExposureKeyExportModel> CreateAsync() { var partitionKey = PartitionKey.None; var newItem = new TemporaryExposureKeyExportModel(); newItem.BatchNum = await _sequence.GetNextAsync(SequenceName, 1); var pk = PartitionKey.Null; return((await _db.TemporaryExposureKeyExport.CreateItemAsync(newItem, pk)).Resource); }
public async Task <TemporaryExposureKeyExportModel> CreateAsync() { var pk = PartitionKey.None; var newItem = new TemporaryExposureKeyExportModel(); var batchNum = await _sequence.GetNextAsync(SequenceName, 1); newItem.id = batchNum.ToString(); newItem.BatchNum = batchNum; await _db.TemporaryExposureKeyExport.CreateItemAsync(newItem, pk); return(newItem); }
public async Task RunAsync() { try { Logger.LogInformation($"start {nameof(RunAsync)}"); var batchTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); var items = await TekRepository.GetNextAsync(); foreach (var kv in items.GroupBy(_ => new { RollingStartUnixTimeSeconds = _.GetRollingStartUnixTimeSeconds(), RollingPeriodSeconds = _.GetRollingPeriodSeconds() })) { var batchNum = (int)await Sequence.GetNextAsync(SequenceName, 1); batchTimestamp++; foreach (var region in Regions) { // Security considerations: Random Order TemporaryExposureKey var sorted = kv .OrderBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue)); await CreateAsync((ulong)kv.Key.RollingStartUnixTimeSeconds, (ulong)(kv.Key.RollingStartUnixTimeSeconds + kv.Key.RollingPeriodSeconds), region, batchNum, batchTimestamp, sorted.ToArray()); } foreach (var key in kv) { key.Exported = true; await TekRepository.UpsertAsync(key); } } // Write Export Files json var models = await TekExportRepository.GetKeysAsync(0); await BlobService.WriteFilesJsonAsync(models); } catch (Exception ex) { Logger.LogError(ex, $"Error on {nameof(TemporaryExposureKeyExportBatchService)}"); throw; } }
public async Task Create(UserModel user) { user.JumpConsistentSeed = await _sequence.GetNextAsync(SequenceName, 1); await _db.User.CreateItemAsync(user, new PartitionKey(user.PartitionKey)); }