public void CheckMessages(object sender, System.Timers.ElapsedEventArgs e)
            {
                Debug.Print("PW: Checking notifier queue for messages");
                // Make sure this matches MessagingConfig in FrontDeskSolution
                var connectionString = ConfigurationManager.ConnectionStrings["ServiceBroker"].ConnectionString;

                try
                {
                    using (var sqlConnection = new SqlConnection(connectionString))
                    {
                        sqlConnection.Open();
                        using (var sqlTransaction = sqlConnection.BeginTransaction())
                        {
                            var rawMessage = ServiceBrokerWrapper.WaitAndReceive(sqlTransaction, NotifierQueue, 10 * 1000);

                            if (rawMessage != null && rawMessage.Body.Length > 0)
                            {
                                Debug.Print("Raw Message: " + ServiceBrokerWrapper.GetString(rawMessage.Body));

                                var emailSender = StructureMap.ObjectFactory.GetInstance <ISendConfirmationEmails>();
                                AppointmentScheduledEvent appointmentScheduledEvent = JsonConvert.DeserializeObject <AppointmentScheduledEvent>(ServiceBrokerWrapper.GetString(rawMessage.Body));

                                emailSender.SendConfirmationEmail(appointmentScheduledEvent.AppointmentScheduled);
                            }
                            sqlTransaction.Commit();
                        }
                        sqlConnection.Close();
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print("PW: Error checking notifier queue: " + ex.ToString());
                }
                //Debug.Print("Done checking queue for messages");
            }
Beispiel #2
0
        public void UpdateRoom(int roomId)
        {
            if (roomId == RoomId)
            {
                return;
            }

            RoomId = roomId;

            var appoinmentUpdateEvent = new AppointmentScheduledEvent(this);

            DomainEvents.Raise(appoinmentUpdateEvent);
        }
        public Appointment AddNewAppointment(Appointment appointment)
        {
            if (appointment.Id != Guid.Empty &&
                _appointments.Any(a => a.Id == appointment.Id))
            {
                throw new ArgumentException("Cannot add duplicate appointment to schedule.", nameof(appointment));
            }

            _appointments.Add(appointment);

            MarkConflictingAppointments();

            var appointmentScheduledEvent = new AppointmentScheduledEvent(appointment);

            return(appointment);
        }
Beispiel #4
0
        public Appointment AddNewAppointment(Appointment appointment)
        {
            if (_appointments.Any(a => a.Id == appointment.Id))
            {
                throw new ArgumentException("Cannot add duplicate appointment to schedule.", nameof(appointment));
            }

            //appointment.State = TrackingState.Added;
            _appointments.Add(appointment);

            MarkConflictingAppointments();

            var appointmentScheduledEvent = new AppointmentScheduledEvent(appointment);

            return(appointment);
        }
Beispiel #5
0
        public Appointment AddNewAppointment(Appointment appointment)
        {
            Guard.Against.Null(appointment, nameof(appointment));
            Guard.Against.Default(appointment.Id, nameof(appointment.Id));
            Guard.Against.DuplicateAppointment(_appointments, appointment, nameof(appointment));

            _appointments.Add(appointment);

            MarkConflictingAppointments();

            var appointmentScheduledEvent = new AppointmentScheduledEvent(appointment);

            Events.Add(appointmentScheduledEvent);

            return(appointment);
        }
        public Appointment AddNewAppointment(Appointment appointment)
        {
            if (this.appointments.Any(a => a.Id == appointment.Id))
            {
                throw new ArgumentException("Cannot add duplicate appointment to schedule.", "appointment");
            }

            this.appointments.Add(appointment);

            this.MarkConflictingAppointments();

            var appointmentScheduledEvent = new AppointmentScheduledEvent(appointment);

            this.RaiseEvent(appointmentScheduledEvent);

            return(appointment);
        }
Beispiel #7
0
        public Appointment AddNewAppointment(Appointment appointment)
        {
            if (_appointments.Any(a => a.Id == appointment.Id))
            {
                throw new ArgumentException("Não é possível inserir horário duplicado na agenda.", "appointment");
            }

            appointment.State = TrackingState.Added;
            _appointments.Add(appointment);

            MarkConflictingAppointments();

            var appointmentScheduledEvent = new AppointmentScheduledEvent(appointment);

            DomainEvents.Raise(appointmentScheduledEvent);

            return(appointment);
        }
        public IEnumerable <string> Get()
        {
            var appointmentConfirmedEvent = new AppointmentConfirmedEvent();

            DomainEvents.Raise(appointmentConfirmedEvent);

            var appointmentScheduledEvent = new AppointmentScheduledEvent(null);

            DomainEvents.Raise(appointmentScheduledEvent);

            Debug.WriteLine(DomainEvents.Container.WhatDidIScan());
            Debug.WriteLine(DomainEvents.Container.WhatDoIHave());

            var handlers  = DomainEvents.Container.GetAllInstances <IHandle <AppointmentConfirmedEvent> >();
            var handlers1 = DomainEvents.Container.GetAllInstances <EmailConfirmationHandler>();
            var handlers2 = DomainEvents.Container.GetAllInstances(typeof(IHandle <AppointmentConfirmedEvent>));
            var handlers3 = DomainEvents.Container.GetAllInstances(typeof(EmailConfirmationHandler));

            //var handlers4 = DomainEvents.Container.GetAllInstances(typeof(IHandle<>));


            return(new string[] { "value1", "value2" });
        }