From f30c3a80fc170109e15e75f1477263d38026436e Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 21 五月 2024 15:33:25 +0800 Subject: [PATCH] 机械臂本地控制,安防中心成员限制 --- HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs | 2 HDL-ON_Android/Properties/AndroidManifest.xml | 2 HDL_ON/UI/UI2/1-HomePage/HomePage.cs | 6 + HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs | 4 + HDL_ON/Common/ApiUtlis.cs | 6 +- HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs | 2 HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs | 16 +++- HDL_ON/DAL/Mqtt/MqttClient.cs | 31 ++++++++++ HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs | 2 HDL_ON/Common/HDLCommon.cs | 3 HDL_ON/DAL/Server/HttpUtil.cs | 17 +++-- HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs | 2 HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs | 18 ++++++ HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs | 22 ++++--- 14 files changed, 101 insertions(+), 32 deletions(-) diff --git a/HDL-ON_Android/Properties/AndroidManifest.xml b/HDL-ON_Android/Properties/AndroidManifest.xml index e38e966..2bd7bc3 100644 --- a/HDL-ON_Android/Properties/AndroidManifest.xml +++ b/HDL-ON_Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@ 锘�<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.4.5" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202405201"> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.4.5" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202405211"> <uses-sdk android:minSdkVersion="26" android:targetSdkVersion="29" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <!--鍙嬬洘--> diff --git a/HDL_ON/Common/ApiUtlis.cs b/HDL_ON/Common/ApiUtlis.cs index 2094e6c..edc5d3a 100644 --- a/HDL_ON/Common/ApiUtlis.cs +++ b/HDL_ON/Common/ApiUtlis.cs @@ -72,6 +72,8 @@ /// 涓嬭浇鏁版嵁瀹屾垚鏍囪 /// </summary> public bool DownloadDataComplete = false; + + public bool hadInternet = true; /// <summary> /// 涓嬭浇鏁版嵁 /// </summary> @@ -97,17 +99,15 @@ string code = StateCode.SUCCESS; Inverter.Ins.H5Page = null;//閲嶇疆鍏変紡椤甸潰 - bool hadInternet = true; var downloadDataThread = new System.Threading.Thread(() => { try { //澧炲姞3绉掍簯鏈嶅姟鍣ㄨ繛鎺ユ娴嬶紝杩炰笉涓婃湇鍔″櫒鐨勬椂鍊欎笉鍒锋柊鏁版嵁 + hadInternet = true; var dataList = new List<GlobalRegionListRes>(); var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark }); - Console.WriteLine(DateTime.Now); var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost, "", 3); - Console.WriteLine(DateTime.Now); if (revertObj == null || revertObj.Code != StateCode.SUCCESS) { DownloadDataComplete = true; diff --git a/HDL_ON/Common/HDLCommon.cs b/HDL_ON/Common/HDLCommon.cs index 4ebf51c..9e8aee9 100644 --- a/HDL_ON/Common/HDLCommon.cs +++ b/HDL_ON/Common/HDLCommon.cs @@ -802,7 +802,8 @@ } else { - IMessageCommon.Current.ShowErrorInfoAlter(result.Code); + if (result.Code != "-1") + IMessageCommon.Current.ShowErrorInfoAlter(result.Code); } } catch (Exception ex) diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index 246c9b7..cea69ec 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -13,6 +13,8 @@ using HDL_ON.UI; using HDL_ON.DAL.Server; using HDL_ON; +using Newtonsoft.Json; +using System.Collections.Generic; namespace HDL_ON.DAL.Mqtt { @@ -159,6 +161,7 @@ public static void InitState() { IfNeedReadAllDeviceStatus = true; + Common.ApiUtlis.Ins.hadInternet = true; StartCloudMqtt(); } @@ -338,7 +341,13 @@ public static async Task StartCloudMqtt() { //娌℃湁缃戠粶鐨勭姸鎬佷笅灏濊瘯涓�涓嬭繛鎺qtt 锛屽畨鍗撶殑缃戠粶鐘舵�佸彉鍖栫洃鍚湁寮傚父锛屼慨鏀瑰簳灞傞夯鐑� - if (MainPage.InternetStatus == 0 && MainPage.LinkHdlMqttCount > 1) + if (MainPage.InternetStatus == 0 && MainPage.LinkHdlMqttCount > 1 ) + { + return; + } + + + if (!Common.ApiUtlis.Ins.hadInternet) { return; } @@ -364,6 +373,26 @@ await Task.Factory.StartNew((Func<Task>)(async () => { try { + try + { + //澧炲姞3绉掍簯鏈嶅姟鍣ㄨ繛鎺ユ娴嬶紝杩炰笉涓婃湇鍔″櫒鐨勬椂鍊欎笉鍒锋柊鏁版嵁 + var dataList = new List<GlobalRegionListRes>(); + var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark }); + var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost, "", 3); + if (revertObj == null || revertObj.Code != StateCode.SUCCESS) + { + Common.ApiUtlis.Ins.hadInternet = false; + return; + } + else + { + Common.ApiUtlis.Ins.hadInternet = true; + } + } + catch + { + } + #region 鍒濆鍖栬繙绋婱qtt RemoteMqttIsConnecting = true; RemoteMqttClient = new MqttFactory().CreateMqttClient(); diff --git a/HDL_ON/DAL/Server/HttpUtil.cs b/HDL_ON/DAL/Server/HttpUtil.cs index ae59520..cd66d30 100644 --- a/HDL_ON/DAL/Server/HttpUtil.cs +++ b/HDL_ON/DAL/Server/HttpUtil.cs @@ -38,7 +38,7 @@ /// <summary> /// 璇锋眰瓒呮椂鏃堕棿 /// </summary> - public const int TIME_OUT = 15; + public const int TIME_OUT = 10; /// <summary> /// 鐗规畩鎺ュ彛璇锋眰瓒呮椂鏃堕棿 /// </summary> @@ -162,6 +162,11 @@ { return new ResponsePackNew() { Code = "0" ,Data = "" }; } + if (!Common.ApiUtlis.Ins.hadInternet) + { + MainPage.Log("娌℃湁澶栫綉锛岀洿鎺ラ��鍑鸿姹�"); + return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR, message = Language.StringByID(StringId.FailedRequestServer) }; + } #region HttpWebRequest try { @@ -214,7 +219,7 @@ } } IRestResponse response = client.Execute(request); - HDL_ON.Utlis.WriteLine("鍙戦��", requestFullUrl, response.Request.Body?.Value.ToString()); + MainPage.Log("鍙戦��:"+ requestFullUrl, response.Request.Body?.Value.ToString()); if(apiPath == NewAPI.API_POST_Login) { var ddd = Newtonsoft.Json.JsonConvert.SerializeObject(response); @@ -261,14 +266,14 @@ } catch { } } - return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR }; + return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR, message = Language.StringByID(StringId.FailedRequestServer) }; } } catch (Exception ex) { HDL_ON.Utlis.WriteLine(ex.Message); - return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR }; + return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR ,message = Language.StringByID(StringId.FailedRequestServer) }; } #endregion @@ -503,14 +508,14 @@ else { HDL_ON.Utlis.WriteLine(response.Content); - return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR }; + return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR, message = Language.StringByID(StringId.FailedRequestServer) }; } } catch (Exception ex) { HDL_ON.Utlis.WriteLine(ex.Message); - return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR }; + return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR, message = Language.StringByID(StringId.FailedRequestServer) }; } #endregion diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs index d3a4868..03de85a 100644 --- a/HDL_ON/UI/UI2/1-HomePage/HomePage.cs +++ b/HDL_ON/UI/UI2/1-HomePage/HomePage.cs @@ -444,7 +444,7 @@ SelectedImagePath = "Collection/DefenseStatusIcon.png", UnSelectedImagePath = "Collection/DisarmStatusIcon.png" }; - if (DB_ResidenceData.Instance.GatewayType == 1) + if (DB_ResidenceData.Instance.GatewayType == 1 && !DB_ResidenceData.Instance.CurrentRegion.isOtherShare) { topView.AddChidren(btnSecurityStatus); @@ -502,6 +502,10 @@ UnSelectedImagePath = "Collection/MsgIcon.png", SelectedImagePath = "Collection/MsgIconTip.png", }; + if(btnSecurityStatus.Parent == null) + { + btnMsgIcon.X = Application.GetRealWidth(329); + } topView.AddChidren(btnMsgIcon); diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs index c8b2efd..59d643c 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs @@ -748,7 +748,7 @@ case ShowFunction.SecurityMonitoring: if (!MainPage.NoLoginMode) { - if (OnAppConfig.Instance.RequestHttpsHost.Contains("bahrain")) + if (OnAppConfig.Instance.RequestHttpsHost.Contains("bahrain") || !Common.ApiUtlis.Ins.hadInternet) { functionCount = 0; } @@ -775,10 +775,16 @@ functionOnCount = FunctionList.List.GetAcstParentList().FindAll((obj) => obj.trait_on_off.curValue.ToString() == "on").Count; break; case ShowFunction.VideoDoorLock: - functionCount = FunctionList.List.GetVideoDoorLockList().Count; - functionOnCount = FunctionList.List.GetAcstParentList().FindAll((obj) => obj.GetAttrState("status").ToString() == "open" - || obj.GetAttrState("status").ToString() == "normal_open").Count; - + if (Common.ApiUtlis.Ins.hadInternet) + { + functionCount = FunctionList.List.GetVideoDoorLockList().Count; + functionOnCount = FunctionList.List.GetAcstParentList().FindAll((obj) => obj.GetAttrState("status").ToString() == "open" + || obj.GetAttrState("status").ToString() == "normal_open").Count; + } + else + { + functionCount = 0; + } break; case ShowFunction.Aks: functionCount = FunctionList.List.GetVideoControlsList().Count; diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs b/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs index 88447f3..c0e43e7 100644 --- a/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs @@ -385,6 +385,16 @@ System.Threading.Thread.Sleep(sleepTime); } break; + case ShowFunction.MechanicalArm: + foreach (var f in FunctionList.List.GetMechanicalArmList()) + { + f.trait_on_off.curValue = onoff; + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add(FunctionAttributeKey.OnOff, f.trait_on_off.curValue.ToString()); + Control.Ins.SendWriteCommand(f, d); + System.Threading.Thread.Sleep(sleepTime); + } + break; } } else @@ -423,6 +433,14 @@ } Control.Ins.SwtichFunctions(onoff == "on", eleList); break; + case ShowFunction.MechanicalArm: + List<Function> meArmList = new List<Function>(); + foreach (var f in FunctionList.List.GetMechanicalArmList()) + { + meArmList.Add(f); + } + Control.Ins.SwtichFunctions(onoff == "on", meArmList); + break; } diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs index e75b636..6a9bac7 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs @@ -86,16 +86,18 @@ btnSwitch.MouseUpEventHandler = (sender, e) => { - if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣� - { - new Tip() - { - CloseTime = 1, - Text = Language.StringByID(StringId.DeviceOfflineCannotOption), - Direction = AMPopTipDirection.None, - }.Show(MainPage.BaseView); - return; - } + //DriverLayer.Control.Ins.GatewayOnline_Cloud = false; + //DriverLayer.Control.Ins.GatewayOnline_Local = true; + //if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣� + //{ + // new Tip() + // { + // CloseTime = 1, + // Text = Language.StringByID(StringId.DeviceOfflineCannotOption), + // Direction = AMPopTipDirection.None, + // }.Show(MainPage.BaseView); + // return; + //} btnSwitch.IsSelected = !btnSwitch.IsSelected; if(SPK.NotStatusSpkList.Contains( function.spk )) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs index c8c2e0e..8bf6a94 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs @@ -579,7 +579,7 @@ /// <param name="api_Url">璇锋眰鍦板潃(涓嶆槸缁濆鍦板潃)</param> /// <param name="tag">鏍囪->鎻忚堪鎺ュ彛(鑷畾涔�)</param> /// <returns></returns> - public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag,int mTimeout = 3) + public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag,int mTimeout = 8) { Log($"{DateTime.Now}->鍙戦��->{tag}", api_Url,o.ToString()); var requestJson = HttpUtil.GetSignRequestJson(o); diff --git a/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs b/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs index c5c07c0..0d20f45 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs @@ -727,6 +727,10 @@ { btnAddIcon.MouseUpEventHandler = (sender, e) => { + if (btnSecurityTitle.IsSelected) + { + return; + } if (!btnAutomationTitle.IsSelected) { //濡傛灉鏄垚鍛� diff --git a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs index ff748b3..d457f62 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/MechanicalArmPage.cs @@ -154,7 +154,7 @@ { var dic = new Dictionary<string, string>(); dic.Add(FunctionAttributeKey.OnOff, statu); - Control.Ins.SendWriteCommand(this.device, dic, true); + Control.Ins.SendWriteCommand(this.device, dic); HdlThreadLogic.Current.RunMain(() => { this.btnPictrue.CanClick = true; diff --git a/HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs b/HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs index 5cfa50d..f4873e7 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs @@ -230,7 +230,7 @@ { if (TipType.flicker == tipType) { - if (responsePackNew == null) + if (responsePackNew == null || responsePackNew.Code == "-1") { responsePackNew = new ResponsePackNew { message = "娌″洖澶�,璇风‘璁ょ綉缁滄槸鍚︽甯�.", Code = "-1", }; } diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs index 0734e13..7ba3ab9 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs @@ -325,7 +325,7 @@ /// <param name="api_Url">璇锋眰鍦板潃(涓嶆槸缁濆鍦板潃)</param> /// <param name="tag">鏍囪->鎻忚堪鎺ュ彛(鑷畾涔�)</param> /// <returns></returns> - public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag, int mTimeout = 15) + public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag, int mTimeout = 10) { JObject jobject = JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(o)); return UI2.Intelligence.Automation.Send.Current.RequestServerhomeId(jobject, api_Url, tag, mTimeout); -- Gitblit v1.8.0