Ejemplo n.º 1
0
 private void setfav_processing(string data)
 {
     try
     {
         List<FavoriteChannel> lf = new List<FavoriteChannel>();
         lf = account.favorite_channel;
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(data);
         foreach (XmlElement xitem in doc.DocumentElement.SelectNodes("//message"))
         {
             Boolean isdel = false;
             string id_channel = "";
             XmlDocument mdoc = new XmlDocument();
             mdoc.LoadXml("<root>" + xitem.GetXml() + "</root>");
             foreach (XmlElement titem in mdoc.DocumentElement.SelectNodes("//text"))
             {
                 if (titem.InnerText == "Favorite channel was set")
                 {
                     isdel = false;
                 }
                 else isdel = true;
             }
             foreach (XmlElement link in mdoc.DocumentElement.SelectNodes("//channel"))
             {
                 id_channel = link.InnerText;
             }
             if (isdel)
             {
                 foreach (FavoriteChannel far in lf)
                 {
                     if (far.id_channel == id_channel)
                     {
                         lf.Remove(far);
                         break;
                     }
                 }
             }
             else
             {
                 FavoriteChannel fav = new FavoriteChannel();
                 fav.id_channel = id_channel;
                 lf.Add(fav);
             }
         }
         account.favorite_channel = lf;
     }
     catch (Exception)
     {
         throw new System.InvalidOperationException("Error to set/delete favorite channel");
     }
 }
Ejemplo n.º 2
0
 private void fav_processing(string data)
 {
     try
     {
         List<FavoriteChannel> fchannels = new List<FavoriteChannel>();
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(data);
         foreach (XmlElement xitem in doc.DocumentElement.SelectNodes("//item"))
         {
             FavoriteChannel fav = new FavoriteChannel();
             XmlDocument idoc = new XmlDocument();
             idoc.LoadXml("<root>" + xitem.GetXml() + "</root>");
             foreach (XmlElement link in idoc.DocumentElement.SelectNodes("//channel_id"))
             {
                 fav.id_channel = link.InnerText;
             }
             fchannels.Add(fav);
         }
         account.favorite_channel = fchannels;
     }
     catch (Exception)
     {
         throw new System.InvalidOperationException("Error to get favorite channel list");
     }
 }