Ejemplo n.º 1
0
 /// <summary>
 /// 执行完托盘检查通过后,显示
 /// </summary>
 /// <param name="TrayNO"></param>
 /// <returns></returns>
 public ActionResult ShowTrayRFID(string TrayNO)
 {
     GetLoginInfo();
     if (Login_Info == null)
     {
         return(Content("<script>location.href='/Home'</script>"));
     }
     StdQuery1 = new StdQuery(Login_Info.User_ID, Login_Info.User_Name, Login_Info.Token);
     try
     {
         StdQuery1.ClearParameter();
         StdQuery1.SetParameter("TrayNO", TrayNO);
         DataTable dt = StdQuery1.Execute("QryTrayRfidGoods");//查询集货标签商品复检情况
         return(Content(dt.ToJson()));
     }
     catch (Exception ex)
     {
         return(Content(ex.Message));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 读取设备数据
        /// </summary>
        /// <returns></returns>
        public ActionResult ReadRfid(string TrayNO)
        {
            GetLoginInfo();
            if (Login_Info == null)
            {
                return(Content("<script>location.href='/Home'</script>"));
            }
            StdQuery1 = new StdQuery(Login_Info.User_ID, Login_Info.User_Name, Login_Info.Token);
            int ReadCount = 1; //控制是否继续读取,大于2不读

            try
            {
                string  strData   = "";
                int     iret      = 0;
                Byte    gFlg      = 0x00;//0x00 从头开始读;0x01连续读;
                UIntPtr dnhReport = UIntPtr.Zero;
                while (ReadCount <= 2)
                {
                    ReadCount++;
                    iret = RFIDLIB.rfidlib_reader.RDR_BuffMode_FetchRecords(hreader, gFlg); // send command to device
                    if (iret == 0)                                                          //取数据
                    {
                        // Get records from dll buffer memory
                        dnhReport = RFIDLIB.rfidlib_reader.RDR_GetTagDataReport(hreader, RFIDLIB.rfidlib_def.RFID_SEEK_FIRST);
                        while (dnhReport != UIntPtr.Zero)// 有数据
                        {
                            ReadCount = 1;
                            Byte[] byData = new Byte[32];
                            UInt32 len    = (UInt32)byData.Length;
                            if (RFIDLIB.rfidlib_reader.RDR_ParseTagDataReportRaw(dnhReport, byData, ref len) == 0)
                            {
                                if (len > 0)
                                {
                                    string RFID = ";" + BitConverter.ToString(byData, 0, (int)len).Replace("-", string.Empty);
                                    if (!strData.Contains(RFID))
                                    {
                                        strData += RFID;
                                    }
                                }
                            }
                            dnhReport = RFIDLIB.rfidlib_reader.RDR_GetTagDataReport(hreader, RFIDLIB.rfidlib_def.RFID_SEEK_NEXT);
                        }
                        gFlg = 0x01;  // if received ok ,get next records from device
                    }
                }
                strData = strData == "" ? "" : strData.Substring(1);
                //strData = "123;456;9999";
                if (strData != "")
                {
                    CratesRfidReading(TrayNO, strData); //循环写入标签
                }
                StdQuery1.ClearParameter();
                StdQuery1.SetParameter("TrayNO", TrayNO);
                DataTable dt = StdQuery1.Execute("QryTrayRfidGoods");//查询集货标签商品复检情况
                return(Content(dt.ToJson()));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }