private static void ProcessContentReply(string xml) { // Load the xml document XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); // Get RSS Feed string rssBase64 = doc.GetElementsByTagName("Rss")[0].InnerText; // Get Catalog Code string catalogCode = doc.GetElementsByTagName("CatalogCode")[0].InnerText; // The RSS is base64 encoded, so we need to decode it string rss = Encoding.UTF8.GetString(Convert.FromBase64String(rssBase64)); // Save RSS feed to file TextWriter writer = new StreamWriter("rss\\" + catalogCode + ".rss", false); writer.Write(rss); writer.Close(); // Update catalog last updated time FoeClientCatalogItem item = FoeClientCatalog.Get(catalogCode); item.DtLastUpdated = DateTime.Now; FoeClientCatalog.Add(item); }
private static void ProcessCatalogReply(string xml) { List <FoeClientCatalogItem> catalog = new List <FoeClientCatalogItem>(); // Load the xml document XmlDocument rawDoc = new XmlDocument(); rawDoc.LoadXml(xml); // Get RSS Feed string rssBase64 = rawDoc.GetElementsByTagName("Rss")[0].InnerText; // The RSS is base64 encoded, so we need to decode it string rss = Encoding.UTF8.GetString(Convert.FromBase64String(rssBase64)); // Within the RSS is the catalog in XML format XmlDocument doc = new XmlDocument(); doc.LoadXml(rss); // Get catalog list XmlNodeList nodes = doc.GetElementsByTagName("CatalogItem"); foreach (XmlNode item in nodes) { FoeClientCatalogItem newItem = new FoeClientCatalogItem(); newItem.Code = item["Code"].InnerText; newItem.ContentType = item["ContentType"].InnerText; newItem.Name = item["Name"].InnerText; newItem.Description = item["Description"].InnerText; newItem.IsSubscribed = false; newItem.DtLastUpdated = DateTime.Now; // Check if the catalog item already exists FoeClientCatalogItem curr = FoeClientCatalog.Get(newItem.Code); if (curr != null) { // It already existed, we'll update it but keep the subscription status newItem.IsSubscribed = curr.IsSubscribed; newItem.DtLastUpdated = curr.DtLastUpdated; } catalog.Add(newItem); } // Check if list is empty if (catalog.Count > 0) { // Delete current catalog FoeClientCatalog.DeleteAll(); foreach (FoeClientCatalogItem item in catalog) { FoeClientCatalog.Add(item); } } }
private static void ProcessContentReply(string catalog, string foe) { // Save RSS to file TextWriter writer = new StreamWriter(@"rss\\" + catalog + ".rss", false); writer.Write(foe); writer.Close(); // Update catalog last updated time FoeClientCatalogItem item = FoeClientCatalog.Get(catalog); item.DtLastUpdated = DateTime.Now; FoeClientCatalog.Add(item); }
private static void ProcessCatalogReply(string foe) { string[] catalogs = foe.Trim().Split(new char[] { ',' }); // Check if list is empty if (catalogs.Length > 0) { // Delete current catalog FoeClientCatalog.DeleteAll(); for (int i = 0; i < catalogs.Length - 1; i++) { FoeClientCatalogItem item = new FoeClientCatalogItem(); item.Code = catalogs[i]; item.IsSubscribed = false; item.DtLastUpdated = DateTime.Now; FoeClientCatalog.Add(item); } } }