private static EventMessageCollection FillMessageCollection(IDataReader dr)
        {
            var arr = new EventMessageCollection();

            try
            {
                EventMessage obj;
                while (dr.Read())
                {
                    //fill business object
                    obj = FillMessage(dr, false);
                    //add to collection
                    arr.Add(obj);
                }
            }
            catch (Exception exc)
            {
                Exceptions.Exceptions.LogException(exc);
            }
            finally
            {
                //close datareader
                CBO.CloseDataReader(dr, true);
            }
            return(arr);
        }
 public EventMessageCollection GetMessages( string eventName )
 {
     EventMessageCollection oEventMessageCollection = new EventMessageCollection();
     string[] EventMessageFiles;
     string EventMessageFile;
     string[] subscribers = new string[0];
     if( EventQueueConfiguration.GetConfig().PublishedEvents[eventName] != null )
     {
         subscribers = EventQueueConfiguration.GetConfig().PublishedEvents[eventName].Subscribers.Split( ";".ToCharArray() );
     }
     else
     {
         subscribers[0] = "";
     }
     for( int indx = 0; indx <= subscribers.Length - 1; indx++ )
     {
         EventMessageFiles = Directory.GetFiles( m_messagePath, MessageName( eventName, subscribers[indx], "*" ) );
         foreach( string tempLoopVar_EventMessageFile in EventMessageFiles )
         {
             EventMessageFile = tempLoopVar_EventMessageFile;
             oEventMessageCollection.Add( DeserializeMessage( EventMessageFile, subscribers[indx] ) );
         }
     }
     return oEventMessageCollection;
 }
示例#3
0
        public EventMessageCollection GetMessages(string eventName)
        {
            EventMessageCollection oEventMessageCollection = new EventMessageCollection();

            string[] EventMessageFiles;
            string   EventMessageFile;

            string[] subscribers = new string[0];
            if (EventQueueConfiguration.GetConfig().PublishedEvents[eventName] != null)
            {
                subscribers = EventQueueConfiguration.GetConfig().PublishedEvents[eventName].Subscribers.Split(";".ToCharArray());
            }
            else
            {
                subscribers[0] = "";
            }
            for (int indx = 0; indx <= subscribers.Length - 1; indx++)
            {
                EventMessageFiles = Directory.GetFiles(m_messagePath, MessageName(eventName, subscribers[indx], "*"));
                foreach (string tempLoopVar_EventMessageFile in EventMessageFiles)
                {
                    EventMessageFile = tempLoopVar_EventMessageFile;
                    oEventMessageCollection.Add(DeserializeMessage(EventMessageFile, subscribers[indx]));
                }
            }
            return(oEventMessageCollection);
        }
示例#4
0
        /// <summary>
        /// Processes the messages.
        /// </summary>
        /// <param name="eventMessages">The event messages.</param>
        /// <returns></returns>
        public static bool ProcessMessages(EventMessageCollection eventMessages)
        {
            bool         success = Null.NullBoolean;
            EventMessage message;

            for (int messageNo = 0; messageNo <= eventMessages.Count - 1; messageNo++)
            {
                message = eventMessages[messageNo];
                try
                {
                    object oMessageProcessor = Reflection.CreateObject(message.ProcessorType, message.ProcessorType);
                    if (!((EventMessageProcessorBase)oMessageProcessor).ProcessMessage(message))
                    {
                        throw new Exception();
                    }

                    // Set Message comlete so it is not run a second time
                    DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);

                    success = true;
                }
                catch
                {
                    // log if message could not be processed
                    var log = new LogInfo {
                        LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
                    };
                    log.AddProperty("EventQueue.ProcessMessage", "Message Processing Failed");
                    log.AddProperty("ProcessorType", message.ProcessorType);
                    log.AddProperty("Body", message.Body);
                    log.AddProperty("Sender", message.Sender);
                    foreach (string key in message.Attributes.Keys)
                    {
                        log.AddProperty(key, message.Attributes[key]);
                    }

                    if (!string.IsNullOrEmpty(message.ExceptionMessage))
                    {
                        log.AddProperty("ExceptionMessage", message.ExceptionMessage);
                    }

                    LogController.Instance.AddLog(log);
                    if (message.ExpirationDate < DateTime.Now)
                    {
                        // Set Message comlete so it is not run a second time
                        DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
                    }
                }
            }

            return(success);
        }
示例#5
0
        public EventMessageCollection GetMessages(string eventName, string subscriberId)
        {
            EventMessageCollection oEventMessageCollection = new EventMessageCollection();

            string[] EventMessageFiles;
            string   EventMessageFile;

            EventMessageFiles = Directory.GetFiles(m_messagePath, MessageName(eventName, subscriberId, "*"));
            foreach (string tempLoopVar_EventMessageFile in EventMessageFiles)
            {
                EventMessageFile = tempLoopVar_EventMessageFile;
                oEventMessageCollection.Add(DeserializeMessage(EventMessageFile, subscriberId));
            }
            return(oEventMessageCollection);
        }
示例#6
0
        public bool ProcessMessages(EventMessageCollection eventMessages)
        {
            EventMessage message;

            foreach (EventMessage tempLoopVar_message in eventMessages)
            {
                message = tempLoopVar_message;
                try
                {
                    object oMessageProcessor = Reflection.CreateObject(message.ProcessorType, message.ProcessorType);
                    if (!((EventMessageProcessorBase)oMessageProcessor).ProcessMessage(message))
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    //log if message could not be processed
                    EventLogController objEventLog     = new EventLogController();
                    LogInfo            objEventLogInfo = new LogInfo();
                    objEventLogInfo.AddProperty("EventQueue.ProcessMessage", "Message Processing Failed");
                    objEventLogInfo.AddProperty("ProcessorType", message.ProcessorType);
                    objEventLogInfo.AddProperty("Body", message.Body);
                    objEventLogInfo.AddProperty("Sender", message.Sender);
                    foreach (string key in message.Attributes.Keys)
                    {
                        objEventLogInfo.AddProperty(key, message.Attributes[key]);
                    }
                    // HACK : Modified to not error if object is null.
                    //if( message.ExceptionMessage.Length > 0 )
                    if (!String.IsNullOrEmpty(message.ExceptionMessage))
                    {
                        objEventLogInfo.AddProperty("ExceptionMessage", message.ExceptionMessage);
                    }
                    objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                    objEventLog.AddLog(objEventLogInfo);
                }
            }
            return(true);
        }
		/// <summary>
		/// Processes the messages.
		/// </summary>
		/// <param name="eventMessages">The event messages.</param>
		/// <returns></returns>
        public static bool ProcessMessages(EventMessageCollection eventMessages)
        {
            bool success = Null.NullBoolean;
            EventMessage message;
            for (int messageNo = 0; messageNo <= eventMessages.Count - 1; messageNo++)
            {
                message = eventMessages[messageNo];
                try
                {
                    object oMessageProcessor = Reflection.CreateObject(message.ProcessorType, message.ProcessorType);
                    if (!((EventMessageProcessorBase) oMessageProcessor).ProcessMessage(message))
                    {
                        throw new Exception();
                    }
					
                    //Set Message comlete so it is not run a second time
                    DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);

                    success = true;
                }
                catch
                {
					//log if message could not be processed
                    var objEventLog = new EventLogController();
                    var objEventLogInfo = new LogInfo();
                    objEventLogInfo.AddProperty("EventQueue.ProcessMessage", "Message Processing Failed");
                    objEventLogInfo.AddProperty("ProcessorType", message.ProcessorType);
                    objEventLogInfo.AddProperty("Body", message.Body);
                    objEventLogInfo.AddProperty("Sender", message.Sender);
                    foreach (string key in message.Attributes.Keys)
                    {
                        objEventLogInfo.AddProperty(key, message.Attributes[key]);
                    }
                    if (!String.IsNullOrEmpty(message.ExceptionMessage))
                    {
                        objEventLogInfo.AddProperty("ExceptionMessage", message.ExceptionMessage);
                    }
                    objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                    objEventLog.AddLog(objEventLogInfo);
                    if (message.ExpirationDate < DateTime.Now)
                    {
						//Set Message comlete so it is not run a second time
                        DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
                    }
                }
            }
            return success;
        }
        private static EventMessageCollection FillMessageCollection(IDataReader dr)
        {
            var arr = new EventMessageCollection();
            try
            {
                EventMessage obj;
                while (dr.Read())
                {
					//fill business object
                    obj = FillMessage(dr, false);
                    //add to collection
                    arr.Add(obj);
                }
            }
            catch (Exception exc)
            {
                Exceptions.Exceptions.LogException(exc);
            }
            finally
            {
				//close datareader
                CBO.CloseDataReader(dr, true);
            }
            return arr;
        }
 public EventMessageCollection GetMessages( string eventName, string subscriberId )
 {
     EventMessageCollection oEventMessageCollection = new EventMessageCollection();
     string[] EventMessageFiles;
     string EventMessageFile;
     EventMessageFiles = Directory.GetFiles( m_messagePath, MessageName( eventName, subscriberId, "*" ) );
     foreach( string tempLoopVar_EventMessageFile in EventMessageFiles )
     {
         EventMessageFile = tempLoopVar_EventMessageFile;
         oEventMessageCollection.Add( DeserializeMessage( EventMessageFile, subscriberId ) );
     }
     return oEventMessageCollection;
 }
 public bool ProcessMessages( EventMessageCollection eventMessages )
 {
     EventMessage message;
     foreach( EventMessage tempLoopVar_message in eventMessages )
     {
         message = tempLoopVar_message;
         try
         {
             object oMessageProcessor = Reflection.CreateObject( message.ProcessorType, message.ProcessorType );
             if( !( (EventMessageProcessorBase)oMessageProcessor ).ProcessMessage( message ) )
             {
                 throw new Exception();
             }
         }
         catch
         {
             //log if message could not be processed
             EventLogController objEventLog = new EventLogController();
             LogInfo objEventLogInfo = new LogInfo();
             objEventLogInfo.AddProperty( "EventQueue.ProcessMessage", "Message Processing Failed" );
             objEventLogInfo.AddProperty( "ProcessorType", message.ProcessorType );
             objEventLogInfo.AddProperty( "Body", message.Body );
             objEventLogInfo.AddProperty( "Sender", message.Sender );
             foreach( string key in message.Attributes.Keys )
             {
                 objEventLogInfo.AddProperty( key, message.Attributes[key] );
             }
             // HACK : Modified to not error if object is null.
             //if( message.ExceptionMessage.Length > 0 )
             if (!String.IsNullOrEmpty(message.ExceptionMessage))
             {
                 objEventLogInfo.AddProperty( "ExceptionMessage", message.ExceptionMessage );
             }
             objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
             objEventLog.AddLog( objEventLogInfo );
         }
     }
     return true;
 }