static void Main(string[] args)
        {
            var repo     = new TextRepository();
            var messages = new TextMessages();

            Console.WriteLine("Listening for ExchangeText event, press Ctrl+C to stop...");
            messages.ConsumeMessagesInLoop(TextMessages.QueueTextListener, TextMessages.ExchangeText, (model, id) => {
                var text = repo.GetText(id);
                Console.WriteLine(id + ": " + text);
            });
        }
Пример #2
0
        static void Main(string[] args)
        {
            var messages = new TextMessages();
            var repo     = new TextRepository();
            var metrics  = new TextMetrics();

            Console.WriteLine("Listening for ExchangeTextRankCalculated event, press Ctrl+C to stop...");
            messages.ConsumeMessagesInLoop(TextMessages.QueueTextSuccessMarker, TextMessages.ExchangeTextRankCalculated, (model, json) => {
                var message           = TextRankCalculatedMessage.FromJson(json);
                bool isTextSuccessful = (message.Score > minSuccessfulScore);
                messages.SendTextSuccessMarked(message.ContextId, isTextSuccessful);
            });
        }
        static void Main(string[] args)
        {
            var messages = new TextMessages();
            var repo     = new TextRepository();
            var stats    = new TextStatsReport();

            Console.WriteLine("Listening for TextScoreTask event, press Ctrl+C to stop...");
            messages.ConsumeMessagesInLoop(TextMessages.QueueTextStatistics, TextMessages.ExchangeTextRankCalculated, (model, json) => {
                TextRankCalculatedMessage message = TextRankCalculatedMessage.FromJson(json);
                stats.AddRankResult(message.Score);
                repo.SetStatsReport(stats.ToJson());
            });
        }
        static void Main(string[] args)
        {
            var messages = new TextMessages();
            var repo     = new TextRepository();
            var metrics  = new TextMetrics();

            Console.WriteLine("Listening for ExchangeProcessingAccepted event, press Ctrl+C to stop...");
            messages.ConsumeMessagesInLoop(TextMessages.QueueTextRancCalc, TextMessages.ExchangeProcessingAccepted, (model, json) => {
                var message = TextProcessingAcceptedMessage.FromJson(json);
                if (message.Accepted)
                {
                    messages.SendTextRankTask(message.ContextId);
                }
            });
        }
        static void Main(string[] args)
        {
            var messages = new TextMessages();
            var repo     = new TextRepository();

            Console.WriteLine("Listening for TextScoreTask event, press Ctrl+C to stop...");
            messages.ConsumeMessagesInLoop(TextMessages.QueueVowelConsRater, TextMessages.ExchangeTextScoreTask, (model, message) => {
                VowelConsCountMessage count = VowelConsCountMessage.FromJson(message);
                string id   = count.ContextId;
                float score = (float)count.VowelCount / (float)count.ConsCount;
                repo.SetTextScore(id, score);
                Console.WriteLine(id + " score: " + score);
                messages.SendTextRankCalculated(id, score);
            });
        }
Пример #6
0
        static void Main(string[] args)
        {
            var messages = new TextMessages();
            var repo     = new TextRepository();
            var metrics  = new TextMetrics();

            Console.WriteLine("Listening for ExchangeTextRankTask event, press Ctrl+C to stop...");
            messages.ConsumeMessagesInLoop(TextMessages.QueueVowelConsCounter, TextMessages.ExchangeTextRankTask, (model, id) => {
                try
                {
                    string text    = repo.GetText(id);
                    int vowelCount = metrics.GetVowelCount(text);
                    int consCount  = metrics.GetConsonantsCount(text);
                    messages.SendTextScoreTask(id, vowelCount, consCount);
                    Console.WriteLine(id + " vowel count: " + vowelCount + ", cons count: " + consCount);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("exception occured: " + ex.ToString());
                }
            });
        }