From e327510c7329aa9a95e62a460ec659ea0c9563ad Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期六, 19 十二月 2020 19:05:47 +0800
Subject: [PATCH] Merge branch 'CJL' into NewFilePath
---
HDL-ON_iOS/ViewController.cs | 2
HDL-ON_iOS/Resources/Language.ini | 3
HDL-ON_Android/Assets/Language.ini | 3
HDL_ON/Common/HDLCommon.cs | 9 +
HDL_ON/UI/UI1-Login/LoginPageBLL.cs | 12 ++
HDL_ON/Common/R.cs | 4 +
HDL_ON/DAL/DriverLayer/Packet.cs | 2
HDL_ON/DAL/DriverLayer/Control.cs | 75 +++++++++++++-----
HDL_ON/UI/MainPage.cs | 4 +
HDL-ON_iOS/AppDelegate.cs | 58 ++++++++++++--
HDL_ON/DAL/Mqtt/MqttClient.cs | 10 +-
HDL-ON_Android/Application.cs | 39 +++++++--
12 files changed, 173 insertions(+), 48 deletions(-)
diff --git a/HDL-ON_Android/Application.cs b/HDL-ON_Android/Application.cs
index 3d80e26..44e4c01 100644
--- a/HDL-ON_Android/Application.cs
+++ b/HDL-ON_Android/Application.cs
@@ -86,7 +86,7 @@
//}
//缃戠粶鍙樺寲澶勭悊
- HDLCommon.Current.UpdateInternetStatus((int)internetStatus, IsEnterBackground);
+ HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground);
};
//寮�鍚畾浣嶆湇鍔�
Shared.Application.StartGPSLocationService();
@@ -309,30 +309,53 @@
int mCount;
+ ///// <summary>
+ ///// 鏄惁杩涘叆鍚庡彴
+ ///// </summary>
+ //public bool IsEnterBackground = false;
+
/// <summary>
- /// 鏄惁杩涘叆鍚庡彴
+ /// 杩涘叆鍚庡彴鐨勬椂闂�
/// </summary>
- public bool IsEnterBackground = false;
+ DateTime CloseTime = DateTime.Now;
/// <summary>
/// BusSocketStop
/// </summary>
void BusSocketStop()
{
- IsEnterBackground = true;
- //BusSocket.Stop();
+ //IsEnterBackground = true;
+ CloseTime = DateTime.Now;
+ MainPage.IsEnterBackground = true;
+ //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵��
+ HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false;
+ HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop();
+
}
-
/// <summary>
/// BusSocketStart
/// </summary>
void BusSocketStart()
{
- IsEnterBackground = false;
+ //IsEnterBackground = false;
- //BusSocket.Start();
+ 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();
+ HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
}
+
+
+
}
}
\ No newline at end of file
diff --git a/HDL-ON_Android/Assets/Language.ini b/HDL-ON_Android/Assets/Language.ini
old mode 100755
new mode 100644
index 70ed926..f672d5f
--- a/HDL-ON_Android/Assets/Language.ini
+++ b/HDL-ON_Android/Assets/Language.ini
@@ -584,7 +584,7 @@
9046=淇敼鎴愬姛!
9047=鎮ㄧ殑瀵嗙爜宸茬粡淇敼鐢熸晥锛岃閲嶆柊鐧诲綍
9048=浣跨敤璐﹀彿瀵嗙爜鐧诲綍
-9049=瀵嗙爜杩炵画杈撻敊娆℃暟宸茶揪鍒�10娆�,鐢ㄦ埛宸茶閿佸畾,璇锋鏃�0鐐瑰悗鍐嶇櫥闄�
+9049=瀵嗙爜閿欒瓒呰繃10娆★紝璐﹀彿琚攣瀹氾紒
9050=楠岃瘉闈㈠ID
9051=淇濆瓨鐢ㄦ埛澶村儚澶辫触
9052=鎺ㄩ�佹敞鍐屾甯�
@@ -596,6 +596,7 @@
9058=鏄惁闇�瑕佷繚瀛�
9059=鏆傛棤鍒嗕韩
9060=浣跨敤鏉冮檺
+9061=璇烽�氳繃蹇樿瀵嗙爜鎵惧洖瀵嗙爜鎴栨鏃�0鐐瑰悗鍐嶇櫥闄�.
10000=鏃犳晥鐧诲綍瀵嗛挜锛岃閲嶆柊鐧诲綍锛�
10001=璇锋眰鏈嶅姟鍣ㄥけ璐ワ紝璇风◢鍚庡啀璇曪紒
diff --git a/HDL-ON_iOS/AppDelegate.cs b/HDL-ON_iOS/AppDelegate.cs
index bd6c6dc..e69297b 100644
--- a/HDL-ON_iOS/AppDelegate.cs
+++ b/HDL-ON_iOS/AppDelegate.cs
@@ -16,7 +16,7 @@
{
public static UIApplication sharedApp;
public static PageLayout CurPageLayout = null;
- public static bool IsBackground;
+ //public static bool IsBackground;
//public static string CheckVersion()
//{
@@ -171,24 +171,26 @@
{
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姝e湪杩炴帴閲嶇疆鐘舵��
+ //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)
@@ -382,7 +384,47 @@
}
}
+ /// <summary>
+ /// 杩涘叆鍚庡彴鐨勬椂闂�
+ /// </summary>
+ DateTime CloseTime = DateTime.Now;
+ /// <summary>
+ /// 杩涘叆鍚庡彴澶勭悊鏃堕棿
+ /// BusSocketStop
+ /// </summary>
+ void BusSocketStop()
+ {
+ //SharedMethod.SharedMethod.IsBackground = true;
+ CloseTime = DateTime.Now;
+ MainPage.IsEnterBackground = true;
+ //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵��
+ 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();
+ }
}
diff --git a/HDL-ON_iOS/Resources/Language.ini b/HDL-ON_iOS/Resources/Language.ini
index 1101296..a720f7c 100644
--- a/HDL-ON_iOS/Resources/Language.ini
+++ b/HDL-ON_iOS/Resources/Language.ini
@@ -585,7 +585,7 @@
9046=淇敼鎴愬姛!
9047=鎮ㄧ殑瀵嗙爜宸茬粡淇敼鐢熸晥锛岃閲嶆柊鐧诲綍
9048=浣跨敤璐﹀彿瀵嗙爜鐧诲綍
-9049=瀵嗙爜杩炵画杈撻敊娆℃暟宸茶揪鍒�10娆�,鐢ㄦ埛宸茶閿佸畾,璇锋鏃�0鐐瑰悗鍐嶇櫥闄�
+9049=瀵嗙爜閿欒瓒呰繃10娆★紝璐﹀彿琚攣瀹氾紒
9050=楠岃瘉闈㈠ID
9051=淇濆瓨鐢ㄦ埛澶村儚澶辫触
9052=鎺ㄩ�佹敞鍐屾甯�
@@ -597,6 +597,7 @@
9058=鏄惁闇�瑕佷繚瀛�
9059=鏆傛棤鍒嗕韩
9060=浣跨敤鏉冮檺
+9061=璇烽�氳繃蹇樿瀵嗙爜鎵惧洖瀵嗙爜鎴栨鏃�0鐐瑰悗鍐嶇櫥闄�.
10000=鏃犳晥鐧诲綍瀵嗛挜锛岃閲嶆柊鐧诲綍锛�
10001=璇锋眰鏈嶅姟鍣ㄥけ璐ワ紝璇风◢鍚庡啀璇曪紒
diff --git a/HDL-ON_iOS/ViewController.cs b/HDL-ON_iOS/ViewController.cs
index 22e1aa9..0e6c711 100644
--- a/HDL-ON_iOS/ViewController.cs
+++ b/HDL-ON_iOS/ViewController.cs
@@ -84,7 +84,7 @@
internetStatus = Reachability.InternetConnectionStatus();
//MainPage.Log($"缃戠粶鐘舵�佸彉鍖栵紝褰撳墠缃戠粶:{internetStatus}");
//缃戠粶鍙樺寲澶勭悊
- HDLCommon.Current.UpdateInternetStatus((int)internetStatus, SharedMethod.SharedMethod.IsBackground);
+ HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground);
//if (internetStatus == NetworkStatus.NotReachable)//娌℃湁缃戠粶杩炴帴 0
//{
diff --git a/HDL_ON/Common/HDLCommon.cs b/HDL_ON/Common/HDLCommon.cs
index 2ef00d9..ee56f54 100644
--- a/HDL_ON/Common/HDLCommon.cs
+++ b/HDL_ON/Common/HDLCommon.cs
@@ -393,22 +393,25 @@
public void UpdateInternetStatus(int internetStatus, bool IsEnterBackground = false)
{
MainPage.Log($"缃戠粶鐘舵�佸彉鍖栵紝褰撳墠缃戠粶:{internetStatus} 鏄惁鍚庡彴:{IsEnterBackground.ToString()}");
+ //缃戠粶鐘舵�佸彉鍖� 閲嶇疆缃戝叧鐘舵�侀噸鏂版悳绱�
+ Control.Ins.GatewayOnline = false;
if (internetStatus == 0)//娌℃湁缃戠粶杩炴帴 0
{
- Control.Ins.GatewayOnline = false;
+ //Control.Ins.GatewayOnline = false;
Control.Ins.IsRemote = false;
MainPage.InternetStatus = 0;
}
else if (internetStatus == 1)//3,4G鐨勭綉缁滆繛鎺� 1
{
- Control.Ins.SearchLoaclGateway();
MainPage.InternetStatus = 1;
+ Control.Ins.SearchLoaclGateway();
+
}
else if (internetStatus == 2)//WiFi缃戠粶
{
- Control.Ins.SearchLoaclGateway();
MainPage.InternetStatus = 2;
+ Control.Ins.SearchLoaclGateway();
}
}
#endregion
diff --git a/HDL_ON/Common/R.cs b/HDL_ON/Common/R.cs
old mode 100755
new mode 100644
index c1448e6..4ff284e
--- a/HDL_ON/Common/R.cs
+++ b/HDL_ON/Common/R.cs
@@ -779,6 +779,10 @@
/// 浣跨敤鏉冮檺
/// </summary>
public const int PermissionToUse = 9060;
+ /// <summary>
+ /// 浣跨敤鏉冮檺
+ /// </summary>
+ public const int PleaseTryToForgetPassword = 9061;
#region 缃戠粶璇锋眰鍝嶅簲閿欒鎻愮ず淇℃伅
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 13b5269..2e8555f 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -25,6 +25,8 @@
public class Control
{
+
+
static Control _control;
public static Control Ins
{
@@ -58,6 +60,14 @@
return t.ToString();
}
+ /// <summary>
+ /// 鏄惁鎼滅储鏈湴缃戝叧鎴愬姛
+ /// </summary>
+ public bool IsSearchLocalGatewaySuccessful = false;
+
+ /// <summary>
+ ///
+ /// </summary>
bool _gatewayOnline = false;
/// <summary>
/// 缃戝叧鏄惁鍦ㄧ嚎
@@ -183,31 +193,54 @@
{
MainPage.Log($"鎼滅储鏈湴缃戝叧鍒楄〃锛岀綉鍏崇被鍨�:{DB_ResidenceData.Instance.GatewayType}");
if (MainPage.InternetStatus == 0)
- return;
- OpenUdp(DB_ResidenceData.Instance.GatewayType == 0 ? 6000 : 8585);
- new System.Threading.Thread(() =>
{
- for (int i = 0; i < 5; i++)
- {
- if (GatewayOnline)
- break;
- if (DB_ResidenceData.Instance.GatewayType == 0)
- {
- new Control_Udp().ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
- }
- else if (DB_ResidenceData.Instance.GatewayType == 1)
- {
- new Control_Udp().SearchLocalGateway();
- }
- System.Threading.Thread.Sleep(500);
- }
- if (!GatewayOnline)//缃戝叧涓嶅湪绾跨殑鏃跺�欐墠鍙皾璇曡繙绋嬭繛鎺�
+ Ins.GatewayOnline = false;
+ return;
+ }
+ else if (MainPage.InternetStatus == 1)
+ {
+ if (!Ins.IsRemote)
{
Ins.IsRemote = true;
DAL.Mqtt.MqttClient.InitState();
}
- })
- { IsBackground = true }.Start();
+ }
+ else if (MainPage.InternetStatus == 2)
+ {
+ OpenUdp(DB_ResidenceData.Instance.GatewayType == 0 ? 6000 : 8585);
+ //閲嶇疆鎼滅储缃戝叧鏍囧織
+ IsSearchLocalGatewaySuccessful = false;
+
+ new System.Threading.Thread(() =>
+ {
+ for (int i = 0; i < 5; i++)
+ {
+ if (IsSearchLocalGatewaySuccessful)
+ break;
+ if (DB_ResidenceData.Instance.GatewayType == 0)
+ {
+ new Control_Udp().ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
+ }
+ else if (DB_ResidenceData.Instance.GatewayType == 1)
+ {
+ new Control_Udp().SearchLocalGateway();
+ }
+ System.Threading.Thread.Sleep(500);
+ }
+
+ if (!IsSearchLocalGatewaySuccessful)
+ {
+ //鏈湴鎼滅储涓嶅埌缃戝叧
+ if (!Ins.IsRemote)
+ {
+ Ins.IsRemote = true;
+ DAL.Mqtt.MqttClient.InitState();
+ }
+ }
+ })
+ { IsBackground = true }.Start();
+ }
+
}
/// <summary>
@@ -443,6 +476,8 @@
var device = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceModule>(bodyJObj.objects.ToString());
if (device.device_mac == DB_ResidenceData.Instance.residenceGatewayMAC)
{
+ //鏈湴鎼滅储缃戝叧鎴愬姛
+ Control.Ins.IsSearchLocalGatewaySuccessful = true;
Ins.GatewayOnline = true;
if (!string.IsNullOrEmpty(device.gatewayId))
{
diff --git a/HDL_ON/DAL/DriverLayer/Packet.cs b/HDL_ON/DAL/DriverLayer/Packet.cs
index f229efc..6164b0e 100644
--- a/HDL_ON/DAL/DriverLayer/Packet.cs
+++ b/HDL_ON/DAL/DriverLayer/Packet.cs
@@ -572,6 +572,8 @@
MainPage.Log($"name : {Name} ; mac : {mac}");
if (DB_ResidenceData.Instance.residenceGatewayMAC == mac)
{
+ //鏈湴鎼滅储缃戝叧鎴愬姛
+ Control.Ins.IsSearchLocalGatewaySuccessful = true;
Control.Ins.GatewayOnline = true;
Control.Ins.IsRemote = false;
DAL.Mqtt.MqttClient.DisConnectRemote();//鏂紑mqtt
diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs
old mode 100755
new mode 100644
index 4ddfc8e..1606485
--- a/HDL_ON/DAL/Mqtt/MqttClient.cs
+++ b/HDL_ON/DAL/Mqtt/MqttClient.cs
@@ -119,7 +119,7 @@
/// <summary>
/// 澶栫綉鐨凪QTT鏄惁姝e湪杩炴帴
/// </summary>
- public static bool remoteMqttIsConnecting;
+ public static bool RemoteMqttIsConnecting;
static bool remoteIsConnected;
static MqttClient()
@@ -138,6 +138,8 @@
{
System.Threading.Thread.Sleep(500);
if (!Control.Ins.IsRemote) continue;
+ //杩涘叆鍚庡彴涓嶅鐞�
+ if (MainPage.IsEnterBackground) continue;
await StartCloudMqtt();
await SubscribeTopics();
@@ -221,7 +223,7 @@
}
//杩藉姞锛氭病鏈夎繙绋嬭繛鎺ョ殑鏉冮檺
- if (remoteMqttIsConnecting || remoteIsConnected)
+ if (RemoteMqttIsConnecting || remoteIsConnected)
{
return;
}
@@ -232,7 +234,7 @@
try
{
#region 鍒濆鍖栬繙绋婱qtt
- remoteMqttIsConnecting = true;
+ RemoteMqttIsConnecting = true;
RemoteMqttClient = new MqttFactory().CreateMqttClient();
@@ -357,7 +359,7 @@
finally
{
//鏈�缁堣閲婃斁杩炴帴鐘舵��
- remoteMqttIsConnecting = false;
+ RemoteMqttIsConnecting = false;
Utlis.WriteLine($"StartCloudMqtt: 缁撴潫");
}
diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs
old mode 100755
new mode 100644
index eb169f9..63c0aa8
--- a/HDL_ON/UI/MainPage.cs
+++ b/HDL_ON/UI/MainPage.cs
@@ -53,6 +53,10 @@
/// 0:鏃犵綉缁�
/// </summary>
public static int InternetStatus = 2;
+ /// <summary>
+ /// 鏄惁杩涘叆鍚庡彴
+ /// </summary>
+ public static bool IsEnterBackground = false;
///// <summary>
///// 鍏徃浠g爜
diff --git a/HDL_ON/UI/UI1-Login/LoginPageBLL.cs b/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
old mode 100755
new mode 100644
index a2d2bb8..eb24336
--- a/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
+++ b/HDL_ON/UI/UI1-Login/LoginPageBLL.cs
@@ -735,6 +735,8 @@
//璐﹀彿鎴栬�呭瘑鐮侀敊璇�
Application.RunOnMainThread(() =>
{
+ waitPage.Hide();
+
if (loginResult.Code == "10008")
{
//鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒
@@ -752,10 +754,16 @@
btnPasswordViewBottomLine.BackgroundColor = CSS_Color.AuxiliaryColor2;
btnPasswordViewBottomLine.Height = Application.GetRealHeight(2);
}
- waitPage.Hide();
+ else if (loginResult.Code == "10019")
+ {
+ var tipStr = Language.StringByID(StringId.AccountLoginLock) + "\r\n" + Language.StringByID(StringId.PleaseTryToForgetPassword);
+ Utlis.ShowTip(tipStr);
+ return;
+ }
+ IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code);
});
- IMessageCommon.Current.ShowErrorInfoAlter(loginResult.Code);
+
}
return result;
}
--
Gitblit v1.8.0