public void UpdateInfos(string url) { try { // read from web XmlDocument doc = XmlWebReader.ReadFromWeb(url); if (doc == null) { Dialog.ShowDialog(new Dialog.DialogConfig() { Message = "Unable to read info file : \n" + url, Title = "Error", Button1 = Dialog.ButtonType.OK, Icon = Dialog.DialogIcon.Error, }); return; } datas.Clear(); listView1.Items.Clear(); // Get apps XmlNodeList nodes = doc.GetElementsByTagName("app"); if (nodes.Count == 0) { Console.WriteLine("Unable to retrieve apps"); } else { // For each app foreach (XmlElement app in nodes) { if (app.HasChildNodes) { datas.Add(generateData(app.ChildNodes, Data.DataType.App)); } } } // Get projects nodes = doc.GetElementsByTagName("project"); if (nodes.Count == 0) { Console.WriteLine("Unable to retrieve projects"); } else { foreach (XmlElement app in nodes) { if (app.HasChildNodes) { datas.Add(generateData(app.ChildNodes, Data.DataType.Project)); } } } UpdateFromRegistry(); FillList(); } catch (Exception ex) { Console.WriteLine(ex); Dialog.ShowDialog(new Dialog.DialogConfig() { Message = "Unable to process info file : \n" + ex, Title = "Error", Button1 = Dialog.ButtonType.OK, Icon = Dialog.DialogIcon.Error, }); } }
private Data generateData(XmlNodeList node, Data.DataType Type) { Data data_output = new Data(Type); foreach (XmlNode item in node) { switch (item.Name) { case "index": data_output.Index = int.Parse(item.InnerText); break; case "name": data_output.Name = item.InnerText; break; case "url": data_output.Url = item.InnerText; break; default: break; } } // Get extra info if available if (Type == Data.DataType.App || Type == Data.DataType.Project) { // Read app's info file XmlElement appInfo = null; try { appInfo = XmlWebReader.ReadFromWeb(data_output.Url).DocumentElement; } catch (Exception ex) { Console.WriteLine("Infos not found for : " + data_output.Url); } if (appInfo == null) { return(data_output); } foreach (XmlNode item in appInfo) { switch (item.Name) { case "productname": data_output.ProductName = item.InnerText; break; case "version": data_output.Version = item.InnerText; break; case "description": data_output.Description = item.InnerText; break; case "size": data_output.Size = item.InnerText; break; case "date": data_output.Date = item.InnerText; break; case "installer": data_output.InstallerUrl = item.InnerText; break; case "url": data_output.PublishUrl = item.InnerText; break; default: break; } } } return(data_output); }