| | | 1 | | using Elsa.Common.Models; |
| | | 2 | | using Elsa.Common.Services; |
| | | 3 | | using Elsa.Extensions; |
| | | 4 | | using Elsa.Workflows.Runtime.Entities; |
| | | 5 | | using Elsa.Workflows.Runtime.Filters; |
| | | 6 | | using Elsa.Workflows.Runtime.OrderDefinitions; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Workflows.Runtime.Stores; |
| | | 9 | | |
| | | 10 | | /// <inheritdoc /> |
| | | 11 | | public class MemoryWorkflowExecutionLogStore : IWorkflowExecutionLogStore |
| | | 12 | | { |
| | | 13 | | private readonly MemoryStore<WorkflowExecutionLogRecord> _store; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Initializes a new instance of the <see cref="MemoryWorkflowExecutionLogStore"/> class. |
| | | 17 | | /// </summary> |
| | 150 | 18 | | public MemoryWorkflowExecutionLogStore(MemoryStore<WorkflowExecutionLogRecord> store) |
| | | 19 | | { |
| | 150 | 20 | | _store = store; |
| | 150 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | | 24 | | public Task AddAsync(WorkflowExecutionLogRecord record, CancellationToken cancellationToken = default) |
| | | 25 | | { |
| | 0 | 26 | | _store.Add(record, x => x.Id); |
| | 0 | 27 | | return Task.CompletedTask; |
| | | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <inheritdoc /> |
| | | 31 | | public Task AddManyAsync(IEnumerable<WorkflowExecutionLogRecord> records, CancellationToken cancellationToken = defa |
| | | 32 | | { |
| | 2640 | 33 | | _store.AddMany(records, x => x.Id); |
| | 143 | 34 | | return Task.CompletedTask; |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <inheritdoc /> |
| | | 38 | | public Task SaveAsync(WorkflowExecutionLogRecord record, CancellationToken cancellationToken = default) |
| | | 39 | | { |
| | 0 | 40 | | _store.Save(record, x => x.Id); |
| | 0 | 41 | | return Task.CompletedTask; |
| | | 42 | | } |
| | | 43 | | |
| | | 44 | | /// <inheritdoc /> |
| | | 45 | | public Task SaveManyAsync(IEnumerable<WorkflowExecutionLogRecord> records, CancellationToken cancellationToken = def |
| | | 46 | | { |
| | 0 | 47 | | _store.SaveMany(records, x => x.Id); |
| | 0 | 48 | | return Task.CompletedTask; |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <inheritdoc /> |
| | | 52 | | public Task<WorkflowExecutionLogRecord?> FindAsync(WorkflowExecutionLogRecordFilter filter, CancellationToken cancel |
| | | 53 | | { |
| | 0 | 54 | | var result = _store.Query(query => Filter(query, filter)).FirstOrDefault(); |
| | 0 | 55 | | return Task.FromResult(result); |
| | | 56 | | } |
| | | 57 | | |
| | | 58 | | /// <inheritdoc /> |
| | | 59 | | public Task<WorkflowExecutionLogRecord?> FindAsync<TOrderBy>(WorkflowExecutionLogRecordFilter filter, WorkflowExecut |
| | | 60 | | { |
| | 0 | 61 | | var result = _store.Query(query => Filter(query, filter).OrderBy(order)).FirstOrDefault(); |
| | 0 | 62 | | return Task.FromResult(result); |
| | | 63 | | } |
| | | 64 | | |
| | | 65 | | /// <inheritdoc /> |
| | | 66 | | public Task<Page<WorkflowExecutionLogRecord>> FindManyAsync(WorkflowExecutionLogRecordFilter filter, PageArgs pageAr |
| | | 67 | | { |
| | 4 | 68 | | var count = _store.Query(query => Filter(query, filter)).LongCount(); |
| | 4 | 69 | | var result = _store.Query(query => Filter(query, filter).Paginate(pageArgs)).ToList(); |
| | 2 | 70 | | return Task.FromResult(Page.Of(result, count)); |
| | | 71 | | } |
| | | 72 | | |
| | | 73 | | /// <inheritdoc /> |
| | | 74 | | public Task<Page<WorkflowExecutionLogRecord>> FindManyAsync<TOrderBy>(WorkflowExecutionLogRecordFilter filter, PageA |
| | | 75 | | { |
| | 0 | 76 | | var count = _store.Query(query => Filter(query, filter)).LongCount(); |
| | 0 | 77 | | var result = _store.Query(query => Filter(query, filter).OrderBy(order).Paginate(pageArgs)).ToList(); |
| | 0 | 78 | | return Task.FromResult(Page.Of(result, count)); |
| | | 79 | | } |
| | | 80 | | |
| | | 81 | | /// <inheritdoc /> |
| | | 82 | | public Task<long> DeleteManyAsync(WorkflowExecutionLogRecordFilter filter, CancellationToken cancellationToken = def |
| | | 83 | | { |
| | 0 | 84 | | var records = _store.Query(query => Filter(query, filter)).ToList(); |
| | 0 | 85 | | _store.DeleteMany(records, x => x.Id); |
| | 0 | 86 | | return Task.FromResult(records.LongCount()); |
| | | 87 | | } |
| | | 88 | | |
| | 4 | 89 | | private IQueryable<WorkflowExecutionLogRecord> Filter(IQueryable<WorkflowExecutionLogRecord> queryable, WorkflowExec |
| | | 90 | | } |