Com.Aote.ObjectTools.GeneralICCard.ReadCard C# (CSharp) Method

ReadCard() public method

读卡
public ReadCard ( ) : void
return void
        public void ReadCard()
        {
            IsBusy = true;
            Error = "";
            State = State.StartLoad;
            //卡上信息初始化
            CardId = "";
            Factory = "";
            Gas = 0;
            BuyTimes = 0;
            Klx = -1;
            Kzt = -1;
            Dqdm = "";
            Yhh = "";
            Tm = "";
            Ljgql = 0;
            Bkcs = 0;
            Ljyql = 0;
            Syql = 0;
            Bjql = 0;
            Czsx = 0;
            Tzed = 0;
            Sqrq = "";
            //读卡
            Thread thread = new Thread(() =>
            {
                dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
                AutomationFactory.GetEvent(ocx, "ReadGasCard");
                int openRen = ocx.ReadGasCard();
                //IsBusy=false;
                if (this.Dispatcher.CheckAccess())
                {
                    IsBusy = false;
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        IsBusy = false;
                    });
                }
                if (openRen == 0)
                {
                    //获取卡上内容
                    AutomationFactory.GetEvent(ocx, "GetCardId");
                    string cardId = ocx.GetCardId();
                    AutomationFactory.GetEvent(ocx, "GetFactory");
                    string factory = ocx.GetFactory();
                    AutomationFactory.GetEvent(ocx, "GetGas");
                    double gas = ocx.GetGas();
                    AutomationFactory.GetEvent(ocx, "GetTimes");
                    int buyTimes = ocx.GetTimes();
                    AutomationFactory.GetEvent(ocx, "GetKlx");
                    int klx = ocx.GetKlx();
                    AutomationFactory.GetEvent(ocx, "GetKzt");
                    int kzt = ocx.GetKzt();
                    AutomationFactory.GetEvent(ocx, "GetDqdm");
                    string dqdm = ocx.GetDqdm();
                    AutomationFactory.GetEvent(ocx, "GetYhh");
                    string yhh = ocx.GetYhh();
                    AutomationFactory.GetEvent(ocx, "GetTm");
                    string tm = ocx.GetTm();
                    AutomationFactory.GetEvent(ocx, "GetLjgql");
                    double ljgql = ocx.GetLjgql();
                    AutomationFactory.GetEvent(ocx, "GetBkcs");
                    int bkcs = ocx.GetBkcs();
                    AutomationFactory.GetEvent(ocx, "GetLjyql");
                    double ljyql = ocx.GetLjyql();
                    AutomationFactory.GetEvent(ocx, "GetSyql");
                    double syql = ocx.GetSyql();
                    AutomationFactory.GetEvent(ocx, "GetBjql");
                    int bjql = ocx.GetBjql();
                    AutomationFactory.GetEvent(ocx, "GetCzsx");
                    int czsx = ocx.GetCzsx();
                    AutomationFactory.GetEvent(ocx, "GetTzed");
                    int tzed = ocx.GetTzed();
                    AutomationFactory.GetEvent(ocx, "GetSqrq");
                    string sqrq = ocx.GetSqrq();
                    //直接赋值
                    if (this.Dispatcher.CheckAccess())
                    {
                        CardId = cardId;
                        Factory = factory;
                        Gas = gas;
                        BuyTimes = buyTimes;
                        Klx = klx;
                        Kzt = kzt;
                        Dqdm = dqdm;
                        Yhh = yhh;
                        Tm = tm;
                        Ljgql = ljgql;
                        Bkcs = bkcs;
                        Ljyql = ljyql;
                        Syql = syql;
                        Bjql = bjql;
                        Czsx = czsx;
                        Tzed = tzed;
                        Sqrq = sqrq;
                        State = State.Loaded;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            CardId = cardId;
                            Factory = factory;
                            Gas = gas;
                            BuyTimes = buyTimes;
                            Klx = klx;
                            Kzt = kzt;
                            Dqdm = dqdm;
                            Yhh = yhh;
                            Tm = tm;
                            Ljgql = ljgql;
                            Bkcs = bkcs;
                            Ljyql = ljyql;
                            Syql = syql;
                            Bjql = bjql;
                            Czsx = czsx;
                            Tzed = tzed;
                            Sqrq = sqrq;
                            State = State.Loaded;
                        });
                    }
                }
                else
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        Error = "读卡错误!错误代码" + openRen;
                        State = State.LoadError;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            Error = "读卡错误!错误代码" + openRen;
                            State = State.LoadError;
                        });
                    }
                }
                if (this.Dispatcher.CheckAccess())
                {
                    OnReadCompleted(null);
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        OnReadCompleted(null);
                    });
                }
            });
            thread.Start();
        }
        #endregion