public ToolInfo.Collection ReadToolInfos(string fileName) { _tools = new ToolInfo.Collection(); if (File.Exists(fileName)) { XmlDocument doc = new XmlDocument(); doc.Load(fileName); XmlNode root = doc.SelectSingleNode("Setting"); XmlElement xle = (XmlElement)root; //Ip = xle.SelectSingleNode(@"/Setting/ip").InnerText; //Port = xle.SelectSingleNode(@"/Setting/port").InnerText; //XmlNodeList apps = xle.SelectNodes("/Setting/apps/app"); foreach (XmlNode nde in root.ChildNodes) { xle = (XmlElement)nde; if (xle.Name == "server") { Ip = xle.GetAttribute("ip"); Port = xle.GetAttribute("port"); } else { foreach (XmlNode xmln in nde.ChildNodes) { XmlElement xlen = (XmlElement)xmln; ToolInfo bti = new ToolInfo(); bti.Id = xlen.GetAttribute("id"); bti.Name = xlen.GetAttribute("name"); bti.exePath = xlen.GetAttribute("path"); bti.inPutf = xlen.GetAttribute("inputf"); bti.outPutf = xlen.GetAttribute("outputf"); bti.cmdStr = xlen.GetAttribute("cmd"); _tools.Add(bti); } } } } return(_tools); }
private void CreatBat(ToolInfo kv) { if (string.IsNullOrWhiteSpace(kv.cmdStr) == false) { var batFileName = string.Format(@"{0}\{1}.bat", Common._root, DateTime.Now.ToString("yyyyMMddHHmmss")); System.IO.File.WriteAllText(batFileName, kv.cmdStr); Process.Start(new ProcessStartInfo() { FileName = batFileName, WindowStyle = ProcessWindowStyle.Hidden }); System.Threading.Thread.Sleep(500); System.IO.File.Delete(batFileName); } else { Process.Start(new ProcessStartInfo() { FileName = kv.exePath }); } }