public async Task Consume(ConsumeContext <ChangeHomeAddressCommand> context)
        {
            try
            {
                Trace.TraceInformation($"Changing address for {context.Message.PersonId}");
                var person = _peopleRepository.Get(context.Message.PersonId);
                person.ChangeHomeAddress(context.Message.NewAddress);
                _peopleRepository.Save(person);

                _notificationHub
                .CreateProxy("http://localhost:2627", "playgroundServer")
                .ProcessFinished(new
                {
                    id           = Guid.NewGuid(),
                    name         = "addressSaved",
                    adtionalInfo = new { }
                });

                await _bus.Publish(HomeAddressChangedEvent.New(person.Id));
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }
Пример #2
0
        public async Task Consume(ConsumeContext <HomeAddressChangedEvent> context)
        {
            //Send notification mail
            var emailProcessId  = Guid.NewGuid();
            var notificationHub = _notificationHub
                                  .CreateProxy("http://localhost:2627", "playgroundServer");

            notificationHub.ProcessStarted(
                new { id = emailProcessId, name = "sendingMail", adtionalInfo = new { } });
            Thread.Sleep(2000);
            notificationHub.ProcessFinished(
                new { id = emailProcessId, name = "emailSent", adtionalInfo = new { } });
        }
        public async Task Consume(ConsumeContext <HomeAddressChangedEvent> context)
        {
            //Calculate new debts values
            var calculateProcessId = Guid.NewGuid();
            var notificationHub    = _notificationHub
                                     .CreateProxy("http://localhost:2627", "playgroundServer");

            notificationHub.ProcessStarted(
                new { id = calculateProcessId, name = "debtsCalculationStarted", adtionalInfo = new { } });
            Thread.Sleep(5000);
            notificationHub.ProcessFinished(
                new { id = calculateProcessId, name = "finishedCalculationDebts", adtionalInfo = new { } });
        }
        public async Task Consume(ConsumeContext <ChangeHomeAddressCommand> context)
        {
            try
            {
                Trace.TraceInformation($"Changing address for {context.Message.PersonId}");
                var person = _peopleRepository.Get(context.Message.PersonId);
                person.ChangeHomeAddress(context.Message.NewAddress);
                _peopleRepository.Save(person);

                var notificationHub = _notificationHub
                                      .CreateProxy("http://localhost:2627", "playgroundServer");
                //Calculate new debts values
                var calculateProcessId = Guid.NewGuid();
                notificationHub.ProcessStarted(
                    new { id = calculateProcessId, name = "debtsCalculationStarted", adtionalInfo = new { } });
                Thread.Sleep(5000);
                notificationHub.ProcessFinished(
                    new { id = calculateProcessId, name = "finishedCalculationDebts", adtionalInfo = new { } });

                //Send notification mail
                var emailProcessId = Guid.NewGuid();
                notificationHub.ProcessStarted(
                    new { id = emailProcessId, name = "sendingMail", adtionalInfo = new { } });
                Thread.Sleep(2000);
                notificationHub.ProcessFinished(
                    new { id = emailProcessId, name = "emailSent", adtionalInfo = new { } });

                notificationHub
                .ProcessFinished(new
                {
                    id           = Guid.NewGuid(),
                    name         = "addressSaved",
                    adtionalInfo = new { }
                });
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }