Пример #1
0
 private void Cancle()
 {
     pwdBLL.closeKey();
     Util.JumpUtil.jumpMainPage();
     this.Dispatcher.Invoke(new Action(() => { Util.JumpUtil.jumpMainPage(); }));
     return;
 }
Пример #2
0
 private void readCard()
 {
     try
     {
         Thread.Sleep(1500);
         //等待用户插卡
         MachCardBLL.waitCard();
     }
     catch (ThreadAbortException ae) { log.Write("error:" + ae.Message); }
     catch (Exception ex)
     {
         log.Write("error:插卡页readCard():" + ex.Message);
     }
     while (true)
     {
         try
         {
             Thread.Sleep(700);
             //卡机内是否有卡
             if (!MachCardBLL.CardUsable())
             {
                 continue;
             }
             PrintInfo("正在读卡,请稍后...");
             Thread.Sleep(1500);
         }
         catch (ThreadAbortException ae) { log.Write("error:" + ae.Message); }
         catch (Exception ex)
         {
             log.Write("error:插卡页readCard():" + ex.Message);
         }
         try
         {
             //签到
             PayAccess.ReadSign();
             string wtNo = wt.GetCardNo();
             if (wtNo != null)
             {
                 if (wtNo.Length == 16)
                 {
                     if (SysBLL.payCostType == 3)
                     {
                         //退卡
                         MachCardBLL.backCard();
                         //等待用户插卡
                         MachCardBLL.waitCard();
                         PrintInfo("暂不支持此卡,请取卡");
                         return;
                     }
                     else
                     {
                         SysBLL.payCardType = 1;
                         SysBLL.payCardNo   = wtNo;
                         if (!pwdBLL.SetCryptMode(1))
                         {
                             throw new Exception("系统异常,请稍后再试...");                        //万通卡加密方式
                         }
                         pwdBLL.closeKey();
                         //pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", wtNo);
                         if (!setPayParam(wtNo, null, wtNo))
                         {
                             //PrintInfo("业务异常,请稍后再试...");
                             //退卡
                             MachCardBLL.backCard();
                             //等待用户插卡
                             MachCardBLL.waitCard();
                             return;
                         }
                         ;
                         SysBLL.payTypeName = "甘肃一卡通";
                         WintopStatusInfo statusInfo = new WintopAccess().queryCardStatus(wtNo);
                         if ((statusInfo.msgrsp.WTSTATE == null) || (statusInfo.msgrsp.WTSTATE.Equals("")))
                         {
                             PrintInfo("业务正忙,请稍后再试");
                             //退卡
                             MachCardBLL.backCard();
                             //等待用户插卡
                             MachCardBLL.waitCard();
                             return;
                         }
                         if ("01".Equals(statusInfo.msgrsp.WTSTATE))
                         {
                             //执行下一步操作
                             this.Dispatcher.Invoke(new Action(() => { Util.JumpUtil.jumpCommonPage("FormInputPassword"); }));
                             return;
                         }
                         else
                         {
                             PrintInfo("该卡已挂失,无法正常使用");
                             //退卡
                             MachCardBLL.backCard();
                             //等待用户插卡
                             MachCardBLL.waitCard();
                             return;
                         }
                     }
                 }
             }
             dictionary = null;
             //银行卡
             dictionary = BankBLL.ReadBankCard();
             SysBLL.IcBankDictionary = dictionary;
             //if (SysBLL.payCostType == 3)
             //{
             SysBLL.payCardType = 0;
             SysBLL.payCardNo   = dictionary["cardNo"];
             if (!pwdBLL.SetCryptMode(0))
             {
                 throw new Exception("系统异常,请稍后再试...");                         //拉卡拉加密方式
             }
             pwdBLL.closeKey();
             //pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", dictionary["cardNo"]);
             //if (!setPayParam("", dictionary, dictionary["cardNo"])) throw new Exception("查询失败");
             if (!setPayParam("", dictionary, dictionary["cardNo"]))
             {
                 return;
             }
             ;
             SysBLL.payTypeName = "银行卡";
             this.Dispatcher.Invoke(new Action(() => { Util.JumpUtil.jumpCommonPage("FormInputPassword"); }));
             return;
             //}
             //else
             //{
             //    //退卡
             //    MachCardBLL.backCard();
             //    //等待用户插卡
             //    MachCardBLL.waitCard();
             //    PrintInfo("暂不支持此卡,请取卡");
             //}
         }
         catch (ThreadAbortException ae)
         {
             log.Write("error:读卡失败:" + ae.Message);
             return;
         }catch (WtException we)
         {
             log.Write("error:读卡异常");
             PrintInfo("读取失败");
             //退卡
             MachCardBLL.backCard();
             //等待用户插卡
             MachCardBLL.waitCard();
         }
         catch (Exception ex)
         {
             log.Write("error:读卡异常:" + ex.Message);
             PrintInfo("读取失败");
             //退卡
             MachCardBLL.backCard();
             //等待用户插卡
             MachCardBLL.waitCard();
         }
         finally
         {
             //btnOkBg.Enabled = true;
         }
     }
 }
Пример #3
0
        public static Boolean Sign(int type, string mackeyExpress, string pinKeyExpress)
        {
            PasswordBLL pwdBLL = new PasswordBLL();

            //bool ret = pwdBLL.OpenDevice(SysConfigHelper.readerNode("ZT598Port"), "9600");
            //if (!ret)
            //{
            //    return false;
            //}
            try
            {
                bool setMode = true;
                if (type == 0)
                {
                    setMode = pwdBLL.SetCryptMode(0);
                    log.Write("设置加密模式返回:" + setMode);
                    if (!setMode)
                    {
                        return(false);
                    }
                    //激活万通主密钥

                    /* if (!pwdBLL.ActivWorkKey(0, 0))
                     * {
                     *   return false;
                     * }*/
                    log.Write("下载工作秘钥");
                    bool pingSuccess = pwdBLL.DownloadWorkKey(0, 0, pinKeyExpress);
                    if (!pingSuccess)
                    {
                        return(false);
                    }
                    bool macSuccess = pwdBLL.DownloadWorkKey(0, 1, mackeyExpress);
                    if (!macSuccess)
                    {
                        return(false);
                    }
                    SysBLL.RebuildBatchNo();
                }
                else if (type == 1)
                {
                    setMode = pwdBLL.SetCryptMode(1);
                    log.Write("设置加密模式返回:" + setMode);
                    if (!setMode)
                    {
                        return(false);
                    }
                    //激活万通主密钥

                    /*if(!pwdBLL.ActivWorkKey(1, 0))
                     * {
                     *  return false;
                     * }*/
                    log.Write("开始下载工作秘钥" + ",pinKeyExpress:" + pinKeyExpress);
                    bool pingSuccess = pwdBLL.DownloadWorkKey(1, 2, pinKeyExpress);
                    log.Write("下载工作秘钥返回::" + pingSuccess + ",pinKeyExpress:" + pinKeyExpress);
                    if (!pingSuccess)
                    {
                        return(false);
                    }
                    log.Write("开始下载工作秘钥" + ",mackeyExpress:" + mackeyExpress);
                    bool macSuccess = pwdBLL.DownloadWorkKey(1, 3, mackeyExpress);
                    log.Write("下载工作秘钥返回::" + macSuccess + ",mackeyExpress:" + mackeyExpress);
                    if (!macSuccess)
                    {
                        return(false);
                    }
                }
                pwdBLL.closeKey();
                return(true);
            }
            catch (Exception ex) { log.Write("error:Sign():" + ex.Message + ex.InnerException); return(false); }
        }