Example #1
0
        public JsonResult IcCard()
        {
            int    isGetCar = 0;
            string plateNum = "";
            string sound    = "";

            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("IcCard");

            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.Default.GetString(bytes);
                log.Debug("有卡号信息上传,解析流得到字符串 - " + req);

                JavaScriptSerializer js     = new JavaScriptSerializer();
                AIOICCard            iccard = js.Deserialize <AIOICCard>(req);

                string warehouse = "1";
                string hallID    = iccard.equipmentID;
                string ccode     = iccard.cardInfo;

                int wh = 1;
                if (!string.IsNullOrEmpty(warehouse))
                {
                    wh = Convert.ToInt32(warehouse);
                }
                int hall = 0;
                if (!string.IsNullOrEmpty(hallID))
                {
                    hall = Convert.ToInt32(hallID);
                }
                if (hall < 10)
                {
                    resp.Message = "车厅号不正确,hallID- " + hallID;
                    return(Json(resp));
                }
                log.Debug("一体机刷卡信息中,warehouse - " + warehouse + " ,hallID - " + hall);
                resp = new CWTaskTransfer(hall, wh).DealFingerICCardMessage(ccode);
                if (resp.Code == 1)
                {
                    ZhiWenResult result = resp.Data as ZhiWenResult;
                    isGetCar = result.IsTakeCar;
                    plateNum = result.PlateNum;
                    sound    = result.Sound;
                }
                log.Debug("一体机刷卡,返回 - " + resp.Message);
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            var json = new
            {
                status    = resp.Code,
                msg       = resp.Message,
                isTakeCar = isGetCar,
                carBrand  = plateNum,
                counter   = 0,
                sound     = sound
            };

            return(Json(json));
        }
Example #2
0
        public JsonResult ZhiWen()
        {
            int      isGetCar = 0;
            string   plateNum = "";
            Response resp     = new Response();
            Log      log      = LogFactory.GetLogger("ZhiWen");

            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.Default.GetString(bytes);
                log.Debug("有指纹信息上传!");

                JavaScriptSerializer js     = new JavaScriptSerializer();
                AIOFingerPrint       fpring = js.Deserialize <AIOFingerPrint>(req);

                string warehouse   = "1";
                string hallID      = fpring.equipmentID;
                string fingerPrint = fpring.zhiWenInfo;

                int wh = 1;
                if (!string.IsNullOrEmpty(warehouse))
                {
                    wh = Convert.ToInt32(warehouse);
                }
                int hall = 0;
                if (!string.IsNullOrEmpty(hallID))
                {
                    hall = Convert.ToInt32(hallID);
                }
                log.Debug("指纹信息中,warehouse - " + warehouse + " ,hallID - " + hall);
                if (hall < 10)
                {
                    resp.Message = "车厅号不正确,hallID- " + hallID;
                    return(Json(resp));
                }

                string[] arrayFinger = fingerPrint.Trim().Split(' ');
                byte[]   psTZ        = new byte[arrayFinger.Length];
                for (int i = 0; i < arrayFinger.Length; i++)
                {
                    psTZ[i] = Convert.ToByte(arrayFinger[i].Trim(), 16);
                }

                log.Debug("接收到的指纹数量- " + psTZ.Length);
                if (psTZ.Length > 380)
                {
                    resp = new CWTaskTransfer(hall, wh).DealFingerPrintMessage(psTZ);
                    if (resp.Code == 1)
                    {
                        ZhiWenResult result = resp.Data as ZhiWenResult;
                        isGetCar = result.IsTakeCar;
                        plateNum = result.PlateNum;
                    }
                }
                else
                {
                    resp.Message = "上传的指纹特性数量不正确,Length- " + psTZ.Length;
                }
                log.Debug("指纹上传返回值 - " + resp.Message);
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }

            var json = new
            {
                status    = resp.Code,
                msg       = resp.Message,
                isTakeCar = isGetCar,
                carBrand  = plateNum,
                counter   = 0,
                sound     = ""
            };

            return(Json(json));
        }