Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var  input = String.Empty;
            long cell  = 0;

            Console.WriteLine("Enter a message. 'Quit' to quit.");
            while ((input = Console.ReadLine()) != "Quit")
            {
                Console.WriteLine("Enter a cellphone just numbers.");
                cell = long.TryParse(Console.ReadLine(), out cell) ? cell : 0;

                if (cell == 0)
                {
                    Console.WriteLine("Start again and use just numbers!");
                    Console.WriteLine("Enter a message. 'Quit' to quit.");
                }
                else
                {
                    var a = new TextMessages(1, input, cell);

                    PublishMessageAsync(a);
                    Console.WriteLine("Message published!");
                    Console.WriteLine("Enter a message. 'Quit' to quit.");
                }
            }
        }
Exemplo n.º 2
0
        public string Post([FromBody] UploadModel model)
        {
            var    repo = new TextRepository();
            string id   = repo.CreateText(model.Data);

            var messages = new TextMessages();

            messages.SendTextCreated(id);

            return(id);
        }
        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);
            });
        }
Exemplo n.º 4
0
        private async void SendMessage()
        {
            TextMessage message = (_messageType == typeof(UnicastMessage)
                ? new UnicastMessage(_messageContent, _receiver)
                : new TextMessage(EMessageTypes.BROADCAST, _messageContent));

            message.MyMessage = true;

            await Client.Client.Instance.SendTextAsync(message);

            TextMessages.Add(message);
        }
        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());
            });
        }
        public TextAnalyticsResponse <SentimentResponse> Get(TextMessages messages)
        {
            var requestContent =
                new StringContent(JsonConvert.SerializeObject(messages), Encoding.UTF8, JsonContentType);

            var httpResponse = HttpClient.PostAsync(SentimentEndpoint, requestContent).Result;

            httpResponse.EnsureSuccessStatusCode();

            TextAnalyticsResponse <SentimentResponse> response = ReadResponseMessage <SentimentResponse>(httpResponse);

            return(response);
        }
        private static TextMessages BuildTextMessage(string message)
        {
            var messages = new TextMessages
            {
                Messages = new List <TextRequest> {
                    new TextRequest {
                        Id = "1", Language = "en", Text = message
                    }
                }
            };

            return(messages);
        }
Exemplo n.º 8
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();

            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);
            });
        }
        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);
                }
            });
        }
Exemplo n.º 11
0
        public static void PublishMessageAsync(TextMessages message)
        {
            using (var bus = RabbitHutch.CreateBus("host=localhost"))
            {
                try
                {
                    bus.SendReceive.Send("Teste", message);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);;
                }

                bus.Dispose();
            }
        }
Exemplo n.º 12
0
 public JogoGourmetBusiness()
 {
     _textMessages     = new TextMessages();
     _pratosPrincipais = new List <Pratos>();
     _pratosPensados   = new List <Pratos>();
     _pratosPrincipais.Add(new Pratos()
     {
         Tipo = "massa", Prato = new List <string>()
         {
             "Lasanha"
         }, EhDerivado = true
     });
     _pratosPrincipais.Add(new Pratos()
     {
         Tipo = "Bolo de Chocolate", EhDerivado = false
     });
 }
Exemplo n.º 13
0
 private void SelectedDateCommandExecute(object obj)
 {
     //почему вылетает если берем дату из будущего на
     if (SelectedDate != null)
     {
         var res = serviceUI.GetMessegesOnDate(SelectedUser, SelectedDate);
         if (res != null)
         {
             TextMessages = new ObservableCollection <string>(res);
         }
         else
         {
             TextMessages.Clear();
             TextMessages.Add("no data");
         }
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Associates the window with the specified TextMessage, creating an appropriate
 /// Serialized Object and Property, if non-null and clearing values otherwise.
 /// </summary>
 void BindProperty(TextMessages bind)
 {
     if (_current != bind)
       {
     if (null != bind)
       {
     _serializedObject = new SerializedObject(bind);
     _serializedProperty = _serializedObject.FindProperty("messages");
       }
     else
       {
     _serializedObject = null;
     _serializedProperty = null;
       }
     _current = bind;
       }
 }
        static void Main(string[] args)
        {
            int remainingAccepts = processingLimit;

            var messages = new TextMessages();
            var repo     = new TextRepository();
            var metrics  = new TextMetrics();

            Console.WriteLine("Listening for ExchangeText/ExchangeTextSuccessMarked events, press Ctrl+C to stop...");

            using (var connection = messages.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    messages.ListenMessages(channel, TextMessages.QueueTextProcessingLimiter, TextMessages.ExchangeText, (model, id) => {
                        Console.WriteLine("captured text '" + repo.GetText(id) + "' with id=" + id);
                        bool accepted = false;
                        if (remainingAccepts > 0)
                        {
                            --remainingAccepts;
                            accepted = true;
                        }
                        repo.SetTextStatus(id, accepted ? TextStatus.Accepted : TextStatus.Rejected);
                        messages.SendProcessingAccepted(id, accepted);
                    });
                    messages.ListenMessages(channel, TextMessages.QueueTextProcessingLimiterRevoke, TextMessages.ExchangeTextSuccessMarked, (model, json) => {
                        var message = TextSuccessMarkedMessage.FromJson(json);
                        repo.SetTextStatus(message.ContextId, TextStatus.Ready);
                        Console.WriteLine("revoke transaction for successful text '" + repo.GetText(message.ContextId) + "' with id=" + message.ContextId);
                        if (message.Success)
                        {
                            ++remainingAccepts;
                        }
                    });
                    while (true)
                    {
                        Thread.Sleep(Timeout.Infinite);
                    }
                }
        }
Exemplo n.º 16
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());
                }
            });
        }
Exemplo n.º 17
0
        public async Task <ActionResult> SendAsync(SmsViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.InvalidModelState(this.ModelState));
            }

            var meta = await AppUsers.GetCurrentAsync().ConfigureAwait(true);

            model.UserId = meta.UserId;

            try
            {
                bool result = await TextMessages.SendAsync(this.Tenant, model, meta).ConfigureAwait(true);

                return(this.Ok(result));
            }
            catch (Exception ex)
            {
                this.Failed(ex.Message, HttpStatusCode.InternalServerError);
                throw;
            }
        }
Exemplo n.º 18
0
 static void HandleTextMessage(TextMessages textMessage)
 {
     Console.WriteLine("Got message: {0}", textMessage.Mensagem);
     Console.ResetColor();
 }