Пример #1
0
 public async Task SendMessage(ChatMessage message)
 {
     if (message.MessageText.StartsWith(OrchestrationConfiguration.StockCommandToken, StringComparison.InvariantCultureIgnoreCase))
     {
         string stockCode = message.MessageText.Substring(7);
         await _stockBot.GetStock(stockCode, OrchestrationConfiguration.BotStockEndPoint, OrchestrationConfiguration.BotStockCodeToken, OrchestrationConfiguration.BotHTTPMethod, true, this, message.UserEmail);
     }
     else
     {
         List <Guid> removedIds = null;
         if (_manager.AddMessage(message, out removedIds))
         {
             try
             {
                 message = _chatMessageBusiness.Add(message);
                 await Clients.All.SendAsync("addMessage", message);
                 await RemoveMessages(removedIds);
             }
             catch (Exception)
             {
                 ChatMessage error = new ChatMessage();
                 error.MessageText = "Error while tryng to send your message, please try again";
                 await SendErrorMessage(error);
             }
         }
     }
 }
        protected override void Evaluate()
        {
            if (Parameters.Count != 1)
            {
                throw new Exception(string.Format("Expected 1 parameter, got {0} in function name {1}.",
                                                  Parameters.Count, Text));
            }

            ParameterTextParser.ValidateStringAgainstSet(Parameters[0], new[] { "all" }.Concat(_categories).ToArray());

            var output = "";

            UIMap.PopulationAndProduction.MakeActive();
            UIMap.PopulationAndProduction.SelectResearchTab();

            output += "Available Labs: " + UIMap.PopulationAndProduction.AvailableLabs.Text + "\n\n";

            if (Parameters[0] == "all")
            {
                foreach (var cat in _categories)
                {
                    UIMap.PopulationAndProduction.SelectResearchByCategory(cat);
                    output += ReadResearchTables();
                }
            }
            else
            {
                UIMap.PopulationAndProduction.SelectResearchByCategory(Parameters[0]);
                output += ReadResearchTables();
            }

            Messages.AddMessage(MessageType.Information, output);
        }