/// <summary> /// 得到一个对象实体 /// </summary> public DJK.Model.djk_cloudData DataRowToModel(DataRow row) { DJK.Model.djk_cloudData model = new DJK.Model.djk_cloudData(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["savedDate"] != null && row["savedDate"].ToString() != "") { model.savedDate = DateTime.Parse(row["savedDate"].ToString()); } if (row["healthData"] != null) { model.healthData = row["healthData"].ToString(); } if (row["verifyCode"] != null) { model.verifyCode = row["verifyCode"].ToString(); } if (row["deviceNo"] != null) { model.deviceNo = row["deviceNo"].ToString(); } if (row["orgnizationID"] != null) { model.orgnizationID = row["orgnizationID"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DJK.Model.djk_cloudData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update djk_cloudData set "); if (model.savedDate != null) { strSql.Append("savedDate='" + model.savedDate + "',"); } else { strSql.Append("savedDate= null ,"); } if (model.healthData != null) { strSql.Append("healthData='" + model.healthData + "',"); } else { strSql.Append("healthData= null ,"); } if (model.verifyCode != null) { strSql.Append("verifyCode='" + model.verifyCode + "',"); } else { strSql.Append("verifyCode= null ,"); } if (model.deviceNo != null) { strSql.Append("deviceNo='" + model.deviceNo + "',"); } else { strSql.Append("deviceNo= null ,"); } if (model.orgnizationID != null) { strSql.Append("orgnizationID='" + model.orgnizationID + "',"); } else { strSql.Append("orgnizationID= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where ID=" + model.ID + ""); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
public ResultCalculation(string vcode) { verifyCode = vcode; dalClarity = new DJK.DAL.admin_Clarity(); dalData = new DJK.DAL.admin_MedicalData(); dalSource = new DJK.DAL.admin_MedicalSource(); modelData = new DJK.Model.djk_cloudData(); dal = new DJK.DAL.djk_cloudData(); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DJK.Model.djk_cloudData model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.savedDate != null) { strSql1.Append("savedDate,"); strSql2.Append("'" + model.savedDate + "',"); } if (model.healthData != null) { strSql1.Append("healthData,"); strSql2.Append("'" + model.healthData + "',"); } if (model.verifyCode != null) { strSql1.Append("verifyCode,"); strSql2.Append("'" + model.verifyCode + "',"); } if (model.deviceNo != null) { strSql1.Append("deviceNo,"); strSql2.Append("'" + model.deviceNo + "',"); } if (model.orgnizationID != null) { strSql1.Append("orgnizationID,"); strSql2.Append("'" + model.orgnizationID + "',"); } strSql.Append("insert into djk_cloudData("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); strSql.Append(";select @@IDENTITY"); object obj = DbHelperSQL.GetSingle(strSql.ToString()); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public DJK.Model.djk_cloudData GetModel(string verifyCode) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" ID,savedDate,healthData,verifyCode,deviceNo,orgnizationID "); strSql.Append(" from djk_cloudData "); strSql.Append(" where verifyCode=" + verifyCode + ""); DJK.Model.djk_cloudData model = new DJK.Model.djk_cloudData(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public int SendData(string dataJson) { HealthData hd = new HealthData(); try { hd = JsonConvert.DeserializeObject <HealthData>(dataJson); TestDatas tds = hd.TestDatas; HeadData head = hd.HeadData; string healthData = JsonConvert.SerializeObject(tds); string uploadTime = head.uploadTime; string verifyCode = head.verifyCode; string orgID = head.organizationID; string devNo = head.deviceNo; DJK.Model.djk_cloudData model = new DJK.Model.djk_cloudData(); model.healthData = healthData; model.orgnizationID = orgID; model.deviceNo = devNo; model.verifyCode = verifyCode; model.savedDate = Convert.ToDateTime(uploadTime); DJK.DAL.djk_cloudData dalCloud = new djk_cloudData(); int rtn = dalCloud.Add(model); if (rtn > 0) { return(1); } else { return(0); } } catch (Exception ex) { string ss = ex.ToString(); return(0); } }
public string getResult() { modelData = dal.GetModel(verifyCode); if (modelData == null) { return(""); } healthData = modelData.healthData; TestDatas tds = JsonConvert.DeserializeObject <TestDatas>(healthData); mpList = tds.MatrixDatas; ipList = tds.InfoDatas; string rtn = ""; List <DJK.Model.admin_MedicalData> result = new List <DJK.Model.admin_MedicalData>(); List <TestData> resultList = new List <TestData>(); result = dalData.getModelList(); foreach (DJK.Model.admin_MedicalData model in result) { if (model.DataFormula != null && model.DataFormula > 0) { int formula = (int)model.DataFormula; int dataMin = (int)(model.DataMin == null ? 0 : model.DataMin); int dataMax = (int)(model.DataMax == null ? 5 : model.DataMax); model.DataValue = getDataValue(formula, model.ID, dataMin, dataMax); TestData td = new TestData(); td.no = model.Code; td.name = model.Item; td.value = model.DataValue.ToString(); resultList.Add(td); } rtn = JsonConvert.SerializeObject(resultList); } return(rtn); }