wxr
2020-12-19 e327510c7329aa9a95e62a460ec659ea0c9563ad
Merge branch 'CJL' into NewFilePath
12个文件已修改
185 ■■■■ 已修改文件
HDL-ON_Android/Application.cs 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_Android/Assets/Language.ini 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_iOS/AppDelegate.cs 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_iOS/Resources/Language.ini 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_iOS/ViewController.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Common/HDLCommon.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Common/R.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/DriverLayer/Control.cs 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/DriverLayer/Packet.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/Mqtt/MqttClient.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/MainPage.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI1-Login/LoginPageBLL.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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正在连接重置状态
            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();
        }
    }
}
HDL-ON_Android/Assets/Language.ini
old mode 100755 new mode 100644
@@ -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=请求服务器失败,请稍后再试!
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正在连接重置状态
            //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正在连接重置状态
            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();
        }
    }
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=请求服务器失败,请稍后再试!
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
            //{
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
HDL_ON/Common/R.cs
old mode 100755 new mode 100644
@@ -779,6 +779,10 @@
        /// 使用权限
        /// </summary>
        public const int PermissionToUse = 9060;
        /// <summary>
        /// 使用权限
        /// </summary>
        public const int PleaseTryToForgetPassword = 9061;
        #region 网络请求响应错误提示信息
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,13 +193,29 @@
        {
            MainPage.Log($"搜索本地网关列表,网关类型:{DB_ResidenceData.Instance.GatewayType}");
            if (MainPage.InternetStatus == 0)
            {
                Ins.GatewayOnline = false;
                return;
            }
            else if (MainPage.InternetStatus == 1)
            {
                if (!Ins.IsRemote)
                {
                    Ins.IsRemote = true;
                    DAL.Mqtt.MqttClient.InitState();
                }
            }
            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 (GatewayOnline)
                        if (IsSearchLocalGatewaySuccessful)
                        break;
                    if (DB_ResidenceData.Instance.GatewayType == 0)
                    {
@@ -201,13 +227,20 @@
                    }
                    System.Threading.Thread.Sleep(500);
                }
                if (!GatewayOnline)//网关不在线的时候才可尝试远程连接
                    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))
                        {
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
HDL_ON/DAL/Mqtt/MqttClient.cs
old mode 100755 new mode 100644
@@ -119,7 +119,7 @@
        /// <summary>
        /// 外网的MQTT是否正在连接
        /// </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 初始化远程Mqtt
                    remoteMqttIsConnecting = true;
                    RemoteMqttIsConnecting = true;
                    RemoteMqttClient = new MqttFactory().CreateMqttClient();
@@ -357,7 +359,7 @@
                finally
                {
                    //最终要释放连接状态
                    remoteMqttIsConnecting = false;
                    RemoteMqttIsConnecting = false;
                    Utlis.WriteLine($"StartCloudMqtt: 结束");
                }
HDL_ON/UI/MainPage.cs
old mode 100755 new mode 100644
@@ -53,6 +53,10 @@
        /// 0:无网络
        /// </summary>
        public static int InternetStatus = 2;
        /// <summary>
        /// 是否进入后台
        /// </summary>
        public static bool IsEnterBackground = false;
        ///// <summary>
        ///// 公司代码
HDL_ON/UI/UI1-Login/LoginPageBLL.cs
old mode 100755 new mode 100644
@@ -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;
        }