/// <summary> /// 通过井ID获取井次信息 /// </summary> /// <param name="regionid"></param> /// <param name="jstring"></param> /// <returns></returns> public DataTable GetAllLogsByWellId(String wellid, out String jstring) { try { InitHashTable(); colName.Clear(); colData.Clear(); ht.Add("wellid", wellid); strJsonSend = JsonHepler.HashtableToJson(ht, 0); jstring = _realdbws.GetAllLogsByWellId(strJsonSend); Hashtable tempHT = (Hashtable)JsonConvert.DeserializeObject(jstring, typeof(Hashtable)); //获取列名 colName = JsonHepler.getJsonCol(tempHT, "title"); //获取数据 colData = JsonHepler.getJsonData(tempHT, "data", colName.Count); return(JsonHepler.List2DataTable(colData, colName)); } catch (System.Exception ex) { Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.GetAllLogsByWellId()"); jstring = String.Empty; return(null); } }
/// <summary> /// 获取仪器信息 /// </summary> /// <param name="jstring">输出JsonString</param> /// <returns>Jstring转换成DataTable</returns> public DataTable GetAllInstName(out String jstring) { try { colName.Clear(); colData.Clear(); strJsonSend = JsonHepler.HashtableToJson(ht, 0); jstring = _realdbws.GetAllInstName(strJsonSend); Hashtable tempHT = (Hashtable)JsonConvert.DeserializeObject(jstring, typeof(Hashtable)); //获取列名 colName = JsonHepler.getJsonCol(tempHT, "title"); //获取数据 colData = JsonHepler.getJsonData(tempHT, "data", colName.Count); return(JsonHepler.List2DataTable(colData, colName)); } catch (System.Exception ex) { Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.GetAllInstName()"); jstring = ""; DataTable dt = new DataTable(); return(dt); } }
/// <summary> /// 写曲线 /// </summary> /// <returns>写的记录条数</returns> public int WriteCurveData(String title, String regionName, out String jstring) { int sum = 0; try { InitHashTable(false, title, regionName); colName.Clear(); colData.Clear(); strJsonSend = JsonHepler.HashtableToJson(ht, 0); jstring = _realdbws.WriteCurveData(strJsonSend); Hashtable tempHT = (Hashtable)JsonConvert.DeserializeObject(jstring, typeof(Hashtable)); //获取列名 colName = JsonHepler.getJsonCol(tempHT, "title"); //获取数据 colData = JsonHepler.getJsonData(tempHT, "data", colName.Count); //return JsonHepler.List2DataTable(colData, colName); } catch (System.Exception ex) { Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.GetAllLogsByWellId()"); jstring = String.Empty; //return null; } return(sum); }
/// <summary> /// 生成推送Json字符串 /// </summary> /// <param name="logid">井id</param> /// <param name="recordno">表号</param> /// <param name="size">记录size</param> /// <param name="instname">仪器名</param> /// <param name="_curvename">曲线名</param> /// <param name="_curvedata">曲线数据</param> /// <returns></returns> public String InitCurveTable(String logid, String recordno, int size, String instname, List <String> _curvename, DataTable _curvedata) { String temp0 = ""; String temp1 = ""; String temp2 = ""; DataTable dt = _curvedata.Copy(); ht.Clear(); ht.Add("logid", logid); ht.Add("recordno", recordno); ht.Add("instname", instname); ht.Add("indexname", "DATE,TIME"); ht.Add("user", "yuwenmao"); ht.Add("password", "123"); ht.Add("size", size); ht.Add("msg", ""); ht.Add("return", size); temp0 = JsonHepler.HashtableToJson(ht, 0); //title string strCurveNames = "\"title\" :["; DataRow rowCurveData = dt.Rows[0]; foreach (String cv in _curvename) { String elem = "\""; if (cv.Length < 1) { elem += "-999.25\""; } else { elem += cv + "\""; } strCurveNames += elem + ","; } strCurveNames = strCurveNames.Remove(strCurveNames.Length - 1); strCurveNames += "]"; temp1 = temp0.Insert(1, strCurveNames + ","); //data string strCurveData = ""; strCurveData += createDataString(dt); temp2 = temp1.Insert(1, strCurveData + "],"); return(temp2); }
/// <summary> /// 连接测试 /// </summary> /// <returns>是否连接异常</returns> public bool ConnectTest() { try { String jstring; colName.Clear(); colData.Clear(); InitHashTable(); strJsonSend = JsonHepler.HashtableToJson(ht, 0); jstring = _realdbws.GetAllRegions(strJsonSend); Hashtable tempHT = (Hashtable)JsonConvert.DeserializeObject(jstring, typeof(Hashtable)); //获取列名 colName = JsonHepler.getJsonCol(tempHT, "title"); //获取数据 colData = JsonHepler.getJsonData(tempHT, "data", colName.Count); JsonHepler.List2DataTable(colData, colName); return(true); } catch (System.Exception ex) { Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.ConnectTest()"); return(false); } }