/// <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> /// 通过井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> /// <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> /// 初始化没有header的哈希表 /// </summary> /// <param name="hasHeader">是否包含Header</param> /// <param name="_titles">title 列表</param> /// <param name="_datas">data 列表</param> /// <returns></returns> public Hashtable InitHashTable(bool hasHeader, List <String> _titles, List <String> _datas) { if (!hasHeader) { ht.Clear(); ht.Add("user", "yuwenmao"); ht.Add("password", "123"); ht.Add("size", "1"); ht.Add("msg", ""); ht.Add("return", ""); ht.Add("title", JsonHepler.List2JsonAarry(_titles)); ht.Add("data", JsonHepler.List2JsonAarry(_datas)); } return(ht); }
/// <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); }
public async Task <string> SignInAsync(LoginModel model) { BaseResult result = new BaseResult(); #region 判断验证码 if (!ValidateCaptchaCode(model.CaptchaCode)) { result.ResultCode = ResultCodeAddMsgKey.SignInCaptchaCodeErrorCode; result.ResultMsg = ResultCodeAddMsgKey.SignInCaptchaCodeErrorMsg; return(JsonHepler.ObjectToJSON(result)); } #endregion #region 判断错误次数 var ErrorTimes = HttpContext.Session.GetInt32(ManagerSignInErrorTimes); if (ErrorTimes == null) { HttpContext.Session.SetInt32(ManagerSignInErrorTimes, 1); ErrorTimes = 1; } else { HttpContext.Session.SetInt32(ManagerSignInErrorTimes, ErrorTimes.Value + 1); } if (ErrorTimes > MaxErrorTimes) { result.ResultCode = ResultCodeAddMsgKey.SignInErrorTimesOverTimesCode; result.ResultMsg = ResultCodeAddMsgKey.SignInErrorTimesOverTimesMsg; return(JsonHepler.ObjectToJSON(result)); } #endregion #region 再次属性判断 LoginModelValidation validation = new LoginModelValidation(); ValidationResult results = validation.Validate(model); if (!results.IsValid) { result.ResultCode = ResultCodeAddMsgKey.CommonModelStateInvalidCode; result.ResultMsg = results.ToString("||"); } #endregion model.Ip = HttpContext.GetClientUserIp(); var manager = _servie.SignIn(model); return(null); }
/// <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); } }