protected void Page_Load(object sender, EventArgs e) { var DeUid = Request["DeUid"]; var EnUid = Request["EnUid"]; var message = "404,參數空值"; if (string.IsNullOrEmpty(EnUid)) { } else { var longUid = ToolLibs.EncryptDES(EnUid, Config.DESKey, Config.DESIV); message = $"加密後:{longUid.ToString()}"; } if (string.IsNullOrEmpty(DeUid)) { } else { var longUid = Convert.ToInt64(ToolLibs.DecryptDES(DeUid, Config.DESKey, Config.DESIV)); message = $"解密後:{longUid.ToString()}"; } Response.Write(message); }
/// <summary> /// 建立評語的資料 /// </summary> /// <param name="measure"></param> /// <returns></returns> public static bool InitialResultRemark() { var result = false; try { using (var db = new HealthPaltformContext()) { if (!db.ResultRemark.Any()) { var tmpData = ToolLibs.GetResultRemarkData(); var obj = ToolLibs.ResultRemarkConvert(tmpData); if (obj.Result.Any()) { foreach (var unit in obj.Result) { //建立新物件 var tmpResult = new Models.Entity.ResultRemark(); //型態 tmpResult.Type = ToolLibs.GetEnum <ResultRemarkType>(unit.Type); //低標 tmpResult.LowRange = Convert.ToDouble(unit.LowRange); //頂標 tmpResult.HightRange = Convert.ToDouble(unit.HightRange); //等級 tmpResult.Level = unit.Level; //評語 tmpResult.Message = unit.Message; //建立日期 tmpResult.CreateDate = DateTime.Now; //新增資料 db.ResultRemark.Add(tmpResult); } //儲存新增 if (db.SaveChanges() > 0) { result = true; } } } } return(result); } catch (DbEntityValidationException ex) { new Log().Error($"產生與資料庫相關的錯誤\n" + $"Data:{ex.ToString()}"); return(result); } }
public static List <ComboEnumsData> CounerClinicSettingData() { var clinicStatusTypes = Enum.GetValues(typeof(TimePeriod)).Cast <TimePeriod>().ToList(); List <ComboEnumsData> comboData = new List <ComboEnumsData>(); foreach (var c in clinicStatusTypes) { comboData.Add(new ComboEnumsData(ToolLibs.GetEnumDescription(c), (int)c)); } return(comboData); }
public void PrepareData(string uid) { //將Request回來的UID解密 var longUid = Convert.ToInt64(ToolLibs.DecryptDES(uid, Config.DESKey, Config.DESIV)); log.Info($"取得檢測資料\tUid:{longUid}"); //取得檢測資料 var measureInfo = DBService.MeasureInfo.GetMeasureInfoByUID(longUid); log.Trace($"Data\t{measureInfo.MIData}"); log.Info($"取得會員資料\t身分證:{measureInfo.MemberIDNo}"); //取得會員資料 var memberInfo = DBService.MemberInfo.GetMemberInfoByIDNo(measureInfo.MemberIDNo); //所記錄的測量資料 var mIData = JsonConvert.DeserializeObject <Models.Utility.MIData>(measureInfo.MIData); //舒張壓 var tmpBP_Systolic = DBService.ResultRemark.GetRemarkByType(Enums.ResultRemarkType.LBP, ToolLibs.ConvertStrToDouble(mIData.BP_Systolic)); log.Info($"舒張壓 Remark\t{tmpBP_Systolic.Message}\t{tmpBP_Systolic.Level}"); //收縮壓 var tmpHP_Diastolic = DBService.ResultRemark.GetRemarkByType(Enums.ResultRemarkType.HBP, ToolLibs.ConvertStrToDouble(mIData.BP_Diastolic)); log.Info($"收縮壓 Remark\t{tmpHP_Diastolic.Message}\t{tmpHP_Diastolic.Level}"); //脈博 var tmpHeatRate = DBService.ResultRemark.GetRemarkByType(Enums.ResultRemarkType.HR, ToolLibs.ConvertStrToDouble(mIData.HeatRate)); var HPRemark = string.IsNullOrEmpty(tmpHeatRate.Level) ? $"{tmpHeatRate.Message}" : $"{tmpHeatRate.Level},{tmpHeatRate.Message}"; log.Info($"脈博 Remark\t{tmpHeatRate.Message}\t{tmpHeatRate.Level}"); //BMI var tmpBMI = DBService.ResultRemark.GetRemarkByType(Enums.ResultRemarkType.BMI, ToolLibs.ConvertStrToDouble(mIData.BMI)); var BMIRemark = tmpBMI.Message == "正常" ? $"{tmpBMI.Message}" : $"{tmpBMI.Message}需多注意飲食管理"; log.Info($"BMI Remark\t{tmpBMI.Message}\t{tmpBMI.Level}"); htmlBMI = mIData.BMI; htmlHeight = mIData.Height; htmlWeight = mIData.Weight; htmlLowBP = mIData.BP_Systolic; htmlHighBP = mIData.BP_Diastolic; htmlHeartBeat = mIData.HeatRate; htmlBodyTemperture = mIData.BodyTemperture; htmlBMIRemark = BMIRemark; htmlHPRemark = HPRemark; htmlAlertStatus = "N"; log.Info($"網頁帶入的資料BMI:{htmlBMI}\t" + $"身高:{htmlHeight}\t" + $"體重:{htmlWeight}\t" + $"舒張壓:{htmlLowBP}\t" + $"收縮壓:{htmlHighBP}\t" + $"脈搏:{htmlHeartBeat}\t" + $"體溫:{htmlBodyTemperture}\t" + $"BMI註記:{htmlBMIRemark}\t" + $"血壓註記:{htmlHPRemark}"); }
protected void Page_Load(object sender, EventArgs e) { var plainText = GetDocumentContents(new HttpRequestWrapper(this.Request)); if (string.IsNullOrWhiteSpace(plainText)) { log.Info($"收到的資料為空\n" + $"Data:{JsonConvert.SerializeObject(plainText)}\n"); Response.Write(JsonConvert.SerializeObject(new { ResultCode = 404, ErrorMessage = $"轉換失敗,傳入的資料為空 Data:{plainText}" })); return; } log.Info($"開始解析資料,Data:{plainText}"); var MIData = JsonConvert.DeserializeObject <MIData>(plainText); log.Info($"檢查是否存在會員資料:{MIData.Member_IDNo}"); var dbIDNo = DBService.MemberInfo.QueryMemberInfoByIDNo(MIData.Member_IDNo); log.Trace($"回傳的會員資料UID", dbIDNo); try { if (string.IsNullOrEmpty(dbIDNo)) { log.Info($"新建會員資料"); //儲存該筆資料 var memberInfo = new MemberInfo(); //取得系統ID var tmpID = ToolLibs.GetDateTimeNowDefaultString(); log.Info($"新建的會員資料ID:{tmpID}"); #region MemberInfo memberInfo.ID = tmpID; memberInfo.IDNo = MIData.Member_IDNo; memberInfo.Name = "Test"; memberInfo.Genger = 0; memberInfo.BDate = DateTime.Now; memberInfo.Tel = ""; memberInfo.Mobile = ""; memberInfo.Email = ""; memberInfo.Fax = ""; memberInfo.Occupation = ""; memberInfo.CreateDate = DateTime.Now; #endregion log.Trace("新增會員資料", memberInfo); DBService.MemberInfo.InsertMemberInfo(memberInfo); } //建立新的測量資料 var measuerInfo = new MeasureInfo(); //傳入身份證字號 measuerInfo.MemberIDNo = MIData.Member_IDNo; //字串處理,將多餘的 \n \r 去除,並將數據帶入 measuerInfo.MIData = Regex.Replace(plainText, @"\n|\r", ""); //帶入現在時間 measuerInfo.MIDate = DateTime.Now; //新增資料,並紀錄新增後的UID var measureInfoID = DBService.MeasureInfo.InsertMeasureInfo(measuerInfo).ToString(); //將網址帶入的UID加密 var encryptID = ToolLibs.EncryptDES(measureInfoID, Config.DESKey, Config.DESIV); //組出網址 var encryptCodeURL = $"{Config.BaseURL}MInfo.aspx?UID={encryptID}"; log.Info($"回傳的網址", encryptCodeURL); var result = string.Empty; if (encryptCodeURL == "") { result = JsonConvert.SerializeObject(new { ResultCode = 404, ErrorMessage = "轉換失敗" }); Response.Write(result); } else { Response.Write(JsonConvert.SerializeObject(new { ResultCode = 200, Url = encryptCodeURL })); } log.Info($"回傳的結果,Data:{result}"); } catch (Exception ex) { log.Error($"資料轉換錯誤\n" + $"Data:{JsonConvert.SerializeObject(MIData)}\n" + $"Exception:{ex.ToString()}"); Response.Write(JsonConvert.SerializeObject(new { ResultCode = 404, ErrorMessage = $"{ex.ToString()}" })); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.InputStream.Length <= 0) { Response.Clear(); Response.ContentType = "text/plain"; Response.StatusCode = 400; Response.TrySkipIisCustomErrors = true; Response.Write("4001 資料內容格式有誤或超出正常範圍"); Response.End(); log.Info("4001 資料內容格式有誤或超出正常範圍"); return; } System.Diagnostics.Debug.WriteLine(JsonConvert.SerializeObject(Request.Headers)); string documentContents; using (Stream receiveStream = Request.InputStream) { using (StreamReader readStream = new StreamReader(receiveStream, Request.ContentEncoding)) { documentContents = readStream.ReadToEnd(); //LOG.Debug("IP:" + Request.UserHostAddress); //LOG.Debug(documentContents + Environment.NewLine); } } System.Diagnostics.Debug.WriteLine(documentContents); string[] str = documentContents.Replace("\r\n", "\n").Split('\n'); Dictionary <string, string> dic = str.Where(x => !x.StartsWith("Feedback")).ToDictionary(x => x.Split('=')[0].Trim(), x => x.Substring(x.IndexOf('=') + 1).Trim()); if (dic.ContainsKey(string.Empty)) { dic.Remove(string.Empty); } ChangeValue(ref dic); TaiDocModel result = DictionaryToObject <TaiDocModel>(dic); List <Feedback> fbl = new List <Feedback>(); List <string> dif = str.Where(x => x.StartsWith("Feedback")).ToList(); foreach (string d in dif) //解析feedbak內容 { string t = d.Replace("Feedback", ""); t = d.Substring(d.IndexOf('=') + 1).Trim(); Dictionary <string, string> fb = t.Replace("@#@", "\n").Split('\n').ToDictionary(x => x.Split('=')[0].Trim(), x => x.Substring(x.IndexOf('=') + 1).Trim()); fbl.Add(DictionaryToObject <Feedback>(fb)); } if (fbl.Count > 0) { result.Feedback = fbl.ToList(); } var settings = new JsonSerializerSettings() { ContractResolver = new NullToEmptyStringResolver() }; string json = JsonConvert.SerializeObject(result, settings); log.Info($"TaiDoc解析完成的字串", json); #region APIDataSave var dbIDNo = DBService.MemberInfo.QueryMemberInfoByIDNo(result.Member_IDNo); if (string.IsNullOrEmpty(dbIDNo)) { log.Info($"新建會員資料"); //儲存該筆資料 var memberInfo = new Models.Entity.MemberInfo(); //取得系統ID var tmpID = ToolLibs.GetDateTimeNowDefaultString(); log.Info($"新建的會員資料ID:{tmpID}"); #region MemberInfo memberInfo.ID = tmpID; memberInfo.IDNo = result.Member_IDNo; memberInfo.Name = "Test"; memberInfo.Genger = 0; memberInfo.BDate = DateTime.Now; memberInfo.Tel = ""; memberInfo.Mobile = ""; memberInfo.Email = ""; memberInfo.Fax = ""; memberInfo.Occupation = ""; memberInfo.CreateDate = DateTime.Now; #endregion log.Trace("新增會員資料", memberInfo); DBService.MemberInfo.InsertMemberInfo(memberInfo); } //建立新的測量資料 var measuerInfo = new Models.Entity.MeasureInfo(); //傳入身份證字號 measuerInfo.MemberIDNo = result.Member_IDNo; //字串處理,將多餘的 \n \r 去除,並將數據帶入 measuerInfo.MIData = Regex.Replace(json, @"\n|\r", ""); //帶入現在時間 measuerInfo.MIDate = DateTime.Now; //新增資料,並紀錄新增後的UID var measureInfoID = DBService.MeasureInfo.InsertMeasureInfo(measuerInfo).ToString(); //將網址帶入的UID加密 var encryptID = ToolLibs.EncryptDES(measureInfoID, Config.DESKey, Config.DESIV); //組出網址 var encryptCodeURL = $"{Config.BaseURL}MInfo.aspx?UID={encryptID}"; log.Info($"回傳的網址", encryptCodeURL); #endregion TransferToTaiDoc(result); Response.Clear(); Response.ContentType = "text/plain"; Response.StatusCode = 200; Response.Write("200"); Response.End(); log.Info($"回傳的結果,Data:200"); } }
private string TransferToTaiDoc(TaiDocModel taiDocObj) { TaiDocResultData taiDocResultData = new TaiDocResultData(); var checkStatus = TransferTaiDocDataCheck(taiDocObj); if (checkStatus) { if (string.IsNullOrEmpty(taiDocObj.Member_IDNo)) { log.Info($"請檢查身份證字號,IDNo:{taiDocObj.Member_IDNo}"); } else if (string.IsNullOrEmpty(taiDocObj.DateTime.ToString())) { log.Info($"請檢查量測日期,DateTime:{taiDocObj.DateTime}"); } else { var temperature = ""; if (!string.IsNullOrWhiteSpace(taiDocObj.EarTemperture)) { temperature = taiDocObj.EarTemperture; } if (!string.IsNullOrWhiteSpace(taiDocObj.BodyTemperture)) { temperature = taiDocObj.BodyTemperture; } taiDocResultData.Data.Add(new Data { ID = taiDocObj.Member_IDNo, MeasureTime = taiDocObj.DateTime.ToString("yyyy-MM-dd HH:mm:ss"), Systolic = taiDocObj.BP_Systolic, Diastolic = taiDocObj.BP_Diastolic, Heartbeat = taiDocObj.HeartRate, Oxygen = taiDocObj.SPO2, Sugar = taiDocObj.BG, Temperature = string.IsNullOrWhiteSpace(temperature) ? null : Convert.ToDouble(temperature).ToString("f1") }); log.Info($"轉換完成的資料:{JsonConvert.SerializeObject(taiDocResultData.Data)}"); } } else { taiDocResultData = null; log.Info($"沒有符合的量測資料:{JsonConvert.SerializeObject(taiDocObj)}"); } var redictor = $"{System.Configuration.ConfigurationManager.AppSettings["TaiDocResultURL"]}"; log.Info($"TaiDocResultURL:{redictor}"); HttpWebRequest httpWebRequest = WebRequest.Create($"{redictor}") as HttpWebRequest; if (httpWebRequest != null) { byte[] array = new byte[0]; if (taiDocResultData != null) { taiDocResultData.Success = true; string text = ToolLibs.ConvertObjToJSON(taiDocResultData); array = Encoding.UTF8.GetBytes(text); log.Info("Post過去的JSON", text); } else { string s = ToolLibs.ConvertObjToJSON(new { Sucess = false, Message = "沒有符合的量測資料" }); array = Encoding.UTF8.GetBytes(s); } httpWebRequest.Method = "POST"; httpWebRequest.KeepAlive = true; httpWebRequest.ContentType = "application/json"; httpWebRequest.Timeout = 30000; httpWebRequest.ContentLength = array.Length; httpWebRequest.ContentLength = array.Length; Stream requestStream = httpWebRequest.GetRequestStream(); requestStream.Write(array, 0, array.Length); requestStream.Close(); string Message = ""; using (HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse) { using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream())) { Message = streamReader.ReadToEnd(); } } requestStream.Close(); log.Info($"回傳的Response:{Message}"); return(Message); } log.Info("Result資料異常"); return("Result資料異常"); }