Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public override bool WriteInitSubzVal(decimal dMoney)
        {
            Dictionary <byte, List <byte> > dicSect = EquipmentGeneral.GetCardSectionPieceList();
            byte bSection = 2;

            YuChuanDevice.rf_beep(_iBeepInterval);

            try
            {
                #region 写入初始水控金额数据

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

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

                //水控金额反码
                string strSubComplement = EquipmentGeneral.GetComplement(strSubVal);

                string strPieceData = strSubVal + strSubComplement + strSubVal + this._strSubValCRC;
                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 = strSubVal + strSubComplement + strSubVal + this._strSubValBakCRC;
                if (strPieceData.Length != 32)
                {
                    return(false);
                }

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

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

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