/// <summary> /// 导出一条记录 /// </summary> /// <param name="dataID">数据ID</param> /// <param name="insertStr">插入字符串</param> /// <param name="orgTable">源表格</param> /// <param name="desSysTable">目标表格</param> /// <param name="path">存储路径</param> /// <param name="eError"></param> private void OutPutOneRacord(long dataID, string insertStr, DataTable orgTable, SysCommon.DataBase.SysTable desSysTable, string path, out Exception eError) { eError = null; string insertallStr = insertStr; string pointName = "";//控制点名 DataRow[] drs = orgTable.Select("ID =" + dataID); if (drs.Length == 0) { eError = new Exception("未找到ID为:'" + dataID + "'的记录"); return; } DataRow dr = drs[0]; for (int i = 5; i < dr.Table.Columns.Count - 1; i++) { Type columType = dr.Table.Columns[i].DataType; string columValue = dr[i].ToString(); string str = ModDBOperator.GetSQlEX(columType, columValue); insertallStr += str + ","; } insertallStr = insertallStr.Substring(0, insertallStr.Length - 1) + ")"; //导出元数据 desSysTable.UpdateTable(insertallStr, out eError); if (eError != null) { return; } //创建数据文件 pointName = dr[5].ToString(); string pDataName = path + "\\" + pointName + ".dwg"; //数据文件名 if (File.Exists(pDataName)) { if (SysCommon.Error.ErrorHandle.ShowFrmInformation("是", "否", "已存在同名文件,是否替换?")) { File.Delete(pDataName); } else { return; } } if (dr[dr.Table.Columns.Count - 1].ToString() != "") { byte[] picByte = dr[dr.Table.Columns.Count - 1] as byte[]; if (picByte.Length > 0) { FileStream pFStream = new FileStream(pDataName, FileMode.CreateNew, FileAccess.Write); pFStream.Write(picByte, 0, picByte.Length); MemoryStream meStream = new MemoryStream(picByte, true); meStream.Write(picByte, 0, picByte.Length); } } }