Beispiel #1
0
 public void HandleCardMessage(Device.CardReader device, string cardid)
 {
     try
     {
         if (this.CheckCardID(cardid))
         {
             this.card = this.IC.GetCard(cardid);
             if (this.card.CardNo == string.Empty)
             {
                 MessageBox.Show("此卡还没有注册!");
                 this.card = null;
             }
             else if (this.card.Status != 0)
             {
                 MessageBox.Show("卡[" + this.card.CardNo + "]当前状态不允许发卡!");
                 this.card = null;
             }
             else
             {
                 this.txt_icno_new.Text = this.card.CardNo;
             }
         }
     }
     catch (Exception)
     {
     }
 }
        /// <summary>
        /// 使用明进康刷卡器时,由物理卡号查询用户信息
        /// </summary>
        /// <param name="code"></param>
        /// <param name="isPhysc"></param>
        /// <returns></returns>
        public ActionResult FindCardOfGUI(string iccode, bool isPhysc)
        {
            CWICCard cwiccd = new CWICCard();
            ICCard   iccd   = null;

            if (isPhysc)
            {
                iccd = cwiccd.Find(ic => ic.PhysicCode == iccode);
            }
            else
            {
                iccd = cwiccd.Find(ic => ic.UserCode == iccode);
            }
            if (iccd == null)
            {
                iccd = new ICCard();
                if (isPhysc)
                {
                    //如果查找不到该卡号,则查询下存车指纹库内,是否有,有的话,其编号多少
                    SaveCertificate scert = new CWSaveProof().Find(s => s.Proof == iccode);
                    if (scert != null)
                    {
                        iccd.PhysicCode = iccode;
                        iccd.UserCode   = scert.SNO.ToString();
                        iccd.Status     = EnmICCardStatus.Init;
                        iccd.CreateDate = DateTime.Parse("2017-1-1");
                        iccd.LossDate   = DateTime.Parse("2017-1-1");
                        iccd.LogoutDate = DateTime.Parse("2017-1-1");
                    }
                }
            }
            return(Json(iccd, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        /// <summary>
        /// 获取应用密文
        /// </summary>
        /// <param name="card">卡片信息</param>
        /// <returns></returns>
        public void GENERATEARQC(ICCard card, string transactionType = TransactionType.Pay)
        {
            PublicStaticData.TransactionType = TransactionType.Pay;
            Random random = new Random();

            PublicStaticData.RadomData = CodeConvert.ToHexString(new byte[] { (byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256) });
            card.RadomData             = PublicStaticData.RadomData;
            StringBuilder cdol1Builder = new StringBuilder();

            card.CDOL1.ToList().ForEach(cdo => cdol1Builder.Append(PublicStaticData.CDOL1[cdo]));
            cdol1Builder.Insert(0, (cdol1Builder.Length / 2).ToString("x2"));
            APDUEntity entity = new APDUEntity("80", "AE", "80", "00", cdol1Builder.ToString());
            string     arqc   = CardReader.SendAPDU(entity.ToString());

            List <TLVEntity> entityList = TLVHelper.ToTLVEntityList(arqc);

            if (entityList.Count == 0)
            {
                throw new CardReadException("获取应用密文(ARQC)失败");
            }
            TLVEntity arqcEntity = entityList[0];

            card.CID            = arqcEntity.Value[0].ToString("x2");                                               //密文信息 L:1
            card.ATC            = CodeConvert.ToHexString(new byte[] { arqcEntity.Value[1], arqcEntity.Value[2] }); //ATC 应用交易计数器 L:2
            card.AC             = CodeConvert.ToHexString(arqcEntity.Value.Take(11).Skip(3).ToArray());             //AC应用密文 L:8
            card.IssBankAppData = CodeConvert.ToHexString(arqcEntity.Value.Skip(11).ToArray());                     //发卡行应用数据
        }
Beispiel #4
0
        /// <summary>
        /// 获取处理选项
        /// </summary>
        /// <param name="card"></param>
        public void GPO(ICCard card)
        {
            StringBuilder body    = new StringBuilder();
            List <string> gpoList = new List <string>();

            if (card.GPOL == null || card.GPOL.Count == 0)
            {
                throw new CardReadException("未读取到处理选项列表");
            }
            gpoList = card.GPOL.ToList();
            gpoList.ForEach(pdo => body.Append(PublicStaticData.PDOL[pdo]));
            body.Insert(0, (body.Length / 2).ToString("x2"));
            body.Insert(0, "83");
            body.Insert(0, (body.Length / 2).ToString("x2"));
            APDUEntity       GPO     = new APDUEntity("80", "A8", "00", "00", body.ToString());
            string           result  = CardReader.SendAPDU(GPO.ToString());
            List <TLVEntity> tlvList = TLVHelper.ToTLVEntityList(result);
            TLVEntity        entity  = null;

            if (tlvList != null && tlvList.Count > 0)
            {
                entity = tlvList[0];
            }
            card.AIP = CodeConvert.ToHexString(entity.Value.Take(2).ToArray());//前两位是AIP
            List <string> afl = new List <string>();

            for (int i = 2; i < entity.Value.Length; i = i + 4)
            {
                afl.Add(CodeConvert.ToHexString(entity.Value.Take(i + 4).Skip(i).ToArray()));
            }
            card.AFL = afl;
        }
Beispiel #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.curbill != null)
     {
         if (this.card == null)
         {
             MessageBox.Show("请放好IC卡!");
         }
         else
         {
             string billNo = this.curbill.BillNo;
             int    ictype = this.curbill.ISZLK ? 5 : 4;
             string iD     = LocalInfo.Current.user.ID;
             string code   = FrmMain.localinfo.workpoint.Code;
             if (this.iccardmanageservice.OperCardAssign(this.card.ICNo, ictype, billNo, iD, code) == -1)
             {
                 MessageBox.Show("数据库操作失败!请重新尝试!");
             }
             else
             {
                 MessageBox.Show("发卡成功!请取走IC卡!");
                 this.InitFrm();
                 this.bills         = null;
                 this.curbill       = null;
                 this.card          = null;
                 this.textBox6.Text = "";
                 this.textBox8.Text = "";
                 this.textBox8.Focus();
             }
         }
     }
 }
Beispiel #6
0
 private void btn_ok_Click(object sender, EventArgs e)
 {
     if ((this.FYD != null) && (this.card != null))
     {
         if (this.IC.ISFixVeh(this.FYD.vehno))
         {
             MessageBox.Show("固定车辆请做多次卡车辆发卡单进行补卡!");
         }
         else
         {
             try
             {
                 string code = FrmMain.localinfo.workpoint.Code;
                 string iD   = LocalInfo.Current.user.ID;
                 VehIC_WF.CommonService.Result result = this.cs.UpdateFYDBillCard(this.FYD.billno, this.card.ICNo, code, iD);
                 if (!result.Flag)
                 {
                     MessageBox.Show(result.Desc);
                 }
                 else
                 {
                     MessageBox.Show("补卡成功!");
                     this.card = null;
                     this.FYD  = null;
                     this.InitForm();
                 }
             }
             catch (Exception)
             {
                 MessageBox.Show("数据异常,请重试!");
             }
         }
     }
 }
Beispiel #7
0
 public FrmRFCancel(RFFYD fyd, ICCard TempCard)
 {
     this.InitializeComponent();
     this.fyd          = fyd;
     this.card         = TempCard;
     base.DialogResult = DialogResult.Cancel;
 }
Beispiel #8
0
        public IcController(ICCard pICCard, bool pCanReadCard)
        {
            this._canReadCard = pCanReadCard;
            this._icCardCfg   = pICCard;
            TimerCallback callback = new TimerCallback(this.Alarm);

            this._readCardNoTimer = new Timer(callback, null, -1, int.Parse(this._icCardCfg.Interval));
        }
Beispiel #9
0
        public ActionResult Edit(int ID)
        {
            CustomerModel model  = new CustomerModel();
            CWICCard      cwiccd = new CWICCard();
            Customer      cust   = cwiccd.FindCust(ID);

            model.ID            = cust.ID;
            model.UserName      = cust.UserName;
            model.FamilyAddress = cust.FamilyAddress;
            model.MobilePhone   = cust.MobilePhone;
            model.PlateNum      = cust.PlateNum;
            model.Type          = cust.Type;
            model.Warehouse     = cust.Warehouse;
            model.LocAddress    = cust.LocAddress;
            model.Deadline      = cust.Deadline.ToString();

            ICCard iccd = cwiccd.Find(ic => ic.CustID == ID);

            if (iccd != null)
            {
                model.UserCode = iccd.UserCode;
                model.Status   = iccd.Status;
            }

            List <SelectListItem> items = new List <SelectListItem>();

            foreach (var tp in Enum.GetValues(typeof(EnmICCardType)))
            {
                SelectListItem item = new SelectListItem()
                {
                    Text = tp.ToString(), Value = tp.ToString()
                };
                items.Add(item);
            }
            ViewData["list"] = items;

            #region 查找指纹
            List <FingerPrint> printList = new CWFingerPrint().FindList(p => p.CustID == ID);
            if (printList.Count == 1)
            {
                model.FingerPrint1 = printList[0].SN_Number.ToString();
            }
            if (printList.Count == 2)
            {
                model.FingerPrint1 = printList[0].SN_Number.ToString();
                model.FingerPrint2 = printList[1].SN_Number.ToString();
            }
            if (printList.Count == 3)
            {
                model.FingerPrint1 = printList[0].SN_Number.ToString();
                model.FingerPrint2 = printList[1].SN_Number.ToString();
                model.FingerPrint3 = printList[2].SN_Number.ToString();
            }
            #endregion

            return(View(model));
        }
Beispiel #10
0
 public void InitView()
 {
     this.card                     = null;
     this.txt_billno.Text          = string.Empty;
     this.txt_icno.Text            = string.Empty;
     this.txt_vehno.Text           = string.Empty;
     this.cb_vehtype.SelectedIndex = -1;
     this.txt_vendor.Text          = string.Empty;
     this.chbox_fixveh.Checked     = false;
 }
Beispiel #11
0
        public void ViewNoticeBill()
        {
            if (this.curnotice != null)
            {
                this.txt_billno.Text     = this.curnotice.billno;
                this.txt_billstatus.Text = Common.GetNoticeStatusDesc(this.curnotice.status);
                this.txt_billtype.Text   = this.curnotice.billtypedesc;
                this.txt_fkr.Text        = this.curnotice.fkr;
                this.txt_fksj.Text       = this.curnotice.fksj;
                ICCard card = this.IC.GetCard(this.curnotice.icno);
                this.txt_icno.Text    = card.CardNo;
                this.txt_vehno.Text   = this.curnotice.vehno;
                this.txt_vehtype.Text = this.curnotice.vehtype;
                this.txt_remark.Text  = this.curnotice.Remark;
                this.treeList1.Nodes.Clear();
                this.chbox_fixveh.Checked    = this.curnotice.vehisfix;
                this.chbox_needweigh.Checked = this.curnotice.needweigh;
                this.rb_wzlx_in.Checked      = this.curnotice.wzlx == "0";
                this.rb_wzlx_out.Checked     = this.curnotice.wzlx == "1";
                if (this.curnotice.Items != null)
                {
                    this.treeList1.Nodes.Clear();
                    for (int i = 0; i < this.curnotice.Items.Length; i++)
                    {
                        NBItem item       = this.curnotice.Items[i];
                        string str        = string.Empty;
                        int    imageIndex = 1;
                        switch (item.status)
                        {
                        case 0:
                            str = "初始";
                            if (!item.Available)
                            {
                                imageIndex = 3;
                            }
                            break;

                        case 1:
                            str        = "开始";
                            imageIndex = 2;
                            break;

                        case 2:
                            str        = "完成";
                            imageIndex = 0;
                            break;
                        }
                        object[] nodeData = new object[] { item.rowno, item.invcode, item.invname, item.spectypegraphid, item.unit, item.plannum, item.planassistnum, item.factnum, item.factassistnum, str, item.remark };
                        this.treeList1.AppendNode(nodeData, -1, imageIndex, imageIndex, imageIndex);
                    }
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// 获取应用标识符
        /// </summary>
        /// <returns></returns>
        public void GetAID(ICCard card)
        {
            string           result  = CardReader.SendAPDU(APDUCommand.GETDATA);
            List <TLVEntity> tlvList = TLVHelper.ToTLVEntityList(result);
            var entity = TLVHelper.GetValueByTag(tlvList, EMVTag.AID);

            if (entity == null)
            {
                throw new CardReadException("获取不到卡片的应用标识符!");
            }
            card.AID = CodeConvert.ToHexString(entity.Value);
        }
Beispiel #13
0
        /// <summary>
        /// IC卡读取
        /// </summary>
        /// <param name="icCard"></param>
        private void Read(ICCard icCard)
        {
            ICCardHotReset();
            ICCardReader reader = new ICCardReader(this);

            reader.SelectPaySystem();
            reader.GetAID(icCard);
            reader.GetPDOL(icCard);
            reader.GPO(icCard);          //应用初始化
            reader.GetData(icCard);      //卡片数据读取
            reader.GENERATEARQC(icCard); //生成应用密文
        }
Beispiel #14
0
        /// <summary>
        /// 获取处理选项数据对象列表(PDOL)
        /// </summary>
        /// <returns></returns>
        public void GetPDOL(ICCard card)
        {
            string           aid     = card.AID;
            APDUEntity       apdu    = new APDUEntity("00", APDU_INS.SELECT, "04", "00", string.Format("{0}{1}", (aid.Length / 2).ToString("x2"), aid));
            string           result  = CardReader.SendAPDU(apdu.ToString());
            List <TLVEntity> tlvList = TLVHelper.ToTLVEntityList(result);
            var entity = TLVHelper.GetValueByTag(tlvList, EMVTag.PDOL);

            if (entity == null)
            {
                throw new CardReadException("获取不到卡片的处理选项数据对象列表!");
            }
            card.GPOL = CodeConvert.ToTLStringList(entity.Value);
        }
Beispiel #15
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.curbill != null)
         {
             if (this.card == null)
             {
                 MessageBox.Show("请放好IC卡!");
             }
             else
             {
                 string   iCNo    = this.card.ICNo;
                 string   vehID   = this.curbill.VehID;
                 bool     flag    = this.iccardmanageservice.ISExistTaskOfVehNo(vehID) > 0;
                 string[] vehinfo = new string[] { this.curbill.VehID, this.curbill.VehType, this.curbill.ISMulti ? "1" : "0" };
                 int      ictype  = this.curbill.ISMulti ? 2 : 3;
                 string   iD      = LocalInfo.Current.user.ID;
                 string   billNo  = this.curbill.BillNo;
                 string   dept    = this.curbill.Dept;
                 string   code    = FrmMain.localinfo.workpoint.Code;
                 if (this.iccardmanageservice.FixVehCardAssign(iCNo, ictype, iD, billNo, vehinfo, dept, code) == -1)
                 {
                     MessageBox.Show("数据库操作失败!请重新尝试!");
                 }
                 else
                 {
                     if (this.curbill.ISMulti && flag)
                     {
                         MessageBox.Show("发卡成功,请取走卡!\r\n已经将未执行作业单完成绑定!");
                     }
                     else
                     {
                         MessageBox.Show("发卡成功,请取走卡!");
                     }
                     this.curbill        = null;
                     this.card           = null;
                     this.textBox18.Text = string.Empty;
                     this.InitView();
                     this.txt_vehno.Text = "";
                     this.txt_vehno.Focus();
                 }
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("数据处理异常!" + exception.ToString());
     }
 }
Beispiel #16
0
        public byte[] Query(string terminalNo, string pinBlock, CreditCard creditCard)
        {
            ICCard Card = creditCard as ICCard;

            if (Card == null)
            {
                throw new ArgumentException("无效的卡片");
            }
            Bitmap map = new Bitmap();

            map[2]                              =
                map[3]                          =
                    map[11]                     =
                        map[22]                 =
                            map[25]             =
                                map[26]         =
                                    map[35]     =
                                        map[41] = map[42] = map[49] = map[52] = map[53] = map[60] = map[64] = true;
            Iso8583 iso8583 = new Iso8583(map);

            iso8583[2].FieldLenIndicator.Content = (Card.CardNo.Length / 2).ToString();
            iso8583[2].Content  = Card.CardNo;
            iso8583[3].Content  = "310000";
            iso8583[11].Content = Settings.SysTraceNum;
            iso8583[22].Content = "021";
            iso8583[25].Content = "00";
            iso8583[26].Content = "06";
            iso8583[35].FieldLenIndicator.Content = (Card.Msg2.Length / 2).ToString();
            iso8583[35].Content = Card.Msg2;
            iso8583[41].Content = terminalNo;
            iso8583[42].Content = Settings.MerchantCode;
            iso8583[49].Content = "156";
            iso8583[52].Content = pinBlock;

            iso8583[53].Content = "26";
            iso8583[60].FieldLenIndicator.Content = "011";
            iso8583[60].Content = "00003010003";
            iso8583[64].Content = "1111111111111111";

            Message msg = new Message(iso8583);

            msg.TPDU.Content        = Settings.TPDU;
            msg.MessageHead.Content = Settings.MsgHead;
            msg.MessageType.Content = "0200";
            StringBuilder mac = new StringBuilder();

            byte[] subMsg = msg.Pack();
            return(subMsg);
        }
Beispiel #17
0
 private void listBox1_DoubleClick(object sender, EventArgs e)
 {
     if (this.listBox1.SelectedIndex != -1)
     {
         this.txt_vehno.Text           = this.listBox1.Text;
         this.listBox1.Visible         = false;
         this.txt_vehno.SelectionStart = this.txt_vehno.Text.Length;
         this.txt_vehno.Focus();
         if (!this.GetBillInfo())
         {
             this.card = null;
             this.InitForm();
         }
     }
 }
Beispiel #18
0
 /// <summary>
 /// 异步读卡
 /// </summary>
 /// <returns></returns>
 private Task <ICCard> ReadICCardAsync(string ipaddrs)
 {
     return(Task <ICCard> .Factory.StartNew(() => {
         ICCard iccd = new ICCard {
             PhysicCode = "0", UserCode = ""
         };
         #region
         if (string.IsNullOrEmpty(ipaddrs))
         {
             return iccd;
         }
         Log log = LogFactory.GetLogger("ReadICCardAsync");
         try
         {
             IPAddress ip;
             if (!IPAddress.TryParse(ipaddrs, out ip))
             {
                 return iccd;
             }
             ICCardReader reader = new ICCardReader(ipaddrs);
             bool nback = reader.Connect();
             if (nback)
             {
                 uint physic = 0;
                 int ret = reader.GetPhyscard(ref physic);
                 if (ret == 0)
                 {
                     string physc = physic.ToString();
                     iccd.PhysicCode = physc;
                     ICCard ccd = new CWICCard().Find(ic => ic.PhysicCode == physc);
                     if (ccd != null)
                     {
                         iccd.UserCode = ccd.UserCode;
                     }
                 }
             }
             reader.Disconnect();
         }
         catch (Exception ex)
         {
             log.Error(ex.ToString());
         }
         #endregion
         return iccd;
     }));
 }
Beispiel #19
0
        private void txt_vehno_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyValue)
            {
            case 13:
                this.listBox1.Visible = false;
                if (!this.GetNoticeBill())
                {
                    this.card = null;
                    this.InitForm();
                    this.InitMember();
                }
                return;

            case 0x1b:
                if (this.listBox1.Visible)
                {
                    this.listBox1.Visible = false;
                    this.txt_vehno.Focus();
                }
                return;

            case 0x20:
                this.listBox1.Visible = false;
                return;

            case 40:
                if (this.listBox1.Visible)
                {
                    this.listBox1.Focus();
                    this.listBox1.SetSelected(0, true);
                }
                return;
            }
            string vehnoex = this.txt_vehno.Text.Trim();

            if ((vehnoex != "") && (vehnoex.Length > 1))
            {
                this.listBox1.Items.Clear();
                this.listBox1.Visible = this.FillListView(vehnoex);
            }
            else
            {
                this.listBox1.Visible = false;
            }
        }
Beispiel #20
0
        public ActionResult Delete(int ID)
        {
            #region
            CWICCard cwiccd = new CWICCard();
            Customer cust   = cwiccd.FindCust(ID);
            if (cust != null)
            {
                ICCard iccd = cwiccd.Find(ic => ic.CustID == ID);
                if (iccd != null)
                {
                    iccd.CustID = 0;
                    Response _resp = cwiccd.Update(iccd);
                    if (_resp.Code == 0)
                    {
                        //记录
                    }
                }
                Response resp = cwiccd.Delete(ID);
                if (resp.Code == 0)
                {
                    var data = new
                    {
                        code    = 1,
                        message = "删除用户失败,请联系管理员!"
                    };
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }

                #region  除相关指纹
                CWFingerPrint      fprint    = new CWFingerPrint();
                List <FingerPrint> fingerLst = fprint.FindList(p => p.CustID == ID);
                foreach (FingerPrint print in fingerLst)
                {
                    fprint.Delete(print.ID);
                }
                #endregion
            }
            #endregion
            var nback = new
            {
                code    = 2,
                message = "删除成功!"
            };
            return(Json(nback, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 新增一条记录
        /// </summary>
        /// <param name="qcRecord">质检实体</param>
        /// <returns></returns>
        public static bool InsertOneICCard(ICCard qcICCard)
        {
            bool rbool = true;
            using (DCCarManagementDataContext db = new DCCarManagementDataContext())
            {
                try
                {
                    rbool = LinQBaseDao.InsertOne(db, qcICCard);
                }
                catch
                {
                    rbool = false;
                }
                finally { db.Connection.Close(); }

            }
            return rbool;
        }
Beispiel #22
0
        /// <summary>
        /// 读卡
        /// </summary>
        public void ReadCreditCard()
        {
            if (CardContainer.Count == 0)
            {
                return;
            }
            //卡机内有卡进行读卡操作
            string cardType = GetCardType();

            if (cardType.Equals(CardType.NoCard))
            {
                throw new ApplicationException("卡机内无卡或卡片无法识别!");
            }
            if (cardType.Equals(CardType.CPU_T_0)
                ||
                cardType.Equals(CardType.CPU_T_1)
                ||
                cardType.Equals(CardType.CPU_TYPE_A)
                ||
                cardType.Equals(CardType.CPU_TYPE_B)
                )
            {//IC卡操作
                ICCard creditCard = new ICCard();
                Read(creditCard);
                this.CardContainer[0] = creditCard;
                //缓存卡片数据
                this.CacheCard = new CreditCardCacheData()
                {
                    CardNo = creditCard.CardNo, Msg2 = creditCard.Msg2
                };
            }
            else
            {//磁卡操作
                MagCard creditCard = new MagCard();
                Read(creditCard);
                this.CardContainer[0] = creditCard;
                //缓存卡片数据
                this.CacheCard = new CreditCardCacheData()
                {
                    CardNo = creditCard.CardNo, Msg2 = creditCard.Msg2
                };
            }
        }
Beispiel #23
0
        /// <summary>
        /// 获取所有应用文件的数据
        /// </summary>
        /// <param name="card">卡片</param>
        /// <returns></returns>
        public List <TLVEntity> GetData(ICCard card)
        {
            List <TLVEntity> tlvList  = new List <TLVEntity>();
            List <string>    dataList = new List <string>();

            card.AFL.ToList().ForEach(af => GetDataBySF(dataList, af));
            foreach (string data in dataList)
            {
                tlvList.AddRange(TLVHelper.ToTLVEntityList(data));
            }
            //card.AppFileDataList = tlvList;
            //卡号
            card.CardNo = CodeConvert.ToHexString(TLVHelper.GetValueByTag(tlvList, EMVTag.PAN).Value).Replace("F", "");
            //序列号 858323域使用
            card.PANSerialNum = CodeConvert.ToHexString(TLVHelper.GetValueByTag(tlvList, EMVTag.PANSerialNum).Value);
            card.AppVersionNo = CodeConvert.ToHexString(TLVHelper.GetValueByTag(tlvList, EMVTag.AppVersionNo).Value); //应用版本号
            string msg2 = CodeConvert.ToHexString(TLVHelper.GetValueByTag(tlvList, EMVTag.Msg2).Value);               //等价2磁道数据

            msg2 = msg2.ToUpper().Replace("D", "=");                                                                  //有些银行为对为D的情况做处理
            if (msg2.EndsWith("F"))
            {
                msg2 = msg2.Substring(0, msg2.Length - 1);
            }
            if (msg2.StartsWith(card.CardNo + "="))
            {
                string dateString = msg2.Split('=')[1].Substring(0, 4);
                dateString         = string.Format("{0}-{1}-{2}", "20" + dateString.Substring(0, 2), dateString.Substring(2, 2), "01");
                card.EffectiveDate = Convert.ToDateTime(dateString);
            }
            card.Msg2 = msg2;//等价2磁道数据
            //卡风险管理数据对象列表1 用于获取应用密文
            card.CDOL1 = CodeConvert.ToTLStringList(TLVHelper.GetValueByTag(tlvList, EMVTag.CDOL1).Value);
            card.CDOL2 = CodeConvert.ToTLStringList(TLVHelper.GetValueByTag(tlvList, EMVTag.CDOL2).Value);
            var proid = TLVHelper.GetValueByTag(tlvList, EMVTag.ProductId);

            if (proid != null)
            {
                card.ProductId = CodeConvert.ToHexString(proid.Value);
            }
            return(tlvList);
        }
Beispiel #24
0
 public void HandleCardMessage(Device.CardReader device, string cardid)
 {
     if (this.CheckCardID(cardid))
     {
         this.card = this.iccardmanageservice.GetCard(cardid);
         if (this.card.CardNo == string.Empty)
         {
             MessageBox.Show("此卡还没有注册!");
             this.card = null;
         }
         else if (this.card.Status != 0)
         {
             MessageBox.Show("卡" + this.card.CardNo + "当前状态不允许发卡!");
             this.card = null;
         }
         else
         {
             this.textBox18.Text = this.card.CardNo;
         }
     }
 }
Beispiel #25
0
        private void listBox1_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyValue)
            {
            case 13:
                this.txt_vehno.Text           = this.listBox1.Text;
                this.listBox1.Visible         = false;
                this.txt_vehno.SelectionStart = this.txt_vehno.Text.Length;
                this.txt_vehno.Focus();
                if (!this.GetBillInfo())
                {
                    this.card = null;
                    this.InitForm();
                }
                break;

            case 0x1b:
                this.listBox1.Visible = false;
                this.txt_vehno.Focus();
                break;
            }
        }
Beispiel #26
0
        public ActionResult HandleCard(string iccode, int type)
        {
            CWICCard cwiccd = new CWICCard();
            ICCard   iccd   = cwiccd.Find(ic => ic.UserCode == iccode);

            if (iccd == null)
            {
                var data = new Response
                {
                    Code    = 0,
                    Message = "找不到该卡"
                };
                return(Json(data));
            }
            switch (type)
            {
            case 1:
                iccd.Status   = EnmICCardStatus.Lost;
                iccd.LossDate = DateTime.Now;
                break;

            case 2:
                iccd.Status   = EnmICCardStatus.Normal;
                iccd.LossDate = DateTime.Parse("2017-1-1");
                break;

            case 3:
                iccd.Status     = EnmICCardStatus.Disposed;
                iccd.LogoutDate = DateTime.Now;
                break;

            default:
                break;
            }
            Response resp = cwiccd.Update(iccd);

            return(Json(resp));
        }
Beispiel #27
0
        /// <summary>
        /// 创建实例
        /// 如果遇到多个卡,其中有的是相同的品牌,一个程序集不能加载两次
        /// </summary>
        /// <returns></returns>
        private IIcController CreateInstance(ICCard pICCardConfig)
        {
            IIcController io = null;

            try
            {
                string driverPath = System.AppDomain.CurrentDomain.BaseDirectory;
                driverPath = Path.Combine(driverPath, pICCardConfig.Driver);
                //修改开始 20181120
                Assembly assembly = null;
                if (loadedAssmbly.ContainsKey(driverPath))
                {
                    assembly = loadedAssmbly[driverPath];
                }
                else
                {
                    assembly = Assembly.LoadFile(driverPath);
                }

                //修改介绍  下面一句被注释掉
                // Assembly assembly = Assembly.LoadFile(driverPath);

                string name = assembly.FullName.Split(',')[0] + ".IcController";
                Type   type = assembly.GetType(name);
                IcCardReaderLogger.Debug(string.Format("载入硬件封装模块!DLL={0}", driverPath));
                io = Activator.CreateInstance(type, pICCardConfig, _canReadData) as IIcController;
                IcCardReaderLogger.Debug("创建IC读卡器实例成功!");
                //添加到数据字典
                loadedAssmbly.Add(driverPath, assembly);
            }
            catch (Exception ex)
            {
                IcCardReaderLogger.Error("创建IC读卡器实例失败!原因:" + ex.Message);
                throw ex;
            }
            return(io);//
        }
Beispiel #28
0
        public byte[] CancelPay(byte[] preMsg, CreditCard creditCard, string posSerialNo)
        {
            ICCard Card = creditCard as ICCard;

            if (Card == null)
            {
                throw new ArgumentException("无效的卡片");
            }
            Iso8583 pre_iso8583 = new Iso8583();
            Message pre_Msg     = new Message(pre_iso8583);

            pre_Msg.Unpack(preMsg);

            string[] extendData        = posSerialNo.Split(',');
            string   posserialNo       = extendData[0];
            string   AuthorizationCode = extendData.Length > 1 ? extendData[1] : null;
            string   preSysTraceNum    = pre_iso8583[11].Content;

            if (Settings.SysTraceNum.Equals(preSysTraceNum))
            {
                Settings.SysTraceNum = (Convert.ToInt32(Settings.SysTraceNum) + 1).ToString();
            }
            Bitmap map = new Bitmap();

            map[3]                                                                          =
                map[4]                                                                      =
                    map[11]                                                                 =
                        map[14]                                                             =
                            map[22]                                                         =
                                map[23]                                                     =
                                    map[25]                                                 =
                                        map[26]                                             =
                                            map[35]                                         =
                                                map[37]                                     =
                                                    map[41]                                 =
                                                        map[42]                             =
                                                            map[49]                         =
                                                                map[52]                     =
                                                                    map[53]                 =
                                                                        map[55]             =
                                                                            map[60]         =
                                                                                map[61]     =
                                                                                    map[64] = true;
            if (!string.IsNullOrEmpty(AuthorizationCode))
            {
                map[38] = true;
            }
            Iso8583 iso8583 = new Iso8583(map);

            iso8583[3].Content  = "200000";
            iso8583[4].Content  = pre_iso8583[4].Content;
            iso8583[11].Content = Settings.SysTraceNum;
            iso8583[14].Content = Card.EffectiveDate.ToString("yyMM");//有效日期
            iso8583[22].Content = pre_iso8583[22].Content;
            iso8583[23].Content = pre_iso8583[23].Content;
            iso8583[25].Content = pre_iso8583[25].Content;
            iso8583[26].Content = pre_iso8583[26].Content;
            iso8583[35].FieldLenIndicator.Content = Card.Msg2.Length.ToString();
            iso8583[35].Content = Card.Msg2;
            iso8583[37].Content = posserialNo;
            if (!string.IsNullOrEmpty(AuthorizationCode))
            {
                iso8583[38].Content = AuthorizationCode;
            }
            iso8583[41].Content = pre_iso8583[41].Content;
            iso8583[42].Content = pre_iso8583[42].Content;
            iso8583[49].Content = pre_iso8583[49].Content;
            iso8583[52].Content = pre_iso8583[52].Content;
            iso8583[53].Content = pre_iso8583[53].Content;
            iso8583[55].Content = string.Format("9F3602{0}", Card.ATC);
            iso8583[55].FieldLenIndicator.Content = string.Format("{0:000}", (iso8583[55].Content.Length / 2));
            iso8583[60].FieldLenIndicator.Content = "013";
            iso8583[60].Content = string.Format("23{0}00050", Settings.BatchNo);
            iso8583[61].FieldLenIndicator.Content = "012";
            iso8583[61].Content = string.Format("{0}{1}", Settings.BatchNo, preSysTraceNum);
            iso8583[64].Content = "1111111111111111";
            Message msg = new Message(iso8583);

            msg.TPDU.Content        = Settings.TPDU;
            msg.MessageHead.Content = Settings.MsgHead;
            msg.MessageType.Content = "0200";
            StringBuilder mac = new StringBuilder();

            byte[] subMsg = msg.Pack();
            return(subMsg);
        }
Beispiel #29
0
        public byte[] Pay(string terminalNo, string PayMoney, string pinBlock, CreditCard creditCard)
        {
            ICCard Card = creditCard as ICCard;

            if (Card == null)
            {
                throw new ArgumentException("无效的卡片");
            }
            Bitmap map = new Bitmap();

            map[2]                                                                      =
                map[3]                                                                  =
                    map[4]                                                              =
                        map[11]                                                         =
                            map[14]                                                     =
                                map[22]                                                 =
                                    map[23]                                             =
                                        map[25]                                         =
                                            map[26]                                     =
                                                map[35]                                 =
                                                    map[41]                             =
                                                        map[42]                         =
                                                            map[49]                     =
                                                                map[52]                 =
                                                                    map[53]             =
                                                                        map[55]         =
                                                                            map[60]     =
                                                                                map[64] = true;
            Iso8583 iso8583 = new Iso8583(map);

            iso8583[2].FieldLenIndicator.Content = Card.CardNo.Length.ToString();
            iso8583[2].Content  = Card.CardNo;
            iso8583[3].Content  = "000000";
            iso8583[4].Content  = PayMoney;
            iso8583[11].Content = Settings.SysTraceNum;

            iso8583[14].Content = Card.EffectiveDate.ToString("yyMM"); //有效日期
            iso8583[22].Content = "051";                               //IC卡支付
            iso8583[23].Content = Card.PANSerialNum.PadLeft(4, '0');
            iso8583[25].Content = "00";
            iso8583[26].Content = "06";
            iso8583[35].FieldLenIndicator.Content = Card.Msg2.Length.ToString();
            iso8583[35].Content = Card.Msg2;
            iso8583[41].Content = terminalNo;
            iso8583[42].Content = Settings.MerchantCode;
            iso8583[49].Content = "156";
            iso8583[52].Content = pinBlock;
            iso8583[53].Content = "26";
            iso8583[55].Content = Card.BuildPart55Data(terminalNo, TransactionType.Pay, PayMoney, Settings.SysTraceNum);
            iso8583[55].FieldLenIndicator.Content = string.Format("{0:000}", (iso8583[55].Content.Length / 2));
            iso8583[60].FieldLenIndicator.Content = "019";
            iso8583[60].Content = string.Format("22{0}00050000000", Settings.BatchNo);
            iso8583[64].Content = "1111111111111111";
            Message msg = new Message(iso8583);

            msg.TPDU.Content        = Settings.TPDU;
            msg.MessageHead.Content = Settings.MsgHead;
            msg.MessageType.Content = "0200";
            StringBuilder mac = new StringBuilder();

            byte[] subMsg = msg.Pack();
            return(subMsg);
        }
Beispiel #30
0
 private void InitMember()
 {
     this.curnotice = null;
     this.card      = null;
 }