コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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 });
        }
コード例 #7
0
        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();
            }
        }
コード例 #8
0
 private Task ExecuteAsync(Func <SqlCommand, Task> func, CancellationToken cancellationToken)
 {
     return(SqlRunner.ExecuteAsync(func, _connectionString, true, cancellationToken));
 }
コード例 #9
0
 public async Task InsertAsync()
 => await SqlRunner.ExecuteAsync(ConnectionStrings.GPitFuturesSetup, InsertSql, this).ConfigureAwait(false);
コード例 #10
0
 public async Task InsertAsync(string connectionString) =>
 await SqlRunner.ExecuteAsync(connectionString, InsertSql, this);
コード例 #11
0
 public async Task UpdateSecurityStamp(string connectionString) =>
 await SqlRunner.ExecuteAsync(connectionString, UpdateSecurityStampSql, new { id = Id, securityStamp = SecurityStamp });