Example #1
0
        /// <summary>
        /// Retrieves all new, outbound <see cref="INExternMsg"/> objects of the specified
        /// message type with the specified name from the database.
        /// </summary>
        /// <param name="messageType">The message type.</param>
        /// <param name="messageName">The message name.</param>
        public void Receive(string messageType,
                            string messageName)
        {
            if (string.IsNullOrWhiteSpace(messageType))
            {
                throw new ArgumentException("Message type is required.", nameof(messageType));
            }

            if (string.IsNullOrWhiteSpace(messageName))
            {
                throw new ArgumentException("Message name is required.", nameof(messageName));
            }

            foreach (var message in INExternMsgHelper.GetMessages(ConnectionString,
                                                                  INExternMsgHelper.IN_EXTERN_MSG_SELECT_CMD,
                                                                  new Dictionary <string, object>()
            {
                { "@MsgName", messageName },
                { "@MsgType", messageType }
            },
                                                                  StringComparison))
            {
                if (SetStatusProcessingOnReceive)
                {
                    message.SetDatabaseStatus(ConnectionString, ExternMsgStatus.Processing);
                }

                OnMessageReceived(message);
            }
        }
Example #2
0
        /// <summary>
        /// Retrieves all new, outbound <see cref="INExternMsg"/> objects from the database.
        /// </summary>
        public void Receive()
        {
            foreach (var message in INExternMsgHelper.GetMessages(ConnectionString,
                                                                  INExternMsgHelper.IN_EXTERN_MSG_SELECT_ALL_CMD,
                                                                  null,
                                                                  StringComparison))
            {
                if (SetStatusProcessingOnReceive)
                {
                    message.SetDatabaseStatus(ConnectionString, ExternMsgStatus.Processing);
                }

                OnMessageReceived(message);
            }
        }
Example #3
0
        /// <summary>
        /// Retrieves a single <see cref="INExternMsg"/> from the database using the specified
        /// message ID.
        /// </summary>
        /// <param name="messageId">ID of the message to retrieve from the database.</param>
        /// <returns><see cref="INExternMsg"/> with the specified message ID.</returns>
        public INExternMsg Get(string messageId)
        {
            if (string.IsNullOrWhiteSpace(messageId))
            {
                throw new ArgumentException("Message ID is required.", nameof(messageId));
            }

            var message = INExternMsgHelper.GetMessages(ConnectionString,
                                                        INExternMsgHelper.IN_EXTERN_MSG_SELECT_ID_CMD,
                                                        new Dictionary <string, object>()
            {
                { "@MsgId", messageId }
            },
                                                        StringComparison);

            return(message?.FirstOrDefault());
        }