退出软件断开与板子连接
This commit is contained in:
parent
5d04921387
commit
386a663026
|
|
@ -3,7 +3,7 @@
|
|||
<connectionStrings>
|
||||
<!-- 数据库连接字符串 -->
|
||||
<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
|
||||
<add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangtan_mazuike_xx;userid=root;password=root" />
|
||||
<add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangtan_mazuike;userid=root;password=root" />
|
||||
</connectionStrings>
|
||||
<!--<runtime>
|
||||
--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
|
||||
<add key="returnDrugMode" value="2" />
|
||||
<!-- 自动退出时间,单位秒,为0时不自动退出 -->
|
||||
<add key="autoExit" value="5"/>
|
||||
<add key="autoExit" value="0"/>
|
||||
|
||||
<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
|
||||
<add key="stopRecord" value="180"/>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using DM_Weight.util;
|
|||
using DM_Weight.ViewModels;
|
||||
using log4net;
|
||||
using Mina.Core.Future;
|
||||
using Mina.Core.Session;
|
||||
using Mina.Filter.Codec;
|
||||
using Mina.Filter.Logging;
|
||||
using Mina.Transport.Socket;
|
||||
|
|
@ -60,17 +61,21 @@ namespace DM_Weight.Port
|
|||
logger.Info("MessageReceived>>>>>>>>>>>>>>>>" + OpenStatus);
|
||||
};
|
||||
|
||||
acceptor.SessionClosed += new EventHandler<IoSessionEventArgs>(SessionCloseMethod);
|
||||
|
||||
acceptor.SessionClosed += (o, e) =>
|
||||
{
|
||||
logger.Info("SessionClosed");
|
||||
//Task.Delay(50).Wait();
|
||||
SocketConnect();
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
_fingerprintUtil.FingerDisconnect();
|
||||
});
|
||||
};
|
||||
//acceptor.SessionClosed += (o, e) =>
|
||||
//{
|
||||
// logger.Info($"SessionClosed;ExitFlag:{ExitFlag}");
|
||||
// //Task.Delay(50).Wait();
|
||||
// if (!ExitFlag)
|
||||
// {
|
||||
// SocketConnect();
|
||||
// Task.Factory.StartNew(() =>
|
||||
// {
|
||||
// _fingerprintUtil.FingerDisconnect();
|
||||
// });
|
||||
// }
|
||||
//};
|
||||
this.SocketConnect();
|
||||
}
|
||||
int i = 0;
|
||||
|
|
@ -84,7 +89,6 @@ namespace DM_Weight.Port
|
|||
{
|
||||
if (i <= 3)
|
||||
{
|
||||
Thread.Sleep(1950);
|
||||
//没连上会再连两次
|
||||
SocketConnect();
|
||||
}
|
||||
|
|
@ -107,6 +111,21 @@ namespace DM_Weight.Port
|
|||
ConnectedStatus = iConnectFuture.Connected;
|
||||
}
|
||||
|
||||
private void SessionCloseMethod(System.Object o, IoSessionEventArgs e)
|
||||
{
|
||||
logger.Info($"SessionClosed");
|
||||
SocketConnect();
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
_fingerprintUtil.FingerDisconnect();
|
||||
});
|
||||
}
|
||||
public void SocketDisConnect()
|
||||
{
|
||||
acceptor.SessionClosed -=new EventHandler<IoSessionEventArgs>(SessionCloseMethod);
|
||||
iConnectFuture.Session.CloseNow();
|
||||
}
|
||||
|
||||
public void SendMessage(MyBaseMessage baseMessage)
|
||||
{
|
||||
if (!ConnectedStatus)
|
||||
|
|
|
|||
|
|
@ -503,7 +503,7 @@ namespace DM_Weight.ViewModels
|
|||
&& cs.Quantity >= oi._OrderDetail.Quantity).First();
|
||||
if (cs == null)
|
||||
{
|
||||
empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo},{oi._OrderDetail.SetEffDate};";
|
||||
empChannelStock += $"{oi.OrderNo},{oi._OrderDetail.DrugId},{oi._OrderDetail.SetManuNo};";
|
||||
continue;
|
||||
}
|
||||
cs.Quantity = cs.Quantity - oi._OrderDetail.Quantity;
|
||||
|
|
|
|||
|
|
@ -377,6 +377,7 @@ _exitCommand ??= new DelegateCommand(Exit);
|
|||
void Exit()
|
||||
{
|
||||
//_chkFunction.HIKLoginOut();
|
||||
_socketHelper.SocketDisConnect();
|
||||
Process.GetCurrentProcess().Kill();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue