public void Handle(AlertInfo alertInfo)
 {
     bus.SendCommand <Messages.Alert> (new Messages.Alert {
         BrokerId    = alertInfo.Broker.Id,
         AlertTypeId = (int)alertInfo.AlertType,
         DateTimeUTC = alertInfo.DateTimeUTC,
         Description = alertInfo.Description
     });
 }
        public void Handle(AlertInfo alertInfo)
        {
            var body = string.Format("QueueSpy Alert!\nUser: {0}\nBroker: {1}\n{2}",
                                     alertInfo.User.Email,
                                     alertInfo.Broker.Url,
                                     alertInfo.Description);

            bus.Publish(new Messages.SendEmailRequest {
                ToAddress = alertInfo.User.Email,
                Subject   = "[ALERT!] " + alertInfo.Description,
                Body      = body
            });
        }
Exemple #3
0
        void HandleBrokerEvent(QueueSpy.Messages.BrokerEvent brokerEvent)
        {
            logger.Log(string.Format("Got BrokerEvent {0}", brokerEvent.Description));

            // Very simple initial implementation, just alert on all broker events
            // TODO: Filter on user preferences
            var broker = dbReader.GetById <Broker> (brokerEvent.BrokerId);
            var user   = dbReader.GetById <User> (broker.UserId);

            var alertInfo = new AlertInfo {
                Broker      = broker,
                User        = user,
                AlertType   = AlertTypeFromEventTypeId(brokerEvent.EventTypeId),
                DateTimeUTC = brokerEvent.DateTimeUTC,
                Description = brokerEvent.Description
            };

            foreach (var alertSink in alertSinks)
            {
                alertSink.Handle(alertInfo);
            }
        }