提交修改
This commit is contained in:
		
							parent
							
								
									8ce450a4f5
								
							
						
					
					
						commit
						1402d31de2
					
				| 
						 | 
					@ -37,7 +37,7 @@
 | 
				
			||||||
		<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
 | 
							<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
 | 
				
			||||||
		<add key="returnDrugMode" value="2" />
 | 
							<add key="returnDrugMode" value="2" />
 | 
				
			||||||
		<!-- 自动退出时间,单位秒,为0时不自动退出 -->
 | 
							<!-- 自动退出时间,单位秒,为0时不自动退出 -->
 | 
				
			||||||
		<add key="autoExit" value="80"/>
 | 
							<add key="autoExit" value="5"/>
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
 | 
							<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
 | 
				
			||||||
		<add key="stopRecord" value="180"/>
 | 
							<add key="stopRecord" value="180"/>
 | 
				
			||||||
| 
						 | 
					@ -117,8 +117,8 @@
 | 
				
			||||||
		<add key="HIKPassword" value="HKC123456"/>
 | 
							<add key="HIKPassword" value="HKC123456"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<!--交接柜网口地址及端口-->
 | 
							<!--交接柜网口地址及端口-->
 | 
				
			||||||
		<add key="modbusIp" value="127.0.0.1"/>
 | 
							<add key="modbusIp" value="10.1.100.13"/>
 | 
				
			||||||
		<add key="modbusPort" value="4002"/>
 | 
							<add key="modbusPort" value="502"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<!--温湿度串口-->
 | 
							<!--温湿度串口-->
 | 
				
			||||||
		<add key="wsdSerialPort" value="COM1"/>
 | 
							<add key="wsdSerialPort" value="COM1"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,15 +19,15 @@ namespace DM_Weight.Finger
 | 
				
			||||||
    public class FingerprintUtil
 | 
					    public class FingerprintUtil
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
 | 
					        private ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
 | 
				
			||||||
        public static zkemkeeper.CZKEMClass axCZKEM1= new zkemkeeper.CZKEMClass();
 | 
					        public zkemkeeper.CZKEMClass axCZKEM1= new zkemkeeper.CZKEMClass();
 | 
				
			||||||
        public static bool bIsConnected = false;
 | 
					        public bool bIsConnected = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static string fingerIp = ConfigurationManager.AppSettings["fingerIp"].ToString();
 | 
					        private string fingerIp = ConfigurationManager.AppSettings["fingerIp"].ToString();
 | 
				
			||||||
        private static int fingerPort = 4370;
 | 
					        private int fingerPort = 4370;
 | 
				
			||||||
        private static int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"].ToString());
 | 
					        private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"].ToString());
 | 
				
			||||||
        private static int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"].ToString());
 | 
					        private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"].ToString());
 | 
				
			||||||
        private static IEventAggregator _eventAggregator;
 | 
					        private IEventAggregator _eventAggregator;
 | 
				
			||||||
        public FingerprintUtil(IEventAggregator eventAggregator)
 | 
					        public FingerprintUtil(IEventAggregator eventAggregator)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@ namespace DM_Weight.Finger
 | 
				
			||||||
           //});
 | 
					           //});
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void ConnectionMain()
 | 
					        public void ConnectionMain()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -55,9 +55,6 @@ namespace DM_Weight.Finger
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                logger.Info($"连接指纹机2");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                _eventAggregator.GetEvent<FingerprintEvent>().Publish(new FingerprintMsg()
 | 
					                _eventAggregator.GetEvent<FingerprintEvent>().Publish(new FingerprintMsg()
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Message = "CONNECT",
 | 
					                    Message = "CONNECT",
 | 
				
			||||||
| 
						 | 
					@ -72,10 +69,11 @@ namespace DM_Weight.Finger
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 用于退出登录重连指纹机
 | 
					        /// 用于退出登录重连指纹机
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public static void FingerDisconnect()
 | 
					        public void FingerDisconnect()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                logger.Info("重连指纹机");
 | 
				
			||||||
                axCZKEM1.Disconnect(); 
 | 
					                axCZKEM1.Disconnect(); 
 | 
				
			||||||
                axCZKEM1.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
 | 
					                axCZKEM1.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
 | 
				
			||||||
                axCZKEM1.OnEnrollFingerEx -= new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
 | 
					                axCZKEM1.OnEnrollFingerEx -= new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
 | 
				
			||||||
| 
						 | 
					@ -89,7 +87,7 @@ namespace DM_Weight.Finger
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //If your fingerprint(or your card) passes the verification,this event will be triggered
 | 
					        //If your fingerprint(or your card) passes the verification,this event will be triggered
 | 
				
			||||||
        private static void axCZKEM1_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode)
 | 
					        private void axCZKEM1_OnAttTransactionEx(string sEnrollNumber, int iIsInValid, int iAttState, int iVerifyMethod, int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int iWorkCode)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            FingerprintMsg message = new FingerprintMsg()
 | 
					            FingerprintMsg message = new FingerprintMsg()
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -102,7 +100,7 @@ namespace DM_Weight.Finger
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //When you are enrolling your finger,this event will be triggered.
 | 
					        //When you are enrolling your finger,this event will be triggered.
 | 
				
			||||||
        private static void axCZKEM1_OnEnrollFinger(int iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
 | 
					        private void axCZKEM1_OnEnrollFinger(int iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            FingerprintMsg message = new FingerprintMsg()
 | 
					            FingerprintMsg message = new FingerprintMsg()
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -119,7 +117,7 @@ namespace DM_Weight.Finger
 | 
				
			||||||
            _eventAggregator.GetEvent<FingerprintEvent>().Publish(message);
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Publish(message);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static void axCZKEM1_OnEnrollFingerEx(string iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
 | 
					        private void axCZKEM1_OnEnrollFingerEx(string iEnrollNumber, int iFingerIndex, int iActionResult, int iTemplateLength)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            FingerprintMsg message = new FingerprintMsg()
 | 
					            FingerprintMsg message = new FingerprintMsg()
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using Common.Logging;
 | 
					using Common.Logging;
 | 
				
			||||||
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
using Mina.Core.Future;
 | 
					using Mina.Core.Future;
 | 
				
			||||||
using Mina.Filter.Codec;
 | 
					using Mina.Filter.Codec;
 | 
				
			||||||
using Mina.Transport.Socket;
 | 
					using Mina.Transport.Socket;
 | 
				
			||||||
| 
						 | 
					@ -18,8 +19,10 @@ namespace DM_Weight.Port
 | 
				
			||||||
        AsyncSocketConnector acceptor = new AsyncSocketConnector();
 | 
					        AsyncSocketConnector acceptor = new AsyncSocketConnector();
 | 
				
			||||||
        IConnectFuture iConnectFuture;
 | 
					        IConnectFuture iConnectFuture;
 | 
				
			||||||
        string ip = ConfigurationManager.AppSettings["fingerIp"].ToString();
 | 
					        string ip = ConfigurationManager.AppSettings["fingerIp"].ToString();
 | 
				
			||||||
        public FingerHelper()
 | 
					        FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					        public FingerHelper(FingerprintUtil fingerprintUtil)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
            acceptor.ExceptionCaught += (o, e) => logger.Error(e.Exception);
 | 
					            acceptor.ExceptionCaught += (o, e) => logger.Error(e.Exception);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //acceptor.FilterChain.AddLast("logger", new LoggingFilter());
 | 
					            //acceptor.FilterChain.AddLast("logger", new LoggingFilter());
 | 
				
			||||||
| 
						 | 
					@ -38,6 +41,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
                logger.Info("SessionClosed");
 | 
					                logger.Info("SessionClosed");
 | 
				
			||||||
                Task.Delay(50).Wait();
 | 
					                Task.Delay(50).Wait();
 | 
				
			||||||
                SocketConnect();
 | 
					                SocketConnect();
 | 
				
			||||||
 | 
					                _fingerprintUtil.FingerDisconnect();
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            this.SocketConnect();
 | 
					            this.SocketConnect();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -45,7 +49,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            iConnectFuture = acceptor.Connect(new IPEndPoint(IPAddress.Parse(ip), 4370)).Await();
 | 
					            iConnectFuture = acceptor.Connect(new IPEndPoint(IPAddress.Parse(ip), 4370)).Await();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Console.WriteLine(iConnectFuture.Connected.ToString());
 | 
					            logger.Info($"再次连接结果:{iConnectFuture.Connected.ToString()}");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void SendMessage(MyBaseMessage baseMessage)
 | 
					        public void SendMessage(MyBaseMessage baseMessage)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,10 +81,10 @@ namespace DM_Weight.Port
 | 
				
			||||||
                    BoxOperate = false;
 | 
					                    BoxOperate = false;
 | 
				
			||||||
                    this.SetModusIpMaster();
 | 
					                    this.SetModusIpMaster();
 | 
				
			||||||
                    // return TimeSpan.FromSeconds (1);
 | 
					                    // return TimeSpan.FromSeconds (1);
 | 
				
			||||||
                    Task.Factory.StartNew(() =>
 | 
					                    //Task.Factory.StartNew(() =>
 | 
				
			||||||
                    {
 | 
					                    //{
 | 
				
			||||||
                        FingerprintUtil.FingerDisconnect();
 | 
					                    //    FingerprintUtil.FingerDisconnect();
 | 
				
			||||||
                    });
 | 
					                    //});
 | 
				
			||||||
                }).Execute<bool[]>(() =>
 | 
					                }).Execute<bool[]>(() =>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    bool[] flags = new bool[18];
 | 
					                    bool[] flags = new bool[18];
 | 
				
			||||||
| 
						 | 
					@ -120,10 +120,10 @@ namespace DM_Weight.Port
 | 
				
			||||||
                    logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
 | 
					                    logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
 | 
				
			||||||
                    Thread.Sleep(50);
 | 
					                    Thread.Sleep(50);
 | 
				
			||||||
                    this.SetModusIpMaster();
 | 
					                    this.SetModusIpMaster();
 | 
				
			||||||
                    Task.Factory.StartNew(() =>
 | 
					                    //Task.Factory.StartNew(() =>
 | 
				
			||||||
                    {
 | 
					                    //{
 | 
				
			||||||
                        FingerprintUtil.FingerDisconnect();
 | 
					                    //    FingerprintUtil.FingerDisconnect();
 | 
				
			||||||
                    });
 | 
					                    //});
 | 
				
			||||||
                    //return TimeSpan.FromSeconds (1);
 | 
					                    //return TimeSpan.FromSeconds (1);
 | 
				
			||||||
                })).Execute(() =>
 | 
					                })).Execute(() =>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -173,6 +173,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
        private static SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
 | 
					        private static SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
 | 
				
			||||||
        public static void SpeakAsync(string textinfo)
 | 
					        public static void SpeakAsync(string textinfo)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            speechSynthesizer.Rate = 2;
 | 
				
			||||||
            speechSynthesizer.SpeakAsync(textinfo);
 | 
					            speechSynthesizer.SpeakAsync(textinfo);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using DM_Weight.Models;
 | 
					using DM_Weight.Finger;
 | 
				
			||||||
 | 
					using DM_Weight.Models;
 | 
				
			||||||
using DM_Weight.msg;
 | 
					using DM_Weight.msg;
 | 
				
			||||||
using DM_Weight.util;
 | 
					using DM_Weight.util;
 | 
				
			||||||
using DM_Weight.ViewModels;
 | 
					using DM_Weight.ViewModels;
 | 
				
			||||||
| 
						 | 
					@ -31,9 +32,11 @@ namespace DM_Weight.Port
 | 
				
			||||||
        string ip = ConfigurationManager.AppSettings["modbusIp"].ToString();
 | 
					        string ip = ConfigurationManager.AppSettings["modbusIp"].ToString();
 | 
				
			||||||
        int port =Convert.ToInt32(ConfigurationManager.AppSettings["modbusPort"]);
 | 
					        int port =Convert.ToInt32(ConfigurationManager.AppSettings["modbusPort"]);
 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
        public SocketHelper(IEventAggregator eventAggregator)
 | 
					        public DateTime dateTime { get; set; } = DateTime.Now;
 | 
				
			||||||
 | 
					        FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					        public SocketHelper(IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _eventAggregator=eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
            acceptor.ExceptionCaught += (o, e) =>
 | 
					            acceptor.ExceptionCaught += (o, e) =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                logger.Error($"网口通信超时:{e.Exception}");
 | 
					                logger.Error($"网口通信超时:{e.Exception}");
 | 
				
			||||||
| 
						 | 
					@ -54,17 +57,16 @@ namespace DM_Weight.Port
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                OpenStatus = (bool)e.Message;
 | 
					                OpenStatus = (bool)e.Message;
 | 
				
			||||||
                logger.Info("MessageReceived>>>>>>>>>>>>>>>>" + OpenStatus);
 | 
					                logger.Info("MessageReceived>>>>>>>>>>>>>>>>" + OpenStatus);
 | 
				
			||||||
                if(OpenStatus)
 | 
					                //if(OpenStatus)
 | 
				
			||||||
                {
 | 
					                //{
 | 
				
			||||||
                    HomeWindow.idleTimer.Stop();
 | 
					                //    HomeWindow.idleTimer.Stop();
 | 
				
			||||||
                }
 | 
					                //}
 | 
				
			||||||
                else
 | 
					                //else
 | 
				
			||||||
                {
 | 
					                //{
 | 
				
			||||||
                    HomeWindow.idleTimer.AutoReset = true;
 | 
					                //    HomeWindow.idleTimer.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0") * 1000;
 | 
				
			||||||
                    HomeWindow.idleTimer.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0") * 1000;
 | 
					                //    HomeWindow.idleTimer.Start();
 | 
				
			||||||
                    HomeWindow.idleTimer.Start();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }    
 | 
					                //}    
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,15 +75,44 @@ namespace DM_Weight.Port
 | 
				
			||||||
                logger.Info("SessionClosed");
 | 
					                logger.Info("SessionClosed");
 | 
				
			||||||
                //Task.Delay(50).Wait();
 | 
					                //Task.Delay(50).Wait();
 | 
				
			||||||
                SocketConnect();
 | 
					                SocketConnect();
 | 
				
			||||||
 | 
					                Task.Factory.StartNew(() =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _fingerprintUtil.FingerDisconnect();
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            this.SocketConnect();
 | 
					            this.SocketConnect();
 | 
				
			||||||
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        int i = 0;
 | 
				
			||||||
        public void SocketConnect()
 | 
					        public void SocketConnect()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            Thread.Sleep(50);
 | 
				
			||||||
 | 
					            i++;
 | 
				
			||||||
            iConnectFuture = acceptor.Connect(new IPEndPoint(IPAddress.Parse(ip), port)).Await();
 | 
					            iConnectFuture = acceptor.Connect(new IPEndPoint(IPAddress.Parse(ip), port)).Await();
 | 
				
			||||||
 | 
					            logger.Info($"第{i}次连接结果:{iConnectFuture.Connected.ToString()}");
 | 
				
			||||||
 | 
					            if (!iConnectFuture.Connected)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if (i <= 3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    //没连上会再连两次
 | 
				
			||||||
 | 
					                    SocketConnect();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    logger.Error($"尝试{i}次连接后均连接不上");
 | 
				
			||||||
 | 
					                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Message = $"网口连接断开!",
 | 
				
			||||||
 | 
					                        Type = MsgType.ERROR
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                i = 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logger.Info(iConnectFuture.Connected.ToString());
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void SendMessage(MyBaseMessage baseMessage)
 | 
					        public void SendMessage(MyBaseMessage baseMessage)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -862,6 +862,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo) });
 | 
					                    _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo) });
 | 
				
			||||||
 | 
					                    _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex)
 | 
					                catch (Exception ex)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -871,12 +872,14 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                        Type = MsgType.ERROR,
 | 
					                        Type = MsgType.ERROR,
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                    _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                    logger.Info($"网口连接异常,正在重试{ex.Message}");
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                _socketHelper.OpenStatus = true;
 | 
					                _socketHelper.OpenStatus = true;
 | 
				
			||||||
                Thread.Sleep(200);
 | 
					                Thread.Sleep(200);
 | 
				
			||||||
                int i = 10;
 | 
					                int i = 40;
 | 
				
			||||||
                new PromiseUtil<int>().taskAsyncLoop(500, 0, async (options, next, stop) =>
 | 
					                int iException = 0;
 | 
				
			||||||
 | 
					                new PromiseUtil<int>().taskAsyncLoop(200, 0, async (options, next, stop) =>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    _socketHelper.IsMultiThread = true;
 | 
					                    _socketHelper.IsMultiThread = true;
 | 
				
			||||||
| 
						 | 
					@ -896,30 +899,43 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                if (i == 0)
 | 
					                                if (i == 0)
 | 
				
			||||||
                                {
 | 
					                                {
 | 
				
			||||||
                                    ModbusHelper.SpeakAsync("请及时关闭药箱");
 | 
					                                    ModbusHelper.SpeakAsync("请及时关闭药箱");
 | 
				
			||||||
                                    i = 10;
 | 
					                                    i = 40;
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                                next();
 | 
					                                next();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            else
 | 
					                            else
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
 | 
					                                _socketHelper.OpenStatus = false;
 | 
				
			||||||
 | 
					                                _socketHelper.IsMultiThread = false;
 | 
				
			||||||
 | 
					                                _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
                                stop();
 | 
					                                stop();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        else
 | 
					                        else
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
 | 
					                            _socketHelper.OpenStatus = false;
 | 
				
			||||||
                            _socketHelper.IsMultiThread = false;
 | 
					                            _socketHelper.IsMultiThread = false;
 | 
				
			||||||
 | 
					                            _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
                            stop();
 | 
					                            stop();
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        iException = 0;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    catch (Exception ex)
 | 
					                    catch (Exception ex)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        iException++;
 | 
				
			||||||
 | 
					                        if (iException >= 3)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            _socketHelper.OpenStatus = false;
 | 
					                            _socketHelper.OpenStatus = false;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        // _socketHelper.OpenStatus = false;
 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            Message = $"网口连接异常,正在重试{ex.Message}",
 | 
					                            Message = $"网口连接异常,正在重试{ex.Message}",
 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        logger.Info($"网口连接异常,正在重试{ex.Message}");
 | 
				
			||||||
 | 
					                        next();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -570,48 +570,31 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            FindDrawerCount();
 | 
					            FindDrawerCount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
					            int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
				
			||||||
            //int stopRecord = Convert.ToInt32(ConfigurationManager.AppSettings["stopRecord"] ?? "0");
 | 
					            if (autoExit > 0)
 | 
				
			||||||
            //if (autoExit > 0)
 | 
					            {
 | 
				
			||||||
            //{
 | 
					                System.Timers.Timer timer = new System.Timers.Timer();
 | 
				
			||||||
            //    System.Timers.Timer timer = new System.Timers.Timer();
 | 
					                timer.Interval = autoExit* 1000;
 | 
				
			||||||
            //    timer.Interval = 100;
 | 
					                timer.Elapsed += (sender, e) =>
 | 
				
			||||||
            //    timer.Elapsed += (sender, e) =>
 | 
					                {
 | 
				
			||||||
            //    {
 | 
					                    // 串口无人操作
 | 
				
			||||||
            //        // 串口无人操作
 | 
					                    if (!_socketHelper.OpenStatus)
 | 
				
			||||||
            //        bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
 | 
					                    {
 | 
				
			||||||
            //        bool allTrue =  Array.TrueForAll(boolArrs, b => b==false);
 | 
					                        // 无人操作鼠标键盘
 | 
				
			||||||
            //        logger.Info($"进入自动退出定时方法{allTrue}");
 | 
					                        if ((DateTime.Now - _socketHelper.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
 | 
				
			||||||
            //        //false是关着,true是开着
 | 
					                        {
 | 
				
			||||||
            //        if (allTrue)
 | 
					                            logger.Info($"设备内无人操作,用户【{Operator?.Nickname}】自动退出登录");
 | 
				
			||||||
            //        {
 | 
					                            Operator = null;
 | 
				
			||||||
            //            //PerformanceCounter pc = new PerformanceCounter("System", "% Idle Time", true);
 | 
					                            Reviewer = null;
 | 
				
			||||||
            //            //float systemIdleTime = pc.NextValue();
 | 
					                            Application.Current.Dispatcher.Invoke(() =>
 | 
				
			||||||
            //            //Console.WriteLine($"systemIdleTime:{systemIdleTime}");
 | 
					                            {
 | 
				
			||||||
 | 
					                                _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
            //            //// 获取系统空闲时间
 | 
					                                timer.Stop();
 | 
				
			||||||
            //            //TimeSpan idleTime = SystemInformation.IdleTime;
 | 
					                            });
 | 
				
			||||||
            //            //// 打印空闲时间
 | 
					                        }
 | 
				
			||||||
            //            //Console.WriteLine("系统空闲时间: " + idleTime.ToString());
 | 
					                    }
 | 
				
			||||||
            //            long lTime = CheckComputerFreeState.GetLastInputTime(); 
 | 
					                };
 | 
				
			||||||
            //            logger.Info($"自动退出时间{lTime}");
 | 
					                timer.Start();
 | 
				
			||||||
            //            // 30秒内无人操作鼠标键盘
 | 
					            }
 | 
				
			||||||
            //            //if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
 | 
					 | 
				
			||||||
            //            if (lTime > autoExit)
 | 
					 | 
				
			||||||
            //            {
 | 
					 | 
				
			||||||
            //                logger.Info($"设备{autoExit}秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
 | 
					 | 
				
			||||||
            //                _chkFunction.HIKStopDVRRecord();
 | 
					 | 
				
			||||||
            //                Operator = null;
 | 
					 | 
				
			||||||
            //                Reviewer = null;
 | 
					 | 
				
			||||||
            //                Application.Current.Dispatcher.Invoke(() =>
 | 
					 | 
				
			||||||
            //                {
 | 
					 | 
				
			||||||
            //                    _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					 | 
				
			||||||
            //                    timer.Stop();
 | 
					 | 
				
			||||||
            //                });
 | 
					 | 
				
			||||||
            //            }
 | 
					 | 
				
			||||||
            //        }
 | 
					 | 
				
			||||||
            //    };
 | 
					 | 
				
			||||||
            //    timer.Start();
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
            #region 温度查询定时
 | 
					            #region 温度查询定时
 | 
				
			||||||
            //int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
 | 
					            //int interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"]);
 | 
				
			||||||
            //if (interval > 0)
 | 
					            //if (interval > 0)
 | 
				
			||||||
| 
						 | 
					@ -624,7 +607,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            //    //WDTimer.AutoReset = true;
 | 
					            //    //WDTimer.AutoReset = true;
 | 
				
			||||||
            //    //WDTimer.Enabled = true;
 | 
					            //    //WDTimer.Enabled = true;
 | 
				
			||||||
            //}
 | 
					            //}
 | 
				
			||||||
            Task.Factory.StartNew(async () =>
 | 
					            Task.Factory.StartNew(() =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                while (true)
 | 
					                while (true)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -639,7 +622,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                            AddTime = DateTime.Now
 | 
					                            AddTime = DateTime.Now
 | 
				
			||||||
                        }).ExecuteCommand();
 | 
					                        }).ExecuteCommand();
 | 
				
			||||||
                        logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
 | 
					                        logger.Info($"保存温湿度信息:{temp.Temp},{temp.Humi}");
 | 
				
			||||||
                        await Task.Delay(1200000);//20分钟查一次
 | 
					                        Task.Delay(1200000);//20分钟查一次
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
| 
						 | 
					@ -688,14 +671,14 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            Reviewer = null;
 | 
					            Reviewer = null;
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (_socketHelper.IsMultiThread)
 | 
					                //if (_socketHelper.IsMultiThread)
 | 
				
			||||||
                {
 | 
					                //{
 | 
				
			||||||
                    Application.Current.Dispatcher.BeginInvoke(() =>
 | 
					                //    Application.Current.Dispatcher.BeginInvoke(() =>
 | 
				
			||||||
                    {
 | 
					                //    {
 | 
				
			||||||
                        _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
					                //        _regionManager.RequestNavigate("MainRegion", "LoginWindow");
 | 
				
			||||||
                    });
 | 
					                //    });
 | 
				
			||||||
                }
 | 
					                //}
 | 
				
			||||||
                else
 | 
					                //else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,7 +62,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private HkcChangeShifts listHkcChangeShifts=new HkcChangeShifts();
 | 
					        private HkcChangeShifts listHkcChangeShifts=new HkcChangeShifts();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //private FingerprintUtil _fingerprintUtil;
 | 
					        private FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private PortUtil _portUtil;
 | 
					        private PortUtil _portUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -114,17 +114,17 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        //    _regionManager = regionManager;
 | 
					        //    _regionManager = regionManager;
 | 
				
			||||||
        //    _eventAggregator = eventAggregator;
 | 
					        //    _eventAggregator = eventAggregator;
 | 
				
			||||||
        //}
 | 
					        //}
 | 
				
			||||||
        public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil)
 | 
					        public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil,FingerprintUtil fingerprintUtil)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //_fingerprintUtil = fingerprintUtil;
 | 
					            _fingerprintUtil = fingerprintUtil;
 | 
				
			||||||
            _portUtil = portUtil;
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
            _regionManager = regionManager;
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
            _eventAggregator = eventAggregator; 
 | 
					            _eventAggregator = eventAggregator; 
 | 
				
			||||||
            //FingerMsg = !_fingerprintUtil.bIsConnected;
 | 
					            FingerMsg = !_fingerprintUtil.bIsConnected;
 | 
				
			||||||
            FingerMsg = !FingerprintUtil.bIsConnected;
 | 
					            //FingerMsg = !FingerprintUtil.bIsConnected;
 | 
				
			||||||
            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
 | 
					            _eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
 | 
				
			||||||
            logger.Info($"LoginWindowViewModel;FingerMsg:{FingerprintUtil.bIsConnected}");
 | 
					            logger.Info($"LoginWindowViewModel;FingerMsg:{_fingerprintUtil.bIsConnected}");
 | 
				
			||||||
            //_fingerprintUtil.FingerDisconnect();
 | 
					            _fingerprintUtil.FingerDisconnect();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private DelegateCommand? _loginCommand;
 | 
					        private DelegateCommand? _loginCommand;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -106,7 +106,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_socketHelper.IsMultiThread)
 | 
					            if (_socketHelper.IsMultiThread)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Application.Current.Dispatcher.Invoke(new Action(() => {
 | 
					                Application.Current.Dispatcher.BeginInvoke(new Action(() => {
 | 
				
			||||||
                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
					                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
 | 
				
			||||||
                    SnackbarMessageQueue.Enqueue(msg.Message);
 | 
					                    SnackbarMessageQueue.Enqueue(msg.Message);
 | 
				
			||||||
                }));
 | 
					                }));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -662,6 +662,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo - 1) });
 | 
					                    _socketHelper.SendMessage(new MyBaseMessage() { lockNo = (short)(DrawerNo - 1) });
 | 
				
			||||||
 | 
					                    _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception ex)
 | 
					                catch (Exception ex)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -709,8 +710,9 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                //    }
 | 
					                //    }
 | 
				
			||||||
                //});
 | 
					                //});
 | 
				
			||||||
                Thread.Sleep(200);
 | 
					                Thread.Sleep(200);
 | 
				
			||||||
                int i = 10;
 | 
					                int i = 40;
 | 
				
			||||||
                new PromiseUtil<int>().taskAsyncLoop(500, 0, async (options, next, stop) =>
 | 
					                int iException = 0;
 | 
				
			||||||
 | 
					                new PromiseUtil<int>().taskAsyncLoop(200, 0, async (options, next, stop) =>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    _socketHelper.IsMultiThread = true;
 | 
					                    _socketHelper.IsMultiThread = true;
 | 
				
			||||||
                    try
 | 
					                    try
 | 
				
			||||||
| 
						 | 
					@ -730,30 +732,41 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                                if (i == 0)
 | 
					                                if (i == 0)
 | 
				
			||||||
                                {
 | 
					                                {
 | 
				
			||||||
                                    ModbusHelper.SpeakAsync("请及时关闭药箱");
 | 
					                                    ModbusHelper.SpeakAsync("请及时关闭药箱");
 | 
				
			||||||
                                    i = 10;
 | 
					                                    i = 40;
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                                next();
 | 
					                                next();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            else
 | 
					                            else
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
 | 
					                                _socketHelper.IsMultiThread = false;
 | 
				
			||||||
 | 
					                                _socketHelper.OpenStatus = false;
 | 
				
			||||||
 | 
					                                _socketHelper.dateTime=DateTime.Now;
 | 
				
			||||||
                                stop();
 | 
					                                stop();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        else
 | 
					                        else
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            _socketHelper.IsMultiThread = false;
 | 
					                            _socketHelper.IsMultiThread = false;
 | 
				
			||||||
 | 
					                            _socketHelper.OpenStatus = false;
 | 
				
			||||||
 | 
					                            _socketHelper.dateTime = DateTime.Now;
 | 
				
			||||||
                            stop();
 | 
					                            stop();
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        iException = 0;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    catch (Exception ex)
 | 
					                    catch (Exception ex)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        iException++;
 | 
				
			||||||
 | 
					                        if (iException >= 3)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            _socketHelper.OpenStatus = false;
 | 
					                            _socketHelper.OpenStatus = false;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            Message = $"网口连接异常,正在重试{ex.Message}",
 | 
					                            Message = $"网口连接异常,正在重试{ex.Message}",
 | 
				
			||||||
                            Type = MsgType.ERROR,
 | 
					                            Type = MsgType.ERROR,
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
					                        _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
 | 
				
			||||||
 | 
					                        next();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                //StateTimer.Start();
 | 
					                //StateTimer.Start();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,54 +32,56 @@ namespace DM_Weight.Views
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindow));
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindow));
 | 
				
			||||||
        int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
					        int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
 | 
				
			||||||
        public static System.Timers.Timer idleTimer;//= new System.Timers.Timer(60000);
 | 
					        //public static System.Timers.Timer idleTimer;//= new System.Timers.Timer(60000);
 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
        SocketHelper _socketHelper;
 | 
					        SocketHelper _socketHelper;
 | 
				
			||||||
        public HomeWindow(IEventAggregator eventAggregator, SocketHelper socketHelper)
 | 
					        public HomeWindow(IEventAggregator eventAggregator, SocketHelper socketHelper)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            InitializeComponent();
 | 
					            InitializeComponent();
 | 
				
			||||||
            if (autoExit > 0)
 | 
					            //if (autoExit > 0)
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                idleTimer = new System.Timers.Timer(autoExit * 1000);
 | 
					            //    idleTimer = new System.Timers.Timer(autoExit * 1000);
 | 
				
			||||||
                idleTimer.Elapsed += OnTimerElapsed;
 | 
					            //    idleTimer.Elapsed += OnTimerElapsed;
 | 
				
			||||||
                this.MouseDown += OnUserActivity;
 | 
					            //    idleTimer.AutoReset = true;
 | 
				
			||||||
                this.MouseMove += OnUserActivity;
 | 
					            //    idleTimer.Enabled= true;
 | 
				
			||||||
                this.KeyDown += OnUserActivity;
 | 
					            //    this.MouseDown += OnUserActivity;
 | 
				
			||||||
                idleTimer.Start();
 | 
					            //    this.MouseMove += OnUserActivity;
 | 
				
			||||||
                _eventAggregator = eventAggregator;
 | 
					            //    this.KeyDown += OnUserActivity;
 | 
				
			||||||
            }
 | 
					            //    idleTimer.Start();
 | 
				
			||||||
 | 
					            //    _eventAggregator = eventAggregator;
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
            _socketHelper = socketHelper;
 | 
					            _socketHelper = socketHelper;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private void OnUserActivity(object sender, EventArgs e)
 | 
					        //private void OnUserActivity(object sender, EventArgs e)
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            idleTimer.Stop();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            idleTimer.AutoReset = true;
 | 
					 | 
				
			||||||
            idleTimer.Interval =autoExit * 1000;
 | 
					 | 
				
			||||||
            idleTimer.Start();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        private void OnTimerElapsed(object sender, ElapsedEventArgs e)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // 串口无人操作
 | 
					 | 
				
			||||||
            //bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
 | 
					 | 
				
			||||||
            //bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
 | 
					 | 
				
			||||||
            logger.Info($"进入自动退出定时方法{ModbusHelper.BoxOperate}");
 | 
					 | 
				
			||||||
            //if (ModbusHelper.BoxOperate)
 | 
					 | 
				
			||||||
            if (!_socketHelper.OpenStatus)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (idleTimer.Enabled)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    idleTimer.Stop();
 | 
					 | 
				
			||||||
                    //无人操作,自动退出
 | 
					 | 
				
			||||||
                    _eventAggregator.GetEvent<LoginOutEvent>().Publish();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            //else
 | 
					 | 
				
			||||||
        //{
 | 
					        //{
 | 
				
			||||||
            //    idleTimer.Interval = autoExit * 1000;
 | 
					        //    idleTimer.Stop();
 | 
				
			||||||
            //    idleTimer.AutoReset = true;
 | 
					        //    idleTimer.Interval =autoExit * 1000;
 | 
				
			||||||
 | 
					        //    idleTimer.Start();
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					        //private void OnTimerElapsed(object sender, ElapsedEventArgs e)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    idleTimer.Stop();
 | 
				
			||||||
 | 
					        //    // 串口无人操作
 | 
				
			||||||
 | 
					        //    //bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
 | 
				
			||||||
 | 
					        //    //bool allTrue = Array.TrueForAll(boolArrs, b => b == false);
 | 
				
			||||||
 | 
					        //    logger.Info($"进入自动退出定时方法{ModbusHelper.BoxOperate}");
 | 
				
			||||||
 | 
					        //    //if (ModbusHelper.BoxOperate)
 | 
				
			||||||
 | 
					        //    if (!_socketHelper.OpenStatus)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        if (idleTimer.Enabled)
 | 
				
			||||||
 | 
					        //        {
 | 
				
			||||||
 | 
					        //            idleTimer.Stop();
 | 
				
			||||||
 | 
					        //            //无人操作,自动退出
 | 
				
			||||||
 | 
					        //            _eventAggregator.GetEvent<LoginOutEvent>().Publish();
 | 
				
			||||||
 | 
					        //        }
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //    idleTimer.Start();
 | 
				
			||||||
 | 
					        //    //else
 | 
				
			||||||
 | 
					        //    //{
 | 
				
			||||||
 | 
					        //    //    idleTimer.Interval = autoExit * 1000;
 | 
				
			||||||
 | 
					        //    //    idleTimer.AutoReset = true;
 | 
				
			||||||
 | 
					        //    //}
 | 
				
			||||||
        //}
 | 
					        //}
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue