/// <summary> /// 删除某条测线,包涵dat源文件和dat归一化文件 /// </summary> /// <param name="Name"></param> /// <returns></returns> public static bool DeleteBoth(string Name) { try { //删除原文件 string normalFile = Name + ".dat"; if (!File.Exists(normalFile)) { return(true); } File.Delete(normalFile); //删除归一化文件 string geoFile = "GEO_" + Name + ".dat"; if (!File.Exists(geoFile)) { return(true); } File.Delete(geoFile); //删除原始图片 string pictureFile = Name + "img.jpg"; string pictureFile_help = pictureFile + ".gsr2"; if (!File.Exists(pictureFile)) { return(true); } File.Delete(pictureFile); File.Delete(pictureFile_help); //删除截图 string SSImageFile = Name + "_SSImage.jpg"; if (!File.Exists(SSImageFile)) { return(true); } File.Delete(SSImageFile); return(true); } catch (Exception ex) { Log4netHelper.Error(ex); return(false); } }
/// <summary> /// 在原dat文件上追加一条原始数据 /// </summary> /// <param name="name"></param> /// <param name="ModbusData"></param> public static bool AppendDat(string Name, double[] ModbusData) { StringBuilder strFileContext = new StringBuilder(1024); string normalFile = Name + ".dat"; //if (!File.Exists(normalFile)) // return false; //if (Convert.ToInt32(new FileInfo(normalFile).Length) == 0) // return false; if (ModbusData.Length == 0) { return(false); } for (int i = 0; i < ModbusData.Length; i++) { strFileContext.Append(ModbusData[i].ToString() + "\t"); } if (strFileContext.Equals("")) { return(false); } if (strFileContext == null) { return(false); } try { using (FileStream fs = File.Open(normalFile, FileMode.Append, FileAccess.Write)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(strFileContext); } } } catch (Exception ex) { Log4netHelper.Error(ex); } return(true); }
public static string getValue(string name, string child) { try { XmlDocument doc = new XmlDocument(); doc.Load(pathFile); string fetname = ""; string sql = "select gears from info where name = '" + name + "'"; DataTable dt = SQLiteHelper.ExecuteDataTable(sql, null); if (dt.Rows.Count == 0) { return(""); } fetname = dt.Rows[0].ItemArray[0].ToString(); if (fetname.Equals("") && Monitor_HCCS.Service.BLECode.GetIntance.CurrentService != null) { fetname = doc.SelectSingleNode("Mapping/DEVICE").InnerText.ToString(); XmlNode xn = doc.SelectSingleNode("Mapping/" + fetname.ToUpper() + "/" + child); string str = xn.InnerText.ToString(); doc = null; return(str); } else { XmlNode xn = doc.SelectSingleNode("Mapping/" + "FET-" + fetname.ToUpper() + "/" + child); string str = xn.InnerText.ToString(); doc = null; return(str); } } catch (System.Exception ex) { Log4netHelper.Error(ex); return(""); } }