コード例 #1
0
        public async Task SaveCommand(SourcedCommand command)
        {
            var tableCommand         = MapToAzureModel(command);
            var tableInsertOperation = TableOperation.Insert(tableCommand);

            await commandsTable.ExecuteAsync(tableInsertOperation);
        }
コード例 #2
0
 public Task SaveCommand(SourcedCommand command)
 {
     lock (locker)
     {
         Commands.Add(command);
         return(Task.CompletedTask);
     }
 }
コード例 #3
0
 private TableCommandModel MapToAzureModel(SourcedCommand command)
 {
     return(new TableCommandModel {
         RowKey = command.CommandId.ToString(),
         PartitionKey = command.CommandId.ToString(),
         CommandTypeHint = modelSerializer.GetTypeHint(command),
         CommandJsonData = modelSerializer.Serialize(command)
     });
 }
コード例 #4
0
ファイル: EventSource.cs プロジェクト: ddomurad/dungeon.cqrs
        public async Task PushChanges(SourcedCommand command)
        {
            var cmdId = command.CommandId;

            foreach (var aggregate in commitedEventStreams)
            {
                UpdateStream(aggregate, cmdId);
            }

            // foreach (var aggregate in commitedEventStreams)
            //     await ValidateStream(aggregate);

            await SaveStream(commitedEventStreams);

            foreach (var aggregate in commitedEventStreams)
            {
                UpdateAggregateVersion(aggregate);
            }

            await eventStore.SaveCommand(command);

            foreach (var aggregate in commitedEventStreams)
            {
                await SendEvents(aggregate, command);
            }

            foreach (var aggregate in commitedEventStreams)
            {
                aggregate.CommitChanges();
            }

            if (snapshotManager != null)
            {
                foreach (var aggregate in commitedEventStreams)
                {
                    await TakeSnapshot(aggregate);
                }
            }

            commitedEventStreams.Clear();
        }
コード例 #5
0
 public async Task SaveCommand(SourcedCommand command)
 {
     var collection = mongoDatabase.GetCollection <SourcedCommand>("Commands");
     await collection.InsertOneAsync(command);
 }