示例#1
0
 /// <summary>
 /// Generate the DTO for this <see cref="DbQMessage"/>.
 /// </summary>
 /// <typeparam name="T">The type of message to convert to.</typeparam>
 public QMessage <T> ToModel <T>(JsonSerializerOptions options = null) where T : class => new QMessage <T>
 {
     Id           = Id,
     Date         = Date,
     DequeueCount = DequeueCount,
     QueueName    = QueueName,
     Value        = JsonSerializer.Deserialize <T>(Payload, options ?? WorkerJsonOptions.GetDefaultSettings())
 };
示例#2
0
 /// <summary>
 /// Generates the DTO for this <see cref="DbScheduledTask"/>.
 /// </summary>
 /// <param name="options">Provides options to be used with <see cref="JsonSerializer"/>.</param>
 public ScheduledTask <TState> ToModel <TState>(JsonSerializerOptions options = null) where TState : class => new ScheduledTask <TState>
 {
     Id             = Id,
     Description    = Description,
     Group          = Group,
     Errors         = Errors,
     ExecutionCount = ExecutionCount,
     LastExecution  = LastExecution,
     NextExecution  = NextExecution,
     Progress       = Progress,
     State          = JsonSerializer.Deserialize <TState>(Payload, options ?? WorkerJsonOptions.GetDefaultSettings()),
     Status         = Status,
     Type           = Type,
     WorkerId       = WorkerId
 };
示例#3
0
 internal DbScheduledTask From <TState>(ScheduledTask <TState> model, JsonSerializerOptions options = null) where TState : class
 {
     Id             = model.Id;
     Description    = model.Description;
     Group          = model.Group;
     Errors         = model.Errors;
     ExecutionCount = model.ExecutionCount;
     LastExecution  = model.LastExecution;
     NextExecution  = model.NextExecution;
     Progress       = model.Progress;
     Payload        = JsonSerializer.Serialize(model.State, options ?? WorkerJsonOptions.GetDefaultSettings());
     Status         = model.Status;
     Type           = model.Type;
     WorkerId       = model.WorkerId;
     return(this);
 }
示例#4
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="dbContext"></param>
 /// <param name="queueNameResolver"></param>
 /// <param name="workerJsonOptions"></param>
 public EFMessageQueue(TaskDbContext dbContext, IQueueNameResolver <T> queueNameResolver, WorkerJsonOptions workerJsonOptions)
 {
     _dbContext             = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _queueName             = queueNameResolver?.Resolve() ?? throw new ArgumentNullException(nameof(queueNameResolver));
     _jsonSerializerOptions = workerJsonOptions?.JsonSerializerOptions ?? throw new ArgumentNullException(nameof(workerJsonOptions));
 }
 /// <summary>
 /// creates the <see cref="EFScheduledTaskStore{TState}"/>
 /// </summary>
 /// <param name="dbContext"></param>
 /// <param name="workerJsonOptions"></param>
 public EFScheduledTaskStore(TaskDbContext dbContext, WorkerJsonOptions workerJsonOptions)
 {
     _dbContext             = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _jsonSerializerOptions = workerJsonOptions?.JsonSerializerOptions ?? throw new ArgumentNullException(nameof(workerJsonOptions));
 }
 /// <summary>
 /// Constructs a new <see cref="SqlServerMessageQueue{T}"/>.
 /// </summary>
 /// <param name="dbConnectionFactory">A factory class that generates instances of type <see cref="IDbConnection"/>.</param>
 /// <param name="queueNameResolver">Resolves the queue name.</param>
 /// <param name="workerJsonOptions">These are the options regarding json Serialization. They are used internally for persisting payloads.</param>
 public SqlServerMessageQueue(IDbConnectionFactory dbConnectionFactory, IQueueNameResolver <T> queueNameResolver, WorkerJsonOptions workerJsonOptions)
 {
     _dbConnectionFactory   = dbConnectionFactory ?? throw new ArgumentNullException(nameof(dbConnectionFactory));
     _queueNameResolver     = queueNameResolver ?? throw new ArgumentNullException(nameof(queueNameResolver));
     _jsonSerializerOptions = workerJsonOptions?.JsonSerializerOptions ?? throw new ArgumentNullException(nameof(workerJsonOptions));
 }
示例#7
0
 /// <summary>
 /// Constructs a new <see cref="RelationalMessageQueue{T}"/>.
 /// </summary>
 /// <param name="dbContext">A <see cref="DbContext"/> for hosting multiple <see cref="IMessageQueue{T}"/>.</param>
 /// <param name="queueNameResolver">Resolves the queue name.</param>
 /// <param name="workerJsonOptions">These are the options regarding json Serialization. They are used internally for persisting payloads.</param>
 public RelationalMessageQueue(TaskDbContext dbContext, IQueueNameResolver <T> queueNameResolver, WorkerJsonOptions workerJsonOptions)
 {
     _dbContext             = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _queueNameResolver     = queueNameResolver ?? throw new ArgumentNullException(nameof(queueNameResolver));
     _jsonSerializerOptions = workerJsonOptions?.JsonSerializerOptions ?? throw new ArgumentNullException(nameof(workerJsonOptions));
     _queryDescriptor       = new MessageQueueQueryDescriptor(dbContext);
 }