void LoadConfig() { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(ConfigFile); XmlNode xnRoot = xmlDoc.SelectSingleNode("Config"); XmlNodeList xnl = xnRoot.ChildNodes; foreach (XmlNode node in xnl) { XmlNodeList xnlChildren = node.ChildNodes; if (node.Name == "Main") { foreach (XmlNode item in xnlChildren) { if (item.Name == "AutoRun") { bool.TryParse(item.InnerText, out bool result); Main.AutoRun = result; } else if (item.Name == "Interval") { int.TryParse(item.InnerText, out int result); Main.Interval = result; } } } else if (node.Name == "DB") { foreach (XmlNode item in xnlChildren) { if (item.Name == "IP") { DB.IP = item.InnerText; } else if (item.Name == "Port") { DB.Port = item.InnerText; } else if (item.Name == "Name") { DB.Name = item.InnerText; } else if (item.Name == "UserID") { DB.UserID = item.InnerText; } else if (item.Name == "Pwd") { DB.Pwd = item.InnerText; } } } } } catch (Exception e) { Log.ShowLog("ERROR: " + e.Message, LogBox.Level.error); } }
public int StopService() { int iRet = 0; if (IsServiceOpen) { Log.ShowLog("==> StopService..."); iRet = vciApp.AppServer.stopService(); } return(iRet); }
public void ShowDB(string StrTable) { string StrSQL = "select * from " + StrTable; using (SqlConnection sqlConn = new SqlConnection(StrConn)) { sqlConn.Open(); SqlCommand sqlCmd = new SqlCommand(StrSQL, sqlConn); SqlDataReader sqlData = sqlCmd.ExecuteReader(); string str = ""; int c = sqlData.FieldCount; while (sqlData.Read()) { for (int i = 0; i < c; i++) { object obj = sqlData.GetValue(i); if (obj.GetType() == typeof(DateTime)) { str += ((DateTime)obj).ToString("yyyy-MM-dd") + "\t"; } else { str += obj.ToString() + "\t"; } } str += "\n"; } Log.ShowLog(str); sqlConn.Close(); } }
/// <summary> /// 运行EPB标定 /// iType = 1:7S EPB标定,其余值为自动判断 /// strVIN, VIN号 /// </summary> /// <param name="iType"></param> /// <param name="strVIN"></param> /// <returns></returns> public bool Run(int iType, string strVIN) { Log.ShowLog("====== 开始 EPB 标定程序 ======"); this.StrVIN = strVIN; this.IsSuccess = false; // 获取与VIN号对应的车型代码 string strVehicleType = DataBase.GetVehicleType(strVIN); if (strVehicleType == "") { Log.ShowLog("=> 未获取到车型代码,退出标定", LogBox.Level.error); return(IsSuccess); } int iRet = 0; iRet = Vci.StartService(); if (iRet == 0) { Log.ShowLog("=> StartService success"); if (!DoubleStartDevice()) { #if !DEBUG Close(); return(IsSuccess); #endif } } else { Thread.Sleep(200); iRet = Vci.StartService(); if (iRet == 0) { Log.ShowLog("=> StartService success"); if (!DoubleStartDevice()) { #if !DEBUG Close(); return(IsSuccess); #endif } } else { Log.ShowLog("=> StartService failed", LogBox.Level.error); #if !DEBUG Close(); return(IsSuccess); #endif } } switch (iType) { case 1: iRet = EPBCaliRun(); break; default: if (strVehicleType.StartsWith("X41")) { Log.ShowLog("=> 车型代码为:\"" + strVehicleType + "\",调用 7S EPB 标定程序"); iRet = EPBCaliRun(); } else if (strVehicleType.StartsWith("X11")) { Log.ShowLog("=> 车型代码为:\"" + strVehicleType + "\",不进行 EPB 标定"); return(true); } else { Log.ShowLog("=> 未知车型代码:\"" + strVehicleType + "\",默认调用 7S EPB 标定程序", LogBox.Level.error); iRet = EPBCaliRun(); } break; } Close(); return(IsSuccess); }