Com.Aote.ObjectTools.GeneralICCard.MakeNewCard C# (CSharp) Méthode

MakeNewCard() public méthode

public MakeNewCard ( ) : void
Résultat void
        public void MakeNewCard()
        {
            IsBusy = true;
            Error = "";
            State = State.Start;
            //执行写卡线程
            Thread thread = new Thread(() =>
            {
                dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
                AutomationFactory.GetEvent(ocx, "ReadGasCard");
                int openRen = ocx.ReadGasCard();
                //读卡失败
                if (openRen != 0)
                {
                    if (this.Dispatcher.CheckAccess())
                    {
                        Error = "擦卡不成功!错误代码" + openRen;
                        State = State.Error;
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            Error = "擦卡不成功!错误代码" + openRen;
                            State = State.Error;
                        });
                    }
                }
                else
                {
                    //获取擦卡所需数据
                    AutomationFactory.GetEvent(ocx, "GetCardId");
                    string _cardId = ocx.GetCardId();
                    AutomationFactory.GetEvent(ocx, "GetFactory");
                    string _factory = ocx.GetFactory();
                    AutomationFactory.GetEvent(ocx, "GetKlx");
                    int _klx = ocx.GetKlx();
                    AutomationFactory.GetEvent(ocx, "GetDqdm");
                    string _dqdm = ocx.GetDqdm();
                    //擦卡
                    AutomationFactory.GetEvent(ocx, "FormatGasCard");
                    int sellRen = ocx.FormatGasCard(_factory, Kmm, _klx, _cardId, _dqdm);
                    //售气成功返回true,失败false;
                    if (sellRen == 0)
                    {
                        if (this.Dispatcher.CheckAccess())
                        {
                            State = State.End;
                        }
                        else
                        {
                            this.Dispatcher.BeginInvoke(() =>
                            {
                                State = State.End;
                            });
                        }
                    }
                    else
                    {
                        if (this.Dispatcher.CheckAccess())
                        {
                            Error = "擦卡不成功!错误代码" + sellRen;
                            State = State.Error;
                        }
                        else
                        {
                            this.Dispatcher.BeginInvoke(() =>
                            {
                                Error = "擦卡不成功!错误代码" + sellRen;
                                State = State.Error;
                            });
                        }
                    }
                }
                //IsBusy=false;
                if (this.Dispatcher.CheckAccess())
                {
                    IsBusy = false;
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        IsBusy = false;
                    });
                }
                if (this.Dispatcher.CheckAccess())
                {
                    OnCompleted(null);
                }
                else
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        OnCompleted(null);
                    });
                }
            });
            thread.Start();
        }
        #endregion