public static StuLibSyncSetting Convert(string strSet) { StuLibSyncSetting set = new StuLibSyncSetting(); if (!string.IsNullOrEmpty(strSet)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(strSet); //源读者库连接字符串 XmlNode node = doc.SelectSingleNode("//rootNote/sourceConnectionString"); set.SouIP = node.Attributes["servierIP"].Value; set.SouDBName = node.Attributes["dBName"].Value; set.SouPW = node.Attributes["password"].Value; set.SouUserName = node.Attributes["uerName"].Value; //目标读者库连接字符串 //node = doc.SelectSingleNode("//rootNote/targetConnectionString"); //set.TarIP = node.Attributes["servierIP"].Value; //set.TarDBName = node.Attributes["dBName"].Value; //set.TarPW = node.Attributes["password"].Value; //set.TarUserName = node.Attributes["uerName"].Value; node = doc.SelectSingleNode("//rootNote/syncModel"); set.SyncMode = (StudentSyncMode)int.Parse(node.Attributes["syncModel"].Value); set.SyncTime = node.Attributes["syncTime"].Value; //node = doc.SelectSingleNode("//rootNote/showMessage"); //set.RollNowsRRid = node.Attributes["rrID"].Value; //set.RollNows = node.InnerText; } return(set); }
public static string Convert(StuLibSyncSetting set) { XmlDocument doc = new XmlDocument(); XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null); doc.AppendChild(dec); XmlElement rootElement = doc.CreateElement("rootNote"); XmlElement children1 = doc.CreateElement("sourceConnectionString"); children1.SetAttribute("servierIP", set.SouIP); children1.SetAttribute("dBName", set.SouDBName); children1.SetAttribute("password", set.SouPW); children1.SetAttribute("uerName", set.SouUserName); rootElement.AppendChild(children1); //目标读者库连接字符串 //XmlElement children2 = doc.CreateElement("targetConnectionString"); //children2.SetAttribute("servierIP", set.TarIP); //children2.SetAttribute("dBName", set.TarDBName); //children2.SetAttribute("password", set.TarPW); //children2.SetAttribute("uerName", set.TarUserName); //rootElement.AppendChild(children2); XmlElement children3 = doc.CreateElement("syncModel"); children3.SetAttribute("syncModel", ((int)set.SyncMode).ToString()); children3.SetAttribute("syncTime", set.SyncTime); rootElement.AppendChild(children3); //XmlElement children4 = doc.CreateElement("showMessage"); //children4.SetAttribute("rrID", set.RollNowsRRid); //children4.InnerText = set.RollNows; //rootElement.AppendChild(children4); doc.AppendChild(rootElement); return(doc.OuterXml); }