public void ReInitCard()
{
IsBusy = true;
Error = "";
State = State.Start;
//执行写卡线程
Thread thread = new Thread(() =>
{
dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
AutomationFactory.GetEvent(ocx, "WriteGasCard");
int sellRen = ocx.WriteNewCard(Factory, Kmm, Klx, Kzt, CardId, Dqdm, Yhh, Tm, Gas, BuyTimes, Ljgql, Bkcs, Bjql, Czsx, Tzed, Sqrq);
//IsBusy=false;
AutomationFactory.GetEvent(ocx, "GetKmm");
AutomationFactory.GetEvent(ocx, "GetCardId");
string mm = ocx.GetKmm();
string kh = ocx.GetCardId();
if (this.Dispatcher.CheckAccess())
{
Kmm = mm;
CardId = kh;
IsBusy = false;
}
else
{
this.Dispatcher.BeginInvoke(() =>
{
Kmm = mm;
CardId = kh;
IsBusy = false;
});
}
//售气成功返回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;
});
}
}
if (this.Dispatcher.CheckAccess())
{
OnCompleted(null);
}
else
{
this.Dispatcher.BeginInvoke(() =>
{
OnCompleted(null);
});
}
});
thread.Start();
}
#endregion