public void SellGas()
{
IsBusy = true;
Error = "";
State = State.Start;
//执行写卡线程
Thread thread = new Thread(() =>
{
dynamic ocx = AutomationFactory.CreateObject("HJIC.HJICCtrl.1");
AutomationFactory.GetEvent(ocx, "WriteGasCard");
string kmm1 = Kmm.Replace("\\","/");
kmm1 = kmm1.Replace("/", "\\");
int sellRen = ocx.WriteGasCard(Factory, kmm1, Klx, CardId, Dqdm, Gas, BuyTimes, Ljgql, Bjql, Czsx, Tzed,Sqrq);
//IsBusy=false;
AutomationFactory.GetEvent(ocx, "GetKmm");
string mm = ocx.GetKmm();
if (this.Dispatcher.CheckAccess())
{
Kmm = mm;
IsBusy = false;
}
else
{
this.Dispatcher.BeginInvoke(() =>
{
Kmm = mm;
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