From d6578b10542226650e263815dea75e598a7090f9 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 17 八月 2022 13:22:02 +0800
Subject: [PATCH] tcp状态更新,iOS扫描
---
HDL_ON/DAL/DriverLayer/Control_Tcp.cs | 811 ++++++++++++++++++++++++++
HDL-ON_Android/Properties/AndroidManifest.xml | 2
HDL_ON/DAL/DriverLayer/UdpSocket.cs | 1
DLL/IOS/HDL.Shared.IOS.ScanQRCode.dll | 0
HDL_ON/DAL/DriverLayer/Control_TcpServer.cs | 2
HDL-ON_Android/Assets/Language.ini | 4
HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacControlPage.cs | 10
HDL-ON_iOS/HDL-ON_iOS.csproj | 3
HDL-ON_Android/Assets/Phone/Public/IotCheckIcon.png | 0
HDL_ON/HDL_ON.projitems | 1
HDL-ON_Android/Assets/Phone/Public/IotCheckOnIcon.png | 0
HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs | 10
HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandListPage.cs | 19
HDL-ON_Android/HDL-ON_Android.csproj | 2
HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs | 125 +++
HDL-ON_iOS/Info.plist | 4
HDL-ON_iOS/Resources/Language.ini | 13
HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs | 8
HDL_ON/DAL/DriverLayer/Control.cs | 135 +++-
HDL_ON/UI/MainPage.cs | 11
HDL_ON/Entity/Function/Scene.cs | 5
HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_AuthorizedPage.cs | 114 +++
HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPageBLL.cs | 12
HDL_ON/Entity/Integratedbrand/IntegratedBrand.cs | 2
HDL_ON/Common/ImageUtlis.cs | 68 +
HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs | 74 +
HDL-ON_iOS/Scan.cs | 101 ++-
HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs | 8
HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/iot_BindTipPage.cs | 62 +
HDL_ON/Common/R.cs | 4
HDL_ON/DAL/Server/HttpServerRequest.cs | 18
HDL_ON/DAL/DriverLayer/Control_TcpClient.cs | 178 ++++-
32 files changed, 1,573 insertions(+), 234 deletions(-)
diff --git a/DLL/IOS/HDL.Shared.IOS.ScanQRCode.dll b/DLL/IOS/HDL.Shared.IOS.ScanQRCode.dll
new file mode 100644
index 0000000..8d81fa4
--- /dev/null
+++ b/DLL/IOS/HDL.Shared.IOS.ScanQRCode.dll
Binary files differ
diff --git a/HDL-ON_Android/Assets/Language.ini b/HDL-ON_Android/Assets/Language.ini
index 3de2aa2..ed2b28e 100644
--- a/HDL-ON_Android/Assets/Language.ini
+++ b/HDL-ON_Android/Assets/Language.ini
@@ -546,6 +546,7 @@
558=Someone is sitting
559=Bind a third-party account
560=Bound
+561=Original password
@@ -1751,6 +1752,7 @@
558=鏈変汉鍧愮潃
559=缁戝畾绗笁鏂硅处鍙�
560=宸茬粦瀹�
+561=鍘熷瘑鐮�
@@ -2935,6 +2937,7 @@
558=Someone is sitting
559=Bind a third-party account
560=Bound
+561=Original password
2532=Visitor Invitation Record
@@ -4130,6 +4133,7 @@
558=Someone is sitting
559=Bind a third-party account
560=Bound
+561=Original password
2532=Visitor Invitation Record
diff --git a/HDL-ON_Android/Assets/Phone/Public/IotCheckIcon.png b/HDL-ON_Android/Assets/Phone/Public/IotCheckIcon.png
new file mode 100644
index 0000000..0fa6702
--- /dev/null
+++ b/HDL-ON_Android/Assets/Phone/Public/IotCheckIcon.png
Binary files differ
diff --git a/HDL-ON_Android/Assets/Phone/Public/IotCheckOnIcon.png b/HDL-ON_Android/Assets/Phone/Public/IotCheckOnIcon.png
new file mode 100644
index 0000000..0dffe12
--- /dev/null
+++ b/HDL-ON_Android/Assets/Phone/Public/IotCheckOnIcon.png
Binary files differ
diff --git a/HDL-ON_Android/HDL-ON_Android.csproj b/HDL-ON_Android/HDL-ON_Android.csproj
index b8f8906..232a6cb 100644
--- a/HDL-ON_Android/HDL-ON_Android.csproj
+++ b/HDL-ON_Android/HDL-ON_Android.csproj
@@ -260,6 +260,8 @@
<AndroidAsset Include="Assets\Phone\FunctionIcon\Icon\HomeIcon\sensormegahealth.png" />
<AndroidAsset Include="Assets\Phone\Public\Iot_agreement_icon.png" />
<AndroidAsset Include="Assets\Phone\Public\LinkIotIcon.png" />
+ <AndroidAsset Include="Assets\Phone\Public\IotCheckIcon.png" />
+ <AndroidAsset Include="Assets\Phone\Public\IotCheckOnIcon.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\colors.xml" />
diff --git a/HDL-ON_Android/Properties/AndroidManifest.xml b/HDL-ON_Android/Properties/AndroidManifest.xml
index 0729416..f4b6684 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="1.6.0" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202208031">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.6.0" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202208151">
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="29" />
<!--鍙嬬洘-->
<!--<uses-sdk android:minSdkVersion="8"></uses-sdk>-->
diff --git a/HDL-ON_iOS/HDL-ON_iOS.csproj b/HDL-ON_iOS/HDL-ON_iOS.csproj
index f197eec..a1955c5 100644
--- a/HDL-ON_iOS/HDL-ON_iOS.csproj
+++ b/HDL-ON_iOS/HDL-ON_iOS.csproj
@@ -114,6 +114,9 @@
<Reference Include="Shared.IOS.HDLFVSDK">
<HintPath>..\DLL\IOS\Shared.IOS.HDLFVSDK.dll</HintPath>
</Reference>
+ <Reference Include="HDL.Shared.IOS.ScanQRCode">
+ <HintPath>..\DLL\IOS\HDL.Shared.IOS.ScanQRCode.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
diff --git a/HDL-ON_iOS/Info.plist b/HDL-ON_iOS/Info.plist
index 076ab47..0000150 100644
--- a/HDL-ON_iOS/Info.plist
+++ b/HDL-ON_iOS/Info.plist
@@ -100,9 +100,9 @@
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>CFBundleShortVersionString</key>
- <string>1.5.902207251</string>
+ <string>1.6.002208151</string>
<key>CFBundleVersion</key>
- <string>1.5.907251</string>
+ <string>1.6.008151</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Use geographic location to provide services such as weather</string>
<key>NSAppleMusicUsageDescription</key>
diff --git a/HDL-ON_iOS/Resources/Language.ini b/HDL-ON_iOS/Resources/Language.ini
index bfc05e6..ed2b28e 100644
--- a/HDL-ON_iOS/Resources/Language.ini
+++ b/HDL-ON_iOS/Resources/Language.ini
@@ -544,6 +544,9 @@
556=Someone is running
557=Someone is standing
558=Someone is sitting
+559=Bind a third-party account
+560=Bound
+561=Original password
@@ -1747,6 +1750,9 @@
556=鏈変汉鍦ㄨ窇
557=鏈変汉绔欑潃
558=鏈変汉鍧愮潃
+559=缁戝畾绗笁鏂硅处鍙�
+560=宸茬粦瀹�
+561=鍘熷瘑鐮�
@@ -2929,6 +2935,9 @@
556=Someone is running
557=Someone is standing
558=Someone is sitting
+559=Bind a third-party account
+560=Bound
+561=Original password
2532=Visitor Invitation Record
@@ -4122,6 +4131,10 @@
556=Someone is running
557=Someone is standing
558=Someone is sitting
+559=Bind a third-party account
+560=Bound
+561=Original password
+
2532=Visitor Invitation Record
2533=Visitor management
diff --git a/HDL-ON_iOS/Scan.cs b/HDL-ON_iOS/Scan.cs
index 9bc60b9..8f159ad 100644
--- a/HDL-ON_iOS/Scan.cs
+++ b/HDL-ON_iOS/Scan.cs
@@ -2,7 +2,7 @@
using HDL_ON_iOS;
using Shared;
using ZXing.Mobile;
-
+using HDL.Shared.IOS.ScanQRCode;
namespace HDL_ON
{
public class Scan
@@ -27,51 +27,78 @@
}
- static MobileBarcodeScanner scanner;
- public async void OpenScan(Action<string> action)
+ void ScanResult(string result)
{
- string cancel = "鍙栨秷";
- string flashText = "";
- string titleText = "浜岀淮鐮佹壂鎻�";
- if (Language.CurrentLanguage != "Chinese")
- {
- cancel = "Cancel";
- flashText = "";
- titleText = "Scan";
- }
-
- if (scanner == null)
- {
- var mZXingOverlayView = new ZXingOverlayView(cancel, flashText, titleText);
- scanner = new MobileBarcodeScanner(AppDelegate.rootViewController) { FlashButtonText = flashText, TopText = titleText, BottomText = "", CancelButtonText = cancel };
- scanner.UseCustomOverlay = true;
-
- scanner.CustomOverlay = mZXingOverlayView;
- var bOn = false;
- mZXingOverlayView.OnCancel += () =>
- {
- scanner?.Cancel();
- };
-
- mZXingOverlayView.OnTorch += () =>
- {
- bOn = !bOn;
- scanner?.Torch(bOn);
- };
-
- }
-
- var result = await scanner.Scan();
-
if (result != null)
{
- action?.Invoke(result.Text);
+ action?.Invoke(result);
}
else
{
action?.Invoke(null);
Console.WriteLine("浜岀淮鐮佽繑鍥炲�间负null");
}
+
+ }
+
+ static MobileBarcodeScanner scanner;
+
+
+ Action<string> action;
+
+ public void OpenScan(Action<string> action)
+ {
+ this.action = action;
+
+ string cancel = "鍙栨秷";
+ //string flashText = "";
+ string titleText = "浜岀淮鐮佹壂鎻�";
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ cancel = "Cancel";
+ //flashText = "";
+ titleText = "Scan";
+ }
+ var d1 = new HDLQRCodeScanFinish(ScanResult);
+ HDL.Shared.IOS.ScanQRCode.HDLScanQRCodeSDK.SharedInstance().ScanQRCodeWith(cancel, titleText, d1);
+
+
+
+ //if (scanner == null)
+ //{
+ // var mZXingOverlayView = new ZXingOverlayView(cancel, flashText, titleText);
+ // scanner = new MobileBarcodeScanner(AppDelegate.rootViewController) { FlashButtonText = flashText, TopText = titleText, BottomText = "", CancelButtonText = cancel };
+ // scanner.UseCustomOverlay = true;
+
+ // scanner.CustomOverlay = mZXingOverlayView;
+ // var bOn = false;
+ // mZXingOverlayView.OnCancel += () =>
+ // {
+ // scanner?.Cancel();
+ // };
+
+ // mZXingOverlayView.OnTorch += () =>
+ // {
+ // bOn = !bOn;
+ // scanner?.Torch(bOn);
+ // };
+
+ //}
+
+ //var result = await scanner.Scan();
+
+ //if (result != null)
+ //{
+ // action?.Invoke(result.Text);
+ //}
+ //else
+ //{
+ // action?.Invoke(null);
+ // Console.WriteLine("浜岀淮鐮佽繑鍥炲�间负null");
+ //}
+
+
+
}
public static byte[] BytesFromText(string text, int width = 300, int height = 300)
diff --git a/HDL_ON/Common/ImageUtlis.cs b/HDL_ON/Common/ImageUtlis.cs
index b13acd1..54cdb55 100644
--- a/HDL_ON/Common/ImageUtlis.cs
+++ b/HDL_ON/Common/ImageUtlis.cs
@@ -4,6 +4,8 @@
using System.IO;
using HDL_ON.Common;
using System.Collections.Generic;
+using System.Text;
+using System.Security.Cryptography;
namespace HDL_ON
{
@@ -179,19 +181,26 @@
/// </summary>
public byte[] GetImageDownloadUrl(string imageKey)
{
- var requestJson = HttpUtil.GetSignRequestJson(new GetImageUrlObj()
+ if (imageKey.StartsWith("https:"))
{
- imageKey = imageKey,
- });
- var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetImageUrl, requestJson);
- if (revertObj.Code == StateCode.SUCCESS)
+ return HttpUtil.HttpsDownload(imageKey);
+ }
+ else
{
- if (revertObj.Data != null)
+ var requestJson = HttpUtil.GetSignRequestJson(new GetImageUrlObj()
{
- if (!string.IsNullOrEmpty(revertObj.Data.ToString()))
+ imageKey = imageKey,
+ });
+ var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetImageUrl, requestJson);
+ if (revertObj.Code == StateCode.SUCCESS)
+ {
+ if (revertObj.Data != null)
{
- var url = revertObj.Data.ToString();
- return HttpUtil.HttpsDownload(url);
+ if (!string.IsNullOrEmpty(revertObj.Data.ToString()))
+ {
+ var url = revertObj.Data.ToString();
+ return HttpUtil.HttpsDownload(url);
+ }
}
}
}
@@ -294,6 +303,34 @@
}
}
+
+ string strKey = "abcdefgh";//娉ㄦ剰锛氳繖閲岀殑瀵嗛挜sKey蹇呴』鑳借浆涓�8涓猙yte锛屽嵆杈撳叆瀵嗛挜涓�8鍗婅涓瓧绗︽垨鑰�4涓叏瑙掑瓧绗︽垨鑰�4涓眽瀛楃殑瀛楃涓�
+ string strIV = "ijklmnop";
+
+ // 鍔犲瘑
+ private string Encrypt(string _strQ)
+ {
+ byte[] buffer = Encoding.UTF8.GetBytes(_strQ);
+ MemoryStream ms = new MemoryStream();
+ DESCryptoServiceProvider des = new DESCryptoServiceProvider();
+ CryptoStream encStream = new CryptoStream(ms, des.CreateEncryptor(Encoding.UTF8.GetBytes(strKey), Encoding.UTF8.GetBytes(strIV)), CryptoStreamMode.Write);
+ encStream.Write(buffer, 0, buffer.Length);
+ encStream.FlushFinalBlock();
+ return Convert.ToBase64String(ms.ToArray());
+ }
+
+ // 瑙e瘑
+ private string Decrypt(string _strQ)
+ {
+ byte[] buffer = Convert.FromBase64String(_strQ);
+ MemoryStream ms = new MemoryStream();
+ DESCryptoServiceProvider des = new DESCryptoServiceProvider();
+ CryptoStream encStream = new CryptoStream(ms, des.CreateDecryptor(Encoding.UTF8.GetBytes(strKey), Encoding.UTF8.GetBytes(strIV)), CryptoStreamMode.Write);
+ encStream.Write(buffer, 0, buffer.Length);
+ encStream.FlushFinalBlock();
+ return Encoding.UTF8.GetString(ms.ToArray());
+ }
+
/// <summary>
/// 2020-12-03
/// 妫�娴嬪姞杞藉浘鐗�
@@ -306,6 +343,13 @@
{
try
{
+ var imageUrl = imageKey;
+
+ if (imageUrl.StartsWith("http"))
+ {
+ imageKey = Encrypt(imageKey);
+ }
+
//1.鏈湴榛樿鍥惧簱鍥剧墖锛岀洿鎺ュ姞杞芥湰鍦�
if (imageKey.Contains("Classification/Room/Roombg") || imageKey.Contains("Intelligence/Gallery/scenebg"))
{
@@ -333,7 +377,7 @@
//2.2 鏈湴娌$紦瀛橈紝寮�鍚嚎绋嬩簯绔笅杞界劧鍚庣紦瀛�
System.Threading.Tasks.Task.Run(() =>
{
- byte[] imageBytes = GetImageDownloadUrl(imageKey);
+ byte[] imageBytes = GetImageDownloadUrl(imageUrl);
if (imageBytes != null)
{
WriteFileByBytes(imageKey, imageBytes);
@@ -343,14 +387,14 @@
if (frameLayout != null)
{
frameLayout.BackgroundImagePath = imageKey;
- //Utlis.WriteLine("imageKey 鍔犺浇浜戠涓嬭浇鍥剧墖鎴愬姛");
+ Utlis.WriteLine("imageKey 鍔犺浇浜戠涓嬭浇鍥剧墖鎴愬姛");
}
});
}
else
{
//2.4 涓嬭浇鏄惁锛屾槸鍚︿娇鐢ㄩ粯璁ゅ浘鐗�
- //Utlis.WriteLine("imageKey 鍔犺浇浜戠鍥剧墖澶辫触");
+ Utlis.WriteLine("imageKey 鍔犺浇浜戠鍥剧墖澶辫触");
}
});
}
diff --git a/HDL_ON/Common/R.cs b/HDL_ON/Common/R.cs
index 9cf7833..c1c0dbf 100644
--- a/HDL_ON/Common/R.cs
+++ b/HDL_ON/Common/R.cs
@@ -5,6 +5,10 @@
public static class StringId
{
/// <summary>
+ /// 鍘熷瘑鐮�
+ /// </summary>
+ public const int OriginalPassword = 561;
+ /// <summary>
/// 宸茬粦瀹�
/// </summary>
public const int Bound = 560;
diff --git a/HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs b/HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs
index 66599af..98e640b 100644
--- a/HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs
+++ b/HDL_ON/DAL/DriverLayer/A_Protocol_Common.cs
@@ -196,6 +196,16 @@
return $"/user/{Control.Ins.GatewayId}/custom/security/list/get";
}
}
+ /// <summary>
+ /// 蹇冭烦鍖�
+ /// </summary>
+ public string HeartBeat
+ {
+ get
+ {
+ return $"/user/{Control.Ins.GatewayId}/custom/gateway/heartbeat";
+ }
+ }
#region 闂ㄩ攣
public string OneKeyUnlock
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 2b0623c..ab30fc6 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -4,26 +4,12 @@
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.UI;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using Shared;
namespace HDL_ON.DriverLayer
{
- /// <summary>
- /// 閫氳鏂瑰紡
- /// </summary>
- public enum CommunicationMode
- {
- none,
- /// <summary>
- /// 鏈湴udp
- /// </summary>
- local_BusUdp,
- /// <summary>
- /// 鏈湴tcp瀹㈡埛绔�
- /// </summary>
- tcp_local_client,
- }
-
public class Control
{
@@ -43,6 +29,11 @@
/// 璁板綍鎺ユ敹鍒扮殑娑堟伅锛屾柟渚縵b鐨勫伐绋嬪笀璋冭瘯浠栦滑鐨勮澶�
/// </summary>
public List<string> MsgInfoList = new List<string>();
+ /// <summary>
+ /// 鏈湴tcp瀹㈡埛绔繛鎺ユ槸鍚︽垚鍔�
+ /// 鏄惁鐧诲綍缃戝叧鎴愬姛
+ /// </summary>
+ public bool LocalTcpClientLogin = false;
int _msg_id = 1;
/// <summary>
@@ -200,11 +191,6 @@
public Control_Udp myUdp1 = null;
/// <summary>
- /// 閫氳鏂瑰紡
- /// </summary>
- public CommunicationMode communicationMode;
-
- /// <summary>
/// 鎵撳紑tcp鏈嶅姟绔�
/// </summary>
public void OpenTcpServer()
@@ -297,6 +283,38 @@
}
}
+
+ private System.Threading.Thread loginGatewayThread;
+
+ /// <summary>
+ /// 鐧诲綍缃戝叧
+ /// </summary>
+ public void LoginGateway()
+ {
+ if(loginGatewayThread== null)
+ {
+ loginGatewayThread = new System.Threading.Thread(() => {
+ while (true)
+ {
+ if (Ins.GatewayOnline_Local && myTcpClient.isConnected && LocalTcpClientLogin)
+ {
+ var sendData = new { clientType = "app", version = "1.0" };
+ var sendJob = new { id = Control.Ins.msg_id.ToString(), time_stamp = Utlis.GetTimestamp(), objects = sendData };
+
+ var bodyString = JsonConvert.SerializeObject(sendJob);
+
+ var sendBytes = ConvertSendBodyData($"/user/{GatewayId}/custom/gateway/login", bodyString);
+
+ Ins.myTcpClient.SendMessage(sendBytes);
+ }
+ System.Threading.Thread.Sleep(2000);
+ }
+
+ });
+ }
+ }
+
+
/// <summary>
/// 鍦烘櫙鎺у埗鍏ュ彛
/// </summary>
@@ -342,15 +360,6 @@
}
}
}
- /// <summary>
- /// 瀹夐槻鎺у埗
- /// </summary>
- public void ControlArm()
- {
- DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
- //var pack = httpServer.GetSecurityAlarmLogList
- }
-
/// <summary>
/// 鍙戦�佸懡浠�
@@ -903,6 +912,12 @@
//}
receiveObj.BodyDataString = res[1];
+ if(receiveObj.Topic == CommunicationTopic.ct.HeartBeat)
+ {
+
+ return null;
+ }
+
//2021-09-23 杩囨护涓嶉渶瑕佽В瀵嗙殑涓婚 鐩墠鎼滅储缃戝叧涓婚涓嶅姞瀵�
if (receiveObj.Topic != CommunicationTopic.SearchLoaclGatewayReply)
{
@@ -943,6 +958,21 @@
}
}
+ try
+ {
+ var idMsg = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(res[1]);
+ var hasProcess = hasItBeenProcessed(idMsg.id);
+ if (hasProcess)
+ {
+ return null;
+ }
+ MainPage.Log($"澶勭悊灞�鍩熺綉鏁版嵁id:{idMsg.id}");
+
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"瑙f瀽灞�鍩熺綉鏁版嵁寮傚父{ex.Message}");
+ }
if (receiveObj.Topic == CommunicationTopic.SearchLoaclGatewayReply || receiveObj.Topic == CommunicationTopic.GatewayBroadcast)
{
@@ -975,17 +1005,22 @@
//2021-09-23 鏂板鑾峰彇褰撳墠缃戝叧鏄惁鏈湴鍔犲瘑
Ins.IsLocalEncrypt = device.isLocalEncrypt;
//MainPage.Log("缃戝叧鏈湴鍔犲瘑鐘舵�侊細" + device.local_encrypt.ToString());
+
+ OpenTcpClent();
+
+ LoginGateway();
+
}
}
else if (receiveObj.Topic == CommunicationTopic.ct.ReadStatus + "_reply" ||
receiveObj.Topic == CommunicationTopic.ct.ControlFunctionTopic + "_reply" ||
receiveObj.Topic == CommunicationTopic.ct.GatewayUpStatus ||
- receiveObj.Topic.Contains( CommunicationTopic.ct.GatewayUpSortTopic))
+ receiveObj.Topic.Contains(CommunicationTopic.ct.GatewayUpSortTopic))
{
//TODO 鏆傛椂涓嶄紶姝g‘鐨勬暟鎹笂鍘伙紝濡傛灉鍚庨潰瑕佷紭鍖栧墠闈㈣繖浜涗唬鐮�
UpdataFunctionStatus(receiveObj.BodyDataString, null);
}
- else if (receiveObj.Topic == CommunicationTopic.ct.ControlSeurity +"_reply"
+ else if (receiveObj.Topic == CommunicationTopic.ct.ControlSeurity + "_reply"
|| receiveObj.Topic == CommunicationTopic.ct.ReadSecurityStatus + "_reply"
|| receiveObj.Topic == CommunicationTopic.ct.SecurityStatusUp)
{
@@ -993,7 +1028,8 @@
{
MainPage.Log($"灞�鍩熺綉瀹夐槻淇℃伅: {receiveObj.Topic} : 鍐呭: {res[1]}");
var tt = "";
- lock (tt) {
+ lock (tt)
+ {
var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<SecurityStatusObj>(receiveObj.BodyDataString);
if (temp != null)
{
@@ -1012,8 +1048,16 @@
}
}
}
- catch (Exception ex){
+ catch (Exception ex)
+ {
MainPage.Log($"瀹夐槻灞�鍩熺綉寮傚父锛歿ex.Message}");
+ }
+ }
+ else if (receiveObj.Topic == $"/user/{GatewayId}/custom/gateway/login_reply") {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(receiveObj.BodyDataString);
+ if (temp.GetValue("objects").ToString().Contains("success"))
+ {
+ LocalTcpClientLogin = true;
}
}
else
@@ -1025,6 +1069,29 @@
return receiveObj;
}
+
+ private List<string> processedDataList = new List<string>();
+ /// <summary>
+ /// 鏄惁宸茬粡澶勭悊杩囨暟鎹�
+ /// </summary>
+ /// <returns></returns>
+ private bool hasItBeenProcessed(string msgId)
+ {
+ if (processedDataList.Contains(msgId))
+ {
+ return true;
+ }
+ else
+ {
+ if(processedDataList.Count> 50)
+ {
+ processedDataList.RemoveAt(0);
+ }
+ return false;
+ }
+
+ }
+
/// <summary>
/// 鏇存柊璁惧鐘舵��
/// A鍗忚鏁版嵁
diff --git a/HDL_ON/DAL/DriverLayer/Control_Tcp.cs b/HDL_ON/DAL/DriverLayer/Control_Tcp.cs
new file mode 100644
index 0000000..481c997
--- /dev/null
+++ b/HDL_ON/DAL/DriverLayer/Control_Tcp.cs
@@ -0,0 +1,811 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.Timers;
+using HDL_ON;
+using HDL_ON.Entity;
+using HDL_ON.UI;
+
+namespace HDL_ON.DriverLayer
+{
+ /// <summary>
+ /// link缃戝叧鏈湴閾炬帴閫昏緫
+ /// </summary>
+ public class Control_Tcp
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// link缃戝叧閾炬帴閫昏緫
+ /// </summary>
+ private static Control_Tcp m_Current = null;
+ /// <summary>
+ /// link缃戝叧閾炬帴閫昏緫
+ /// </summary>
+ public static Control_Tcp Current
+ {
+ get
+ {
+ if (m_Current == null)
+ {
+ m_Current = new Control_Tcp();
+ }
+ return m_Current;
+ }
+ }
+ /// <summary>
+ /// Link缃戝叧tcp鎺ユ敹鍥炶皟,鐞嗚涓婂畠涓嶄細澶勭悊zigbee鐨勪笂鎶�(绗竴涓弬鏁版槸缃戝叧鐨刴ac,绗簩涓弬鏁版槸鎺ユ敹鐨勬暟鎹�)
+ /// </summary>
+ private Action<string, string, string> tcpReceiveEvent = null;
+ /// <summary>
+ /// Tcp瀹㈡埛绔繛鎺ユ睜
+ /// </summary>
+ private List<TcpConnectData> listTcpClient = new List<TcpConnectData>();
+ /// <summary>
+ /// 鏄惁鎼滅储缃戝叧
+ /// </summary>
+ private bool isSearchGateway = false;
+
+ #endregion
+
+ #region 鈻� 鎼滅储Link缃戝叧_______________________
+
+// /// <summary>
+// /// 鎼滅储Link缃戝叧
+// /// </summary>
+// /// <param name="resultEvent">鎼滅储鍒扮綉鍏崇殑鍥炶皟鍑芥暟,-1:寮傚父浜� 1:鏀跺埌涓�涓狝缃戝叧</param>
+// /// <param name="searchTime">鎼滅储鏃堕棿(绉�)</param>
+// /// <param name="connectLocalOnly">褰撴悳绱㈠埌缃戝叧鏃�,鏄惁鍙繛鎺ユ湰鍦扮殑(涓嶈兘鐬庤繛鍏朵粬鐨勭綉鍏�,浣嗘槸缃戝叧鎼滅储鐣岄潰鐗规畩)</param>
+// public void SearchLinkGateway(Action<int, AGatewayInfo> resultEvent, int searchTime, bool connectLocalOnly)
+// {
+// this.isSearchGateway = true;
+// //绠椾簡,鍦ㄨ繖閲屽惎鍔ㄨ繙绋嬭繛鎺ュ惂,鍙嶆涔熷氨鎵ц涓�娆�
+// HdlLinkCloudConnectLogic.Current.StartCloudMqttConnection();
+
+// var listGateway = HdlLinkGatewayLogic.Current.GetAllLocalGateway();
+// var dicGateway = new Dictionary<string, ZigBee.Device.LinkGateway>();
+// foreach (var gw in listGateway)
+// {
+// //鑾峰彇鏈湴鍏ㄩ儴鐨凙缃戝叧鐨刴ac
+// dicGateway[gw.GwMac] = gw;
+// }
+// //閲嶅妫�娴�
+// var listCheck = new HashSet<string>();
+
+// var sendData = "Topic:/user/all/custom/gateway/search\r\n";
+
+// var dic = new Dictionary<string, string>();
+// dic["id"] = HdlGatewayResourse.AGatewayLinkFlage;
+// dic["time_stamp"] = HdlHttpLogic.Current.GetTimestamp().PadRight(13, '0');
+// var bodyData = Newtonsoft.Json.JsonConvert.SerializeObject(dic);
+// sendData += "Length:" + bodyData.Length + "\r\n\r\n";
+// sendData += bodyData;
+
+// //鍒濆鍖杣dp
+// var udpLogic = new HdlUdpLogic();
+// if (udpLogic.InitUdp("239.0.168.188", 8585) == false)
+// {
+// //鍏抽棴udp
+// udpLogic.CloseUdp();
+
+// resultEvent?.Invoke(-1, null);
+// return;
+// }
+
+// HDL_ON.DriverLayer.Control.Ins.OpenUdp(8585);
+
+// //鎺ユ敹浜嬩欢
+// Action<System.Net.IPEndPoint, string> actionEvent = (ipPoint, result) =>
+// {
+// //澶勭悊鎼滅储A缃戝叧鏃�,缃戝叧鍥炲鐨勬暟鎹�
+// try
+// {
+// /////
+// System.Net.IPAddress s = ipPoint.Address;
+// MainPage.Log("TcpClient->SearchLinkGateway", $"{s}==缃戝叧鎼滅储鏈湴鍥炲,鏁版嵁鍐呭{result}");
+
+// //妫�楠孉鍗忚缃戝叧涓婚(濡傛灉妫�楠屾槸鎸囧畾涓婚,鍒欒繑鍥炶礋杞芥暟鎹�,鍚﹀垯杩斿洖null)
+// var resultData = HdlLinkGatewaySendLogic.Current.CheckLinkGatewayTopic("/user/all/custom/gateway/search_reply", result);
+// if (resultData == null) { return; }
+// //璋冪敤鍥炶皟鍑芥暟
+// var info = Newtonsoft.Json.JsonConvert.DeserializeObject<AGatewayInfo>(resultData);
+// if (info == null)
+// {
+// //鏁版嵁寮傚父锛岄��鍑�
+// return;
+// }
+// if (!(string.IsNullOrEmpty(info.HomeId) == true || info.HomeId == Common.Config.Instance.HomeId))
+// {
+// //缃戝叧宸茬粡缁戝畾鍏朵粬浣忓畢锛岄��鍑�
+// return;
+// }
+// ///tcp杩炴帴鐩爣璁惧鐨刬p
+// info.Ip_address = ipPoint.Address.ToString();
+// //鎼滅储鍒扮殑杩欎釜缃戝叧,鏄惁鏄瓨鍦ㄥ湪鏈湴浜嗙殑
+// if (dicGateway.ContainsKey(info.Device_mac) == true)
+// {
+// var gateWay = dicGateway[info.Device_mac];
+// //濡傛灉鎼滅储寰楀埌鏈湴瀛樺湪鐨勭綉鍏�,鍒欎娇鐢ㄦ湰鍦伴�氫俊
+// gateWay.OnlineStatu = 1;
+// gateWay.isLocalEncrypt = info.isLocalEncrypt;
+// gateWay.Master = info.Master;
+// //gateWay.Slaver_list1 = info.Slaver_list1;
+// gateWay.Oid = info.Oid;
+// gateWay.InGatewayHomeId = info.HomeId;
+// info.IsBindGateway = true;
+
+// Common.Config.Instance.Home.NowHomeOnlineStatu = "1";
+// }
+// //鎼滅储鍒扮殑缃戝叧,寤虹珛閾炬帴
+// if (connectLocalOnly == false || info.IsBindGateway == true)
+// {
+// this.ConnectLocalLinkGateway(info.Device_mac, info.Ip_address, info.GatewayId, info.isLocalEncrypt);
+// }
+// else
+// {
+// //鑾峰彇杩炴帴瀵硅薄
+// var connectObj = this.GetConnectObject(info.Device_mac, false);
+// if (connectObj != null)
+// {
+// //濡傛灉鏈夎繖涓璞�, 鍒欐浛鎹竴涓嬪畠鐨勭綉鍏砳d
+// connectObj.GatewayId = info.GatewayId;
+// connectObj.localEncrypt = info.isLocalEncrypt;
+// return;
+// }
+// }
+// if (listCheck.Contains(info.Device_mac) == true)
+// {
+// //宸茬粡澶勭悊杩囦簡
+// return;
+// }
+// listCheck.Add(info.Device_mac);
+
+
+//#if DEBUG
+// Console.WriteLine($"鎼滅储缃戝叧鎹曟姄鍒扮綉鍏�:{info.Device_mac}");
+//#endif
+// //info
+
+// //鍥炶皟鍑芥暟
+// resultEvent?.Invoke(1, info);
+// }
+// catch (Exception e)
+// {
+// string str = e.Message;
+// }
+// };
+// udpLogic.ReceviceEvent += actionEvent;
+// var dateTime = System.DateTime.Now.AddSeconds(searchTime);
+// while (this.isSearchGateway && System.DateTime.Now < dateTime)
+// {
+// udpLogic.SendData(sendData, "239.0.168.188", 8585);
+// udpLogic.SendData(sendData, "255.255.255.255", 8585);
+// System.Threading.Thread.Sleep(1000);
+// }
+// udpLogic.ReceviceEvent -= actionEvent;
+// //鍒叧閭d箞蹇�
+// System.Threading.Thread.Sleep(300);
+// this.isSearchGateway = false;
+// //鍏抽棴udp
+// udpLogic.CloseUdp();
+
+// }
+
+// /// <summary>
+// /// 鍋滄鎼滅储Link缃戝叧
+// /// </summary>
+// public void StopSearchLinkGateway()
+// {
+// this.isSearchGateway = false;
+// }
+
+ #endregion
+
+ #region 鈻� 閾炬帴鏈湴Link缃戝叧___________________
+
+ /// <summary>
+ /// 閾炬帴Link缃戝叧
+ /// </summary>
+ /// <param name="i_mac">缃戝叧mac</param>
+ /// <param name="i_ipAdrr">缃戝叧ip</param>
+ /// <param name="i_gwId">缃戝叧Id</param>
+ /// <param name="isBinded">璇cp鎵�鎸囧悜鐨勭綉鍏�,鏄惁鏄綋鍓嶄綇瀹呮墍缁戝畾鐨�</param>
+ /// <returns></returns>
+ public void ConnectLocalLinkGateway(string i_mac, string i_ipAdrr, string i_gwId, bool localEncrypt)
+ {
+ if (i_mac == string.Empty || i_ipAdrr == string.Empty)
+ {
+ return;
+ }
+ var connectData = new TcpConnectData();
+ connectData.GatewayId = i_gwId;
+ connectData.GatewayIp = i_ipAdrr;
+ connectData.GatewayMac = i_mac;
+ connectData.localEncrypt = localEncrypt;
+ lock (this.listTcpClient)
+ {
+ //鎵惧埌褰撳墠缃戝叧鐨勮繛鎺�
+ if (this.listTcpClient.Find((v) => v.GatewayMac == i_mac) != null)
+ {
+ return;
+ }
+ this.listTcpClient.Add(connectData);
+ }
+
+ try
+ {
+ //TCP杩炴帴
+ connectData.tcpClient = new Communication.TcpClient(i_ipAdrr, 8586);
+ connectData.tcpClient.Connect();
+ connectData.tcpClient.ReadFormSocket();
+ connectData.tcpClient.ExitEvent += (s, e) =>
+ {
+ StopConnectLinkGateway(connectData);
+ };
+ connectData.tcpClient.ReceiveBytesAction += (topic, bytes, socket) =>
+ {
+ managerLinkGatewayData(topic, bytes, socket);
+ };
+
+
+ }
+ catch
+ {
+#if DEBUG
+ //HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, i_ipAdrr + "Tcp閾炬帴涓嶄簡");
+#endif
+ StopConnectLinkGateway(connectData);
+ }
+ }
+
+ public TcpConnectData GetConnectObjectBySocket(Socket socket)
+ {
+ lock (listTcpClient)
+ {
+ var tcpConnectData = listTcpClient.Find(tcd => tcd.tcpClient._socket == socket);
+ return tcpConnectData;
+ }
+ }
+
+ /// <summary>
+ /// 鏂紑鍏ㄩ儴鐨凩ink缃戝叧杩炴帴
+ /// </summary>
+ public void StopAllConnectLinkGateway()
+ {
+ var listTemp = new List<TcpConnectData>();
+ for (int i = 0; i < this.listTcpClient.Count; i++)
+ {
+ //鍒涘彟澶栦竴涓璞″嚭鏉�,鏄湁浣滅敤鐨�
+ listTemp.Add(this.listTcpClient[i]);
+ }
+ foreach (var data in listTemp)
+ {
+ //鏂紑鎸囧畾鐨刲ink缃戝叧杩炴帴
+ this.StopConnectLinkGateway(data);
+ }
+ //娓呯┖缂撳瓨
+ this.listTcpClient.Clear();
+ }
+
+ /// <summary>
+ /// 鏂紑鎸囧畾鐨刲ink缃戝叧杩炴帴
+ /// </summary>
+ /// <param name="mac">闇�瑕佹柇寮�杩炴帴鐨勭綉鍏砿ac</param>
+ public void StopConnectLinkGateway(string mac)
+ {
+ var tempGateway = listTcpClient.Find((v) => v.GatewayMac == mac);
+ if (tempGateway != null)
+ {
+ //鏂紑鎸囧畾鐨刲ink缃戝叧杩炴帴
+ this.StopConnectLinkGateway(tempGateway);
+ }
+ }
+
+ /// <summary>
+ /// 鏂紑鎸囧畾鐨刲ink缃戝叧杩炴帴
+ /// </summary>
+ /// <param name="connectData">杩炴帴鏁版嵁</param>
+ private void StopConnectLinkGateway(TcpConnectData connectData)
+ {
+ lock (listTcpClient)
+ {
+ this.listTcpClient.Remove(connectData);
+ connectData.tcpClient.Dispose();
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 鍙戦�佹暟鎹埌Link缃戝叧_________________
+ /// <summary>
+ /// 鍙戦�佹暟鎹埌鏈湴Link缃戝叧
+ /// </summary>
+ /// <param name="connectData">閾炬帴淇℃伅</param>
+ /// <param name="sendData">鍙戦�佺殑鏁版嵁</param>
+ /// <returns></returns>
+ private void DoSendDataToLinkGateway(TcpConnectData connectData, string sendData)
+ {
+#if DEBUG
+ MainPage.Log(DateTime.Now + ":TcpClient->DoSendDataToLinkGateway", $"鏈湴鍙戦�佹暟鎹紝Data:{sendData}");
+#endif
+ byte[] byteData;
+ //44bytes 鍔犲瘑鏁版嵁 AES鍔犲瘑 base64瀵嗘枃
+ ////鐩墠榛樿閮芥槸鍔犲瘑杞借嵎
+ //byteData = this.AesEncryptPayload(byteData, Config.Instance.Home.localSecret);
+ //瑙e瘑璐熻浇鏁版嵁(鍥犱负鍐欏瘑閽ョ粰缃戝叧涓�瀹氭槑鏂囷紝鍥犱负閭f椂缃戝叧杩樻病鏈夊瘑閽�)
+ if (connectData.localEncrypt)
+ {
+ var headerAndBody = sendData.Split("\r\n\r\n");
+ string topic = headerAndBody[0].Split("\r\n")[0];
+ //鍔犲瘑杞借嵎
+ var byteBody = this.AesEncryptPayload(System.Text.Encoding.UTF8.GetBytes(headerAndBody[1]), DB_ResidenceData.Instance.CurrentRegion.localSecret);
+ var header = System.Text.Encoding.UTF8.GetBytes($"{topic}\r\nLength:{byteBody.Length}\r\n" + "\r\n");
+
+ byteData = new byte[header.Length + byteBody.Length];
+ System.Array.Copy(header, 0, byteData, 0, header.Length);
+ ///鍙傛暟锛堟簮鏂囦欢锛屽彇婧愭枃浠剁储寮曞�硷紝瀛樺偍鍣紝瀛樻斁浣嶇疆锛屾簮鏂囦欢闀垮害锛�
+ System.Array.Copy(byteBody, 0, byteData, header.Length, byteBody.Length);
+
+ }
+ else
+ {
+ byteData = Encoding.UTF8.GetBytes(sendData);
+ }
+
+ //byteData = Encoding.UTF8.GetBytes(sendData);
+ //灏嗘暟鎹啓鍏ョ綉缁滄祦
+ connectData.tcpClient?.CommSend(byteData, byteData.Length);
+ }
+
+ #endregion
+
+ #region 鈻� 澶勭悊Link缃戝叧鐨勬暟鎹甠________________
+
+ /// <summary>
+ /// 澶勭悊鎺ユ敹鏈湴Link缃戝叧鐨勬暟鎹�(杩斿洖鍊� 0:杩樹笉瀛樺湪瀹屾垚鐨勬暟鎹� 1:宸茬粡瀛樺湪瀹屾垚鐨勬暟鎹�)
+ /// </summary>
+ /// <param name="listByte">鏁版嵁</param>
+ private void managerLinkGatewayData(string topic, byte[] bytes, Socket socket)
+ {
+ try
+ {
+ var arryTopic = topic.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+ if (arryTopic.Length < 2)
+ {
+ //闈炴瑙勪富棰�
+ return;
+ }
+
+
+ var connectData = this.GetConnectObjectBySocket(socket);
+ if (connectData == null)
+ {
+ return;
+ }
+ string gatewayMac = connectData.GatewayMac;
+ string gatewayId = connectData.GatewayId;
+ ///瑙e瘑璐熻浇鏁版嵁
+ if (connectData.localEncrypt == true)
+ {
+ var tempBytes = bytes;
+ bytes = this.AesDecryptPayload(bytes, DB_ResidenceData.Instance.CurrentRegion.localSecret);
+ if (bytes == null)
+ {
+ bytes = tempBytes;
+ }
+ }
+ /////鐩墠缃戝叧榛樿閮芥槸鍔犲瘑鐨�
+ //bytes = this.AesDecryptPayload(bytes, Config.Instance.Home.localSecret);
+ var bodyData = System.Text.Encoding.UTF8.GetString(bytes);
+
+ MainPage.Log(DateTime.Now + ":Control_Tcp->鏈湴鎺ユ敹鏁版嵁", $"Topic:{topic}\r\nData:{bodyData}");
+
+ if (topic.Contains("thing/property/up") == true)
+ {
+ //杩欎釜鏄疞ink璁惧鐨勭姸鎬佷笂鎶�,鍒暣,鍙zigbee鐨�
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(bodyData);
+
+ return;
+ }
+
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+
+ #endregion
+
+ #region 鈻� 缁撴瀯浣揰____________________________
+
+
+ /// <summary>
+ /// Tcp杩炴帴淇℃伅
+ /// </summary>
+ public class TcpConnectData
+ {
+ /// <summary>
+ /// 缃戝叧鐨刴ac(涓婚敭浣跨敤)
+ /// </summary>
+ public string GatewayMac = string.Empty;
+ /// <summary>
+ /// 缃戝叧ip
+ /// </summary>
+ public string GatewayIp = string.Empty;
+ /// <summary>
+ /// 缃戝叧Id(涓嶆槸浜戠鐨勯偅涓�)
+ /// </summary>
+ public string GatewayId = string.Empty;
+
+ //
+ public Communication.TcpClient tcpClient;
+
+ /// <summary>
+ /// 鏈湴鏄惁鍔犲瘑
+ /// </summary>
+ public bool localEncrypt;
+ }
+ #endregion
+
+ #region 鈻� 鍔犲瘑浠ュ強瑙e瘑_______________________
+
+ /// <summary>
+ /// 鍔犲瘑璐熻浇涓轰簩杩涘埗娴�(Link涓撶敤)
+ /// </summary>
+ /// <param name="toEncryptArray"></param>
+ /// <param name="key"></param>
+ /// <returns></returns>
+ private byte[] AesEncryptPayload(byte[] toEncryptArray, string key)
+ {
+ //鍔犲瘑瀵嗛挜涓虹┖
+ if (key == string.Empty)
+ {
+ return toEncryptArray;
+ }
+ try
+ {
+ if (string.IsNullOrEmpty(key)) return toEncryptArray;
+ //閰嶇疆AES鍔犲瘑Key(瀵嗛挜銆佸悜閲忋�佹ā寮忋�佸~鍏�)
+ var rm = new System.Security.Cryptography.RijndaelManaged
+ {
+ Key = Encoding.UTF8.GetBytes(key),
+ IV = Encoding.UTF8.GetBytes(key),
+ Mode = System.Security.Cryptography.CipherMode.CBC,
+ Padding = System.Security.Cryptography.PaddingMode.PKCS7
+ };
+
+ //鍒涘缓AES鍔犲瘑鍣ㄥ璞�
+ var cTransform = rm.CreateEncryptor();
+ //浣跨敤AES灏嗘槑鏂囨祦杞垚瀵嗘枃瀛楄妭鏁扮粍
+ return cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// 閲囩敤Aes瑙e瘑璐熻浇鏁版嵁(Link涓撶敤)
+ /// </summary>
+ /// <param name="toEncryptArray"></param>
+ /// <param name="key"></param>
+ /// <returns></returns>
+ private byte[] AesDecryptPayload(byte[] toEncryptArray, string key)
+ {
+ //瑙e瘑瀵嗛挜涓虹┖
+ if (key == string.Empty)
+ {
+ return toEncryptArray;
+ }
+
+ try
+ {
+ //閰嶇疆AES鍔犲瘑Key(瀵嗛挜銆佸悜閲忋�佹ā寮忋�佸~鍏�)
+ var rm = new System.Security.Cryptography.RijndaelManaged
+ {
+ Key = Encoding.UTF8.GetBytes(key),
+ IV = Encoding.UTF8.GetBytes(key),
+ Mode = System.Security.Cryptography.CipherMode.CBC,
+ Padding = System.Security.Cryptography.PaddingMode.PKCS7
+ };
+
+ //鍒涘缓AES瑙e瘑鍣ㄥ璞�
+ var cTransform = rm.CreateDecryptor();
+
+ //浣跨敤AES灏嗗瘑鏂囨祦杞垚鏄庢枃鐨勫瓧鑺傛暟缁�
+ return cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ #endregion
+
+ }
+}
+namespace Communication
+{
+ //TCP瀹㈡埛绔疄鐜�
+ public class TcpClient
+ {
+ private const int MAX_RECONNECT_TIMES = 3; //鏂嚎閲嶈繛灏濊瘯娆℃暟
+
+ //soket瀵硅薄鍙婂弬鏁�
+ public Socket _socket;
+ private string host;
+ private int port;
+ private bool reconnect;
+ private bool run = true;
+ private int ConnecteFailedCount { get; set; }
+ public int ReconnectStatistics { get; private set; }
+
+ private static uint _keepAliveTime = 5000; //鏃犳暟鎹氦浜掓寔缁椂闂�(ms)
+ private static uint _keepAliveInterval = 500; //鍙戦�佹帰娴嬪寘闂撮殧(ms)
+
+ //閲嶈繛澶辫触浜嬩欢
+ public event EventHandler ExitEvent;
+ public Action<string, byte[], Socket> ReceiveBytesAction;
+
+ //鏋勯�犲嚱鏁�
+ public TcpClient(string host, int port)
+ {
+ this.host = host;
+ this.port = port;
+ reconnect = false;
+ ConnecteFailedCount = 0;
+ }
+
+ //杩炴帴
+ public void Connect()
+ {
+ byteList = new List<byte>(1024 * 5);
+ _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
+ ProtocolType.Tcp);
+ _socket.Connect(host, port);
+ MainPage.Log("TcpClient->Reconnect", $"杩炴帴鎴愬姛锛孖P:{host}");
+ ConnecteFailedCount = MAX_RECONNECT_TIMES;
+
+ //璁剧疆KeepAlive
+ _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
+ byte[] optionValue = new byte[12];
+ BitConverter.GetBytes(1).CopyTo(optionValue, 0);
+ BitConverter.GetBytes(_keepAliveTime).CopyTo(optionValue, 4);
+ BitConverter.GetBytes(_keepAliveInterval).CopyTo(optionValue, 8);
+ _socket.IOControl(IOControlCode.KeepAliveValues, optionValue, null);
+ }
+
+ //閲嶈繛
+ public bool Reconnect()
+ {
+ ReconnectStatistics++;
+ reconnect = false;
+ close();
+ try
+ {
+ MainPage.Log("TcpClient->Reconnect", $"閲嶆柊寮�濮嬭繛鎺ワ紝IP:{host}");
+ Connect();
+ }
+ catch (Exception e)
+ {
+ ConnecteFailedCount--;
+ if (ConnecteFailedCount > 0)
+ {
+ //Console.WriteLine("閲嶈瘯娆℃暟鍓╀綑{0}",ConnecteFailedCount);
+ reconnect = true;
+ return true;
+ }
+ else
+ {
+ //閲嶈繛澶辫触浜嬩欢
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// 鍏抽棴
+ /// </summary>
+ private void close()
+ {
+ try
+ {
+ MainPage.Log("TcpClient->Close", $"Socket 鍏抽棴锛孖P:{host}");
+ _socket.Close();
+ }
+ catch { }
+ }
+
+
+ /// <summary>
+ /// 閲婃斁璧勬簮
+ /// </summary>
+ public void Dispose()
+ {
+ run = false;
+ close();
+ }
+
+
+ //鍙戦�佹暟鎹帴鏀跺疄鐜�,鏂嚎閲嶈繛
+ public int CommSend(byte[] buffer, int size)
+ {
+ int sendSize = 0;
+ try
+ {
+ if (_socket.Connected)
+ {
+ sendSize = _socket.Send(buffer, size, SocketFlags.None);
+ }
+ }
+ catch (Exception e)
+ {
+ MainPage.Log("TcpClient->CommSend", $"鍙戦�佸け璐ワ紝Data:{System.Text.Encoding.UTF8.GetString(buffer)} Exception:{e.Message}");
+ ReconnectStatistics++;
+ reconnect = true;
+ }
+ return sendSize;
+ }
+
+ List<byte> byteList = new List<byte>();
+ //鎺ユ敹鏁版嵁绾跨▼,浣跨敤闃诲鏂瑰紡鎺ユ敹鏁版嵁
+ public void ReadFormSocket()
+ {
+ new System.Threading.Thread(() =>
+ {
+ int count;
+ byte[] byteBuffer = new byte[2048];
+
+ while (run)
+ {
+ try
+ {
+ try
+ {
+ count = _socket.Receive(byteBuffer, SocketFlags.None);
+ for (int i = 0; i < count; i++)
+ {
+ byteList.Add(byteBuffer[i]);
+ }
+ }
+ catch (Exception e)
+ {
+ count = 0;
+ }
+
+ //缃戠粶鏂紑Receive杩斿洖0
+ if (count == 0 || reconnect == true)
+ {
+ if (run)
+ {
+ //閲嶈繛娆℃暟鐢ㄥ敖,閫�鍑�
+ if (Reconnect() == false)
+ {
+ //閫氱煡鍏跺畠鍔熻兘閲婃斁鍙婂垹闄ゅ綋鍓嶅璞�
+ ExitEvent?.Invoke(null, new EventArgs());
+ break;
+ }
+ }
+ else
+ {
+ ExitEvent?.Invoke(null, new EventArgs());
+ }
+ }
+ else
+ {
+
+ while (true)
+ {
+ var bytes = byteList.ToArray();
+ var topMsgs = System.Text.Encoding.UTF8.GetString(bytes).Split("\r\n");
+
+ var lenght = getLenght(topMsgs);
+
+ if (lenght <= 0)
+ {
+ //澶撮儴鏁版嵁杩樻病鏈夋帴鏀跺畬鎴�
+ break;
+ }
+ //鏄惁宸茬粡鑾峰彇瀹屾暣鎵�鏈夌殑鏁版嵁
+ var data = new byte[lenght];
+ int index = getDataIndex(byteList);
+ if (byteList.Count < index + lenght)
+ {
+ //褰撳墠鏁版嵁杩樻病鏈夋帴鏀跺畬鎴�
+ break;
+ }
+ //澶嶅埗鍑篵ody鏁版嵁
+ System.Array.Copy(bytes, index, data, 0, data.Length);
+
+ //淇濈暀鍓╀綑鐨勬暟鎹紝浠ユ鐢�
+ byteList.Clear();
+ for (int i = index + lenght; i < bytes.Length; i++)
+ {
+ byteList.Add(bytes[i]);
+ }
+ var topic = getTopic(topMsgs);
+
+ ReceiveBytesAction?.Invoke(topic, data, _socket);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ MainPage.Log("TcpClient->ReadFormSocket", $"Exception:{e.Message}");
+ }
+ }
+ })
+ {
+ IsBackground = true
+ }.Start();
+
+ }
+
+ /// <summary>
+ /// 鑾峰彇鍐呭闀垮害
+ /// </summary>
+ /// <param name="topMsgs"></param>
+ /// <returns></returns>
+ int getLenght(string[] topMsgs)
+ {
+ for (int i = 0; i < topMsgs.Length; i++)
+ {
+ string topMsg = topMsgs[i].Trim();
+ if (topMsg.StartsWith("Length:"))
+ {
+ return int.Parse(topMsg.Replace("Length:", ""));
+ }
+ }
+ //鎵句笉鍒伴暱搴�
+ return -1;
+ }
+
+ /// <summary>
+ /// 鑾峰彇涓婚
+ /// </summary>
+ /// <param name="topMsgs"></param>
+ /// <returns></returns>
+ private string getTopic(string[] topMsgs)
+ {
+ for (int i = 0; i < topMsgs.Length; i++)
+ {
+ var topMsg = topMsgs[i].Trim();
+ if (topMsg.StartsWith("Topic:"))
+ {
+ return topMsg.Replace("Topic:", "");
+ }
+ }
+ //鎵句笉鍒颁富棰�
+ return null;
+ }
+
+ /**
+ * 鑾峰彇鏁版嵁鐨勫紑濮嬩綅缃�
+ * @param arrayList 鎺ユ敹鍒扮殑鎵�鏈夋暟鎹�
+ * @return 鏁版嵁浣嶇殑寮�濮嬬储寮�
+ */
+ int getDataIndex(List<byte> arrayList)
+ {
+ var r = (byte)'\r';
+ var n = (byte)'\n';
+ for (int i = 0; i < arrayList.Count; i++)
+ {
+ //鎵惧嚭鏁版嵁鍐呭鍓嶉潰鐨勪袱涓崲琛�
+ if (3 <= i && arrayList[i - 3] == r && arrayList[i - 2] == n && arrayList[i - 1] == r && arrayList[i] == n)
+ {
+ //鍓╀綑鐨勬暟鎹�
+ return i + 1;
+ }
+ }
+ return -1;
+ }
+
+
+ }
+}
diff --git a/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs b/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
index aa8aeff..d6f61f1 100644
--- a/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
+++ b/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
@@ -1,7 +1,11 @@
锘縰sing System;
+using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
+using System.Threading;
using System.Threading.Tasks;
+using HDL_ON.Entity;
+using Newtonsoft.Json;
namespace HDL_ON.DriverLayer
{
@@ -18,6 +22,16 @@
public Action<string> ReceiveEvent;
/// <summary>
+ /// 杩炴帴娆℃暟
+ /// </summary>
+ private int reconnectIndex = 0;
+ /// <summary>
+ /// 鏄惁杩炴帴鎴愬姛
+ /// </summary>
+ public bool isConnected = false;
+
+
+ /// <summary>
/// 鏋勯�犲嚱鏁�
/// </summary>
public Control_TcpClient(string serverIp)
@@ -26,18 +40,22 @@
}
//TCP杩炴帴
- public bool Connect(int _port = 8586)
+ private bool ConnectToTcp( )
{
- if (string.IsNullOrEmpty(_ip) || _port == 0)
+ if (string.IsNullOrEmpty(_ip) )
{
return false;
}
- _tcpClient = new TcpClient();
+ if (_tcpClient == null)
+ {
+ _tcpClient = new TcpClient();
+ }
try
{
- _tcpClient.Connect(IPAddress.Parse(_ip), _port);
+ _tcpClient.Connect(IPAddress.Parse(_ip), 8586);
Task.Run(new Action(ReceiveMessage));//寮�鍚嚎绋嬶紝涓嶅仠鎺ユ敹娑堟伅
- MainPage.Log($"鎵撳紑tcp client{_ip}:{_port}");
+ MainPage.Log($"鎵撳紑tcp client{_ip}:8586");
+ isConnected = true;
}
catch (Exception e)
{
@@ -46,6 +64,53 @@
}
return true;//杩斿洖杩炴帴鐘舵��
}
+ /// <summary>
+ /// 杩炴帴tcp绾跨▼
+ /// </summary>
+ private Thread connectThread;
+
+ /// <summary>
+ /// 杩炴帴绾跨▼
+ /// </summary>
+ public void Connect()
+ {
+ if(connectThread == null)
+ {
+ connectThread = new Thread(() => {
+ while (Control.Ins.GatewayOnline_Local)
+ {
+ if (_tcpClient == null)
+ {
+ ConnectToTcp();
+ }
+ else
+ {
+ if (!_tcpClient.Connected)
+ {
+ try
+ {
+ //_tcpClient.ReceiveTimeout =
+ _tcpClient.Connect(IPAddress.Parse(_ip), 8586);
+ Task.Run(new Action(ReceiveMessage));//寮�鍚嚎绋嬶紝涓嶅仠鎺ユ敹娑堟伅
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"tcp閲嶈繛寮傚父:{ex.Message}");
+ _tcpClient.Close();
+ _tcpClient = null;
+ }
+ }
+ }
+ Thread.Sleep(1000);
+
+
+ }
+ });
+ connectThread.Start();
+ }
+ }
+
+
/// <summary>
/// 鍏抽棴杩炴帴
/// </summary>
@@ -65,67 +130,76 @@
/// <param name="bytes">闇�瑕佸彂閫佺殑瀛楄妭</param>
public void SendMessage(byte[] bytes)
{
- NetworkStream networkStream = _tcpClient.GetStream();
- if (networkStream.CanWrite)
+ if (_tcpClient.GetStream().CanWrite)
{
- networkStream.Write(bytes, 0, bytes.Length);
+ _tcpClient.GetStream().Write(bytes, 0, bytes.Length);
}
- //networkStream.Close();
}
-
/// <summary>
- /// 鑾峰彇鍒楄〃鏁版嵁鍥炶皟鏂规硶
+ /// 蹇冭烦鍖呯嚎绋�
/// </summary>
- public Action<string> GetListResponseAction;
+ private Thread heartBeatThread;
+ private DateTime heartBeatTime;
+ public void HeartBeat()
+ {
+ if(heartBeatThread == null)
+ {
+ heartBeatThread = new Thread(() => {
+ if(_tcpClient.Connected&&10 *1000 <(System.DateTime.Now - heartBeatTime).TotalMilliseconds)
+ {
+ var sendBytes = Control.Ins.ConvertSendBodyData(CommunicationTopic.ct.HeartBeat, "");
+ SendMessage(sendBytes);
+ }
+ Thread.Sleep(100);
+ });
+ heartBeatThread.Start();
+ }
+ }
+ /// <summary>
+ /// 鎺ユ敹鏁版嵁绾跨▼
+ /// </summary>
+ private Thread receiveThread;
+
//鎺ユ敹娑堟伅
public void ReceiveMessage()
{
- NetworkStream networkStream = _tcpClient.GetStream();
- while (true)
+ if(receiveThread == null)
{
- // 瀹氫箟涓�涓�2M鐨勭紦瀛樺尯锛�
- byte[] arrMsgRec = new byte[1024 * 1024 * 2];
- int size = networkStream.Read(arrMsgRec, 0, arrMsgRec.Length);
- var tcpDataString = System.Text.Encoding.UTF8.GetString(arrMsgRec, 0, arrMsgRec.Length);
- if (!string.IsNullOrEmpty(tcpDataString))
- {
- ReceiveEvent?.Invoke(tcpDataString);
- }
+ receiveThread = new Thread(() => {
+ while (true)
+ {
+ if(_tcpClient == null)
+ {
+ receiveThread.Abort();
+ receiveThread = null;
+ return;
+ }
+ if (!_tcpClient.Connected)
+ {
+ MainPage.Log("tcp瀹㈡埛绔柇寮�浜嗚繛鎺�...");
+ receiveThread.Abort();
+ receiveThread = null;
+ isConnected = false;
+ return;
+ }
- //// 灏嗘帴鍙楀埌鐨勬暟鎹瓨鍏ュ埌杈撳叆 arrMsgRec涓紱
- //int length = -1;
- //try
- //{
- // length = socketClient.Receive(arrMsgRec); // 鎺ユ敹鏁版嵁锛屽苟杩斿洖鏁版嵁鐨勯暱搴︼紱
- //}
- //catch (Exception ex)
- //{
- // MainPage.Log($"tcpListener error 1 : {ex.Message}");
+ // 瀹氫箟涓�涓�2M鐨勭紦瀛樺尯锛�
+ byte[] arrMsgRec = new byte[1024 * 1024 * 2];
+ int size = _tcpClient.GetStream().Read(arrMsgRec, 0, arrMsgRec.Length);
+ var tcpDataString = System.Text.Encoding.UTF8.GetString(arrMsgRec, 0, arrMsgRec.Length);
- // Flag_Receive = false;
- // // 浠庨�氫俊绾跨▼闆嗗悎涓垹闄よ涓柇杩炴帴鐨勯�氫俊绾跨▼瀵硅薄锛�
- // string keystr = socketClient.RemoteEndPoint.ToString();
- // dic_ClientSocket.Remove(keystr);//鍒犻櫎瀹㈡埛绔瓧鍏镐腑璇ocket
- // dic_ClientThread[keystr].Abort();//鍏抽棴绾跨▼
- // dic_ClientThread.Remove(keystr);//鍒犻櫎瀛楀吀涓绾跨▼
- // tcpClient = null;
- // socketClient = null;
- // break;
- //}
- //byte[] buf = new byte[length];
- //Array.Copy(arrMsgRec, buf, length);
- //lock (tcpClient.m_Buffer)
- //{
- // var tcpDataString = System.Text.Encoding.UTF8.GetString(arrMsgRec, 0, length);
- // if (!string.IsNullOrEmpty(tcpDataString))
- // {
- // ReceiveEvent?.Invoke(tcpDataString);
- // }
+ if (!string.IsNullOrEmpty(tcpDataString))
+ {
+ MainPage.Log($"灞�鍩熺綉tcp鏁版嵁鎺ユ敹");
+ Control.Ins.ConvertReceiveData(arrMsgRec, null);
- // MainPage.Log($"鎺ユ敹鏈嶅姟绔暟鎹�:{tcpDataString}");
- //}
+ }
+ }
+ });
+ //receiveThread.IsBackground = true;
+ receiveThread.Start();
}
}
diff --git a/HDL_ON/DAL/DriverLayer/Control_TcpServer.cs b/HDL_ON/DAL/DriverLayer/Control_TcpServer.cs
index 295098b..1c4daa9 100644
--- a/HDL_ON/DAL/DriverLayer/Control_TcpServer.cs
+++ b/HDL_ON/DAL/DriverLayer/Control_TcpServer.cs
@@ -183,7 +183,7 @@
{
MainPage.Log($"0001 tcpDataString:\r\n {tcpBodyDataString}");
var tcpDataObj = Control.Ins.AnalysisReceiveData(tcpBodyDataString, null);
- if (tcpDataObj.BodyDataString == null)
+ if (tcpDataObj==null || tcpDataObj.BodyDataString == null)
{
return;
}
diff --git a/HDL_ON/DAL/DriverLayer/UdpSocket.cs b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
index e358428..f0893ff 100644
--- a/HDL_ON/DAL/DriverLayer/UdpSocket.cs
+++ b/HDL_ON/DAL/DriverLayer/UdpSocket.cs
@@ -138,6 +138,7 @@
//mqtt杩炴帴鏁版嵁璇诲彇 A鍗忚缃戠粶璁惧淇℃伅璇诲彇鍥炲 澶勭悊
if (((IPEndPoint)packet.RemoteEndPoint).Port == 8585)
{
+ MainPage.Log($"灞�鍩熺綉udp淇℃伅");
Control.Ins.ConvertReceiveData(bytes, ((IPEndPoint)packet.RemoteEndPoint).Address.ToString());
}
else if (((IPEndPoint)packet.RemoteEndPoint).Port == 6000)//澶勭悊bus 6000绔彛鐨勬暟鎹�
diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs
index 3a6d450..a01cdae 100644
--- a/HDL_ON/DAL/Server/HttpServerRequest.cs
+++ b/HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -340,6 +340,20 @@
var requestJson = HttpUtil.GetSignRequestJson(requestObj);
return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_ForgetPwd, requestJson);
}
+ /// <summary>
+ /// 淇敼瀵嗙爜
+ /// </summary>
+ /// <param name="loginPwd"></param>
+ /// <param name="loginNewPwd"></param>
+ /// <returns></returns>
+ public ResponsePackNew UpdataPassword(string loginPwd,string loginNewPwd)
+ {
+ Dictionary<string, object> d = new Dictionary<string, object>();
+ d.Add("loginPwd", loginPwd);
+ d.Add("loginNewPwd", loginNewPwd);
+ var requestJson = HttpUtil.GetSignRequestJson(d);
+ return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Update_Pwd, requestJson);
+ }
/// <summary>
/// 楠岃瘉楠岃瘉鐮�
@@ -2682,10 +2696,10 @@
/// 璁剧疆绗笁鏂硅澶囩粦瀹氱殑浣忓畢
/// </summary>
/// <returns></returns>
- public ResponsePackNew Set3tyIotFunctionToHouse(string deviceId,string homeId, string companyId)
+ public ResponsePackNew Set3tyIotFunctionToHouse(List<string> deviceIds,string homeId, string companyId)
{
Dictionary<string, object> d = new Dictionary<string, object>();
- d.Add("deviceId", deviceId);
+ d.Add("deviceIds", deviceIds);
d.Add("homeId", homeId);
d.Add("companyId", companyId);
var requestJson = HttpUtil.GetSignRequestJson(d);
diff --git a/HDL_ON/Entity/Function/Scene.cs b/HDL_ON/Entity/Function/Scene.cs
index a7ac909..fadf04f 100644
--- a/HDL_ON/Entity/Function/Scene.cs
+++ b/HDL_ON/Entity/Function/Scene.cs
@@ -124,10 +124,7 @@
{
return sceneImageInfo.defaultIconName;
}
- else
- {
- return "Intelligence/Gallery/scenebg1.png";
- }
+ return image;
}
}
set
diff --git a/HDL_ON/Entity/Integratedbrand/IntegratedBrand.cs b/HDL_ON/Entity/Integratedbrand/IntegratedBrand.cs
index 7ba544a..1df2dab 100644
--- a/HDL_ON/Entity/Integratedbrand/IntegratedBrand.cs
+++ b/HDL_ON/Entity/Integratedbrand/IntegratedBrand.cs
@@ -74,7 +74,7 @@
/// <summary>
/// 鍥剧墖url
/// </summary>
- public string authrBandIconUrl;
+ public string authBrandIconUrl;
/// <summary>
/// 璁よ瘉鎺堟潈鍦板潃
/// </summary>
diff --git a/HDL_ON/HDL_ON.projitems b/HDL_ON/HDL_ON.projitems
index 6002a93..b5c2981 100644
--- a/HDL_ON/HDL_ON.projitems
+++ b/HDL_ON/HDL_ON.projitems
@@ -512,6 +512,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\AddFunction\Iot_BrandFunctionListPage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\AddFunction\Iot_AuthorizedPage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\AddFunction\Iot_SupportSpkListPage.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)DAL\DriverLayer\Control_Tcp.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Entity\Device\" />
diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs
index 573664e..0b32010 100644
--- a/HDL_ON/UI/MainPage.cs
+++ b/HDL_ON/UI/MainPage.cs
@@ -465,6 +465,17 @@
}
+ /// <summary>
+ /// 鑷畾涔夋棩蹇楄緭鍑�
+ /// </summary>
+ public static void Log(string tag,string msg)
+ {
+#if DEBUG
+ Console.WriteLine($"{tag}-->{msg}");
+#endif
+ }
+
+
}
}
\ No newline at end of file
diff --git a/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs b/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs
index 1af093e..04c68ec 100644
--- a/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs
+++ b/HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs
@@ -17,14 +17,14 @@
/// <param name="updataFunction"></param>
public void UpdataStates(Function updataFunction, FrameLayout view, VerticalScrolViewLayout scrolView, Room room = null)
{
+ if (view == null || scrolView == null || updataFunction == null)
+ {
+ return;
+ }
Application.RunOnMainThread((() =>
{
try
{
- if (view == null || scrolView == null || updataFunction == null)
- {
- return;
- }
if (!scrolView.ScrollEnabled)
{
return;
diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
index 2dfc170..232684e 100644
--- a/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
+++ b/HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
@@ -185,7 +185,7 @@
{
var btnHumidityIcon = new Button()
{
- X = Application.GetRealWidth(51),
+ X = Application.GetRealWidth(110),
Y = Application.GetRealHeight(66),
Width = Application.GetMinRealAverage(16),
Height = Application.GetMinRealAverage(16),
@@ -194,7 +194,7 @@
bodyDiv.AddChidren(btnHumidityIcon);
var btnHumidityValues = new TextButton()
{
- X = Application.GetRealWidth(70),
+ X = Application.GetRealWidth(130),
Y = Application.GetRealHeight(64),
Height = Application.GetRealHeight(18),
TextColor = 0xFF161616,
@@ -208,7 +208,7 @@
Button btnTempIcon = new Button()
{
- X = Application.GetRealWidth(110),
+ X = Application.GetRealWidth(51),
Y = Application.GetRealHeight(66),
Width = Application.GetMinRealAverage(17),
Height = Application.GetMinRealAverage(17),
@@ -218,7 +218,7 @@
var btnTempValues = new TextButton()
{
- X = Application.GetRealWidth(130),
+ X = Application.GetRealWidth(70),
Y = Application.GetRealHeight(64),
Height = Application.GetRealHeight(18),
TextColor = 0xFF161616,
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_AuthorizedPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_AuthorizedPage.cs
index e3c0244..809444b 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_AuthorizedPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_AuthorizedPage.cs
@@ -2,6 +2,7 @@
using Shared;
using HDL_ON.Entity;
using HDL_ON.DAL.Server;
+using HDL_ON.UI.CSS;
namespace HDL_ON.UI
{
@@ -32,9 +33,99 @@
UnsubscribeAsync3tyIotbind();
Application.RunOnMainThread(() =>
{
- http.Search3tyIotDevice(brand_Iot.companyId);
+ //http.Search3tyIotDevice(brand_Iot.companyId);
boudedAction?.Invoke();
dd.Close();
+
+
+
+ {
+ Dialog dialog = new Dialog()
+ {
+ BackgroundColor = CSS_Color.DialogTransparentColor1,
+ };
+
+ FrameLayout contentView = new FrameLayout()
+ {
+ Gravity = Gravity.Center,
+ Width = Application.GetRealWidth(305),
+ Height = Application.GetRealHeight(180),
+ BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
+ BorderColor = 0x00000000,
+ BorderWidth = 0,
+ Radius = (uint)Application.GetMinRealAverage(10),
+ };
+ dialog.AddChidren(contentView);
+
+ Button btnTitle = new Button()
+ {
+ Gravity = Gravity.CenterHorizontal,
+ Y = Application.GetRealHeight(10),
+ Height = Application.GetRealHeight(38),
+ TextAlignment = TextAlignment.Center,
+ IsBold = true,
+ TextColor = 0xFF222222,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ TextID = StringId.Tip
+ };
+ contentView.AddChidren(btnTitle);
+
+ Button btnMsg = new Button()
+ {
+ Gravity = Gravity.CenterHorizontal,
+ Height = Application.GetRealHeight(70),
+ Y = Application.GetRealHeight(55),
+ TextAlignment = TextAlignment.TopCenter,
+ TextColor = CSS_Color.FirstLevelTitleColor,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ Padding = new Padding(0, Application.GetRealWidth(16), 0, Application.GetRealWidth(16)),
+ Text = "璐︽埛缁戝畾鎴愬姛锛屾偍鍙互缁х画瀹屾垚璁惧鍏宠仈鎿嶄綔",
+ IsMoreLines = true,
+ };
+ contentView.AddChidren(btnMsg);
+ if(Language.CurrentLanguage != "Chinese")
+ {
+ btnMsg.Text = "Account binding is successful.You can continue to complete the device association operation";
+ }
+
+ Button btnLine = new Button()
+ {
+ Y = Application.GetRealHeight(125),
+ Height = Application.GetRealHeight(1),
+ BackgroundColor = CSS.CSS_Color.DividingLineColor,
+ };
+ contentView.AddChidren(btnLine);
+
+ Button btnConfirm = new Button()
+ {
+ Y = btnLine.Bottom,
+ Height = Application.GetRealHeight(55),
+ TextAlignment = TextAlignment.Center,
+ TextColor = CSS_Color.MainColor,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ SelectedTextColor = CSS_Color.MainBackgroundColor,
+ SelectedBackgroundColor = CSS_Color.MainColor,
+ TextID = StringId.Confirm,
+ };
+ btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomLeft);
+ btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomRight);
+ contentView.AddChidren(btnConfirm);
+
+ dialog.Show();
+
+ btnConfirm.MouseDownEventHandler += (sender, e) =>
+ {
+ btnConfirm.IsSelected = true;
+ };
+ btnConfirm.MouseUpEventHandler += (sender, e) =>
+ {
+ dialog.Close();
+ };
+
+ }
+
+
+
});
};
SubscribeAsync3tyIotbind();
@@ -79,17 +170,16 @@
})
{ IsBackground = true }.Start();
}
- /// <summary>
- /// 鎼滅储绗笁鏂硅澶�
- /// </summary>
- private void SearchDevice()
- {
- var pack = http.Search3tyIotDevice(brand_Iot.companyId);
- if(pack!= null)
- {
-
- }
- }
+ ///// <summary>
+ ///// 鎼滅储绗笁鏂硅澶�
+ ///// </summary>
+ //private void SearchDevice()
+ //{
+ // var pack = http.Search3tyIotDevice(brand_Iot.companyId);
+ // if(pack!= null)
+ // {
+ // }
+ //}
/// <summary>
/// 鑾峰彇绗笁鏂瑰姛鑳藉垪琛�
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs
index 56c39d1..ea61167 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs
@@ -12,6 +12,7 @@
FrameLayout contentView;
+ FrameLayout optionView;
IntegratedBrand_Iot brand_Iot;
@@ -61,11 +62,15 @@
TextColor = CSS_Color.FirstLevelTitleColor,
Padding = new Padding(12, Application.GetRealWidth(16), 12, Application.GetRealWidth(16)),
TextSize = CSS_FontSize.TextFontSize,
- Text = "榛樿灏嗙涓夋柟鍝佺墝鐨勮澶囧叏閮ㄥ叧鑱斿埌On Pro涓�,鎮ㄤ篃鍙互閫氳繃涓嬫柟鐨勫紑鍏虫寜閿紝杩涜閫夋嫨鎬у叧鑱斻��",
+ Text = "*鎮ㄥ彲浠ュ皢绗笁鏂瑰搧鐗岀殑璁惧鍏宠仈鍒癘n Pro鎮ㄥ綋鍓嶇殑浣忓畢涓娿��",
IsMoreLines = true,
TextAlignment = TextAlignment.CenterLeft,
};
bodyView.AddChidren(btnTipText);
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnTipText.Text = "*You can associate third-party branded devices with on Pro's current home.";
+ }
contentView = new FrameLayout()
{
@@ -82,6 +87,11 @@
{
try
{
+ var pack0 = http.Search3tyIotDevice(brand_Iot.companyId);
+ if(pack0 != null)
+ {
+
+ }
var pack = http.Get3tyIotDeviceFunctionList(brand_Iot.companyId);
if (pack != null)
{
@@ -104,6 +114,54 @@
});
}
}) { IsBackground = true }.Start();
+
+
+ optionView = new FrameLayout()
+ {
+ Y = Application.GetRealHeight(667 - 80),
+ Height = Application.GetRealHeight(90),
+ Radius = (uint)Application.GetRealWidth(22),
+ Visible = false,
+ };
+ bodyView.AddChidren(optionView);
+
+
+ var btnComfirm = new Button()
+ {
+ Gravity = Gravity.CenterHorizontal,
+ Y = Application.GetRealHeight(14),
+ Width = Application.GetRealWidth(164),
+ Height = Application.GetRealHeight(44),
+ TextAlignment = TextAlignment.Center,
+ BackgroundColor = CSS_Color.MainColor,
+ TextColor = CSS_Color.MainBackgroundColor,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ TextID = StringId.Confirm,
+ Radius = (uint)Application.GetRealHeight(22)
+ };
+ optionView.AddChidren(btnComfirm);
+ btnComfirm.MouseUpEventHandler = (sender, e) => {
+
+ var pack = http.Set3tyIotFunctionToHouse(optionList, DB_ResidenceData.Instance.CurrentRegion.id, brand_Iot.companyId);
+ if (pack != null)
+ {
+ if (pack.Code == StateCode.SUCCESS)
+ {
+ btnComfirm.Visible = false;
+ }
+ }
+ //var pack = http.Set3tyIotFunctionToHouse(function.deviceId, "0", brand_Iot.companyId);
+ //if (pack != null)
+ //{
+ // if (pack.Code == StateCode.SUCCESS)
+ // {
+ // btnName.IsSelected = btnIcon.IsSelected = btnCheckIcon.IsSelected = false;
+ // }
+ //}
+
+ };
+
+
}
@@ -163,11 +221,11 @@
var btnbg = new Button()
{
UnSelectedImagePath = "Collection/Functionbg.png",
- SelectedImagePath = "Collection/FunctionOnbg.png",
+ SelectedImagePath = "Collection/Functionbg.png",
Tag = function.sid
};
functionView.AddChidren(btnbg);
- LoadDeviceFunctionDiv(functionView, function,btnbg);
+ LoadDeviceFunctionDiv(functionView, function);
index++;
@@ -188,6 +246,10 @@
Text = "娌℃湁浠讳綍璁惧"
};
view.AddChidren(btnNoCollectionTip);
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnNoCollectionTip.Text = "No equipment";
+ }
}
}
catch (Exception ex)
@@ -196,16 +258,34 @@
deviceFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) });
#endregion
+
+ deviceFunctionView.AddChidren(new Button {
+ Height = Application.GetRealHeight(90),
+ });
+
}
/// <summary>
/// 鍔犺浇鍔熻兘鎺у埗鍗$墖
/// </summary>
- void LoadDeviceFunctionDiv(FrameLayout view, Function function,Button btnBg)
+ void LoadDeviceFunctionDiv(FrameLayout view, Function function)
{
try
{
+
+
+ var btnCheckIcon = new Button()
+ {
+ X = Application.GetRealWidth(22),
+ Y = Application.GetRealHeight(16),
+ Width = Application.GetRealWidth(21),
+ Height = Application.GetRealWidth(21),
+ UnSelectedImagePath = "Public/IotCheckIcon.png",
+ SelectedImagePath = "Public/IotCheckOnIcon.png",
+ };
+ view.AddChidren(btnCheckIcon);
+
Button btnIcon;
btnIcon = new Button()
{
@@ -237,39 +317,32 @@
Button btnClick = new Button();
view.AddChidren(btnClick);
btnClick.MouseUpEventHandler = (sender, e) => {
- function.collect = !function.collect;
- if (function.collect)
+ btnCheckIcon.IsSelected = function.collect = !function.collect;
+ if (optionList.Contains(function.deviceId))
{
- var pack = http.Set3tyIotFunctionToHouse(function.deviceId, DB_ResidenceData.Instance.CurrentRegion.id,brand_Iot.companyId);
- if (pack != null)
- {
- if(pack.Code == StateCode.SUCCESS)
- {
- btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = true;
- }
- }
+ optionList.Remove(function.deviceId);
}
else
{
- btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = false;
- var pack = http.Set3tyIotFunctionToHouse(function.deviceId, "0", brand_Iot.companyId);
- if (pack != null)
- {
- if (pack.Code == StateCode.SUCCESS)
- {
- btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = false;
- }
- }
+ optionList.Add(function.deviceId);
}
-
+ optionView.Visible = true;
};
-
+ if (function.homeId == DB_ResidenceData.Instance.CurrentRegion.id )
+ {
+ btnCheckIcon.IsSelected = true;
+ optionList.Add(function.deviceId);
+ }
}
catch (Exception ex)
{
MainPage.Log("homepage LoadControlView error : " + ex.Message);
}
}
+ /// <summary>
+ /// 璁板綍闇�瑕佹搷浣滅殑鍒楄〃
+ /// </summary>
+ private List<string> optionList = new List<string>();
void NotListTipView()
@@ -312,7 +385,7 @@
BorderWidth = 0,
Text = "鏌ョ湅璁惧鏀寔鑼冨洿"
};
- contentView.AddChidren(btnAdd);
+ //contentView.AddChidren(btnAdd);
btnAdd.MouseUpEventHandler = (sender, e) =>
{
//var page = new AddThirdPartyBrandListpage(brandList);
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandListPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandListPage.cs
index 32531d7..6ac1e9a 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandListPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandListPage.cs
@@ -55,7 +55,12 @@
TextAlignment = TextAlignment.CenterLeft,
};
bodyView.AddChidren(btnTipText);
-
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnTipText.Text = "Synchronize your devices on the third-party platform to on Pro for control by binding the third-party platform account to the cloud connection";
+ }
+
+
contentView = new VerticalScrolViewLayout()
{
Y = Application.GetRealHeight(150),
@@ -76,7 +81,7 @@
}
/// <summary>
- /// 鑾峰彇缁戝畾鍒楄〃
+ /// 鑾峰彇鍒楄〃
/// </summary>
void GetBindList()
{
@@ -197,9 +202,8 @@
};
row.AddChidren(btnName);
//涓嬭浇绗笁鏂瑰搧鐗宨con
- ImageUtlis.Current.Load3tyBrandIconImages(brand.brandName, brand.authrBandIconUrl, btnIcon);
-
- btnName.MouseUpEventHandler = (sender, e) => {
+ ImageUtlis.Current.Load3tyBrandIconImages(brand.brandName, brand.authBrandIconUrl, btnIcon);
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
if (brand.hasAuthorization)
{
Action unboundAction = () =>
@@ -231,6 +235,11 @@
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
}
};
+
+ btnRight.MouseUpEventHandler = eventHandler;
+ row.MouseUpEventHandler = eventHandler;
+ btnName.MouseUpEventHandler = eventHandler;
+ btnBindTip.MouseUpEventHandler = eventHandler;
}
}
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/iot_BindTipPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/iot_BindTipPage.cs
index 601da76..dc0bd62 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/iot_BindTipPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/iot_BindTipPage.cs
@@ -27,8 +27,7 @@
public void LoadPage(IntegratedBrand_Iot brand_Iot)
{
-
- new TopViewDiv(bodyView, Language.StringByID(StringId.Bind3thIotAccount)).LoadTopView(CSS_Color.MainBackgroundColor);
+ new TopViewDiv(bodyView, brand_Iot.brandName).LoadTopView(CSS_Color.MainBackgroundColor);
bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
@@ -63,6 +62,10 @@
Text = "鍏充簬璐﹀彿缁戝畾鐨勫0鏄�"
};
contentView.AddChidren(btnTipTitle);
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnTipTitle.Text = "Statement on account binding";
+ }
var btnTipText = new Button()
{
@@ -87,6 +90,16 @@
"濡傞渶缁堟浠ヤ笂淇℃伅鐨勬敹闆嗕笌澶勭悊锛屾偍鍙互鍦ㄢ�滄垜鐨勨��> 鈥滅粦瀹氱涓夋柟璐︽埛鈥�>鈥滆В闄も��"
};
contentView.AddChidren(btnTipText);
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnTipText.Text = $"account binding brand: {brand_Iot.brandName} (hereinafter referred to as the third party brand)" + "\r\n" + "\r\n" +
+"After you bind the account of the third-party brand, you will authorize 'on Pro' to use your account of the third-party to jointly manage the device. On Pro will also automatically synchronize the device you added in the third-party brand." + "\r\n" + "\r\n" +
+"To realize the device control function, this application will obtain the following data from a third party:" + "\r\n" + "\r\n" +
+"1. List of some devices added on the third-party brand for intelligent control in on Pro;" + "\r\n" + "\r\n" +
+"2. Equipment and network information, including equipment identifier, MAC address and equipment serial number, is used to identify the currently working equipment and perform equipment control functions." + "\r\n" + "\r\n" +
+"If you do not agree with our collection of the above information, you will not be able to manage third-party branded devices." + "\r\n" + "\r\n" +
+"To terminate the collection and processing of the above information, you can click my > bind third party account > cancel";
+ }
var optionView = new FrameLayout()
@@ -110,7 +123,7 @@
TextAlignment = TextAlignment.Center,
TextColor = CSS_Color.MainColor,
TextSize = CSS_FontSize.SubheadingFontSize,
- Text = "杩斿洖",
+ TextID= StringId.fanhui,
Radius = (uint)Application.GetRealHeight(22)
};
optionView.AddChidren(btnCannel);
@@ -133,6 +146,10 @@
Radius = (uint)Application.GetRealHeight(22)
};
optionView.AddChidren(btnComfirm);
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnComfirm.Text = "Consent authorization";
+ }
if (!brand_Iot.hasAuthorization)
@@ -151,8 +168,8 @@
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
};
- var page = new Iot_AuthorizedPage(brand_Iot,action);
- page.LoadView();
+ var page2 = new Iot_AuthorizedPage(brand_Iot,action);
+ page2.LoadView();
@@ -161,6 +178,10 @@
else
{
btnComfirm.Text = "瑙i櫎鎺堟潈";
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnComfirm.Text = "Cancel authorization";
+ }
btnComfirm.MouseUpEventHandler = (sender, e) =>
{
Dialog dialog = new Dialog()
@@ -168,7 +189,7 @@
BackgroundColor = CSS_Color.DialogTransparentColor1,
};
- FrameLayout contentView = new FrameLayout()
+ FrameLayout contentView2 = new FrameLayout()
{
Gravity = Gravity.Center,
Width = Application.GetRealWidth(305),
@@ -178,7 +199,7 @@
BorderWidth = 0,
Radius = (uint)Application.GetMinRealAverage(10),
};
- dialog.AddChidren(contentView);
+ dialog.AddChidren(contentView2);
Button btnMsg = new Button()
{
@@ -192,7 +213,11 @@
Text = "鎾ら攢鎺堟潈鍚庯紝璇ュ搧鐗屽叧鑱斿湪On Pro涓殑璁惧灏嗗叏閮ㄨ瑙g粦锛岀浉鍏充娇鐢ㄤ俊鎭悎璁惧鍊间篃灏嗗け鏁�",
IsMoreLines = true,
};
- contentView.AddChidren(btnMsg);
+ contentView2.AddChidren(btnMsg);
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnMsg.Text = "After the authorization is revoked, all the devices associated with the brand in on Pro will be unbound, and the relevant use information and device value will also become invalid";
+ }
Button btnLine = new Button()
{
@@ -200,7 +225,7 @@
Height = Application.GetRealHeight(1),
BackgroundColor = CSS.CSS_Color.DividingLineColor,
};
- contentView.AddChidren(btnLine);
+ contentView2.AddChidren(btnLine);
Button btnConfirm = new Button()
{
@@ -213,17 +238,21 @@
SelectedBackgroundColor = CSS_Color.MainColor,
Text = "纭畾鎾ゅ洖鎺堟潈",
};
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ btnConfirm.Text = "Confirm to withdraw authorization";
+ }
btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomLeft);
btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomRight);
- contentView.AddChidren(btnConfirm);
+ contentView2.AddChidren(btnConfirm);
dialog.Show();
- btnConfirm.MouseDownEventHandler += (sender, e) =>
+ btnConfirm.MouseDownEventHandler += (sender2, e2) =>
{
btnConfirm.IsSelected = true;
};
- btnConfirm.MouseUpEventHandler += (sender, e) =>
+ btnConfirm.MouseUpEventHandler += (sender2, e2) =>
{
var http = new HttpServerRequest();
var waitPage = new Loading();
@@ -251,7 +280,14 @@
else
{
dialog.Close();
- new Alert("", "鎿嶄綔澶辫触", "").Show();
+ if (Language.CurrentLanguage != "Chinese")
+ {
+ new Alert("", "Operation failed", "").Show();
+ }
+ else
+ {
+ new Alert("", "鎿嶄綔澶辫触", "").Show();
+ }
}
}
catch { }
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPageBLL.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPageBLL.cs
index a13120e..ce10df7 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPageBLL.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PersonalDataPageBLL.cs
@@ -544,10 +544,16 @@
{
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
{
- var page = new ResetPasswordOptionPage();
- MainPage.BasePageView.AddChidren(page);
- page.LoadPage();
+ //var page = new ResetPasswordOptionPage();
+ //MainPage.BasePageView.AddChidren(page);
+ //page.LoadPage();
+ //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+ var vcp = new ResetPasswordPage();
+ MainPage.BasePageView.AddChidren(vcp);
+ vcp.LoadPage();
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
};
btnResetPasswordRight.MouseUpEventHandler = eventHandler;
btnResetPasswordText.MouseUpEventHandler = eventHandler;
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs
index 61fff82..7b49246 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/ResetAccountPassword/ResetPasswordPage.cs
@@ -23,6 +23,11 @@
#region 鎺т欢View
/// <summary>
+ /// 鍘熷瘑鐮佹枃鏈
+ /// </summary>
+ EditText etOldPwd;
+
+ /// <summary>
/// 瀵嗙爜鏂囨湰妗�
/// </summary>
EditText etPassword;
@@ -64,10 +69,45 @@
new TopViewDiv(bodyView, Language.StringByID(StringId.ModifyPassword)).LoadTopView(backAction);
+
+ #region 鍘熷瘑鐮�
+ FrameLayout oldPwdView = new FrameLayout()
+ {
+ Y = Application.GetRealHeight(64),
+ Height = Application.GetRealHeight(50),
+ BackgroundColor = CSS_Color.MainBackgroundColor,
+ };
+ bodyView.AddChidren(oldPwdView);
+
+ Button btnOldPwdTitle = new Button()
+ {
+ X = Application.GetRealWidth(16),
+ Width = Application.GetRealWidth(180),
+ TextColor = CSS_Color.FirstLevelTitleColor,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ TextAlignment = TextAlignment.CenterLeft,
+ Text = Language.StringByID(StringId.OriginalPassword) + ":"
+ };
+ oldPwdView.AddChidren(btnOldPwdTitle);
+
+ etOldPwd = new EditText()
+ {
+ Width = Application.GetRealWidth(359),
+ TextColor = CSS_Color.PromptingColor1,
+ TextSize = CSS_FontSize.TextFontSize,
+ SecureTextEntry = true,
+ TextAlignment = TextAlignment.CenterRight,
+ Foucs = true
+ };
+ oldPwdView.AddChidren(etOldPwd);
+ oldPwdView.AddChidren(new LineView(oldPwdView.Height));
+ #endregion
+
+
#region 鏂板瘑鐮�
FrameLayout rowView = new FrameLayout()
{
- Y = Application.GetRealHeight(64),
+ Y = oldPwdView.Bottom ,
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
@@ -156,24 +196,24 @@
public partial class ResetPasswordPage
{
- /// <summary>
- /// 鎸囧畾鍏抽棴椤甸潰涓暟
- /// </summary>
- /// <param name="countPage"></param>
- void ClosePageWithCount(int countPage)
- {
- //鍏抽棴澶氬皯涓〉闈�
- for (int i = 0; i < countPage; i++)
- {
- MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1).RemoveFromParent();
- }
- }
+ ///// <summary>
+ ///// 鎸囧畾鍏抽棴椤甸潰涓暟
+ ///// </summary>
+ ///// <param name="countPage"></param>
+ //void ClosePageWithCount(int countPage)
+ //{
+ // //鍏抽棴澶氬皯涓〉闈�
+ // for (int i = 0; i < countPage; i++)
+ // {
+ // MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1).RemoveFromParent();
+ // }
+ //}
/// <summary>
///
/// </summary>
/// <param name="password"></param>
- void ResetPassword(string password)
+ void ResetPassword(string oldPwd, string password)
{
//鏍¢獙瀵嗙爜鏄惁绗﹀悎瑕佹眰
@@ -211,13 +251,13 @@
try
{
// 蹇樿瀵嗙爜
- var resultObj = new HttpServerRequest().ForgetPassword(account, password, verCode, isPhone);
+ var resultObj = new HttpServerRequest().UpdataPassword(oldPwd, password);
if (resultObj.Code == StateCode.SUCCESS)
{
Application.RunOnMainThread(() =>
{
Utlis.ShowTip(Language.StringByID(StringId.PasswordChangeSuccessfully));
- ClosePageWithCount(2);
+ this.RemoveFromParent();
});
}
else
@@ -252,7 +292,7 @@
{
if (btnReset.IsSelected)
{
- ResetPassword(etPassword.Text.ToString());
+ ResetPassword(etOldPwd.Text.Trim().ToString(), etPassword.Text.ToString());
}
};
}
diff --git a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacControlPage.cs b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacControlPage.cs
index bf223e0..a46b9a4 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacControlPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacControlPage.cs
@@ -102,6 +102,7 @@
this.RefreshNowDeviceStatuMemory(this.device);
//鍒锋柊鐣岄潰鐘舵��
this.RefreshFormStatu();
+ controlTime = DateTime.Now;
//璇诲彇鐘舵��
new System.Threading.Thread(() =>
{
@@ -109,7 +110,7 @@
{
if (controlTime == DateTime.MinValue)
{
-
+
}
else if (controlTime.AddSeconds(2) < DateTime.Now)
{
@@ -176,7 +177,6 @@
temp = (int)Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp).Replace(",", "."));
if (temp <= 0)
{
- //榛樿鍊兼敼鎴�16,2022骞�06鏈�10鏃�10:03:19 鎴愮敨瑕佹眰鐨�
temp = 16;
device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
}
@@ -683,10 +683,12 @@
{
//btnIndoorTemp.Text = Language.StringByID(StringId.IndoorTemp) + Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.RoomTemp).Replace(",", "."))) + "掳C"
// + Language.StringByID(StringId.Humidity) + Convert.ToInt32(Convert.ToDouble(device.GetAttrState("room_humidity").Replace(", ", "."))) + "%";
- btnTempValues.Text = Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.RoomTemp).Replace(",", "."))) + "掳C";
- btnHumidityValues.Text = Convert.ToInt32(Convert.ToDouble(device.GetAttrState("room_humidity").Replace(", ", "."))) + "%";
+ btnTempValues.Text = Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.RoomTemp).Replace(",", ".")) + "掳C";
+ btnHumidityValues.Text = Convert.ToDouble(device.GetAttrState("room_humidity").Replace(", ", ".")) + "%";
btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode));
+ btnModeText.Text = acFunction.GetModeAttrText(device.GetAttrState(FunctionAttributeKey.Mode));
+
temp = Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp).Replace(",", ".")));
--
Gitblit v1.8.0