Exemple #1
0
      private async Task createShowResponse(IDialogContext context, String url)
      {
          HttpWebRequest  request  = WebRequest.Create(url) as HttpWebRequest;
          HttpWebResponse response = request.GetResponse() as HttpWebResponse;
          StreamReader    reader   = new StreamReader(response.GetResponseStream());


          string ans = reader.ReadToEnd();

          reader.Close();
          response.Close();

          Declarations.Shows.Show show = JsonConvert.DeserializeObject <Declarations.Shows.Show>(ans);

          await context.PostAsync(createShowMessage(context, show));
      }
Exemple #2
0
      public IMessageActivity createShowMessage(IDialogContext context, Declarations.Shows.Show show)
      {
          IMessageActivity message = context.MakeMessage();
          string           sub;
          string           time = "";

          if (show.network == null)
          {
              if (show.webChannel != null)
              {
                  sub  = show.webChannel.name;
                  time = "";
              }
              else
              {
                  sub = "Channel not available";
              }
          }
          else
          {
              sub  = show.network.name;
              time = show.schedule.time;
          }
          HtmlDocument doc = new HtmlDocument();

          doc.LoadHtml(show.summary);
          string summary = "";

          if (show.summary == "")
          {
              summary = "Not Available";
          }
          else
          {
              HtmlNodeCollection l = doc.DocumentNode.SelectNodes("//p");
              foreach (HtmlNode nodes in l)
              {
                  summary += nodes.InnerText;
              }
          }

          StringBuilder gen = new StringBuilder();

          foreach (string g in show.genres)
          {
              gen.Append(g + ", ");
          }
          string s = "";

          foreach (string d in show.schedule.days)
          {
              s += d;
          }
          StringBuilder res = new StringBuilder();


          res.Append("# " + show.name).AppendLine().AppendLine();
          res.Append(" **Channel:** " + sub).AppendLine().AppendLine();
          res.Append("**Status:** " + show.status).AppendLine().AppendLine();
          res.Append("**Genre:** " + gen.ToString()).AppendLine().AppendLine();
          res.Append("**Premiere:** " + show.premiered).AppendLine().AppendLine();
          res.Append("**Schedule:** " + time + $" {s}").AppendLine().AppendLine();
          res.Append($"**Summary:** {summary}");

          message.Text = res.ToString();
          return(message);
      }