/// <summary> /// 读取服务端更新日志记录 /// </summary> /// <param name="logUrl"></param> public void ReadUpdateLog(string logUrl) { try { System.Net.WebClient wc = new System.Net.WebClient(); wc.Encoding = Encoding.UTF8; string xmlStr = wc.DownloadString(logUrl); XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlStr.Trim()); XmlNode items = xml.SelectSingleNode("Items"); //查找 if (items != null) { this.StartFile = items.Attributes["StartFile"].Value; this.Version = items.Attributes["Version"].Value; this.Description = items.Attributes["Description"].Value; this.UpdateTime = DateTime.Parse(items.Attributes["UpdateTime"].Value); this.VersionNumber = ParseVersionNumber(this.Version); JadeFile jf; FileList.Clear(); foreach (XmlNode item in items.ChildNodes) { jf = new JadeFile { FileName = item.Attributes["FileName"].Value, Url = item.Attributes["Url"].Value }; FileList.Add(jf); } } } catch (Exception ex) { Comm.AddLog("读取版本信息", ex); } }
/// <summary> /// 保存配置数据 /// </summary> public static void Save() { BinaryFormatter bf = new BinaryFormatter(); jadeAppFileName.CreateDirectory(); try { using (FileStream stream = new FileStream(jadeAppFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { XmlSerializer sz = new XmlSerializer(JadeApp.GetType()); sz.Serialize(stream, JadeApp); } } catch (Exception ex) { Comm.AddLog("保存APP配置信息时异常", ex); } }
/// <summary> /// 读取配置数据 /// </summary> public static T Read <T>(string fileName) { var m = default(T); if (!File.Exists(fileName)) { return(default(T)); } try { XmlSerializer xs = new XmlSerializer(typeof(T)); using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { m = (T)xs.Deserialize(stream); } } catch (Exception ex) { Comm.AddLog("读取APP配置信息时异常", ex); } return(m); }