Beispiel #1
0
 public void Record(Response response)
 {
     Trail.Add(response);
 }
Beispiel #2
0
 public void Record(Response response)
 {
     Trail.Add(response);
     _file.Write(_filePath, Trail);
 }
Beispiel #3
0
 public static void FireOnException(Response response)
 {
     var exception = response.Entity as Exception;
       if (exception != null) Console.WriteLine("The dispatch is designed to catch all exceptions. You can listen for them and do what you need with the exception itself. Ex Message:" + exception.Message);
 }
Beispiel #4
0
 public static void ExampleListener(Response response)
 {
     Console.WriteLine("{0} broadcasts: {1}", response.EventName, response.Message);
 }
Beispiel #5
0
 public void Final(Response response)
 {
     Final();
 }
Beispiel #6
0
        /// <summary>
        /// Whenever the dispatcher publishes an event we create a message for it and stick it on the queue. Then we see if anyone is requesting notification and we create a backlog entry for them to be processed at a later date. Likely by a scheduled task or explict request.
        /// </summary>
        /// <param name="response"></param>
        public void ProcessEvent(Response response)
        {
            if (!Subscribers.ContainsKey(response.EventName.Name) || !Subscribers[response.EventName.Name].ContainsKey(response.Type)) return; // Bail early if there are no subscribers.

              // Run through all of the subscribers for this publisher and generate a backlog item for them.
              foreach (var s in Subscribers[response.EventName.Name][response.Type])
              {
            string subject;
            string body;

            if (EmailTemplateLookup.ContainsKey(response.EventName.ToString()) &&
            EmailTemplateLookup[response.EventName.ToString()].ContainsKey(response.Request.Entity.GetType()))
            {
              var temp = EmailTemplateLookup[response.EventName.ToString()][response.Request.Entity.GetType()];
              subject = temp.GetSubject(response.Entity);
              body = temp.GetBody(response.Entity);
            }
            else
            {
              subject = "Automated Notification: You were selected to be notified when the following event occurced: " + response.EventName.Name;
              body = response.Message;
            }

            // Add the backlog item
            var bli = new BackLogItem
            {
              AttempNumber = 0,
              AttemptMessage = "Created.",
              BackLogItemUniqueId = Guid.NewGuid(),
              NextAttempTime = null,
              RequestId = response.RequestId,
              RequestUniqueKey = response.RequestUniqueKey,
              ResponseId = response.ResponseId,
              ResponseUniqueKey = response.ResponseUniqueKey,
              SentDate = null,
              UserId = s,
              WasSent = false,
              Subject = subject,
              Message = body
            };

            BackLog.Add(bli);
              }
        }