Пример #1
0
 public void AskToWeb(QuestionData data)
 {
     if (data.IsError)
         return;
     try
     {
         byte[] response = null;
         if (data.QuestionType == QuestionTypeEnum.Station)
         response = _wc.UploadValues(Addresses.ViaggiaURL,
                 "POST",
                 new NameValueCollection()
                 {
                     { "stazione", data.Station },
                     { "lang", "IT" }
                 });
         else
             if(data.QuestionType == QuestionTypeEnum.TrainNumber)
             response = _wc.UploadValues(Addresses.ViaggiaURLNumbero,
                 "POST",
                 new NameValueCollection()
                 {
                     { "numeroTreno", data.TrainNumber.ToString()},
                     { "lang", "IT" }
                 });
         else
         {
             data.ErrorMessage = "Bravo! Sei riuscito ad arrivare " +
                 "in un punto non previsto. Per favore, segnala " +
                 "questo problema al team di sviluppo di RailBot";
             return;
         }
         Response = System.Text.Encoding.UTF8.GetString(response);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         data.ErrorMessage = "Errore nella ricezione dei dati. "+
             "Per favore riportare questo errore al team " +
             "di sviluppo.";
     }
 }
Пример #2
0
 public void SendStartOrHelpMessage(QuestionData data)
 {
     ResponseData r = new ResponseData(data.UpdateID, data.ChatID);
     if (data.AmIHelp)
     {
         r.Message = Constants.HelpMessage;
     }
     if (data.AmIStart)
     {
         r.Message = Constants.StartMessage;
     }
     SendDataToBot(r);
 }