예제 #1
0
        // POST api/values
        public string Post([FromBody] string poem)
        {
            string[]    lines        = poem.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            string      poemId       = Guid.NewGuid().ToString();
            CharCounter VowelCounter = new CharCounter(Config.VOWELS);
            int         lineIndex    = 1;

            foreach (string line in lines)
            {
                Message msg = new Message();
                msg.corrId      = poemId;
                msg.Line        = lineIndex + Config.LINE_INDEX_DELIMITER + line;
                msg.VowelsCount = VowelCounter.Count(line);
                msg.Target      = MessageTarget.Consonants;

                Console.WriteLine(msg.corrId);
                Console.WriteLine(msg.Line);
                Console.WriteLine(msg.VowelsCount);
                Console.WriteLine(msg.ConsonantsCount);
                Console.WriteLine(msg.Target);

                _transport.Publish(msg);
                ++lineIndex;
            }

            return(poemId);
        }
예제 #2
0
        public async Task Consume(ConsumeContext <Message> context)
        {
            if (context.Message.Target != MessageTarget.Consonants)
            {
                return;
            }

            Message msg = new Message();

            msg.corrId      = context.Message.corrId;
            msg.Line        = context.Message.Line;
            msg.VowelsCount = context.Message.VowelsCount;
            CharCounter ConsonantCounter = new CharCounter(Config.CONSONANTS);

            msg.ConsonantsCount = ConsonantCounter.Count(context.Message.Line);
            msg.Target          = MessageTarget.RateChecker;

            Console.WriteLine(msg.corrId);
            Console.WriteLine(msg.Line);
            Console.WriteLine(msg.VowelsCount);
            Console.WriteLine(msg.ConsonantsCount);

            Publisher publisher = new Publisher();

            publisher.Publish(msg);
        }