| | |
| | | { |
| | | public static UIApplication sharedApp; |
| | | public static PageLayout CurPageLayout = null; |
| | | public static bool IsBackground; |
| | | //public static bool IsBackground; |
| | | |
| | | //public static string CheckVersion() |
| | | //{ |
| | |
| | | { |
| | | Console.WriteLine("OnResignActivation"); |
| | | UserInfo.Current.unlockTime = DateTime.Now; |
| | | HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop(); |
| | | } |
| | | |
| | | public override void DidEnterBackground(UIApplication application) |
| | | { |
| | | SharedMethod.SharedMethod.IsBackground = true; |
| | | //SharedMethod.SharedMethod.IsBackground = true; |
| | | //MainPage.IsEnterBackground = true; |
| | | ////进入后台mqtt正在连接重置状态 |
| | | //HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false; |
| | | //HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop(); |
| | | //进入后台 |
| | | BusSocketStop(); |
| | | Console.WriteLine("DidEnterBackground"); |
| | | } |
| | | |
| | | |
| | | public override void WillEnterForeground(UIApplication application) |
| | | { |
| | | SharedMethod.SharedMethod.IsBackground = false; |
| | | HDL_ON.DriverLayer.UdpSocket._BusSocket.Start(); |
| | | new AppUnlockPage().LoadPage(); |
| | | //回到前台,处理事件 |
| | | BusSocketStart(); |
| | | Console.WriteLine("WillEnterForeground"); |
| | | UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; |
| | | HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway(); |
| | | } |
| | | |
| | | public override void WillTerminate(UIApplication application) |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 进入后台的时间 |
| | | /// </summary> |
| | | DateTime CloseTime = DateTime.Now; |
| | | |
| | | /// <summary> |
| | | /// 进入后台处理时间 |
| | | /// BusSocketStop |
| | | /// </summary> |
| | | void BusSocketStop() |
| | | { |
| | | //SharedMethod.SharedMethod.IsBackground = true; |
| | | CloseTime = DateTime.Now; |
| | | MainPage.IsEnterBackground = true; |
| | | //进入后台mqtt正在连接重置状态 |
| | | HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false; |
| | | HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop(); |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 回到前台,处理事件 |
| | | /// </summary> |
| | | void BusSocketStart() |
| | | { |
| | | if (CloseTime.AddSeconds(10) < DateTime.Now) |
| | | { |
| | | //后台超过10s就断开MQTT重连 |
| | | if (HDL_ON.DriverLayer.Control.Ins.IsRemote) |
| | | { |
| | | HDL_ON.DAL.Mqtt.MqttClient.DisConnectRemote("closeTime", false); |
| | | } |
| | | } |
| | | |
| | | MainPage.IsEnterBackground = false; |
| | | HDL_ON.DriverLayer.UdpSocket._BusSocket.Start(); |
| | | new AppUnlockPage().LoadPage(); |
| | | UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; |
| | | HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway(); |
| | | } |
| | | |
| | | } |
| | | |