public void Handle(NoteCreated evnt)
 {
     using (var connection = _connectionFactory.OpenConnection())
     {
         connection.Insert(evnt, "EventSourcing_Sample_Note");
     }
 }
Exemplo n.º 2
0
 public void Handle(NoteCreated evnt)
 {
     using (var connection = _connectionFactory.OpenConnection())
     {
         connection.Insert(evnt, "EventSourcing_Sample_Note");
     }
 }
Exemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        // load caliper event templates

        sessionLoggedIn = (SessionLoggedIn)gameObject.AddComponent(typeof(SessionLoggedIn));
        noteCreated     = (NoteCreated)gameObject.AddComponent(typeof(NoteCreated));
        noteDeleted     = (NoteDeleted)gameObject.AddComponent(typeof(NoteDeleted));
        noteSaved       = (NoteSaved)gameObject.AddComponent(typeof(NoteSaved));
        noteLoaded      = (NoteLoaded)gameObject.AddComponent(typeof(NoteLoaded));
        imageIdentified = (ImageIdentified)gameObject.AddComponent(typeof(ImageIdentified));
    }
 public void Handle(NoteCreated evnt)
 {
     var note = new NoteEntity
     {
         Id = evnt.Id,
         Title = evnt.Title,
         CreatedTime = evnt.CreatedTime,
         UpdatedTime = evnt.UpdatedTime
     };
     _session.Save(note);
 }
Exemplo n.º 5
0
        public async void handlerShouldExecuteCorrectly()
        {
            var mailClient = new Mock <IMailClient>();

            mailClient.Setup(obj => obj.Send(It.IsAny <NoteCreatedMail>())).Verifiable();

            var handler = new SendNoteCreatedMail(mailClient.Object);

            var noteEvent = new NoteCreated(1, "mytitle", "mydescription");

            await handler.Handle(noteEvent, new CancellationToken());

            mailClient.Verify();
        }
Exemplo n.º 6
0
        static void PublishEventAsync(int eventCount)
        {
            var printSize      = eventCount / 10;
            var eventPublisher = ObjectContainer.Resolve <IMessagePublisher <DomainEventStreamMessage> >();
            var eventStreams   = new List <DomainEventStreamMessage>();
            var commandId      = ObjectId.GenerateNewStringId();
            var note           = new Note(ObjectId.GenerateNewStringId(), "Sample Note");
            var evnt           = new NoteCreated(note, "Sample Note");
            var evnts          = new List <IDomainEvent> {
                evnt
            };
            var waitHandle = new ManualResetEvent(false);

            for (var i = 1; i <= eventCount; i++)
            {
                eventStreams.Add(new DomainEventStreamMessage(commandId, note.Id, 1, 100, evnts, new Dictionary <string, string>()));
            }

            var watch = Stopwatch.StartNew();
            var publishedEventCount = 0;
            var asyncAction         = new Action <DomainEventStreamMessage>(async eventStream =>
            {
                await eventPublisher.PublishAsync(eventStream).ConfigureAwait(false);
                var currentCount = Interlocked.Increment(ref publishedEventCount);
                if (currentCount % printSize == 0)
                {
                    Console.WriteLine("----Published {0} events async, time spent: {1}ms", publishedEventCount, watch.ElapsedMilliseconds);
                }
                if (currentCount == eventCount)
                {
                    waitHandle.Set();
                }
            });

            Console.WriteLine("--Start to publish event async, total count: {0}.", eventCount);
            foreach (var eventStream in eventStreams)
            {
                asyncAction(eventStream);
            }
            waitHandle.WaitOne();
            Console.WriteLine("--Event publish async completed, throughput: {0}/s", eventCount * 1000 / watch.ElapsedMilliseconds);
        }
Exemplo n.º 7
0
        public Note(Guid id, Guid taskId, string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                throw new ArgumentException(nameof(text));
            }
            if (id.Equals(Guid.Empty))
            {
                throw new ArgumentException(nameof(id));
            }
            if (taskId.Equals(Guid.Empty))
            {
                throw new ArgumentException(nameof(taskId));
            }

            State = new NoteState(id, taskId, text);
            var noteCreated = new NoteCreated(id, taskId, text);

            _events.Add(noteCreated);
        }
Exemplo n.º 8
0
        static void PublishEventAsync(int eventCount)
        {
            var printSize = eventCount / 10;
            var eventPublisher = ObjectContainer.Resolve<IMessagePublisher<DomainEventStreamMessage>>();
            var eventStreams = new List<DomainEventStreamMessage>();
            var commandId = ObjectId.GenerateNewStringId();
            var note = new Note(ObjectId.GenerateNewStringId(), "Sample Note");
            var evnt = new NoteCreated(note, "Sample Note");
            var evnts = new List<IDomainEvent> { evnt };
            var waitHandle = new ManualResetEvent(false);

            for (var i = 1; i <= eventCount; i++)
            {
                eventStreams.Add(new DomainEventStreamMessage(commandId, note.Id, 1, 100, evnts, new Dictionary<string, string>()));
            }

            var watch = Stopwatch.StartNew();
            var publishedEventCount = 0;
            var asyncAction = new Action<DomainEventStreamMessage>(async eventStream =>
            {
                await eventPublisher.PublishAsync(eventStream).ConfigureAwait(false);
                var currentCount = Interlocked.Increment(ref publishedEventCount);
                if (currentCount % printSize == 0)
                {
                    Console.WriteLine("----Published {0} events async, time spent: {1}ms", publishedEventCount, watch.ElapsedMilliseconds);
                }
                if (currentCount == eventCount)
                {
                    waitHandle.Set();
                }
            });

            Console.WriteLine("--Start to publish event async, total count: {0}.", eventCount);
            foreach (var eventStream in eventStreams)
            {
                asyncAction(eventStream);
            }
            waitHandle.WaitOne();
            Console.WriteLine("--Event publish async completed, throughput: {0}/s", eventCount * 1000 / watch.ElapsedMilliseconds);
        }
 public void Handle(NoteCreated evnt)
 {
     _connection.Insert(evnt, "EventSourcing_Sample_Note", _transaction);
 }
 protected virtual void OnNoteCreated(NoteArgs e)
 {
     NoteCreated?.Invoke(this, e);
 }