public static void AddFrpSettingToConfig(FrpSettingModel _frp) { XmlDocument xmldoc = GetXMLRootElement(); XmlElement elementroot = (XmlElement)xmldoc.SelectSingleNode("Frps"); if (elementroot != null) { XmlElement newfrpNode = xmldoc.CreateElement("frp"); AddXMLChildNode(xmldoc, newfrpNode, "id", _frp.ID); AddXMLChildNode(xmldoc, newfrpNode, "name", _frp.Name); AddXMLChildNode(xmldoc, newfrpNode, "cffile", _frp.ConfigFile); AddXMLChildNode(xmldoc, newfrpNode, "logfile", _frp.LogFile); AddXMLChildNode(xmldoc, newfrpNode, "autorun", _frp.AutoRun.ToString()); elementroot.AppendChild(newfrpNode); xmldoc.Save("config.xml"); } }
public FrpModel(FrpSettingModel _config) { Config = _config; ListItem = null; IsRun = false; }
private void FrpSetForm_Load(object sender, EventArgs e) { if (frpObj != null) { this.checkBox1.Checked = frpObj.AutoRun; this.textBox_name.Text = frpObj.Name; this.textBox_cf.Text = frpObj.ConfigFile; this.textBox_lf.Text = frpObj.LogFile; } else { frpObj = new FrpSettingModel(); } }
public static void DelFrpSettingFromConfig(FrpSettingModel _frp) { XmlDocument xmldoc = GetXMLRootElement(); XmlElement elementroot = (XmlElement)xmldoc.SelectSingleNode("Frps"); if (elementroot != null) { string xpathstr = "frp[id='{0}']"; XmlNode tempNode = elementroot.SelectSingleNode(string.Format(xpathstr, _frp.ID)); if (tempNode != null) { elementroot.RemoveChild(tempNode); } xmldoc.Save("config.xml"); } }
public static void EditFrpSettingToConfig(FrpSettingModel _frp) { XmlDocument xmldoc = GetXMLRootElement(); XmlElement elementroot = (XmlElement)xmldoc.SelectSingleNode("Frps"); if (elementroot != null) { string xpathstr = "frp[id='{0}']"; XmlElement itemNode = (XmlElement)elementroot.SelectSingleNode(string.Format(xpathstr, _frp.ID)); if (itemNode != null) { XmlNode tempNode = itemNode.SelectSingleNode("id/text()"); if (tempNode != null) { tempNode.Value = _frp.ID; } else { AddXMLChildNode(xmldoc, itemNode, "id", _frp.ID); } tempNode = itemNode.SelectSingleNode("name/text()"); if (tempNode != null) { tempNode.Value = _frp.Name; } else { AddXMLChildNode(xmldoc, itemNode, "name", _frp.Name); } tempNode = itemNode.SelectSingleNode("cffile/text()"); if (tempNode != null) { tempNode.Value = _frp.ConfigFile; } else { AddXMLChildNode(xmldoc, itemNode, "cffile", _frp.ConfigFile); } tempNode = itemNode.SelectSingleNode("logfile/text()"); if (tempNode != null) { tempNode.Value = _frp.LogFile; } else { AddXMLChildNode(xmldoc, itemNode, "logfile", _frp.LogFile); } tempNode = itemNode.SelectSingleNode("autorun/text()"); if (tempNode != null) { tempNode.Value = _frp.AutoRun.ToString(); } else { AddXMLChildNode(xmldoc, itemNode, "autorun", _frp.AutoRun.ToString()); } } xmldoc.Save("config.xml"); } }
public static List <FrpSettingModel> GetAllFrpSetting() { List <FrpSettingModel> list = new List <FrpSettingModel>(); XmlDocument xmldoc = GetXMLRootElement(); XmlElement elementroot = (XmlElement)xmldoc.SelectSingleNode("Frps"); if (elementroot != null) { XmlNodeList allFrp = xmldoc.SelectNodes("Frps/frp"); foreach (XmlNode item in allFrp) { try { FrpSettingModel ftpitem = new FrpSettingModel(); XmlNode tempNode = item.SelectSingleNode("id/text()"); if (tempNode != null) { ftpitem.ID = tempNode.Value; } tempNode = item.SelectSingleNode("name/text()"); if (tempNode != null) { ftpitem.Name = tempNode.Value; } tempNode = item.SelectSingleNode("cffile/text()"); if (tempNode != null) { ftpitem.ConfigFile = tempNode.Value; } tempNode = item.SelectSingleNode("logfile/text()"); if (tempNode != null) { ftpitem.LogFile = tempNode.Value; } tempNode = item.SelectSingleNode("autorun/text()"); if (tempNode != null) { try { ftpitem.AutoRun = bool.Parse(tempNode.Value); } catch { ftpitem.AutoRun = false; } } list.Add(ftpitem); } catch { } } } return(list); }
public FrpSetForm(FrpSettingModel _obj) { InitializeComponent(); frpObj = _obj; }