Пример #1
0
 public bool Add(Model.Messages.Message message)
 {
     using (IDbConnection connection = OpenConnection())
     {
         return(1 == connection.Execute("INSERT INTO ace_demo_message (AccountId, Content) VALUES (@AccountId, @Content);",
                                        message));
     }
 }
Пример #2
0
 public static void DebugLogMessage(this ILog logger, string message, Model.Messages.Message m)
 {
     try
     {
         var jsonText = JsonConvert.SerializeObject(m, DebugPrintSerializerSettings);
         var sb       = new StringBuilder(message).Append("\n");
         sb.Append("----------------------------------------------------------------------------\n");
         sb.Append(PadRight("Body")).Append(jsonText).Append("\n");
         sb.Append("----------------------------------------------------------------------------\n");
         logger.Debug(sb.ToString());
     }
     catch (Exception e)
     {
         logger.Warn("Error in CusomLoggerExtensions while logging Message", e);
     }
 }
Пример #3
0
        private async Task DoActions(Model.Messages.Message action)
        {
            switch (action.MessageIntent)
            {
            case Model.Messages.IntentEnum.Weather:
                var weatherAction = action as Model.Messages.MessageWeather;

                var weatherString = await _weatherApi.GetForecastAsync(weatherAction.Location, weatherAction.When);

                logger.Info(weatherString);
                if (!string.IsNullOrEmpty(weatherString))
                {
                    logger.Debug("");
                }
                // _microsoftSpeech.Speak(weatherString);
                return;

            case Model.Messages.IntentEnum.Time:
                return;

            case Model.Messages.IntentEnum.Alarm:
                return;

            case Model.Messages.IntentEnum.Note:
                return;

            case Model.Messages.IntentEnum.Translate:
                var translation = await _googleTranslator.TranslateAsync("jak sie masz", "pl", "en");

                logger.Debug(translation);
                TextToSpeech.Speak(translation);
                return;

            default:
                return;
            }
        }