Example #1
0
        /// <summary>
        /// 写卡片基本信息
        /// </summary>
        /// <param name="p_intPort"></param>
        /// <param name="p_objCard"></param>
        /// <returns></returns>
        public static bool WriteCardInfo(int p_intPort, PaymentCard p_objCard)
        {
            bool   lUserValid = p_objCard.Valid;
            string l_strCarNo = CardNoToHex(p_objCard.No, lUserValid);
            string l_strDate  = p_objCard.ExpiryDate.Value.ToString("yyMMdd");
            string l_strName  = GetNameCode(p_objCard.Name);

            string l_strData = l_strCarNo + l_strDate + p_objCard.FunctionCode + l_strName;

            //string l_strMoneyLimit = EquipmentGeneral.IntToHex(int.Parse((p_objCard.LimitRemainder * 100).ToString()), 8);
            //string l_strMaxPayment = EquipmentGeneral.IntToHex(int.Parse((p_objCard.DailyMaxPayment * 100).ToString()), 8);
            string l_strMoneyLimit   = EquipmentGeneral.IntToHex((int)(p_objCard.LimitRemainder * 100), 8);
            string l_strMaxPayment   = EquipmentGeneral.IntToHex((int)(p_objCard.DailyMaxPayment * 100), 8);
            string l_strPaymentCount = EquipmentGeneral.IntToHex(p_objCard.Span1PaymentCount) + EquipmentGeneral.IntToHex(p_objCard.Span2PaymentCount) + EquipmentGeneral.IntToHex(p_objCard.Span3PaymentCount) + EquipmentGeneral.IntToHex(p_objCard.Span4PaymentCount);
            string l_strType         = EquipmentGeneral.IntToHex(Convert.ToInt32(char.Parse(p_objCard.Type)));

            l_strData = l_strData + l_strMoneyLimit + p_objCard.PaymentPassword + l_strMaxPayment + l_strPaymentCount + l_strType;

            byte bSection = 0;

            WriteCard(p_intPort, EquipmentGeneral.GetCardSectionPieceList()[bSection][1].ToString(), 2, l_strData);
            bSection = 1;
            CleanCardMoney(p_intPort, EquipmentGeneral.GetCardSectionPieceList()[bSection][0]);
            AddCardMoney(p_intPort, EquipmentGeneral.GetCardSectionPieceList()[bSection][0], (int)(p_objCard.Money * 100));

            bSection = 2;
            CleanCardMoney(p_intPort, EquipmentGeneral.GetCardSectionPieceList()[bSection][0]);
            AddCardMoney(p_intPort, EquipmentGeneral.GetCardSectionPieceList()[bSection][0], (int)(p_objCard.Subsidize * 100));

            return(true);
        }
Example #2
0
        /// <summary>
        /// 获取亲情号码列表及显示信息
        /// </summary>
        /// <param name="iPort">COM口号</param>
        /// <param name="bSection">扇区号</param>
        /// <returns></returns>
        public static List <string> GetPhoneNumList(int iPort, byte bSection)
        {
            Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();
            List <string> listPhone = new List <string>();

            try
            {
                string strReturn = ReadCard(iPort, dicSection[bSection][0].ToString(), 3);
                if (strReturn.Length != 96)
                {
                    return(null);
                }
                strReturn = strReturn.ToUpper();
                string strSub = strReturn.Substring(0, 32);

                strSub = Convert.ToChar(Convert.ToInt32(strSub.Substring(0, 2), 16)).ToString() + strSub.Substring(2, 8);

                listPhone.Add(strSub);

                for (int i = 0; i < 4; i++)
                {
                    strSub = strReturn.Substring(32 + i * 16, 16).TrimStart('0').TrimEnd('F');
                    listPhone.Add(strSub);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listPhone);
        }
Example #3
0
        /// <summary>
        /// 解读第一块信息
        /// </summary>
        /// <param name="p_strCode">16进制信息</param>
        /// <param name="p_objCardInfo">卡</param>
        private static void EncodeBlock1(string p_strCode, PaymentCard p_objCardInfo)
        {
            //取得块1数据
            string l_strTemp = p_strCode.Substring(0, 6);
            var    l_arrTemp = l_strTemp.ToCharArray();

            //取得卡号
            p_objCardInfo.No = Convert.ToInt32(l_arrTemp[5].ToString() + l_arrTemp[2].ToString() + l_arrTemp[3].ToString() + l_arrTemp[0].ToString() + l_arrTemp[1].ToString(), 16);

            //取得状态
            p_objCardInfo.Valid = l_arrTemp[4] == '8' ? true : false;

            //取得有效时间
            l_strTemp = p_strCode.Substring(6, 6);
            p_objCardInfo.ExpiryDate = DateTime.ParseExact("20" + l_strTemp, "yyyyMMdd", null);

            //取得系统功能
            //l_strTemp = Convert.ToString(Convert.ToInt32(p_strCode.Substring(12, 4), 16), 2);
            //p_objCardInfo.FunctionCode = ("0000000000000000").Substring(0, 16 - l_strTemp.Length) + l_strTemp;
            //p_objCardInfo.FunctionCode = p_strCode.Substring(12, 4);
            p_objCardInfo.FunctionCode = Convert.ToString(Convert.ToInt32(p_strCode.Substring(12, 4), 16), 2).PadLeft(16, '0');

            //取得持卡人姓名
            l_strTemp          = p_strCode.Substring(16, 16);
            p_objCardInfo.Name = EquipmentGeneral.HexToStr(l_strTemp);
        }
Example #4
0
        /// <summary>
        /// 获取电话卡用户基本信息
        /// </summary>
        /// <param name="iPort">COM口号</param>
        /// <param name="bSection">扇区号</param>
        /// <returns></returns>
        public static PaymentCard GetUserBasicInfos(int iPort, byte bSection)
        {
            PaymentCard payCard = new PaymentCard();
            Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();

            try
            {
                string strReturn = ReadCard(iPort, dicSection[bSection][1].ToString(), 2);
                if (strReturn.Length != 64)
                {
                    if (strReturn.Length > 64)
                    {
                        strReturn = strReturn.Substring(0, 64);
                    }
                    else
                    {
                        return(null);
                    }
                }

                //PaymentCard l_objCardInfo = new PaymentCard();

                //解读第一块信息
                EncodeBlock1(strReturn.Substring(0, 32), payCard);

                //解读第二块信息
                EncodeBlock2(strReturn.Substring(32, 32), payCard);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(payCard);
        }
Example #5
0
        /// <summary>
        /// 获取卡号
        /// </summary>
        /// <returns></returns>
        public override int GetCardNo()
        {
            int  iCardNo  = 0;
            byte bSection = 3;
            Dictionary <byte, List <byte> > dicSetcion = EquipmentGeneral.GetCardSectionPieceList();

            try
            {
                if (!ReadCardsPrepare(bSection))
                {
                    return(0);
                }

                YuChuanDevice.rf_beep(_iBeepInterval);
                byte[] arrData  = new byte[16];
                int    iResRead = YuChuanDevice.rf_read(dicSetcion[bSection][1], arrData);
                string strPiece = YuChuanDevice.ChangeHexToString(arrData);
                if (strPiece.Length == 32)
                {
                    string strHexCardNo = strPiece.Substring(2, 1) + strPiece.Substring(3, 1) + strPiece.Substring(0, 1) + strPiece.Substring(1, 1);
                    iCardNo = Convert.ToInt32(strHexCardNo, 16);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
            return(iCardNo);
        }
Example #6
0
        /// <summary>
        /// 取得名称的16进制编码
        /// </summary>
        /// <param name="p_strName"></param>
        /// <returns></returns>
        private static string GetNameCode(string p_strName)
        {
            string l_strReturn = EquipmentGeneral.StrToHex(p_strName);

            l_strReturn = l_strReturn + "0000000000000000";

            return(l_strReturn.Substring(0, 16));
        }
Example #7
0
        public override bool WriteInitSubzVal(decimal dMoney)
        {
            byte bSection     = 2;
            int  iCardPieceNo = EquipmentGeneral.GetCardSectionPieceList()[bSection][0];

            JocatDevice.CleanCardMoney(1, iCardPieceNo);
            return(JocatDevice.AddCardMoney(1, iCardPieceNo, (int)(dMoney * 100)));
        }
Example #8
0
        /// <summary>
        /// 解读第2区信息
        /// </summary>
        /// <param name="p_strCode">16进制信息</param>
        /// <param name="p_objCardInfo">卡</param>
        private static void EncodeDivision2(string p_strCode, PaymentCard p_objCardInfo)
        {
            //前8位为最低余额

            //后两们为小数位,所以要除100
            p_objCardInfo.Subsidize       = EquipmentGeneral.HexMoneyToDouble(p_strCode.Substring(0, 8));
            p_objCardInfo.SubsidizeBackup = EquipmentGeneral.HexMoneyToDouble(p_strCode.Substring(32, 8));
            p_objCardInfo.MachineList     = p_strCode.Substring(64, 32);
        }
Example #9
0
        public static string CardNoToHex(int p_intCarNo, bool p_blnActive)
        {
            string l_strReturn = "";

            l_strReturn = EquipmentGeneral.IntToHexInSorting(p_intCarNo, 5);

            l_strReturn = l_strReturn.Insert(4, (p_blnActive) ? "8" : "0");

            return(l_strReturn);
        }
Example #10
0
        /// <summary>
        /// 读取采集卡数据
        /// </summary>
        /// <param name="p_decWater"></param>
        /// <param name="p_decMachine"></param>
        public void ReadCollectCardInfo(out decimal p_decWater, out decimal p_decMachine)
        {
            p_decWater   = 0;
            p_decMachine = 0;
            string l_strData = JocatDevice.ReadCard(m_intComPort, "9", 1);

            string l_strWater   = l_strData.Substring(0, 8);
            string l_strMachine = l_strData.Substring(16, 2);

            p_decWater   = EquipmentGeneral.HexMoneyToDouble(l_strData.Substring(0, 8));
            p_decMachine = EquipmentGeneral.HexMoneyToDouble(l_strData.Substring(16, 2));
        }
Example #11
0
 /// <summary>
 /// 取得卡用户编号
 /// </summary>
 /// <returns></returns>
 public override int GetCardNo()
 {
     try
     {
         byte bSection = 0;
         return(JocatDevice.ReadCardNo(m_intComPort, EquipmentGeneral.GetCardSectionPieceList()[bSection][0]));
     }
     catch
     {
         return(0);
     }
 }
Example #12
0
        /// <summary>
        /// 设置热水管理卡
        /// </summary>
        public void SetWaterAdminCard(string p_strPassword, int p_intPreUse, int p_intDailyUse, decimal p_decPrice)
        {
            //设置读卡器密码
            JocatDevice.SetReaderPassWord(m_intComPort, m_strAdminPassword);

            string l_strCRC = "FFFF9E10";

            string l_strPreUse   = EquipmentGeneral.IntToHexInSorting(p_intPreUse, 4);
            string l_strDailyUse = EquipmentGeneral.IntToHexInSorting(p_intDailyUse, 4);
            string l_strPrice    = EquipmentGeneral.IntToHexInSorting(Convert.ToInt32(p_decPrice * 100), 4);

            string l_strAdmin = p_strPassword + l_strPreUse + l_strDailyUse + l_strPrice + l_strCRC;

            //写入数据
            JocatDevice.WriteCard(m_intComPort, "9", 2, l_strAdmin + l_strAdmin);
        }
Example #13
0
        public static PaymentCard ReadCard(int p_intPort, int p_intSector, string strPwd)
        {
            try
            {
                var l_strReturn = ReadCard(p_intPort, p_intSector.ToString(), 3);
                if (l_strReturn == "")
                {
                    throw new Exception("读卡失败!");
                }

                if (l_strReturn.Substring(32, 32) == "00000000000000000000000000000000")
                {
                    throw new Exception("该卡为新卡。");
                }

                PaymentCard l_objCardInfo = new PaymentCard();

                //取得出厂卡号
                //JocatDevice.SetReaderPassWord(p_intPort, "FFFFFFFFFFFF");
                //l_objCardInfo.MACID = JocatDevice.ReadCard(p_intPort, "0", 1);
                l_objCardInfo.MACID = l_strReturn.Substring(0, 32);

                //JocatDevice.SetReaderPassWord(p_intPort, strPwd);

                //解读第一块信息
                EncodeBlock1(l_strReturn.Substring(32, 32), l_objCardInfo);

                //解读第二块信息
                EncodeBlock2(l_strReturn.Substring(64, 32), l_objCardInfo);

                //读取消费扇区信息
                byte bPosSection = 1;
                l_strReturn = ReadCard(p_intPort, EquipmentGeneral.GetCardSectionPieceList()[bPosSection][0].ToString(), 3);
                EncodeDivision1(l_strReturn, l_objCardInfo);

                //读取水费扇区信息
                byte bSubzSection = 2;
                l_strReturn = ReadCard(p_intPort, EquipmentGeneral.GetCardSectionPieceList()[bSubzSection][0].ToString(), 3);
                EncodeDivision2(l_strReturn, l_objCardInfo);

                return(l_objCardInfo);
            }
            catch (Exception Ex)
            {
                throw new Exception("读卡失败!");;
            }
        }
Example #14
0
        /// <summary>
        /// 写入卡片基本信息
        /// </summary>
        /// <param name="iCom"></param>
        /// <param name="iSection"></param>
        /// <param name="payCard"></param>
        /// <returns></returns>
        public static bool WriteCardBasicInfo(int iCom, byte bSection, PaymentCard payCard)
        {
            bool res = false;

            try
            {
                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();
                bool   bValid     = payCard.Valid;
                string l_strCarNo = CardNoToHex(payCard.No, bValid);
                string l_strDate  = payCard.ExpiryDate.Value.ToString("yyMMdd");
                string l_strName  = GetNameCode(payCard.Name);

                //功能
                string strFunc = string.Empty;
                if (payCard.FunctionCode.Length == 16)
                {
                    strFunc = EquipmentGeneral.BinToHex(payCard.FunctionCode).PadLeft(4, '0');
                }
                else if (payCard.FunctionCode.Length == 4)
                {
                    strFunc = payCard.FunctionCode;
                }
                else
                {
                    strFunc = string.Empty.PadRight(4, '0');
                }

                string l_strData = l_strCarNo + l_strDate + strFunc + l_strName;

                string l_strMoneyLimit   = EquipmentGeneral.IntToHex(int.Parse(((int)(payCard.LimitRemainder * 100)).ToString()), 8);
                string l_strMaxPayment   = EquipmentGeneral.IntToHex(int.Parse(((int)(payCard.DailyMaxPayment * 100)).ToString()), 8);
                string l_strPaymentCount = EquipmentGeneral.IntToHex(payCard.Span1PaymentCount) + EquipmentGeneral.IntToHex(payCard.Span2PaymentCount) + EquipmentGeneral.IntToHex(payCard.Span3PaymentCount) + EquipmentGeneral.IntToHex(payCard.Span4PaymentCount);
                string l_strType         = EquipmentGeneral.IntToHex(Convert.ToInt32(char.Parse(payCard.Type)));

                l_strData = l_strData + l_strMoneyLimit + payCard.PaymentPassword + l_strMaxPayment + l_strPaymentCount + l_strType;

                res = WriteCard(iCom, dicSection[bSection][1].ToString(), 2, l_strData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(res);
        }
Example #15
0
        /// <summary>
        /// 写入电话用户信息及电话号码
        /// </summary>
        /// <param name="iPort">COM口号</param>
        /// <param name="bSection">扇区号</param>
        /// <param name="strCardInfo">电话卡用户信息</param>
        /// <param name="listPhoneNum">电话号码列表</param>
        /// <returns></returns>
        public static bool WritePhoneList(int iPort, byte bSection, string strCardInfo, List <string> listPhoneNum)
        {
            try
            {
                if (listPhoneNum.Count > 4)
                {
                    return(false);
                }

                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();
                strCardInfo = strCardInfo.ToUpper();
                //string strSub = (Convert.ToString(Convert.ToInt32(char.Parse(strCardInfo.Substring(0, 1))), 16) + strCardInfo.Substring(1, strCardInfo.Length - 1)).PadRight(32, 'F');

                string strSub;
                if (strCardInfo.Length == 9)
                {
                    strSub = Convert.ToString(Convert.ToInt32(char.Parse(strCardInfo.Substring(0, 1))), 16) + strCardInfo.Substring(1, strCardInfo.Length - 1);
                }
                strSub = strCardInfo.PadRight(32, 'F');

                string        strPhoneSub   = "FFFFFFFFFFFFFFFF";
                List <string> listPhoneWait = new List <string>();
                for (int i = 0; i < 4; i++)
                {
                    listPhoneWait.Add(strPhoneSub);
                }
                for (int i = 0; i < listPhoneNum.Count; i++)
                {
                    listPhoneWait[i] = listPhoneNum[i].PadLeft(12, '0').PadRight(16, 'F');
                }
                strSub += listPhoneWait[0] + listPhoneWait[1] + listPhoneWait[2] + listPhoneWait[3];
                bool res = JocatDevice.WriteCard(iPort, dicSection[bSection][0].ToString(), 3, strSub);
                if (!res)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(true);
        }
Example #16
0
        /// <summary>
        /// 设置指定卡扇区密码
        /// </summary>
        /// <param name="p_intSector">扇区号</param>
        /// <param name="p_strPassword">密码</param>
        /// <returns></returns>
        public override bool SetCardPassword(int p_intSector, string p_strPassword)
        {
            bool res = false;

            YuChuanDevice.rf_beep(_iBeepInterval);

            try
            {
                if (string.IsNullOrEmpty(p_strPassword))
                {
                    return(res);
                }
                if (p_strPassword.Length != 12)
                {
                    return(res);
                }

                byte[] arrNewPwd = YuChuanDevice.ChangeStrToHex(p_strPassword);

                if (!ReadCardsPrepare((byte)p_intSector))
                {
                    return(false);
                }

                List <byte> listNewPwd = new List <byte>();
                listNewPwd.AddRange(arrNewPwd);
                listNewPwd.AddRange(YuChuanDevice.bCardContentTemplate);

                Dictionary <byte, List <byte> > dicSP = EquipmentGeneral.GetCardSectionPieceList();
                int iPwdPieceNum = dicSP[(byte)p_intSector][3];
                int iResWrite    = YuChuanDevice.rf_write((byte)iPwdPieceNum, listNewPwd.ToArray());
                if (iResWrite == 0)
                {
                    res = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            YuChuanDevice.rf_beep(_iBeepInterval);
            return(res);
        }
Example #17
0
        public override bool SetWatermeterAdminCard(int port, string paymentPassword, int eachTimeMaxinumNumber, int dailyMaxinumNumber, decimal unitPrice)
        {
            byte bSection  = 2;
            bool isSccess  = false;
            byte bPieceOne = EquipmentGeneral.GetCardSectionPieceList()[bSection][1];
            byte bPieceTwo = EquipmentGeneral.GetCardSectionPieceList()[bSection][2];

            string l_strEachAmount = EquipmentGeneral.IntToHexInSorting(eachTimeMaxinumNumber, 4);
            string l_strMaxAmount  = EquipmentGeneral.IntToHexInSorting(dailyMaxinumNumber, 4);

            decimal fUPrice        = unitPrice * 100;
            int     uPrice         = Convert.ToInt32(fUPrice);
            string  l_strUnitPrice = EquipmentGeneral.IntToHexInSorting(uPrice, 4);

            string l_strWaterInfo = paymentPassword + l_strEachAmount + l_strMaxAmount + l_strUnitPrice + "FFFF";

            l_strWaterInfo = l_strWaterInfo + DataConvert.GetCRC16Code(l_strWaterInfo);

            if (l_strWaterInfo.Length != 32)
            {
                return(false);
            }

            if (!ReadCardsPrepare(bSection))
            {
                return(false);
            }
            byte[] arrData = YuChuanDevice.ChangeStrToHex(l_strWaterInfo);
            int    iRes    = YuChuanDevice.rf_write(bPieceOne, arrData);

            if (!ReadCardsPrepare(bSection))
            {
                return(false);
            }
            iRes = YuChuanDevice.rf_write(bPieceTwo, arrData);

            if (iRes == 0)
            {
                isSccess = true;
            }

            return(isSccess);
        }
Example #18
0
        /// <summary>
        /// 获取消费金额
        /// </summary>
        /// <param name="iPort">COM口号</param>
        /// <param name="iSection">扇区号</param>
        /// <returns></returns>
        public static decimal GetPosVal(int iPort, byte bSection)
        {
            decimal dMoney = 0.00M;

            try
            {
                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();
                string strReturn = ReadCard(iPort, dicSection[bSection][0].ToString(), 1);
                if (strReturn.Length != 32)
                {
                    return(0.00M);
                }
                dMoney = EquipmentGeneral.HexMoneyToDouble(strReturn.Substring(0, 8));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dMoney);
        }
Example #19
0
        /// <summary>
        /// 设置亲情号码资料
        /// </summary>
        /// <param name="p_strPhoneInfo">亲情号码卡信息</param>
        /// <param name="p_lisPhones">亲情号码</param>
        /// <returns></returns>
        public bool WriteFamilyPhones(string p_strPhoneInfo, List <string> p_lisPhones)
        {
            byte bSection = 10;
            Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();
            string l_strPhoneInfo = p_strPhoneInfo + "FFFFFFFFFFFFFFFFFFFFFF";

            string l_strPhoneNo1 = FormatPhoneNo(p_lisPhones[0], p_lisPhones[1]);
            string l_strPhoneNo2 = FormatPhoneNo(p_lisPhones[2], p_lisPhones[3]);

            if (l_strPhoneInfo.Length != 32)
            {
                throw new Exception("亲情号码卡信息格式不正确。");
            }

            if ((l_strPhoneNo1 + l_strPhoneNo2).Length != 64)
            {
                throw new Exception("亲情号码格式不正确。");
            }

            return(JocatDevice.WriteCard(m_intComPort, dicSection[bSection][0].ToString(), 3, l_strPhoneInfo + l_strPhoneNo1 + l_strPhoneNo2));
        }
Example #20
0
        /// <summary>
        /// 设置水表管理卡
        /// </summary>
        /// <param name="watermeterPassword">水表消费密码</param>
        /// <param name="amountInEach">单次用水限额</param>
        /// <param name="amountInDay">日用水限额</param>
        /// <param name="unitPrice">每升价格</param>
        /// <returns></returns>
        public override bool SetWatermeterAdminCard(int port, string paymentPassword, int eachTimeMaxinumNumber, int dailyMaxinumNumber, decimal unitPrice)
        {
            byte   bSection = 2;
            bool   isSccess = false;
            string strPiece = EquipmentGeneral.GetCardSectionPieceList()[bSection][1].ToString();

            string l_strEachAmount = EquipmentGeneral.IntToHexInSorting(eachTimeMaxinumNumber, 4);
            string l_strMaxAmount  = EquipmentGeneral.IntToHexInSorting(dailyMaxinumNumber, 4);

            decimal fUPrice        = unitPrice * 100;
            int     uPrice         = Convert.ToInt32(fUPrice);
            string  l_strUnitPrice = EquipmentGeneral.IntToHexInSorting(uPrice, 4);

            string l_strWaterInfo = paymentPassword + l_strEachAmount + l_strMaxAmount + l_strUnitPrice + "FFFF";

            l_strWaterInfo = l_strWaterInfo + DataConvert.GetCRC16Code(l_strWaterInfo);

            isSccess = JocatDevice.WriteCard(port, strPiece, 2, l_strWaterInfo + l_strWaterInfo);

            return(isSccess);
        }
Example #21
0
        public override decimal GetSubzVal()
        {
            decimal dSubzVal = 0.00M;
            byte    bSection = 2;

            try
            {
                if (!ReadCardsPrepare(bSection))
                {
                    return(0);
                }

                YuChuanDevice.rf_beep(_iBeepInterval);

                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();

                byte[] arrData  = new byte[16];
                int    iResRead = YuChuanDevice.rf_read(dicSection[bSection][0], arrData);
                if (iResRead != 0)
                {
                    //读数失败
                    return(0);
                }
                string strPiece = YuChuanDevice.ChangeHexToString(arrData);
                if (strPiece.Length != 32)
                {
                    //读取块数据不完整,不足32位
                    return(0);
                }

                dSubzVal = EquipmentGeneral.HexMoneyToDouble(strPiece.Substring(0, 8));
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(dSubzVal);
        }
Example #22
0
        /// <summary>
        /// 读卡资料
        /// </summary>
        /// <returns></returns>
        public override PaymentCard ReadCard()
        {
            try
            {
                byte bSection      = 0;
                var  l_objCardInfo = JocatDevice.ReadCard(m_intComPort, EquipmentGeneral.GetCardSectionPieceList()[bSection][0], this._strWriterPwd);

                //List<string> l_lisPhones = new List<string>();
                //string l_strPhoneInfo = "";

                //ReadFamilyPhones(out l_strPhoneInfo, out l_lisPhones);

                //l_objCardInfo.FamilyPhoneInfo = l_strPhoneInfo;
                //l_objCardInfo.FamilyPhoneNum = l_lisPhones;

                return(l_objCardInfo);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
Example #23
0
        /// <summary>
        /// 读取亲情电话信息
        /// </summary>
        /// <param name="p_strPhineInfo"></param>
        /// <param name="p_lisPhones"></param>
        private void ReadFamilyPhones(out string p_strPhineInfo, out List <string> p_lisPhones)
        {
            p_strPhineInfo = "";
            p_lisPhones    = new List <string>();
            byte bSection = 10;
            Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();

            try
            {
                string l_strPhoneInfo = JocatDevice.ReadCard(m_intComPort, dicSection[bSection][0].ToString(), 3);

                p_strPhineInfo = ((char)Convert.ToByte(l_strPhoneInfo.Substring(0, 2), 16)).ToString() + l_strPhoneInfo.Substring(2, 8);

                p_lisPhones.Add(CollapsePhoneNo(l_strPhoneInfo.Substring(32, 16).Replace("F", "")));
                p_lisPhones.Add(CollapsePhoneNo(l_strPhoneInfo.Substring(48, 16).Replace("F", "")));
                p_lisPhones.Add(CollapsePhoneNo(l_strPhoneInfo.Substring(64, 16).Replace("F", "")));
                p_lisPhones.Add(CollapsePhoneNo(l_strPhoneInfo.Substring(80, 16).Replace("F", "")));
            }
            catch
            {
                throw new Exception("读取亲情号码信息失败。");
            }
        }
Example #24
0
        public override bool WriteInitUserBasicInfo(PaymentCard payCard)
        {
            YuChuanDevice.rf_beep(_iBeepInterval);
            byte bSection = 3;

            try
            {
                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();
                string strPieceData = string.Empty;

                #region 初始化第1块信息数据

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                //卡号
                string strCardNo = EquipmentGeneral.IntToHex(payCard.No, 4);
                strCardNo = strCardNo.Substring(2, 2) + strCardNo.Substring(0, 2);
                //状态值
                string strState = payCard.Valid ? "80" : "00";
                //注销时间
                string strRegDate = payCard.ExpiryDate.Value.ToString("yyMMdd");
                //功能
                string strFunc = string.Empty;
                if (payCard.FunctionCode.Length == 16)
                {
                    strFunc = EquipmentGeneral.BinToHex(payCard.FunctionCode).PadLeft(4, '0');
                }
                else if (payCard.FunctionCode.Length == 4)
                {
                    strFunc = payCard.FunctionCode;
                }
                else
                {
                    strFunc = string.Empty.PadRight(4, '0');
                }

                //姓名
                string strName = EquipmentGeneral.StrToHex(payCard.Name).PadRight(16, '0');

                strPieceData = strCardNo + strState + strRegDate + strFunc + strName;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                byte[] arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                int    iRes    = YuChuanDevice.rf_write(dicSection[bSection][1], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                #region 初始化第2块信息数据

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                //卡内最低余额
                string strMinVal = EquipmentGeneral.IntToHex((int)(payCard.LimitRemainder * 100), 8);
                //每日最大消费额
                string strMaxPosVal = EquipmentGeneral.IntToHex((int)(payCard.DailyMaxPayment * 100), 8);
                //时段限次消费次数
                string strIntervalCount = EquipmentGeneral.IntToHex(payCard.Span1PaymentCount, 2) + EquipmentGeneral.IntToHex(payCard.Span2PaymentCount, 2) + EquipmentGeneral.IntToHex(payCard.Span3PaymentCount, 2) + EquipmentGeneral.IntToHex(payCard.Span4PaymentCount, 2);
                //卡片类型
                string strType = EquipmentGeneral.IntToHex(Convert.ToInt32(char.Parse(payCard.Type)), 2);

                strPieceData = strMinVal + payCard.PaymentPassword + strMaxPosVal + strIntervalCount + strType;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSection[bSection][2], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }

            YuChuanDevice.rf_beep(_iBeepInterval);
            return(true);
        }
Example #25
0
        public override bool WriteInitPosVal(decimal dMoney)
        {
            YuChuanDevice.rf_beep(_iBeepInterval);
            byte bSection;

            try
            {
                bSection = 4;
                Dictionary <byte, List <byte> > dicSect = EquipmentGeneral.GetCardSectionPieceList();

                #region 写入初始消费金额数据

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                //卡内金额
                string strCardVal = EquipmentGeneral.IntToHex((int)(dMoney * 100), 8).PadRight(8, '0');
                strCardVal = strCardVal.Substring(6, 2) + strCardVal.Substring(4, 2) + strCardVal.Substring(2, 2) + strCardVal.Substring(0, 2);

                //卡内金额反码
                string strComplement = EquipmentGeneral.GetComplement(strCardVal);

                string strPieceData = strCardVal + strComplement + strCardVal + this._strPosValCRC;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                byte[] arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                int    iRes    = YuChuanDevice.rf_write(dicSect[bSection][0], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                #region 写入备份消费金额数据

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                strPieceData = strCardVal + strComplement + strCardVal + this._strPosValCRC;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][1], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                bSection = 5;

                #region 写入初始消费金额数据(备份扇区)

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                strPieceData = strCardVal + strComplement + strCardVal + this._strPosValBakCRC;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][0], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                #region 写入备份消费金额数据(备份扇区)

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                strPieceData = strCardVal + strComplement + strCardVal + this._strPosValBakCRC;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][1], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                bSection = 6;

                #region 写入消费记录初始数据(0号位置)

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                strPieceData = DateTime.Now.AddDays(-1).ToString("yyMMdd01");
                strPieceData = strPieceData.PadLeft(24, '0').PadRight(32, '0');
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][0], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                #region 写入消费记录初始数据(1号位置)

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][1], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                #region 写入消费记录初始数据(2号位置)

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                string strPieceDataTmp = string.Empty.PadLeft(30, '0') + "AA";
                arrData = YuChuanDevice.ChangeStrToHex(strPieceDataTmp);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][2], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion


                bSection = 7;

                #region 写入备份消费记录初始数据(0号位置)

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][0], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                #region 写入备份消费记录初始数据(1号位置)

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][1], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                #region 写入备份消费记录初始数据(2号位置)

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceDataTmp);
                iRes    = YuChuanDevice.rf_write(dicSect[bSection][2], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
            YuChuanDevice.rf_beep(_iBeepInterval);
            return(true);
        }
Example #26
0
        public override PaymentCard GetUserBasicInfos()
        {
            PaymentCard payCard  = new PaymentCard();
            byte        bSection = 3;

            try
            {
                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();

                string strPwdTemp = this._strSectionPwd;
                this._strSectionPwd = string.Empty.PadRight(12, 'F');
                payCard.MACID       = GetMacID();
                this._strSectionPwd = strPwdTemp;

                #region 读第1块

                if (!ReadCardsPrepare(bSection))
                {
                    return(null);
                }

                byte[] arrData  = new byte[16];
                int    iResRead = YuChuanDevice.rf_read(dicSection[bSection][1], arrData);
                if (iResRead != 0)
                {
                    //读数失败
                    return(null);
                }
                string strPiece1 = YuChuanDevice.ChangeHexToString(arrData);
                if (strPiece1.Length != 32)
                {
                    //读取到的块数据不完整,不足32位
                    return(null);
                }

                #endregion

                #region 读第2块

                if (!ReadCardsPrepare(bSection))
                {
                    return(null);
                }

                arrData  = new byte[16];
                iResRead = YuChuanDevice.rf_read(dicSection[bSection][2], arrData);
                if (iResRead != 0)
                {
                    //读数失败
                    return(null);
                }
                string strPiece2 = YuChuanDevice.ChangeHexToString(arrData);
                if (strPiece2.Length != 32)
                {
                    //读取块数据不完整,不足32位
                    return(null);
                }

                #endregion

                #region 解释第一块数据

                string strPieceData = strPiece1;

                //出厂ID
                payCard.MACID = GetMacID();

                //卡号
                string strHexCardNo = strPieceData.Substring(2, 1) + strPieceData.Substring(3, 1) + strPieceData.Substring(0, 1) + strPieceData.Substring(1, 1);
                payCard.No = Convert.ToInt32(strHexCardNo, 16);

                //状态
                payCard.Valid = strPieceData.Substring(4, 2) == "80" ? true : false;

                //注册时间
                try
                {
                    payCard.ExpiryDate = DateTime.ParseExact(strPieceData.Substring(6, 6), "yyMMdd", null);
                }
                catch (Exception EX)
                {
                    payCard.ExpiryDate = null;
                }

                //系统功能
                payCard.FunctionCode = Convert.ToString(Convert.ToInt32(strPieceData.Substring(12, 4), 16), 2).PadLeft(16, '0');

                //卡片所有人姓名
                payCard.Name = EquipmentGeneral.HexToStr(strPieceData.Substring(16, 16));

                #endregion

                #region 解释第二块数据

                strPieceData = strPiece2;

                //最低余额
                payCard.LimitRemainder = (decimal)(Convert.ToInt32(strPieceData.Substring(0, 8), 16) / 100.00M);

                //消费密码
                payCard.PaymentPassword = strPieceData.Substring(8, 6);

                //每天最大消费额
                payCard.DailyMaxPayment = (decimal)(Convert.ToInt32(strPieceData.Substring(14, 8), 16) / 100.00M);

                //时段消费次数
                payCard.Span1PaymentCount = Convert.ToInt32(strPieceData.Substring(22, 2), 16);
                payCard.Span2PaymentCount = Convert.ToInt32(strPieceData.Substring(24, 2), 16);
                payCard.Span3PaymentCount = Convert.ToInt32(strPieceData.Substring(26, 2), 16);
                payCard.Span4PaymentCount = Convert.ToInt32(strPieceData.Substring(28, 2), 16);

                //卡类型
                payCard.Type = ((char)Convert.ToByte(strPieceData.Substring(30, 2), 16)).ToString();

                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(payCard);
        }
Example #27
0
        public override List <string> GetPhoneNumList()
        {
            List <string> listPhones = new List <string>();
            byte          bSection   = 10;

            try
            {
                YuChuanDevice.rf_beep(_iBeepInterval);
                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();

                if (!ReadCardsPrepare(bSection))
                {
                    return(null);
                }

                byte[] arrData  = new byte[16];
                int    iResRead = YuChuanDevice.rf_read(dicSection[bSection][0], arrData);
                if (iResRead != 0)
                {
                    //读数失败
                    return(null);
                }
                string strPiece = YuChuanDevice.ChangeHexToString(arrData);
                if (strPiece.Length != 32)
                {
                    //读取块数据不完整,不足32位
                    return(null);
                }
                strPiece = strPiece.ToUpper().TrimEnd('F');
                strPiece = Convert.ToChar(Convert.ToInt32(strPiece.Substring(0, 2), 16)).ToString() + strPiece.Substring(2, strPiece.Length - 2);
                listPhones.Add(strPiece);

                string strEmpty = string.Empty;
                strEmpty = strEmpty.PadRight(16, '0');
                for (int i = 0; i < 2; i++)
                {
                    if (!ReadCardsPrepare(bSection))
                    {
                        return(null);
                    }

                    arrData  = new byte[16];
                    iResRead = YuChuanDevice.rf_read(dicSection[bSection][i + 1], arrData);
                    if (iResRead != 0)
                    {
                        //读数失败
                        return(null);
                    }
                    strPiece = YuChuanDevice.ChangeHexToString(arrData);
                    if (strPiece.Length != 32)
                    {
                        //读取块数据不完整,不足32位
                        return(null);
                    }

                    string strPhoneOneTmp = strPiece.Substring(0, 16);
                    string strPhoneTwoTmp = strPiece.Substring(16, 16);
                    if (strPhoneOneTmp != strEmpty)
                    {
                        string strPhoneOne = GetPhoneNum(strPhoneOneTmp);
                        if (!string.IsNullOrEmpty(strPhoneOne) && strPhoneOne.Substring(0, 1) != "1" && strPhoneOne.Length != 7 && strPhoneOne.Length != 8)
                        {
                            strPhoneOne = "0" + strPhoneOne;
                        }
                        listPhones.Add(strPhoneOne);
                    }
                    if (strPhoneTwoTmp != strEmpty)
                    {
                        string strPhoneTwo = GetPhoneNum(strPhoneTwoTmp);
                        if (!string.IsNullOrEmpty(strPhoneTwo) && strPhoneTwo.Substring(0, 1) != "1" && strPhoneTwo.Length != 7 && strPhoneTwo.Length != 8)
                        {
                            strPhoneTwo = "0" + strPhoneTwo;
                        }
                        listPhones.Add(strPhoneTwo);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(listPhones);
        }
Example #28
0
        /// <summary>
        /// 解读优卡特消费机水表可读数据格式
        /// </summary>
        /// <param name="dicPieceData"></param>
        /// <param name="payCard"></param>
        /// <returns></returns>
        private ReturnValueInfo DecodeJocatUserInfo(Dictionary <int, string> dicPieceData, ref PaymentCard payCard)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();

            try
            {
                #region 解释第一块数据

                string strPieceData = dicPieceData[1];

                //出厂ID
                payCard.MACID = GetMacID();

                //卡号
                string strHexCardNo = strPieceData.Substring(2, 1) + strPieceData.Substring(3, 1) + strPieceData.Substring(0, 1) + strPieceData.Substring(1, 1);
                payCard.No = Convert.ToInt32(strHexCardNo, 16);

                //状态
                payCard.Valid = strPieceData.Substring(4, 2) == "80" ? true : false;

                //注册时间
                payCard.ExpiryDate = DateTime.ParseExact(strPieceData.Substring(6, 6), "yyMMdd", null);

                //系统功能
                payCard.FunctionCode = Convert.ToString(Convert.ToInt32(strPieceData.Substring(12, 4), 16), 2).PadLeft(16, '0');

                //卡片所有人姓名
                payCard.Name = EquipmentGeneral.HexToStr(strPieceData.Substring(16, 16));

                #endregion

                #region 解释第二块数据

                strPieceData = dicPieceData[2];

                //最低余额
                payCard.LimitRemainder = (decimal)(Convert.ToInt32(strPieceData.Substring(0, 8), 16) / 100.00M);

                //消费密码
                payCard.PaymentPassword = strPieceData.Substring(8, 6);

                //每天最大消费额
                payCard.DailyMaxPayment = (decimal)(Convert.ToInt32(strPieceData.Substring(14, 8), 16) / 100.00M);

                //时段消费次数
                payCard.Span1PaymentCount = Convert.ToInt32(strPieceData.Substring(22, 2), 16);
                payCard.Span2PaymentCount = Convert.ToInt32(strPieceData.Substring(24, 2), 16);
                payCard.Span3PaymentCount = Convert.ToInt32(strPieceData.Substring(26, 2), 16);
                payCard.Span4PaymentCount = Convert.ToInt32(strPieceData.Substring(28, 2), 16);

                //卡类型
                payCard.Type = ((char)Convert.ToByte(strPieceData.Substring(30, 2), 16)).ToString();
                #endregion

                #region 解释第四块数据

                strPieceData = dicPieceData[4];

                payCard.Money = EquipmentGeneral.HexMoneyToDouble(strPieceData.Substring(0, 8));

                #endregion

                #region 解释第五块数据

                strPieceData = dicPieceData[5];

                payCard.MoneyBackup = EquipmentGeneral.HexMoneyToDouble(strPieceData.Substring(0, 8));

                #endregion

                #region 解释第六块数据

                payCard.MachineList += dicPieceData[6];

                #endregion

                #region 解释第八块数据

                strPieceData = dicPieceData[8];

                payCard.Subsidize = EquipmentGeneral.HexMoneyToDouble(strPieceData.Substring(0, 8));

                #endregion

                #region 解释第九块数据

                strPieceData = dicPieceData[9];

                payCard.SubsidizeBackup = EquipmentGeneral.HexMoneyToDouble(strPieceData.Substring(0, 8));

                #endregion

                #region 解释第十块数据

                payCard.MachineList += dicPieceData[10];

                #endregion
            }
            catch (Exception ex)
            {
                rvInfo.isError     = true;
                rvInfo.messageText = ex.Message;
            }

            return(rvInfo);
        }
Example #29
0
        public override bool RechargeSubsidize(decimal p_dMoney)
        {
            try
            {
                byte bSection = 2;
                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();

                #region 读第1块

                if (!ReadCardsPrepare((bSection)))
                {
                    return(false);
                }

                byte[] arrData  = new byte[16];
                int    iResRead = YuChuanDevice.rf_read(dicSection[bSection][0], arrData);
                if (iResRead != 0)
                {
                    //读数失败
                    return(false);
                }
                string strPiece8 = YuChuanDevice.ChangeHexToString(arrData);
                if (strPiece8.Length != 32)
                {
                    //读取块数据不完整,不足32位
                    return(false);
                }
                decimal dMoney = EquipmentGeneral.HexMoneyToDouble(strPiece8.Substring(0, 8));

                #endregion

                dMoney = dMoney + p_dMoney;

                #region 写入第1块数据

                if (!ReadCardsPrepare((bSection)))
                {
                    return(false);
                }

                //水控金额
                string strCardVal = EquipmentGeneral.IntToHex((int)(dMoney * 100), 8).PadRight(8, '0');
                strCardVal = strCardVal.Substring(6, 2) + strCardVal.Substring(4, 2) + strCardVal.Substring(2, 2) + strCardVal.Substring(0, 2);

                //水控金额反码
                string strComplement = EquipmentGeneral.GetComplement(strCardVal);

                string strPieceData = strCardVal + strComplement + strCardVal + this._strSubValCRC;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                int iRes = YuChuanDevice.rf_write(dicSection[bSection][0], arrData);
                if (iRes == 0)
                {
                    YuChuanDevice.rf_beep(_iBeepInterval);
                }
                else
                {
                    return(false);
                }

                #endregion

                #region 读第2块

                if (!ReadCardsPrepare((bSection)))
                {
                    return(false);
                }

                arrData  = new byte[16];
                iResRead = YuChuanDevice.rf_read(dicSection[bSection][1], arrData);
                if (iResRead != 0)
                {
                    //读数失败
                    return(false);
                }
                string strPiece9 = YuChuanDevice.ChangeHexToString(arrData);
                if (strPiece9.Length != 32)
                {
                    //读取块数据不完整,不足32位
                    return(false);
                }
                dMoney = EquipmentGeneral.HexMoneyToDouble(strPiece9.Substring(0, 8));

                #endregion

                dMoney = dMoney + p_dMoney;

                #region 写入第2块数据

                if (!ReadCardsPrepare((bSection)))
                {
                    return(false);
                }

                //水控备份金额
                string strCardBakVal = EquipmentGeneral.IntToHex((int)(dMoney * 100), 8).PadRight(8, '0');
                strCardBakVal = strCardBakVal.Substring(6, 2) + strCardBakVal.Substring(4, 2) + strCardBakVal.Substring(2, 2) + strCardBakVal.Substring(0, 2);

                //水控备份金额反码
                string strBakComplement = EquipmentGeneral.GetComplement(strCardBakVal);

                strPieceData = strCardBakVal + strBakComplement + strCardBakVal + this._strSubValBakCRC;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPieceData);
                iRes    = YuChuanDevice.rf_write(dicSection[bSection][1], arrData);
                if (iRes == 0)
                {
                    YuChuanDevice.rf_beep(_iBeepInterval);
                }
                else
                {
                    return(false);
                }

                #endregion
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Example #30
0
        public override bool WriteInitContactPhone(string strContactInfo, List <string> listPhoneNums)
        {
            YuChuanDevice.rf_beep(_iBeepInterval);
            byte bSection;

            try
            {
                bSection = 10;
                Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList();

                //strContactInfo = Convert.ToString(Convert.ToInt32(char.Parse(strContactInfo.Substring(0, 1))), 16) + strContactInfo.Substring(1, strContactInfo.Length - 1);
                if (string.IsNullOrEmpty(strContactInfo))
                {
                    return(false);
                }

                string strPhoneInfo;
                if (strContactInfo.Length == 9)
                {
                    strContactInfo = Convert.ToString(Convert.ToInt32(char.Parse(strContactInfo.Substring(0, 1))), 16) + strContactInfo.Substring(1, strContactInfo.Length - 1);
                }
                strPhoneInfo = strContactInfo.PadRight(32, 'F');


                #region 初始化卡显示信息

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                byte[] arrData = YuChuanDevice.ChangeStrToHex(strPhoneInfo);
                int    iRes    = YuChuanDevice.rf_write(dicSection[bSection][0], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                string        strPhoneSub   = string.Empty.PadLeft(12, 'F');
                List <string> listPhoneWait = new List <string>();
                for (int i = 0; i < 4; i++)
                {
                    listPhoneWait.Add(strPhoneSub);
                }
                for (int i = 0; i < listPhoneNums.Count; i++)
                {
                    listPhoneWait[i] = listPhoneNums[i].PadLeft(12, '0').PadRight(16, 'F');
                }
                string strPhoneListOne = listPhoneWait[0] + listPhoneWait[1];
                string strPhoneListTwo = listPhoneWait[2] + listPhoneWait[3];

                #region 初始化第一批电话列表

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPhoneListOne);
                iRes    = YuChuanDevice.rf_write(dicSection[bSection][1], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion

                #region 初始化第二批电话列表

                if (!ReadCardsPrepare(bSection))
                {
                    return(false);
                }

                arrData = YuChuanDevice.ChangeStrToHex(strPhoneListTwo);
                iRes    = YuChuanDevice.rf_write(dicSection[bSection][2], arrData);
                if (iRes != 0)
                {
                    return(false);
                }

                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }

            YuChuanDevice.rf_beep(_iBeepInterval);
            return(true);
        }