Http协议网络读卡器Aspx网页Request获取刷卡数据Response回应驱动显示

        中文液晶显示http协议网络读卡器是一款能利用现有的计算机网络,不需要独立布线就可以组成一个高性能低成本实时联网ID卡管理系统的端终设备,刷卡后即时向远程计算机传送卡号信息,电脑对刷卡信息处理后可即时向读卡器发送相应的显示及响应提示。HTTP网络读卡器已广泛用于计费,计件薪酬管理、人事考勤、打印监控、身份识别等场合。 

 产品特点

01、HTTP通讯协议,设备主动读取EM4100及兼容的低频RFID卡并即时将卡号发送到服务器;
02、122x32中文液晶双行显示,可显示任意中文、英文、数字及符号;
03、支持POE交换机网线供电;
04、支持WIFI无线热点连接;
05、支持两组继电器开关控制信号输出;
06、支持TTS中文合成语音播报;
07、公司自主研发、生产,性价比高,自主知识产权;
08、支持安卓Android系统、LINUX系统、WINDOWS系统开发使用。
09、支持x86、龙芯、兆芯、鲲鹏、麒麟、海光、飞腾、RK3288、imx6、全志、RK等CPU内核平台架构的设备使用。

 三种提交方式可自由设置 

RFID网络WIFI无线TCP/UDP/HTTP可编程二次开发读卡器POE供电语音-淘宝网 (taobao.com)

 HttpReader.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Web.Services;
using Newtonsoft.Json;

public partial class HttpReader : System.Web.UI.Page
{
    public string RepStr = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        string info = "";
        string jihao = "";
        string cardtype = "";
        string card = "";
        string Data = "";
        string dn = "";
        string Status = "";

        if (Request.Params["info"] != null) { info = Request.Params["info"]; }             //信息序号
        if (Request.Params["jihao"] != null) { jihao = Request.Params["jihao"]; }          //设备机号(可自编)
        if (Request.Params["cardtype"] != null) { cardtype = Request.Params["cardtype"]; } //卡类型有IC、ID、ISO15693等
        if (Request.Params["card"] != null) { card = Request.Params["card"]; }             //卡序列号
        if (Request.Params["data"] != null) { Data = Request.Params["data"]; }             //扇区内容
        if (Request.Params["dn"] != null) { dn = Request.Params["dn"]; }                   //设备硬件序列号,出厂时已固化,全球唯一
        if (Request.Params["status"] != null) { Status = Request.Params["status"]; }       //读卡状态,如密码认证失败为12


        if (info != "" && jihao != "" && cardtype != "" && card != "")  
        {
            RepStr = "Response=1";           //Response=固定前缀,我们的设备以此来检索返回信息,1信息类型,1为驱动设备显示和响声
            RepStr = RepStr + "," + info;    //信息序号
            RepStr = RepStr + "," + getChinesecode("卡号") + ":" + card + "  " + DateTime.Now.ToString("yy-MM-dd HH:mm:ss");    //显示信息,注意中文汉字一定要转换为设备能显示的编码,其它字母数字符号不需要转换
            RepStr = RepStr + ",20";        //显示时长20秒
            RepStr = RepStr + ",2";         //蜂鸣器发声种类
            RepStr = RepStr + ",0";         //语音种类
        }
        else
        {
            StreamReader sr = new StreamReader(Request.GetBufferlessInputStream());
            string response = sr.ReadToEnd();

            RootObject rb = JsonConvert.DeserializeObject<RootObject>(response);
            info = rb.info;            //接收到的数据包号,需回应该包号
            jihao = rb.jihao;          //设备机号(可自编)
            cardtype = rb.cardtype;    //卡类型有IC、ID、ISO15693等
            card = rb.card;            //接收到的原始16进制卡号,可根据需要自行转换成其他卡号
            Data = rb.data;            //扇区内容
            dn = rb.dn;                //设备硬件序列号,出厂时已固化,全球唯一
            Status = rb.status;        //读卡状态,如密码认证失败为12

            if (info != "" && jihao != "" && cardtype != "" && card != "")  
            {
                RepStr = "Response=1";           //Response=固定前缀,我们的设备以此来检索返回信息,1信息类型,1为驱动设备显示和响声
                RepStr = RepStr + "," + info;    //信息序号
                RepStr = RepStr + "," + getChinesecode("卡号") + ":" + card + "  " + DateTime.Now.ToString("yy-MM-dd HH:mm:ss");    //显示信息,注意中文汉字一定要转换为设备能显示的编码,其它字母数字符号不需要转换
                RepStr = RepStr + ",20";        //显示时长20秒
                RepStr = RepStr + ",2";         //蜂鸣器发声种类
                RepStr = RepStr + ",0";         //语音种类
            }
        }        
    }

    public static string getChinesecode(string inputip)   //获取中文编码
    {
        byte[] Chinesecodearry = System.Text.Encoding.GetEncoding(936).GetBytes(inputip);
        int codelen = (byte)Chinesecodearry.Length;
        string hexcode = "";
        for (int i = 0; i < codelen; i++)
        {
            if (i % 2 == 0) { hexcode = hexcode + "\\x"; }
            hexcode = hexcode + Chinesecodearry[i].ToString("X2");
        }
        return hexcode;
    }

    public class RootObject  //json类
    {
        public string info { get; set; }
        public string jihao { get; set; }
        public string cardtype { get; set; }
        public string card { get; set; }
        public string data { get; set; }
        public string dn { get; set; }
        public string status { get; set; }
    }

    protected string ResponseStr()
    {
        return RepStr;
    }
}

 HttpReader.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HttpReader.aspx.cs" Inherits="HttpReader" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Http读卡器Demo</title>
</head>

<body>
    <form id="form1" runat="server">
    <div style="height: 96px">
        <%  = ResponseStr() %>
    </div>
    </form>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

vx_13822155058

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值