private static void SaveConfigurationFields()
        {
            MSMQUtils MSMQ = new MSMQUtils();

            // Trying to open the queue
            MessageQueue queue = MSMQ.OpenOrCreatePrivateQueue(Config.WebRequestConfigQueue, typeof(SectionsParser).Namespace);

            // Sanit check
            if (queue == null)
            {
                logger.Fatal("Error to open a private WebConfigQueue. The field \"queue\" is null.");
                return;
            }

            // Is there content in the queue? Let's remove it
            MSMQ.DeleteContentPrivateQueue(Config.WebRequestConfigQueue);

            // Serialize the objectc to take up less space
            string serializedConfig = Utils.Compress(JsonConvert.SerializeObject(Config));

            Message message = new Message();

            message.TimeToBeReceived = new TimeSpan(3 * 24, 0, 0);
            message.Body             = serializedConfig;

            queue.Send(message);
        }
Example #2
0
        private static void SendMessage(string queuename, List <Comment> comments)
        {
            MSMQUtils MSMQ = new MSMQUtils();

            // Trying to open the queue
            MessageQueue queue = MSMQ.OpenOrCreatePrivateQueue(queuename, typeof(CommentsParser).Namespace);

            // Sanit check
            if (queue == null)
            {
                logger.Fatal("Error to open a private queue. The field \"queue\" is null.");
                return;
            }

            // Iterate over all comments
            foreach (Comment comment in comments)
            {
                var compactComment = new
                {
                    Author = comment.Author
                };

                string serializedCompactComment = Utils.Compress(JsonConvert.SerializeObject(compactComment));
                queue.Send(serializedCompactComment);
            }

            queue.Dispose();
        }
        private static void SendMessage(string queuename, List <Section> sections)
        {
            MSMQUtils MSMQ = new MSMQUtils();

            // Trying to open the queue
            MessageQueue queue = MSMQ.OpenOrCreatePrivateQueue(queuename, typeof(SectionsParser).Namespace);

            // Sanit check
            if (queue == null)
            {
                logger.Fatal("Error to open a private queue. The field \"queue\" is null.");
                return;
            }

            // Iterate over all sections
            foreach (Section section in sections)
            {
                logger.Trace("Sending " + section.Title + " to " + queuename + " queue");

                string serializedSection = Utils.Compress(JsonConvert.SerializeObject(section));
                queue.Send(serializedSection);
            }

            queue.Dispose();
        }
Example #4
0
        private static void SendMessage(string queuename, List <Topic> topics)
        {
            MSMQUtils MSMQ = new MSMQUtils();

            // Trying to open the queue
            MessageQueue queue = MSMQ.OpenOrCreatePrivateQueue(queuename, typeof(TopicsParser).Namespace);

            // Sanit check
            if (queue == null)
            {
                logger.Fatal("Error to open a private queue. The field \"queue\" is null.");
                return;
            }

            // Iterate over all topics
            foreach (Topic topic in topics)
            {
                var compactTopic = new { Title = topic.Title,
                                         Url   = topic.Url };

                string serializedCompactTopic = Utils.Compress(JsonConvert.SerializeObject(compactTopic));
                queue.Send(serializedCompactTopic);
            }

            queue.Dispose();
        }