/// <summary>Initializes a new instance of the <see cref="ReceiveMessageQueryHandler" /> class.</summary> /// <param name="optionsFactory">The options factory.</param> /// <param name="tableNameHelper">The table name helper.</param> /// <param name="connectionInformation">The connection information.</param> /// <param name="buildDequeueCommand">The build dequeue command.</param> /// <param name="messageDeQueue">The message de queue.</param> /// <param name="dbFactory">The transaction factory.</param> /// <param name="databaseExists">The database exists.</param> /// <param name="configuration">Queue configuration</param> public ReceiveMessageQueryHandler(ISqLiteMessageQueueTransportOptionsFactory optionsFactory, ITableNameHelper tableNameHelper, IConnectionInformation connectionInformation, BuildDequeueCommand buildDequeueCommand, MessageDeQueue messageDeQueue, IDbFactory dbFactory, DatabaseExists databaseExists, QueueConsumerConfiguration configuration) { Guard.NotNull(() => optionsFactory, optionsFactory); Guard.NotNull(() => tableNameHelper, tableNameHelper); Guard.NotNull(() => buildDequeueCommand, buildDequeueCommand); Guard.NotNull(() => messageDeQueue, messageDeQueue); Guard.NotNull(() => databaseExists, databaseExists); Guard.NotNull(() => dbFactory, dbFactory); Guard.NotNull(() => configuration, configuration); _options = new Lazy <SqLiteMessageQueueTransportOptions>(optionsFactory.Create); _tableNameHelper = tableNameHelper; _connectionInformation = connectionInformation; _buildDequeueCommand = buildDequeueCommand; _messageDeQueue = messageDeQueue; _dbFactory = dbFactory; _databaseExists = databaseExists; _configuration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveMessageQueryHandler" /> class. /// </summary> /// <param name="optionsFactory">The options factory.</param> /// <param name="tableNameHelper">The table name helper.</param> /// <param name="commandCache">The command cache.</param> /// <param name="connectionInformation">The connection information.</param> /// <param name="buildDequeueCommand">The build dequeue command.</param> /// <param name="messageDeQueue">The message de queue.</param> /// <param name="dbFactory">The transaction factory.</param> /// <param name="databaseExists">The database exists.</param> /// <param name="readerAsync">The reader asynchronous.</param> public ReceiveMessageQueryHandlerAsync(ISqLiteMessageQueueTransportOptionsFactory optionsFactory, TableNameHelper tableNameHelper, IDbCommandStringCache commandCache, IConnectionInformation connectionInformation, BuildDequeueCommand buildDequeueCommand, MessageDeQueue messageDeQueue, IDbFactory dbFactory, DatabaseExists databaseExists, IReaderAsync readerAsync) { Guard.NotNull(() => optionsFactory, optionsFactory); Guard.NotNull(() => tableNameHelper, tableNameHelper); Guard.NotNull(() => commandCache, commandCache); Guard.NotNull(() => buildDequeueCommand, buildDequeueCommand); Guard.NotNull(() => messageDeQueue, messageDeQueue); Guard.NotNull(() => databaseExists, databaseExists); Guard.NotNull(() => readerAsync, readerAsync); _options = new Lazy <SqLiteMessageQueueTransportOptions>(optionsFactory.Create); _tableNameHelper = tableNameHelper; _commandCache = commandCache; _connectionInformation = connectionInformation; _buildDequeueCommand = buildDequeueCommand; _messageDeQueue = messageDeQueue; _dbFactory = dbFactory; _databaseExists = databaseExists; _readerAsync = readerAsync; }
/// <summary> /// Initializes a new instance of the <see cref="SendMessageCommandHandlerAsync"/> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="tableNameHelper">The table name helper.</param> /// <param name="serializer">The serializer.</param> /// <param name="optionsFactory">The options factory.</param> /// <param name="headers">The headers.</param> /// <param name="configurationSend">The configuration send.</param> /// <param name="sendJobStatus">The send job status.</param> /// <param name="jobExistsHandler">The job exists handler.</param> /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param> /// <param name="databaseExists">The database exists.</param> public SendMessageCommandHandlerAsync( LiteDbConnectionManager connectionInformation, TableNameHelper tableNameHelper, ICompositeSerialization serializer, ILiteDbMessageQueueTransportOptionsFactory optionsFactory, IHeaders headers, TransportConfigurationSend configurationSend, ICommandHandler <SetJobLastKnownEventCommand> sendJobStatus, IQueryHandler <DoesJobExistQuery, QueueStatuses> jobExistsHandler, IJobSchedulerMetaData jobSchedulerMetaData, DatabaseExists databaseExists) { Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => tableNameHelper, tableNameHelper); Guard.NotNull(() => serializer, serializer); Guard.NotNull(() => optionsFactory, optionsFactory); Guard.NotNull(() => headers, headers); Guard.NotNull(() => configurationSend, configurationSend); Guard.NotNull(() => sendJobStatus, sendJobStatus); Guard.NotNull(() => jobExistsHandler, jobExistsHandler); Guard.NotNull(() => jobSchedulerMetaData, jobSchedulerMetaData); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _tableNameHelper = tableNameHelper; _serializer = serializer; _options = new Lazy <LiteDbMessageQueueTransportOptions>(optionsFactory.Create); _headers = headers; _configurationSend = configurationSend; _sendJobStatus = sendJobStatus; _jobExistsHandler = jobExistsHandler; _jobSchedulerMetaData = jobSchedulerMetaData; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteMessageCommandDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public FindRecordsToResetByHeartBeatDecorator(IConnectionInformation connectionInformation, IQueryHandler <FindMessagesToResetByHeartBeatQuery <long>, IEnumerable <MessageToReset <long> > > decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteQueueTablesDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public DeleteQueueTablesDecorator(IConnectionInformation connectionInformation, ICommandHandlerWithOutput <DeleteQueueTablesCommand, QueueRemoveResult> decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteMessageCommandDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public ResetHeartBeatCommandDecorator(IConnectionInformation connectionInformation, ICommandHandlerWithOutput <ResetHeartBeatCommand <long>, long> decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteMessageCommandDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public GetErrorRecordExistsQueryDecorator(IConnectionInformation connectionInformation, IQueryHandler <GetErrorRecordExistsQuery <long>, bool> decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="GetColumnNamesFromTableDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public GetColumnNamesFromTableDecorator(IConnectionInformation connectionInformation, IQueryHandler <GetColumnNamesFromTableQuery, List <string> > decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteMessageCommandDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public DeleteMessageCommandDecorator(IConnectionInformation connectionInformation, ICommandHandlerWithOutput <DeleteMessageCommand, long> decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteMessageCommandDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public MoveRecordToErrorQueueCommandDecorator(IConnectionInformation connectionInformation, ICommandHandler <MoveRecordToErrorQueueCommand> decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="GetColumnNamesFromTableDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public DoesJobExistDecorator(IConnectionInformation connectionInformation, IQueryHandler <DoesJobExistQuery <IDbConnection, IDbTransaction>, QueueStatuses> decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteMessageCommandDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public FindExpiredRecordsToDeleteDecorator(IConnectionInformation connectionInformation, IQueryHandler <FindExpiredMessagesToDeleteQuery, IEnumerable <long> > decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteMessageCommandDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public SetStatusTableStatusCommandDecorator(IConnectionInformation connectionInformation, ICommandHandler <DeleteStatusTableStatusCommand> decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="DeleteMessageCommandDecorator" /> class. /// </summary> /// <param name="connectionInformation">The connection information.</param> /// <param name="decorated">The decorated.</param> /// <param name="databaseExists">The database exists.</param> public SetErrorCountCommandDecorator(IConnectionInformation connectionInformation, ICommandHandler <SetErrorCountCommand> decorated, DatabaseExists databaseExists) { Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _databaseExists = databaseExists; }
public CreateQueueTablesAndSaveConfigurationDecorator(IConnectionInformation connectionInformation, ICommandHandlerWithOutput <CreateQueueTablesAndSaveConfigurationCommand <ITable>, QueueCreationResult> decorated, IGetFileNameFromConnectionString getFileNameFromConnection, DatabaseExists databaseExists) { Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => decorated, decorated); Guard.NotNull(() => getFileNameFromConnection, getFileNameFromConnection); Guard.NotNull(() => databaseExists, databaseExists); _connectionInformation = connectionInformation; _decorated = decorated; _getFileNameFromConnection = getFileNameFromConnection; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="RollbackMessageCommandHandler" /> class. /// </summary> /// <param name="getUtcDateQuery">The get UTC date query.</param> /// <param name="options">The options.</param> /// <param name="tableNameHelper">The table name helper.</param> /// <param name="connectionInformation">The connection information.</param> /// <param name="commandCache">The command cache.</param> /// <param name="dbFactory">The database factory.</param> /// <param name="databaseExists">The database exists.</param> public RollbackMessageCommandHandler(IGetTimeFactory getUtcDateQuery, ISqLiteMessageQueueTransportOptionsFactory options, ITableNameHelper tableNameHelper, IConnectionInformation connectionInformation, IDbCommandStringCache commandCache, IDbFactory dbFactory, DatabaseExists databaseExists) { _getUtcDateQuery = getUtcDateQuery; _options = new Lazy <SqLiteMessageQueueTransportOptions>(options.Create); _tableNameHelper = tableNameHelper; _connectionInformation = connectionInformation; _commandCache = commandCache; _rollbackDictionary = new ConcurrentDictionary <string, string>(); _dbFactory = dbFactory; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveMessageQueryHandler"/> class. /// </summary> /// <param name="optionsFactory">The options factory.</param> /// <param name="tableNameHelper">The table name helper.</param> /// <param name="connectionInformation">The connection information.</param> /// <param name="databaseExists">The database exists.</param> /// <param name="messageDeQueue">The message de queue.</param> public ReceiveMessageQueryHandler(ILiteDbMessageQueueTransportOptionsFactory optionsFactory, TableNameHelper tableNameHelper, LiteDbConnectionManager connectionInformation, DatabaseExists databaseExists, MessageDeQueue messageDeQueue) { Guard.NotNull(() => optionsFactory, optionsFactory); Guard.NotNull(() => tableNameHelper, tableNameHelper); Guard.NotNull(() => databaseExists, databaseExists); Guard.NotNull(() => messageDeQueue, messageDeQueue); Guard.NotNull(() => connectionInformation, connectionInformation); _options = new Lazy <LiteDbMessageQueueTransportOptions>(optionsFactory.Create); _tableNameHelper = tableNameHelper; _connectionInformation = connectionInformation; _databaseExists = databaseExists; _messageDeQueue = messageDeQueue; }
/// <summary> /// Initializes a new instance of the <see cref="RollbackMessageCommandHandler" /> class. /// </summary> /// <param name="getUtcDateQuery">The get UTC date query.</param> /// <param name="options">The options.</param> /// <param name="tableNameHelper">The table name helper.</param> /// <param name="connectionInformation">The connection information.</param> /// <param name="databaseExists">The database exists.</param> public RollbackMessageCommandHandler(IGetTimeFactory getUtcDateQuery, ILiteDbMessageQueueTransportOptionsFactory options, TableNameHelper tableNameHelper, LiteDbConnectionManager connectionInformation, DatabaseExists databaseExists) { Guard.NotNull(() => connectionInformation, connectionInformation); Guard.NotNull(() => tableNameHelper, tableNameHelper); Guard.NotNull(() => getUtcDateQuery, getUtcDateQuery); Guard.NotNull(() => options, options); Guard.NotNull(() => databaseExists, databaseExists); _getUtcDateQuery = getUtcDateQuery; _options = new Lazy <LiteDbMessageQueueTransportOptions>(options.Create); _tableNameHelper = tableNameHelper; _connectionInformation = connectionInformation; _databaseExists = databaseExists; }
/// <summary> /// Initializes a new instance of the <see cref="SendMessageCommandHandler" /> class. /// </summary> /// <param name="tableNameHelper">The table name helper.</param> /// <param name="serializer">The serializer.</param> /// <param name="optionsFactory">The options factory.</param> /// <param name="headers">The headers.</param> /// <param name="commandCache">The command cache.</param> /// <param name="configurationSend">The configuration send.</param> /// <param name="getTimeFactory">The get time factory.</param> /// <param name="dbFactory">The database factory.</param> /// <param name="sendJobStatus">The send job status.</param> /// <param name="jobExistsHandler">The job exists handler.</param> /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param> /// <param name="databaseExists">The database exists.</param> /// <param name="readerAsync">The reader asynchronous.</param> public SendMessageCommandHandlerAsync(TableNameHelper tableNameHelper, ICompositeSerialization serializer, ISqLiteMessageQueueTransportOptionsFactory optionsFactory, IHeaders headers, IDbCommandStringCache commandCache, TransportConfigurationSend configurationSend, IGetTimeFactory getTimeFactory, IDbFactory dbFactory, ICommandHandler <SetJobLastKnownEventCommand <IDbConnection, IDbTransaction> > sendJobStatus, IQueryHandler <DoesJobExistQuery <IDbConnection, IDbTransaction>, QueueStatuses> jobExistsHandler, IJobSchedulerMetaData jobSchedulerMetaData, DatabaseExists databaseExists, IReaderAsync readerAsync) { Guard.NotNull(() => tableNameHelper, tableNameHelper); Guard.NotNull(() => serializer, serializer); Guard.NotNull(() => optionsFactory, optionsFactory); Guard.NotNull(() => headers, headers); Guard.NotNull(() => commandCache, commandCache); Guard.NotNull(() => configurationSend, configurationSend); Guard.NotNull(() => getTimeFactory, getTimeFactory); Guard.NotNull(() => sendJobStatus, sendJobStatus); Guard.NotNull(() => jobExistsHandler, jobExistsHandler); Guard.NotNull(() => jobSchedulerMetaData, jobSchedulerMetaData); Guard.NotNull(() => databaseExists, databaseExists); Guard.NotNull(() => readerAsync, readerAsync); _tableNameHelper = tableNameHelper; _serializer = serializer; _options = new Lazy <SqLiteMessageQueueTransportOptions>(optionsFactory.Create); _headers = headers; _commandCache = commandCache; _configurationSend = configurationSend; _getTime = getTimeFactory.Create(); _dbFactory = dbFactory; _sendJobStatus = sendJobStatus; _jobExistsHandler = jobExistsHandler; _jobSchedulerMetaData = jobSchedulerMetaData; _databaseExists = databaseExists; _readerAsync = readerAsync; }
public async Task <HttpResponseMessage> CreateApplication(CreateApplicationParams parameters) { if (!ModelState.IsValid) { var errors = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)); return(Request.CreateResponse(HttpStatusCode.BadRequest, new ResponseContainer(HttpStatusCode.BadRequest, string.Format("Missing parameters. {0}", errors)))); } if (App.CreationToken != parameters.CreationToken) { Logger.Info("Token does not match {1}. Input Params: {0}", parameters, App.CreationToken); return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } var application = parameters.Application; Database = application.Name; using (var s = Session) { DatabaseExists.Ensure(DocumentStore, Database); var catalog = new AssemblyCatalog(typeof(UserByEmailIndex).Assembly); var provider = new CatalogExportProvider(catalog) { SourceProvider = new CatalogExportProvider(catalog) }; IndexCreation.CreateIndexes(provider, DocumentStore, Database); var config = s.Load <Config>("1"); if (config == null) { config = AutoMapper.Mapper.Map <CreateApplicationParams, Config>(parameters); s.Store(config, "1"); } foreach (var useremail in parameters.AdminEmails) { if (s.Query <User, UserByEmailIndex>() .Any(x => x.Email == useremail)) { continue; } var password = CommandExecutor.ExecuteCommand(new GeneratePasswordCommand(12)); var hashed = await CommandExecutor.ExecuteCommandAsync(new HashPasswordCommandAsync(password, App.Pepper)); var adminUser = new User("admin", "user", useremail, "", hashed.HashedPassword, hashed.Salt, application.Name, "admin", "users/1.ea7e4af2-67e3-405a-88f9-e4f4896b617d", null, null) { Active = true, Approved = true }; s.Store(adminUser); CommandExecutor.ExecuteCommand( new PasswordResetEmailCommand(new PasswordResetEmailCommand.MailTemplate( new[] { adminUser.Email }, config.AdministrativeEmails, adminUser.FullName, password, parameters.Application.Description))); } s.SaveChanges(); } //add admin email to admin group and send email to reset password. BootstrapCommand.Parameters = parameters; BootstrapCommand.AdminInformation = App.AdminInformation; var messages = await CommandExecutor.ExecuteCommandAsync(BootstrapCommand); if (messages.Any()) { return(Request.CreateResponse(HttpStatusCode.Created, new ResponseContainer(HttpStatusCode.Created, string.Join(" ", messages.Select(x => x))))); } return(Request.CreateResponse(HttpStatusCode.Created)); }