From a00556275e92b30d3d26c3f28506d9c14ce37542 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 13 十月 2022 13:55:40 +0800
Subject: [PATCH] 2022年10月13日13:55:39
---
HDL_ON/DAL/DriverLayer/Control.cs | 530 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 470 insertions(+), 60 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 1430b9b..f27460b 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -1,31 +1,18 @@
锘縰sing System;
using System.Collections.Generic;
using System.Text;
+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
{
-
+
static Control _control;
public static Control Ins
{
@@ -42,6 +29,27 @@
/// 璁板綍鎺ユ敹鍒扮殑娑堟伅锛屾柟渚縵b鐨勫伐绋嬪笀璋冭瘯浠栦滑鐨勮澶�
/// </summary>
public List<string> MsgInfoList = new List<string>();
+ private bool _LocalTcpClientLogin = false;
+ /// <summary>
+ /// 鏈湴tcp瀹㈡埛绔繛鎺ユ槸鍚︽垚鍔�
+ /// 鏄惁鐧诲綍缃戝叧鎴愬姛
+ /// </summary>
+ public bool LocalTcpClientLogin
+ {
+ get
+ {
+ return _LocalTcpClientLogin;
+ }
+ set
+ {
+ _LocalTcpClientLogin = value;
+ if (!value)
+ {
+ loginGatewayThread?.Abort();
+ loginGatewayThread = null;
+ }
+ }
+ }
int _msg_id = 1;
/// <summary>
@@ -199,11 +207,6 @@
public Control_Udp myUdp1 = null;
/// <summary>
- /// 閫氳鏂瑰紡
- /// </summary>
- public CommunicationMode communicationMode;
-
- /// <summary>
/// 鎵撳紑tcp鏈嶅姟绔�
/// </summary>
public void OpenTcpServer()
@@ -235,8 +238,9 @@
if (myTcpClient == null)
{
myTcpClient = new Control_TcpClient(reportIp);
- myTcpClient.Connect();
}
+ myTcpClient.Connect();
+
}
/// <summary>
@@ -279,7 +283,8 @@
}
if (DB_ResidenceData.Instance.GatewayType == 0)
{
- new Control_Udp().ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
+ new Control_Udp().ControlBytesSend(Command.ReadGateway, 255, 255,
+ new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
}
else if (DB_ResidenceData.Instance.GatewayType == 1)
{
@@ -294,6 +299,57 @@
{ IsBackground = true }.Start();
}
}
+
+
+ private System.Threading.Thread loginGatewayThread;
+
+ /// <summary>
+ /// 鐧诲綍缃戝叧
+ /// </summary>
+ public void LoginGateway()
+ {
+ if(loginGatewayThread== null)
+ {
+ loginGatewayThread = new System.Threading.Thread(() => {
+ while (!Ins.myTcpClient.isConnected)
+ {
+ if (Ins.GatewayOnline_Local && myTcpClient.isConnected)
+ {
+ 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);
+ }
+ //loginGatewayThread?.Abort();
+ //loginGatewayThread = null;
+
+ });
+ loginGatewayThread.Start();
+ }
+ else
+ {
+ try
+ {
+ loginGatewayThread?.Abort();
+ }catch (Exception ex)
+ {
+ MainPage.Log($"閲嶅惎鐧诲綍缃戝叧绾跨▼寮傚父:{ex.Message}");
+ }
+ finally
+ {
+ loginGatewayThread = null;
+ LoginGateway();
+ }
+ }
+
+ }
+
/// <summary>
/// 鍦烘櫙鎺у埗鍏ュ彛
@@ -340,15 +396,6 @@
}
}
}
- /// <summary>
- /// 瀹夐槻鎺у埗
- /// </summary>
- public void ControlArm()
- {
- DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
- //var pack = httpServer.GetSecurityAlarmLogList
- }
-
/// <summary>
/// 鍙戦�佸懡浠�
@@ -359,10 +406,11 @@
/// <param name="function"></param>
/// <param name="useRemote">鏄惁鐩存帴浣跨敤杩滅▼鍙戦��</param>
/// <returns></returns>
- public void SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false,int resend = 3)
+ public bool SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false,int resend = 3)
{
function.controlCounter++;
function.refreshTime = DateTime.Now;
+
//濡傛灉鏄帶鍒惰皟鍏夌殑寮�鏃讹紝浜害鍊间笉鑳戒负0
if (commandDictionary.Count > 2)
@@ -403,7 +451,7 @@
upDataObj.objects.Add(asd);
revString = Newtonsoft.Json.JsonConvert.SerializeObject(upDataObj);
UpdataFunctionStatus(revString, null, true);
- return;
+ return true;
}
@@ -492,6 +540,8 @@
}
}
+
+ return true;
}
/// <summary>
/// 鍏ㄥ紑鍏ㄥ叧鍔熻兘
@@ -651,6 +701,79 @@
}
/// <summary>
+ /// 鍙戦�佽鍙栧懡浠�
+ /// 鑷姩鍒ゆ柇鏄惁涓篈鍗忚璁惧
+ /// </summary>
+ public void SendReadCommand(List<Function> functions, bool forceRemote = false)
+ {
+ List<string> sids = new List<string>();
+ foreach (Function function in functions)
+ {
+ sids.Add(function.sid);
+ function.refreshTime = DateTime.Now;
+ }
+ if (forceRemote)
+ {
+
+ var pm = new DAL.Server.HttpServerRequest();
+ var pack = pm.RefreshDeviceStatus(sids);
+ }
+ else
+ {
+ if (Ins.GatewayOnline_Local)
+ {
+
+ if (DB_ResidenceData.Instance.GatewayType == 0)
+ {
+ try
+ {
+ var busClient = new Control_Udp();
+ foreach (Function function in functions)
+ {
+ busClient.ReadBusData(function);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"鍙戦�佹暟鎹紓甯�: {ex.Message}");
+ }
+ }
+ else
+ {
+ var objects = new List<Dictionary<string, string>>();
+
+
+ foreach (Function function in functions)
+ {
+ var readKey = new Dictionary<string, string>();
+ readKey.Add("sid", function.sid);
+ objects.Add(readKey);
+ }
+
+
+ var readDataObj = new AlinkReadFunctionStatusObj()
+ {
+ id = Ins.msg_id.ToString(),
+ objects = objects,
+ time_stamp = Utlis.GetTimestamp()
+ };
+ var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj);
+ var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ReadStatus, functionControlDataJson);
+ MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
+ new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id);
+ }
+ }
+ else
+ {
+ var pm = new DAL.Server.HttpServerRequest();
+ var pack = pm.RefreshDeviceStatus(sids);
+ }
+ }
+ }
+
+
+ /// <summary>
/// 瀹夐槻鎺у埗
/// </summary>
public void ControlSecurity(SecurityAlarm securityAlarm,string state)
@@ -714,6 +837,33 @@
new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id,0);
}
}
+
+
+ /// <summary>
+ /// 鑾峰彇闊充箰鐩綍
+ /// </summary>
+ public void GetMusicDirectory(Function function)
+ {
+ if (Ins.GatewayOnline_Local)
+ {
+ var objects = new List<Dictionary<string, string>>();
+ var readKey = new Dictionary<string, string>();
+ readKey.Add("sid", function.sid);
+ objects.Add(readKey);
+ var readDataObj = new AlinkReadFunctionStatusObj()
+ {
+ id = Ins.msg_id.ToString(),
+ objects = objects,
+ time_stamp = Utlis.GetTimestamp()
+ };
+ var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj);
+ var sendBytes = Ins.ConvertSendBodyData($"/base/{DB_ResidenceData.Instance.HomeGateway.gatewayId}/thing/service/MusicPlayGroupListGet/down", functionControlDataJson);
+ MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
+ new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id);
+ }
+
+ }
+
/// <summary>
/// 缃戝叧杩涘叆閰嶇綉妯″紡
/// </summary>
@@ -768,8 +918,8 @@
topicAndLengthBytes.CopyTo(sendDataBytes, 0);
bodyBytes.CopyTo(sendDataBytes, topicAndLengthBytes.Length);
- //var sendDataString = Encoding.UTF8.GetString(sendDataBytes);
- //MainPage.Log($"杞崲HDL-Link鏁版嵁\r\n{sendDataString}\r\n");
+ var sendDataString = Encoding.UTF8.GetString(sendDataBytes);
+ MainPage.Log($"杞崲HDL-Link鏁版嵁\r\n{sendDataString}\r\n");
//***************************************************************
return sendDataBytes;
@@ -793,7 +943,6 @@
{
LocalCommunicationData receiveObj = new LocalCommunicationData();
- MainPage.Log($"灞�鍩熺綉淇℃伅: \r\n{receiveString}");
var res = receiveString.Split("\r\n\r\n");
@@ -825,13 +974,19 @@
//}
receiveObj.BodyDataString = res[1];
+ if (receiveObj.Topic == CommunicationTopic.ct.HeartBeat + "_reply")
+ {
+ Ins.myTcpClient.ClearHeartBeatLog();
+ MainPage.Log("tcp蹇冭烦鍥炲");
+ return null;
+ }
+
//2021-09-23 杩囨护涓嶉渶瑕佽В瀵嗙殑涓婚 鐩墠鎼滅储缃戝叧涓婚涓嶅姞瀵�
if (receiveObj.Topic != CommunicationTopic.SearchLoaclGatewayReply)
{
//鍒ゆ柇褰撳墠缃戝叧鏄惁寮�鍚簡鏈湴鍔犲瘑
if (IsLocalEncryptAndGetAesKey)
{
- MainPage.Log($"灞�鍩熺綉淇℃伅 寮�濮嬭В瀵�");
if (originalReceiveBytes != null)
{
//鎷垮埌鍘熷Bytes鏁版嵁鍘昏В瀵�
@@ -839,13 +994,16 @@
byte[] bodyBytes = new byte[receiveObj.Length];
Array.Copy(originalReceiveBytes, topicBytes.Length + 4, bodyBytes, 0, receiveObj.Length);
byte[] receiveBytes = Securitys.EncryptionService.AesDecryptPayload(bodyBytes, DB_ResidenceData.Instance.CurrentRegion.localSecret);
- var revString = Encoding.UTF8.GetString(receiveBytes);
- receiveObj.BodyDataString = revString;
- MainPage.Log($"灞�鍩熺綉淇℃伅: 瑙e瘑鍚庯細" + receiveObj.BodyDataString);
- //if (receiveObj.Topic.EndsWith("/thing/property/up"))
- //{
- // MsgInfoList.Add(revString + "\r\n");
- //}
+ if (receiveBytes != null)
+ {
+ var revString = Encoding.UTF8.GetString(receiveBytes);
+ receiveObj.BodyDataString = revString;
+ MainPage.Log($"灞�鍩熺綉淇℃伅: 瑙e瘑鍚庯細" + receiveObj.BodyDataString);
+ //if (receiveObj.Topic.EndsWith("/thing/property/up"))
+ //{
+ // MsgInfoList.Add(revString + "\r\n");
+ //}
+ }
}
else
{
@@ -860,12 +1018,31 @@
}
}
+ else
+ {
+ MainPage.Log($"灞�鍩熺綉淇℃伅: 鏄庢枃锛�" + receiveObj.BodyDataString);
+ }
}
+ 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)
{
-
+
var bodyJObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(res[1]);
if (bodyJObj == null)
{
@@ -894,17 +1071,21 @@
//2021-09-23 鏂板鑾峰彇褰撳墠缃戝叧鏄惁鏈湴鍔犲瘑
Ins.IsLocalEncrypt = device.isLocalEncrypt;
//MainPage.Log("缃戝叧鏈湴鍔犲瘑鐘舵�侊細" + device.local_encrypt.ToString());
+
+ OpenTcpClent();
+
+
}
}
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)
{
@@ -912,7 +1093,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)
{
@@ -931,8 +1113,29 @@
}
}
}
- 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;
+ try
+ {
+ loginGatewayThread?.Abort();
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"缁堟鐧诲綍缃戝叧tcp寮傚父锛歿ex.Message}");
+ }
+ finally
+ {
+ loginGatewayThread = null;
+ }
+ MainPage.Log("灞�鍩熺綉tcp杩炴帴鐧诲綍缃戝叧鎴愬姛");
}
}
else
@@ -944,6 +1147,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鍗忚鏁版嵁
@@ -951,6 +1177,12 @@
/// <param name="updateBytes"></param>
public void UpdataFunctionStatus(string revString, byte[] usefulBytes,bool isCloudData = false)
{
+ ////test 浜戠杩炴帴鎴愬姛鏃讹紝涓嶉�傜敤鏈湴鏁版嵁鏇存柊
+ //if (Ins.GatewayOnline_Cloud && !isCloudData)
+ //{
+ // return;
+ //}
+
var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString);
if (temp != null)
{
@@ -963,37 +1195,53 @@
if (Ins.GatewayOnline_Local && isCloudData)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�
{
- if (FunctionList.List.OtherBrandFunction.Count != 0)
+ if (FunctionList.List.OtherBrandFunction.Count == 0)
+ {
+ MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�...");
+ return;
+ }
+ else
{
if (FunctionList.List.OtherBrandFunction.Find((obj) => obj.sid == updateTemp.sid) == null)
{
- //MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�...");
return;
}
}
}
-
-
-
var localFunction = allLocalFuntion.Find((obj) => obj.sid == updateTemp.sid);
if (localFunction == null)
{
continue;
}
+ MainPage.Log(localFunction.name);
+
if (Ins.GatewayOnline_Local && isCloudData)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�
{
- if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk))
+ if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains( localFunction.spk))
{
//MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�........");
+
return;
}
}
+
+ //if (SPK.MusicSpkList().Contains(localFunction.spk))
+ //{
+ // if (updateTemp.status.Count < 3)
+ // {
+ // ///鏄煶涔愬姛鑳界殑
+ // ///涓婃姤灞炴�у皯3鏉′笉鍋氬鐞�
+ // return;
+ // }
+ //}
//MainPage.Log($"A鍗忚鏇存柊鐘舵��:{revString}");
foreach (var attr in updateTemp.status)
{
localFunction.time_stamp = temp.time_stamp;
localFunction.SetAttrState(attr.key, attr.value);
+ //Console.WriteLine("闊充箰鎾斁鍣ㄦ坊鍔犵紦瀛樻暟鎹�=======" + revString);
+
}
//鏇存柊鐣岄潰鐘舵��
@@ -1036,6 +1284,14 @@
case SPK.CurtainSwitch:
localFunction.lastState = localFunction.trait_on_off.curValue.ToString() == "on" ? Language.StringByID(StringId.Open) : Language.StringByID(StringId.Close);
CurtainModulePage.UpdataState(localFunction);
+ break;
+ case SPK.CurtainDream:
+ if(localFunction.GetAttrState(FunctionAttributeKey.Percent) == "0")
+ {
+ localFunction.SetAttrState(FunctionAttributeKey.OnOff, "off");
+ }
+ localFunction.lastState = localFunction.trait_on_off.curValue.ToString() == "on" ? Language.StringByID(StringId.Open) : Language.StringByID(StringId.Close);
+ CurtainDreamPage.UpdataState(localFunction);
break;
case SPK.CurtainTrietex:
localFunction.lastState = Language.StringByID(StringId.Open) + localFunction.GetAttrState(FunctionAttributeKey.Percent) + "%";
@@ -1166,14 +1422,63 @@
case SPK.SensorSmoke:
case SPK.SensorWater:
case SPK.ClothesHanger:
- case SPK.SenesorMegahealth:
- case SPK.SenesorMegahealth2:
case SPK.AirFreshStandard:
case SPK.HvacAirFresh:
case SPK.SensorGas:
+ case SPK.HvacCac:
+ case SPK.SensorHelp:
//璁惧鐘舵�佹帹閫�
//鐘舵�佹洿鏂�
Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status);
+ break;
+ case SPK.SenesorMegahealth:
+ case SPK.SenesorMegahealth2:
+
+ var tempStatus = localFunction.attributes.Find((sta) => sta.key == FunctionAttributeKey.TargetStatus);
+ if (tempStatus != null)
+ {
+
+ switch (tempStatus.state)
+ {//0绌猴紝1璧帮紝2璺戯紝3鍧愶紝4璺屽�掞紝5绔�
+ case "0":
+ localFunction.lastState = Language.StringByID(StringId.SensorNormalState);
+ break;
+ case "1":
+ localFunction.lastState = Language.StringByID(StringId.SomeoneIn);
+ break;
+ case "2":
+ if (localFunction.extSet.labModel)
+ {
+ localFunction.lastState = Language.StringByID(StringId.SomeoneRunning);
+ }
+ break;
+ case "3":
+ if (localFunction.extSet.labModel)
+ {
+ localFunction.lastState = Language.StringByID(StringId.SomeoneSitting);
+ }
+ break;
+ case "4":
+ localFunction.lastState = Language.StringByID(StringId.SomeoneFell);
+ break;
+ case "5":
+ if (localFunction.extSet.labModel)
+ {
+ localFunction.lastState = Language.StringByID(StringId.SomeoneStanding);
+ }
+ break;
+ default:
+
+ break;
+ }
+ }
+ Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status);
+ break;
+ case SPK.AvMusic:
+ case SPK.MusicStandard:
+ //UI.Music.MusicMain.mMusicMain.RefreshView(updateTemp);
+ //Console.WriteLine("闊充箰鎾斁鍣ㄦ樉绀虹姸鎬�======="+ revString);
+ //wjc
break;
}
@@ -1191,5 +1496,110 @@
}
}
+
+
+ #region 闂ㄩ攣
+
+ /// <summary>
+ /// //涓�閿紙杩滅▼锛夊紑閿�
+ /// </summary>
+ public void OneKeyUnlocking(Function doorlock,string extStr)
+ {
+ if (Ins.GatewayOnline_Local)
+ {
+ Dictionary<string, string> dic = new Dictionary<string, string>();
+ var functionControlDataObj = doorlock.GetGatewayAlinkDoorlockData(UserInfo.Current.ID,extStr);
+ var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj);
+ var sendBytes = Ins.ConvertSendBodyData($"/base/{Control.Ins.GatewayId}/thing/service/doorRemoteOpen/down", functionControlDataJson);
+ new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, 0);
+ }
+ else
+ {
+ ConfirmUnlocking(doorlock.deviceId, extStr);
+ }
+ }
+ /// <summary>
+ /// 纭寮�閿�
+ /// </summary>
+ /// <param name="functionId"></param>
+ /// <param name="pwd"></param>
+ public void ConfirmUnlocking(string functionId,string pwd)
+ {
+ Loading loading = new Loading();
+ MainPage.BaseView.AddChidren(loading);
+ loading.BackgroundColor = 0x88000000;
+ loading.LodingBackgroundColor = UI.CSS.CSS_Color.BackgroundColor;
+ loading.Start(Language.StringByID(StringId.PleaseWait));
+ new System.Threading.Thread(() =>
+ {
+ try
+ {
+ Dictionary<string, object> d = new Dictionary<string, object>();
+ d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+ d.Add("deviceId", functionId);
+ d.Add("pwd", pwd);
+ var requestJson = HttpUtil.GetSignRequestJson(d);
+ var pack = HttpUtil.RequestHttpsPost("/home-wisdom/app/device/door/pwdConfirm", requestJson);
+ if (pack.Code == StateCode.SUCCESS)
+ {
+ Newtonsoft.Json.Linq.JObject pairs = Newtonsoft.Json.Linq.JObject.Parse(pack.Data.ToString());
+ var scrip = pairs.GetValue("scrip");
+
+ d = new Dictionary<string, object>();
+ d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+ d.Add("deviceId", functionId);
+ d.Add("scrip", scrip);
+ requestJson = HttpUtil.GetSignRequestJson(d);
+ pack = HttpUtil.RequestHttpsPost("/home-wisdom/app/device/door/remoteOpen", requestJson);
+ //if(pack.Code == StateCode.SUCCESS)
+ //{
+ // return true;
+ //}
+ //else
+ //{
+ // return false;
+ //}
+ if (pack.Code != StateCode.SUCCESS) {
+ Application.RunOnMainThread(() => {
+ new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), pack.message);
+ UserInfo.Current.doorPasswordString = "";//
+ UserInfo.Current.LastTimeOpenDoor = DateTime.MinValue;
+ });
+ }
+ }
+ if (pack.Code != StateCode.SUCCESS)
+ {
+ Application.RunOnMainThread(() => {
+ if(string.IsNullOrEmpty(pack.message))
+ {
+ new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip),
+ Language.StringByID(StringId.OperationFailed));
+ }
+ else
+ {
+ new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), pack.message);
+ }
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ loading.Hide();
+ loading.RemoveFromParent();
+ });
+ }
+ })
+ { IsBackground = true }.Start();
+ }
+ //瀵嗙爜鍐荤粨
+ //瀵嗙爜楠岃瘉
+
+ #endregion
}
-}
\ No newline at end of file
+}
--
Gitblit v1.8.0