using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Site_Interface.yfCallback { /// /// callBackQRCodeFJM 的摘要说明 /// public class callBackQRCodeFJM : IHttpHandler { public void ProcessRequest(HttpContext context) { string responseText = "", body = ""; Model.yfCallback.BackInfoYf info = null; Model.yfCallback.EventBackInfoJKM ret = new Model.yfCallback.EventBackInfoJKM(3); try { string deviceKey = HttpContext.Current.Request.QueryString["deviceKey"]; string time = HttpContext.Current.Request.QueryString["time"]; string ip = HttpContext.Current.Request.QueryString["ip"]; string strevent = HttpContext.Current.Request.QueryString["event"]; System.IO.Stream s = System.Web.HttpContext.Current.Request.InputStream; byte[] b = new byte[s.Length]; s.Read(b, 0, (int)s.Length); body = System.Text.Encoding.UTF8.GetString(b); string r = "[\x00-\x08\x0B\x0C\x0E-\x1F\x26]"; body = System.Text.RegularExpressions.Regex.Replace(body, @"\r", string.Empty); body = System.Text.RegularExpressions.Regex.Replace(body, @"\t", string.Empty); body = System.Text.RegularExpressions.Regex.Replace(body, @"\n", string.Empty); BLL.LogManage.WriteLog11(Model.AccessLog.AllLogType.人脸识别.ToString(), "callBackQRCodeFJM:" + body); info = Newtonsoft.Json.JsonConvert.DeserializeObject(body); if (string.IsNullOrEmpty(deviceKey)) deviceKey = info.deviceKey; Model.LTPCache mac = DAL.cache.GetCache(deviceKey); if (mac != null && info != null) { BLL.MachineYzList bllYz = new BLL.MachineYzList(mac, Global.interType.ToString(), Global.HRServerPhotoPath); Model.yfCallback.JKM_FJM_QrCode jkmQrCode = null; Model.yfCallback.JKM_FJM_Ret.Root retJKM = null; DateTime CheckTime = DateTime.Now; if (!string.IsNullOrEmpty(info.QRdata) && info.QRdata.IndexOf("FJQRJKM")>=0 )//扫码事件 必须是福建码 { jkmQrCode = new Model.yfCallback.JKM_FJM_QrCode(); jkmQrCode.checkTemperature = info.temperature; jkmQrCode.qrCodeContent = info.QRdata; retJKM = BLL.yfCallback.E7SM4FJM.PostQrCode(jkmQrCode); if (retJKM != null && retJKM.Response.Data != null && retJKM.Response.Data.CheckFlag == "TX") { ret.displayModColor = Model.yfCallback.EnumColor.green.ToString(); ret.ttsModContent = String.Format("{0},绿码请通行", string.IsNullOrEmpty(info.temperature) ? "" : info.temperature + "度"); ret.displayModContent = String.Format("{0}绿码请通行", string.IsNullOrEmpty(info.temperature) ? "" : info.temperature + "度"); ret.isOpenRelay = true; ret.imgBase64 = BLL.JKMImage.GetCache("lvma_1.png"); ret.qrCodeStatus = "00"; } else { if (retJKM != null && retJKM.Response.Data != null && retJKM.Response.Data.CheckFlag != "TX") { ret.displayModColor = Model.yfCallback.EnumColor.yellow.ToString(); ret.ttsModContent = String.Format("黄码禁止通行"); ret.displayModContent = "黄码禁止通行"; ret.imgBase64 = BLL.JKMImage.GetCache("huangma_1.png"); ret.isOpenRelay = false; ret.qrCodeStatus = "01"; } else { ret.ttsModContent = String.Format("健康码检验失败"); ret.displayModContent = "健康码检验失败"; ret.isOpenRelay = false; ret.imgBase64 = BLL.JKMImage.GetCache("hongma_1.png"); } } bllYz.Add(Model.EnumYzType.刷健康码, CheckTime, "", "", ret.isOpenRelay ? 0 : 1, info.temperature, ret.isOpenRelay , info.img); } else if (!string.IsNullOrEmpty(info.QRdata) && info.QRdata.IndexOf("MZTJKM_") >= 0)//扫码事件 八闽通 { ret.displayModColor = Model.yfCallback.EnumColor.yellow.ToString(); ret.ttsModContent = String.Format("请用福建健康码"); ret.displayModContent = String.Format("请用福建健康码"); ret.isOpenRelay = false; } else { ret.displayModColor = Model.yfCallback.EnumColor.red.ToString(); ret.ttsModContent = String.Format("未读数到二维码数据"); ret.displayModContent = String.Format("未读数到二维码数据"); ret.isOpenRelay = false; } } else { ret.displayModColor = Model.yfCallback.EnumColor.red.ToString(); ret.ttsModContent = String.Format("设备未授权"); ret.displayModContent = "设备未授权"; ret.isOpenRelay = false; } } catch (Exception ex) { ret.displayModColor = Model.yfCallback.EnumColor.red.ToString(); ret.ttsModContent = "验证异常"; ret.displayModContent = "验证异常"; ret.isOpenRelay = false; } finally { #region 支持跨域请求 responseText = Newtonsoft.Json.JsonConvert.SerializeObject(ret); context.Response.Clear(); context.Response.ClearHeaders(); string origin = context.Request.Headers["Origin"]; context.Response.AppendHeader("Access-Control-Allow-Origin", string.IsNullOrEmpty(origin) ? "*" : origin); string requestHeaders = context.Request.Headers["Access-Control-Request-Headers"]; context.Response.AppendHeader("Access-Control-Allow-Headers", string.IsNullOrEmpty(requestHeaders) ? "*" : requestHeaders); context.Response.AppendHeader("Access-Control-Allow-Methods", "POST, OPTIONS"); #endregion context.Response.Clear(); context.Response.Write(responseText); context.Response.End(); } } public bool IsReusable { get { return false; } } } }