/// <summary>Add event to session log and dispatch it. <see cref="OperationProgressEvent"/> events are not added to event log.</summary> public void LogAndDispatchEvent(IOperationEvent @event) { if (@event is OperationProgressEvent == false) { this.Events.TryAdd(@event); } DispatchEvent(@event); }
public static OperationEventTableEntity Create(IOperationEvent source) { return(new OperationEventTableEntity { DateTime = source.DateTime, OperationId = source.OperationId, PartitionKey = GeneratePartitionKey(source.OperationId), RowKey = GenerateRowKey(source.Type, source.OperationId), Context = source.Context }); }
/// <summary>Dispatch event to observers (in current thread)</summary> public void DispatchEvent(IOperationEvent @event) { var handles = observers.Array; foreach (var handle in handles) { try { handle.observer.OnNext(@event); } catch (Exception error) when(CaptureError(error)) { } } bool CaptureError(Exception e) { Events.TryAdd(new OperationErrorEvent(null, e)); return(false); } }
public Task InsertIfNotExist(IOperationEvent operationEvent) { return(_storage.TryInsertAsync(OperationEventTableEntity.Create(operationEvent))); }
public async Task InsertIfNotExist(IOperationEvent operationEvent) { await _storage.CreateIfNotExistsAsync(OperationEventTableEntity.Create(operationEvent)); }