public async Task <IProgressProvider> CreateAsync(string[] queues, CancellationToken cancellationToken = default(CancellationToken)) { if (_provider != null) { return(_provider); } try { await SyncLock.WaitAsync(cancellationToken); await SqlRunner.ExecuteAsync(async cmd => { cmd.CommandText = await SqlLoader.GetScript("Progress.Setup"); await cmd.ExecuteNonQueryAsync(cancellationToken); }, _connectionString, false, cancellationToken); _provider = new SqlProgressProvider(_connectionString); return(_provider); } finally { SyncLock.Release(); } }
public async Task <IWorkProvider> CreateAsync(string[] queues, CancellationToken cancellationToken = default(CancellationToken)) { try { await SyncLock.WaitAsync(cancellationToken); if (!_initialized) { await SqlRunner.ExecuteAsync(async cmd => { var schemaSetup = await SqlLoader.GetScript("Schema.Setup"); var workSetup = await SqlLoader.GetScript("Work.Setup"); cmd.CommandText = $"{schemaSetup};\r\n{workSetup}"; await cmd.ExecuteNonQueryAsync(cancellationToken); }, _sqlServerQuidjiboConfiguration.ConnectionString, false, cancellationToken); _initialized = true; } return(new SqlWorkProvider( _loggerFactory.CreateLogger <SqlWorkProvider>(), _sqlServerQuidjiboConfiguration.ConnectionString, queues, _sqlServerQuidjiboConfiguration.LockInterval, _sqlServerQuidjiboConfiguration.BatchSize, _sqlServerQuidjiboConfiguration.DaysToKeep)); } finally { SyncLock.Release(); } }
public async Task <IWorkProvider> CreateAsync(string[] queues, CancellationToken cancellationToken = default(CancellationToken)) { try { await SyncLock.WaitAsync(cancellationToken); if (!_initialized) { await SqlRunner.ExecuteAsync(async cmd => { var schemaSetup = await SqlLoader.GetScript("Schema.Setup"); var workSetup = await SqlLoader.GetScript("Work.Setup"); cmd.CommandText = $"{schemaSetup};\r\n{workSetup}"; await cmd.ExecuteNonQueryAsync(cancellationToken); }, _connectionString, false, cancellationToken); _initialized = true; } return(new SqlWorkProvider(_connectionString, queues, _visibilityTimeout, _batchSize)); } finally { SyncLock.Release(); } }
public static async Task SaveToDbAsync(string connectionString, IEnumerable <DataProtectionKey> keys) { const string sql = "INSERT INTO dbo.DataProtectionKeys(FriendlyName, [Xml]) VALUES (@FriendlyName, @Xml);"; var existingDbKeys = await GetFromDbAsync(connectionString); var newKeys = keys.Except(existingDbKeys); await SqlRunner.ExecuteAsync(connectionString, sql, newKeys); }
public async Task InsertAndSetCurrentForSolutionAsync() { await base.InsertAsync().ConfigureAwait(false); await SqlRunner.ExecuteAsync(ConnectionStrings.GPitFuturesSetup, $@"UPDATE Solution SET SolutionDetailId = @Id WHERE Id = @SolutionId", this) .ConfigureAwait(false); }
public async Task InsertRelatedOrganisation(string connectionString, Guid relatedOrganisationId) { const string sql = @" INSERT INTO dbo.RelatedOrganisations ( OrganisationId, RelatedOrganisationId ) VALUES ( @OrganisationId, @relatedOrganisationId );"; await SqlRunner.ExecuteAsync(connectionString, sql, new { OrganisationId, relatedOrganisationId }); }
public async Task <IScheduleProvider> CreateAsync(string[] queues, CancellationToken cancellationToken = default(CancellationToken)) { try { await SyncLock.WaitAsync(cancellationToken); await SqlRunner.ExecuteAsync(async cmd => { var schemaSetup = await SqlLoader.GetScript("Schema.Setup"); var scheduleSetup = await SqlLoader.GetScript("Schedule.Setup"); cmd.CommandText = $"{schemaSetup};\r\n{scheduleSetup}"; await cmd.ExecuteNonQueryAsync(cancellationToken); }, _connectionString, false, cancellationToken); return(await Task.FromResult <IScheduleProvider>(new SqlScheduleProvider(_connectionString, queues))); } finally { SyncLock.Release(); } }
private Task ExecuteAsync(Func <SqlCommand, Task> func, CancellationToken cancellationToken) { return(SqlRunner.ExecuteAsync(func, _connectionString, true, cancellationToken)); }
public async Task InsertAsync() => await SqlRunner.ExecuteAsync(ConnectionStrings.GPitFuturesSetup, InsertSql, this).ConfigureAwait(false);
public async Task InsertAsync(string connectionString) => await SqlRunner.ExecuteAsync(connectionString, InsertSql, this);
public async Task UpdateSecurityStamp(string connectionString) => await SqlRunner.ExecuteAsync(connectionString, UpdateSecurityStampSql, new { id = Id, securityStamp = SecurityStamp });