コード例 #1
0
ファイル: SqlServerStorage.cs プロジェクト: dlongest/HangFire
        public SqlServerStorage(string connectionString, SqlServerStorageOptions options)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            _options          = options;
            _connectionString = connectionString;

            if (options.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    SqlServerObjectsInstaller.Install(connection);
                }
            }

            var defaultQueueProvider = new SqlServerJobQueueProvider(options);

            QueueProviders = new PersistentJobQueueProviderCollection(defaultQueueProvider);
        }
コード例 #2
0
        /// <summary>
        /// Initializes SqlServerStorage from the provided SqlServerStorageOptions and either the provided connection
        /// string or the connection string with provided name pulled from the application config file.       
        /// </summary>
        /// <param name="nameOrConnectionString">Either a SQL Server connection string or the name of 
        /// a SQL Server connection string located in the connectionStrings node in the application config</param>
        /// <param name="options"></param>
        /// <exception cref="ArgumentNullException"><paramref name="nameOrConnectionString"/> argument is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="options"/> argument is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="nameOrConnectionString"/> argument is neither 
        /// a valid SQL Server connection string nor the name of a connection string in the application
        /// config file.</exception>
        public SqlServerStorage(string nameOrConnectionString, SqlServerStorageOptions options)
        {
            if (nameOrConnectionString == null) throw new ArgumentNullException("nameOrConnectionString");
            if (options == null) throw new ArgumentNullException("options");

            _options = options;

            if (IsConnectionString(nameOrConnectionString))
            {
                _connectionString = nameOrConnectionString;
            }
            else if (IsConnectionStringInConfiguration(nameOrConnectionString))
            {
                _connectionString = ConfigurationManager.ConnectionStrings[nameOrConnectionString].ConnectionString;
            }
            else
            {
                throw new ArgumentException(
                    string.Format("Could not find connection string with name '{0}' in application config file",
                                  nameOrConnectionString));
            }

            if (options.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    SqlServerObjectsInstaller.Install(connection);
                }
            }

            var defaultQueueProvider = new SqlServerJobQueueProvider(options);
            QueueProviders = new PersistentJobQueueProviderCollection(defaultQueueProvider);
        }
コード例 #3
0
        public SqlServerJobQueue(IDbConnection connection, SqlServerStorageOptions options)
        {
            if (options == null) throw new ArgumentNullException("options");
            if (connection == null) throw new ArgumentNullException("connection");

            _options = options;
            _connection = connection;
        }
コード例 #4
0
        public SqlServerJobQueueProvider(SqlServerStorageOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            _options = options;
        }
コード例 #5
0
        public SqlServerJobQueue(IDbConnection connection, SqlServerStorageOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            _options    = options;
            _connection = connection;
        }
コード例 #6
0
ファイル: SqlServerStorage.cs プロジェクト: hahmed/HangFire
        public SqlServerStorage(string connectionString, SqlServerStorageOptions options)
        {
            if (connectionString == null) throw new ArgumentNullException("connectionString");
            if (options == null) throw new ArgumentNullException("options");

            _options = options;
            _connectionString = connectionString;

            if (options.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    SqlServerObjectsInstaller.Install(connection);
                }
            }
        }
コード例 #7
0
        public SqlServerStorage(string connectionString, SqlServerStorageOptions options)
        {
            if (connectionString == null) throw new ArgumentNullException("connectionString");
            if (options == null) throw new ArgumentNullException("options");

            _options = options;
            _connectionString = connectionString;

            if (options.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    SqlServerObjectsInstaller.Install(connection);
                }
            }

            var defaultQueueProvider = new SqlServerJobQueueProvider(options);
            QueueProviders = new PersistentJobQueueProviderCollection(defaultQueueProvider);
        }
コード例 #8
0
        /// <summary>
        /// Initializes SqlServerStorage from the provided SqlServerStorageOptions and either the provided connection
        /// string or the connection string with provided name pulled from the application config file.
        /// </summary>
        /// <param name="nameOrConnectionString">Either a SQL Server connection string or the name of
        /// a SQL Server connection string located in the connectionStrings node in the application config</param>
        /// <param name="options"></param>
        /// <exception cref="ArgumentNullException"><paramref name="nameOrConnectionString"/> argument is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="options"/> argument is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="nameOrConnectionString"/> argument is neither
        /// a valid SQL Server connection string nor the name of a connection string in the application
        /// config file.</exception>
        public SqlServerStorage(string nameOrConnectionString, SqlServerStorageOptions options)
        {
            if (nameOrConnectionString == null)
            {
                throw new ArgumentNullException("nameOrConnectionString");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            _options = options;

            if (IsConnectionString(nameOrConnectionString))
            {
                _connectionString = nameOrConnectionString;
            }
            else if (IsConnectionStringInConfiguration(nameOrConnectionString))
            {
                _connectionString = ConfigurationManager.ConnectionStrings[nameOrConnectionString].ConnectionString;
            }
            else
            {
                throw new ArgumentException(
                          string.Format("Could not find connection string with name '{0}' in application config file",
                                        nameOrConnectionString));
            }

            if (options.PrepareSchemaIfNecessary)
            {
                using (var connection = CreateAndOpenConnection())
                {
                    SqlServerObjectsInstaller.Install(connection);
                }
            }

            var defaultQueueProvider = new SqlServerJobQueueProvider(options);

            QueueProviders = new PersistentJobQueueProviderCollection(defaultQueueProvider);
        }
コード例 #9
0
        public SqlServerJobQueueProvider(SqlServerStorageOptions options)
        {
            if (options == null) throw new ArgumentNullException("options");

            _options = options;
        }