From 4f0ab0ad21ce450b7856d50f98322a7899361386 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 22 九月 2020 10:30:01 +0800
Subject: [PATCH] 不要下载这个备份
---
ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs | 2646 +++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 1,966 insertions(+), 680 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
index df2cc00..826613d 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
@@ -1,23 +1,101 @@
锘縰sing System;
using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Shared;
+using Shared.Common;
+using Shared.Common.ResponseEntity;
using Shared.Phone.UserCenter;
namespace ZigBee.Device
{
- public class DoorLock : CommonDevice
+ public class DoorLock : Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo
{
public DoorLock()
{
this.Type = DeviceType.DoorLock;
}
+ #region 闂ㄩ攣鏈湴鍙橀噺
+ /// <summary>
+ /// 鏈湴闂ㄩ攣鐢ㄦ埛鍜岃处鎴峰垪琛�
+ /// key:闂ㄩ攣鐢ㄦ埛ID
+ /// </summary>
+ /// <returns></returns>
+ public Dictionary<int, LocaDoorLockObj> localDoorLockUserList = new Dictionary<int, LocaDoorLockObj>();
+ /// <summary>
+ /// 鏈湴闂ㄨ处鎴峰垪琛�
+ /// key:璐︽埛ID锛堜富璐︽埛鏄疓UID锛屽瓙璐︽埛鏄垎浜繃鏉ョ殑璐︽埛ID锛�
+ /// </summary>
+ /// <returns></returns>
+ public Dictionary<string, LocaDoorLockObj> localDoorLockAccountList = new Dictionary<string, LocaDoorLockObj>();
+
+ public string currentUserDisplayMethod = string.Empty;//褰撳墠鐢ㄦ埛鏄剧ず鏂瑰紡
+ //鏈湴鎵�鏈夎处鎴峰垪琛�
+ public List<Shared.Phone.UserCenter.MemberInfoRes> localAllAccountList = new List<Shared.Phone.UserCenter.MemberInfoRes> { };
+
+ /// <summary>
+ /// 鏄惁甯稿紑妯″紡
+ /// ture:甯稿紑锛� false:鍏抽棴
+ /// </summary>
+ public bool IsDoorLockNormallyMode = false;
+ [Newtonsoft.Json.JsonIgnore]
+ public string LocalTempPassword = string.Empty;//鏈湴鐢熸垚鐨勪复鏃跺瘑鐮�
+ public Dictionary<string, bool> IsFreezeAccount = new Dictionary<string, bool> { };//鏄惁鍐荤粨瀛愯处鎴�
+ public Dictionary<string, bool> HasRemoteUnlockAccess = new Dictionary<string, bool> { };//鏄惁缁欏瓙璐︽埛鎷ユ湁杩滅▼寮�閿佺殑鏉′欢
+ public Dictionary<string, bool> IsFailedToGetDoorLockInfo = new Dictionary<string, bool> { };//鏄惁鑾峰彇闂ㄩ攣鏁版嵁澶辫触
+ [Newtonsoft.Json.JsonIgnore]
+ public string RemoteUnlockPassword = string.Empty;//杩滅▼寮�閿佸瘑鐮�
+
+ public static int RemoteUnlockCount = 5;//杩滅▼寮�閿佹鏁伴檺鍒�
+ public static int failedCount = 3;//杩滅▼寮�閿佸け璐ユ鏁�
+ public static DateTime minValue = DateTime.MinValue;
+
+ #region 涓存椂瀵嗙爜淇℃伅
+ /// <summary>
+ /// 鐢ㄦ埛绠$悊鍙戦�佹暟鎹洖澶�
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public TempPasswordObject tempPasswordObject;
+ /// <summary>
+ /// 涓存椂瀵嗙爜鏈湴瀵硅薄
+ /// </summary>
+ [System.Serializable]
+ public class TempPasswordObject
+ {
+ /// <summary>
+ /// 涓存椂瀵嗙爜ID
+ /// </summary>
+ public int UserId;
+ /// <summary>
+ /// PrimaryId 闂ㄩ攣浜戠涓� 閿�(闈炴洿鏂板瓧娈�,浠ヤ笅鍧囦负鏇存柊瀛楁) -->閿悕 : PrimaryId榛樿鍊�: null
+ /// </summary>
+ //public string PrimaryId;
+ /// <summary>
+ /// 6浣嶆湁鍔ㄦ�佷复鏃跺瘑鐮�
+ /// </summary>
+ public string TempPassword;
+ /// <summary>
+ /// 闂ㄩ攣鏈夋晥鏃堕棿
+ /// </summary>
+ public DateTime ValidTime;
+ /// <summary>
+ /// 闂ㄩ攣澶辨晥鏃堕棿
+ /// </summary>
+ public DateTime InValidTime;
+ }
+ #endregion
+
+ #endregion
+
#region 涓庝簯绔�氳鎺ュ彛
+ #region 闂ㄩ攣鏈嶅姟鍣ㄥ彂閫佸熀鏈俊鎭�
/// <summary>
/// 娣诲姞闂ㄩ攣
/// </summary>
- public class AddDoorLockData
+ public class BaseDoorLockServerData
{
/// <summary>
/// RequestVersion
@@ -30,23 +108,37 @@
/// <summary>
/// 浣忓畢Id -->閿悕 : HomeId
/// </summary>
- public string HomeId = "";
- /// <summary>
- /// 浜戠甯愬彿Id -->閿悕 : CloudAccountId
- /// </summary>
- public string CloudAccountId = "";
+ public string HomeId = Shared.Common.Config.Instance.HomeId;
/// <summary>
/// 闂ㄩ攣Id -->閿悕 : DoorLockId
/// </summary>
public string DoorLockId = "";
/// <summary>
- /// OpenLockMode 寮�閿佹柟寮�(瀵嗙爜銆佹寚绾广�両C鍗�) -->閿悕 : OpenLockMode (鍙��)
- /// </summary>
- public int OpenLockMode = 0;
- /// <summary>
/// 闂ㄩ攣鏈湴鐢ㄦ埛Id -->閿悕 : DoorLockLocalUserId
/// </summary>
public string DoorLockLocalUserId = "";
+
+ /// <summary>
+ /// IsOtherAccountCtrl 鏄惁涓哄瓙甯愬彿鎺у埗杩囨潵 -->閿悕 : IsOtherAccountCtrl
+ /// </summary>
+ public bool IsOtherAccountCtrl = false;
+ }
+ #endregion
+
+ #region 娣诲姞闂ㄩ攣
+ /// <summary>
+ /// 娣诲姞闂ㄩ攣
+ /// </summary>
+ public class AddDoorLockData : BaseDoorLockServerData
+ {
+ /// <summary>
+ /// 浜戠甯愬彿Id -->閿悕 : CloudAccountId
+ /// </summary>
+ public string CloudAccountId = "";
+ /// <summary>
+ /// OpenLockMode 寮�閿佹柟寮�(瀵嗙爜銆佹寚绾广�両C鍗�) -->閿悕 : OpenLockMode (鍙��)
+ /// </summary>
+ public int OpenLockMode = 0;
/// <summary>
/// Data 鐩稿叧鍐呭(濡�:瀵嗙爜銆佹寚绾广�両C鍗� 鐨勪簩杩涘埗) -->閿悕 : Data (鍙��)
public byte[] Data = null;
@@ -65,12 +157,504 @@
/// <summary>
/// EntryTime 褰曞叆鏃堕棿 -->閿悕 : EntryTime(鍙��)
/// </summary>
+ public DateTime EntryTime = System.DateTime.Now;
+ }
+
+ /// <summary>
+ /// 娣诲姞闂ㄩ攣缁撴灉
+ /// </summary>
+ public class AddDoorLockDataRes
+ {
+ /// <summary>
+ /// 鍝嶅簲鐨勭増鏈彿,涓�鑸姹備粈涔堢増鏈彿锛岃繖閲屼笌涔嬭姹傜浉鍚�
+ /// </summary>
+ public string ResponseVersion = string.Empty;
+ /// <summary>
+ /// 鍝嶅簲鐘舵�佺爜:
+ ///<para>(1)Success 鍒橻璋冪敤姝ゆ帴鍙f搷浣滄垚鍔焆, ResponseData鍒欎负null</para>
+ ///<para>(2)ParameterOrEmpty,鍒欏搷搴斿瓧娈典腑[ErrorInfo] 涓洪敊璇俊鎭�, ResponseData鍒欎负null</para>
+ ///(<para>3)NoLogin,鍒欏搷搴斿瓧娈典腑[ErrorInfo] 涓洪敊璇俊鎭负[鏃犳晥鐧诲綍Token!]</para>
+ ///<para>(4)NoRecord,鍒欏搷搴斿瓧娈典腑[ErrorInfo] 涓洪敊璇俊鎭负[褰撳墠鎻愪氦DoorLockId鍊煎湪浜戠涓嶅瓨鍦紝璇风‘璁ゅ�兼槸鍚︽纭�!]</para>
+ ///<para>(5)DoorLockIdNoIsYou,鍒欏搷搴斿瓧娈典腑[ErrorInfo] 涓洪敊璇俊鎭负[褰撳墠鎻愪氦DoorLockId骞朵笉灞炰簬浣犲綋鍓嶅笎鍙风殑锛岃纭鍊兼槸鍚︽纭�!]</para>
+ /// </summary>
+ public string StateCode = string.Empty;
+ }
+ #endregion
+
+ #region 鏇存柊闂ㄩ攣
+ /// <summary>
+ /// 鏇存柊闂ㄩ攣
+ /// </summary>
+ public class RefreshDoorLockData : BaseDoorLockServerData
+ {
+ /// <summary>
+ /// PrimaryId 闂ㄩ攣浜戠涓� 閿�(闈炴洿鏂板瓧娈�,浠ヤ笅鍧囦负鏇存柊瀛楁) -->閿悕 : PrimaryId榛樿鍊�: null
+ /// </summary>
+ public string PrimaryId = "";
+ /// <summary>
+ /// OpenLockMode 寮�閿佹柟寮�(瀵嗙爜銆佹寚绾广�両C鍗�) -->閿悕 : OpenLockMode (鍙��)
+ /// </summary>
+ public int OpenLockMode = 0;
+
+ /// <summary>
+ /// 浣忓畢Id (鍙��)
+ /// </summary>
+ public byte[] Data;
+ /// <summary>
+ /// 鐢ㄦ埛Id澶囨敞
+ /// </summary>
+ public string UserIdRemarks = "";
+ /// <summary>
+ /// 鏄惁涓虹鐞嗗憳闂ㄩ攣
+ /// </summary>
+ public bool IsFreezeUser;
+ /// <summary>
+ /// 鏄惁涓虹鐞嗗憳闂ㄩ攣
+ /// </summary>
+ public bool IsTempUnlockAuthority;
+ }
+ #endregion
+
+ #region 鍒犻櫎闂ㄩ攣
+ /// <summary>
+ /// 鍒犻櫎闂ㄩ攣
+ /// </summary>
+ public class DeleteDoorLockData : BaseDoorLockServerData
+ {
+ /// <summary>
+ /// PrimaryId 闂ㄩ攣浜戠涓� 閿�(闈炴洿鏂板瓧娈�,浠ヤ笅鍧囦负鏇存柊瀛楁) -->閿悕 : PrimaryId榛樿鍊�: null
+ /// </summary>
+ public string PrimaryId = "";
+ /// <summary>
+ /// 闂ㄩ攣Id -->閿悕 : DoorLockId (鍙��)
+ /// DelDoorLockDelType 闂ㄩ攣鍒犻櫎绫诲瀷(0: 鏍规闂ㄩ攣涓婚敭(浜戠涓婚敭)鍒犻櫎(鍗曟潯鍒犻櫎)銆�1:鏍规闂ㄩ攣Id鎵归噺鍒犻櫎(鍑℃槸涓庨棬閿両d鐩稿悓閮戒細鍒犻櫎)銆�2锛氭牴妞愰棬閿両d鍙婇棬閿佹湰鍦扮敤鎴稩d鎵归噺鍒犻櫎(杩欎釜闂ㄩ攣Id杩欎釜闂ㄩ攣鏈湴鐢ㄦ埛Id鍧囦細琚垹闄�)) -->閿悕 : DelDoorLockDelType 榛樿鍊�: 0
+ /// </summary>
+ public int DelDoorLockDelType;
+ }
+ #endregion
+
+ #region 娣诲姞闂ㄩ攣涓存椂瀵嗙爜
+ /// <summary>
+ /// 娣诲姞闂ㄩ攣
+ /// </summary>
+ public class AddDoorLockTempPasswordData
+ {
+ /// <summary>
+ /// RequestVersion
+ /// </summary>
+ public string RequestVersion = Shared.Common.CommonPage.RequestVersion;
+ /// <summary>
+ /// LoginAccessToken
+ /// </summary>
+ public string LoginAccessToken = Shared.Common.Config.Instance.Token;
+ /// <summary>
+ /// 浣忓畢Id -->閿悕 : HomeId
+ /// </summary>
+ public string HomeId = Shared.Common.Config.Instance.HomeId;
+ /// <summary>
+ /// 闂ㄩ攣Id -->閿悕 : DoorLockId
+ /// </summary>
+ public string LocalDoorLockId = "";
+ /// <summary>
+ /// 涓存椂瀵嗙爜Id -->閿悕 : TempPwdId
+ /// </summary>
+ public string TempPwdId = "";
+ /// <summary>
+ /// 涓存椂瀵嗙爜 -->閿悕 : TempPwd
+ /// </summary>
+ public string TempPwd = "";
+ /// <summary>
+ /// 0:00:00] ValidBeginTime 鏈夋晥寮�濮嬫椂闂� -->閿悕 : ValidBeginTime 榛樿鍊�: 0001/1/1
+ /// </summary>
+ public DateTime ValidBeginTime;
+ /// <summary>
+ /// 0:00:00] ValidEndTime 鏈夋晥缁撴潫鏃堕棿 -->閿悕 : ValidEndTime
+ /// </summary>
+ public DateTime ValidEndTime;
+ /// <summary>
+ /// IsOtherAccountCtrl 鏄惁涓哄瓙甯愬彿鎺у埗杩囨潵 -->閿悕 : IsOtherAccountCtrl
+ /// </summary>
+ public bool IsOtherAccountCtrl = false;
+ }
+
+ /// <summary>
+ /// 娣诲姞闂ㄩ攣缁撴灉
+ /// </summary>
+ public class AddDoorLockTempPasswordDataRes : AddDoorLockDataRes
+ {
+ }
+ #endregion
+
+ #region 鍒犻櫎闂ㄩ攣涓存椂瀵嗙爜
+ /// <summary>
+ /// 鍒犻櫎闂ㄩ攣
+ /// </summary>
+ public class DelDoorLockTempPasswordData
+ {
+ /// <summary>
+ /// RequestVersion
+ /// </summary>
+ public string RequestVersion = Shared.Common.CommonPage.RequestVersion;
+ /// <summary>
+ /// LoginAccessToken
+ /// </summary>
+ public string LoginAccessToken = Shared.Common.Config.Instance.Token;
+ /// <summary>
+ /// 浣忓畢Id -->閿悕 : HomeId
+ /// </summary>
+ public string HomeId = Shared.Common.Config.Instance.HomeId;
+ /// <summary>
+ /// LocalDoorLockId 鎼滅储鏈湴闂ㄩ攣Id -->閿悕 : LocalDoorLockId 榛樿鍊�: null
+ /// </summary>
+ public string LocalDoorLockId = "";
+ /// <summary>
+ /// IsOtherAccountCtrl 鏄惁涓哄瓙甯愬彿鎺у埗杩囨潵 -->閿悕 : IsOtherAccountCtrl
+ /// </summary>
+ public bool IsOtherAccountCtrl = false;
+ }
+
+ /// <summary>
+ /// 鍒犻櫎闂ㄩ攣缁撴灉
+ /// </summary>
+ public class DelDoorLockTempPasswordDataRes : AddDoorLockDataRes
+ {
+ }
+ #endregion
+
+ #region 鏇存柊闂ㄩ攣涓存椂瀵嗙爜
+ /// <summary>
+ /// 鏇存柊闂ㄩ攣
+ /// </summary>
+ public class ModifyDoorLockTempPasswordData
+ {
+ /// <summary>
+ /// RequestVersion
+ /// </summary>
+ public string RequestVersion = Shared.Common.CommonPage.RequestVersion;
+ /// <summary>
+ /// LoginAccessToken
+ /// </summary>
+ public string LoginAccessToken = Shared.Common.Config.Instance.Token;
+ /// <summary>
+ /// 浣忓畢Id -->閿悕 : HomeId
+ /// </summary>
+ public string HomeId = Shared.Common.Config.Instance.HomeId;
+ /// <summary>
+ /// 闂ㄩ攣瀵嗙爜涓婚敭(鑾峰彇闂ㄩ攣瀵嗙爜鍒嗛〉涓殑Id) -->閿悕 : DoorLockPwdId
+ /// </summary>
+ public string DoorLockPwdId = "";
+ /// <summary>
+ /// 闂ㄩ攣Id -->閿悕 : DoorLockId
+ /// </summary>
+ public string LocalDoorLockId = "";
+ /// <summary>
+ /// 涓存椂瀵嗙爜Id -->閿悕 : TempPwdId
+ /// </summary>
+ public string TempPwdId = "";
+ /// <summary>
+ /// 涓存椂瀵嗙爜 -->閿悕 : TempPwd
+ /// </summary>
+ public string TempPwd = "";
+ /// <summary>
+ /// 0:00:00] ValidBeginTime 鏈夋晥寮�濮嬫椂闂� -->閿悕 : ValidBeginTime 榛樿鍊�: 0001/1/1
+ /// </summary>
+ public DateTime ValidBeginTime;
+ /// <summary>
+ /// 0:00:00] ValidEndTime 鏈夋晥缁撴潫鏃堕棿 -->閿悕 : ValidEndTime
+ /// </summary>
+ public DateTime ValidEndTime;
+ /// <summary>
+ /// IsOtherAccountCtrl 鏄惁涓哄瓙甯愬彿鎺у埗杩囨潵 -->閿悕 : IsOtherAccountCtrl
+ /// </summary>
+ public bool IsOtherAccountCtrl = false;
+ }
+
+ /// <summary>
+ /// 娣诲姞闂ㄩ攣缁撴灉
+ /// </summary>
+ public class ModigDoorLockTempPasswordDataRes : AddDoorLockDataRes
+ {
+ }
+ #endregion
+
+ #region 鑾峰彇闂ㄩ攣涓存椂瀵嗙爜
+ /// <summary>
+ /// 鑾峰彇闂ㄩ攣
+ /// </summary>
+ public class GetDoorLockTempPasswordData
+ {
+ /// <summary>
+ /// RequestVersion
+ /// </summary>
+ public string RequestVersion = Shared.Common.CommonPage.RequestVersion;
+ /// <summary>
+ /// LoginAccessToken
+ /// </summary>
+ public string LoginAccessToken = Shared.Common.Config.Instance.Token;
+ /// <summary>
+ /// 浣忓畢Id -->閿悕 : HomeId
+ /// </summary>
+ public string HomeId = Shared.Common.Config.Instance.HomeId;
+ /// <summary>
+ /// 闂ㄩ攣Id -->閿悕 : DoorLockId
+ /// </summary>
+ public string LocalDoorLockId = "";
+ /// <summary>
+ /// 涓存椂瀵嗙爜Id -->閿悕 : TempPwdId
+ /// </summary>
+ public string TempPwdId = "";
+ /// <summary>
+ /// 涓存椂瀵嗙爜 -->閿悕 : TempPwd
+ /// </summary>
+ public string TempPwd = "";
+ /// <summary>
+ /// 0:00:00] ValidBeginTime 鏈夋晥寮�濮嬫椂闂� -->閿悕 : ValidBeginTime 榛樿鍊�: 0001/1/1
+ /// </summary>
+ public DateTime? ValidBeginTime;
+ /// <summary>
+ /// 0:00:00] ValidEndTime 鏈夋晥缁撴潫鏃堕棿 -->閿悕 : ValidEndTime
+ /// </summary>
+ public DateTime? ValidEndTime;
+ /// <summary>
+ /// IsOtherAccountCtrl 鏄惁涓哄瓙甯愬彿鎺у埗杩囨潵 -->閿悕 : IsOtherAccountCtrl
+ /// </summary>
+ public bool IsOtherAccountCtrl = false;
+ }
+
+ /// <summary>
+ /// 鑾峰彇闂ㄩ攣涓存椂瀵嗙爜缁撴灉
+ /// </summary>
+ [Serializable]
+ public class GetDoorLockTempPasswordDataRes
+ {
+ public List<CloudDoorLockTempPasswordObj> PageData = new List<CloudDoorLockTempPasswordObj>();
+ public int PageIndex;
+ public int PageSize;
+ public int TotalCount;
+ public int TotalPages;
+ public bool HasPreviousPage;
+ public bool HasNextPage;
+ }
+ [Serializable]
+ public class CloudDoorLockTempPasswordObj
+ {
+ /// <summary>
+ /// 闂ㄩ攣Id -->閿悕 : DoorLockId
+ /// </summary>
+ public string LocalDoorLockId = "";
+ /// <summary>
+ /// 涓存椂瀵嗙爜Id -->閿悕 : TempPwdId
+ /// </summary>
+ public string TempPwdId = "";
+ /// <summary>
+ /// 涓存椂瀵嗙爜 -->閿悕 : TempPwd
+ /// </summary>
+ public string TempPwd = "";
+ /// <summary>
+ /// 0:00:00] ValidBeginTime 鏈夋晥寮�濮嬫椂闂� -->閿悕 : ValidBeginTime 榛樿鍊�: 0001/1/1
+ /// </summary>
+ public DateTime ValidBeginTime;
+ /// <summary>
+ /// 0:00:00] ValidEndTime 鏈夋晥缁撴潫鏃堕棿 -->閿悕 : ValidEndTime
+ /// </summary>
+ public DateTime ValidEndTime;
+ /// <summary>
+ /// 銆愰棬閿佷簯绔富閿��,鐢ㄤ簬銆愭坊鍔犻棬閿佸巻鍙层�戞帴鍙d腑鐨凞oorLockId鍙傛暟鍙娿�愬垹闄ら棬閿併�戞帴鍙d腑鐨凱rimaryId鍙傛暟,娉ㄦ剰涓嶆槸缃戝叧涓殑銆愰棬閿両d
+ /// </summary>
+ public string Id;
+ /// <summary>
+ /// 鍒涘缓鏃堕棿
+ /// </summary>
+ public DateTime CreatedOnUtc;
+ }
+
+ /// <summary>
+ /// 浠庝簯鏈嶅姟鍣ㄤ腑鑾峰彇闂ㄩ攣涓存椂瀵嗙爜
+ /// </summary>
+ public static async System.Threading.Tasks.Task<GetDoorLockTempPasswordDataRes> GetDoorLockTempPasswordFromServer(string RequestName, GetDoorLockTempPasswordData getDoorLockTempPasswordData)
+ {
+ return await System.Threading.Tasks.Task.Run((Func<System.Threading.Tasks.Task<GetDoorLockTempPasswordDataRes>>)(async () =>
+ {
+ GetDoorLockTempPasswordDataRes listInfo = null;
+ var revertObj = await SendDoorLockToServer(RequestName, getDoorLockTempPasswordData);
+ if (revertObj != null && revertObj.ResponseData != null)
+ {
+ var result = revertObj.ResponseData.ToString();
+ if (result != null)
+ {
+ listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDoorLockTempPasswordDataRes>(result);
+ }
+ }
+ return listInfo;
+ }));
+ }
+ #endregion
+
+ #region 鑾峰彇闂ㄩ攣
+ /// <summary>
+ /// 鑾峰彇闂ㄩ攣
+ /// </summary>
+ public class GetDoorLockData : BaseDoorLockServerData
+ {
+ /// <summary>
+ /// 浜戠甯愬彿Id -->閿悕 : CloudAccountId (鍙��)
+ /// </summary>
+ public string CloudAccountId = "";
+ /// <summary>
+ /// 绗嚑椤�
+ /// </summary>
+ public PageSetting pageSetting = new PageSetting();
+ }
+
+ /// <summary>
+ /// 鑾峰彇闂ㄩ攣
+ /// </summary>
+ public class PageSetting
+ {
+ /// <summary>
+ /// 绗嚑椤�
+ /// </summary>
+ public int Page = 1;
+ /// <summary>
+ /// 绗嚑椤�
+ /// </summary>
+ public int PageSize = 10;
+ }
+
+ [Serializable]
+ public class GetDoorLockDataRes
+ {
+ public List<CloudDoorLockObj> PageData = new List<CloudDoorLockObj>();
+ public int PageIndex;
+ public int PageSize;
+ public int TotalCount;
+ public int TotalPages;
+ public bool HasPreviousPage;
+ public bool HasNextPage;
+ }
+ [Serializable]
+ public class CloudDoorLockObj
+ {
+ /// <summary>
+ /// 闂ㄩ攣Id
+ /// </summary>
+ public string DoorLockId;
+ /// <summary>
+ /// 浜戠甯愬彿Id
+ /// </summary>
+ public string CloudAccountId;
+ /// <summary>
+ /// OpenLockMode 寮�閿佹柟寮�(瀵嗙爜銆佹寚绾广�両C鍗�)
+ /// </summary>
+ public int OpenLockMode;
+ /// <summary>
+ /// 闂ㄩ攣鏈湴鐢ㄦ埛Id
+ /// </summary>
+ public string DoorLockLocalUserId;
+ /// <summary>
+ /// 浣忓畢Id
+ /// </summary>
+ public byte[] Data;
+ /// <summary>
+ /// 鐢ㄦ埛Id澶囨敞
+ /// </summary>
+ public string UserIdRemarks;
+ /// <summary>
+ /// 鏄惁涓虹鐞嗗憳闂ㄩ攣
+ /// </summary>
+ public bool IsAdminDoorLock;
+ /// <summary>
+ /// 鏄惁涓虹鐞嗗憳闂ㄩ攣
+ /// </summary>
+ public bool IsFreezeUser;
+ /// <summary>
+ /// 鏄惁涓虹鐞嗗憳闂ㄩ攣
+ /// </summary>
+ public bool IsTempUnlockAuthority;
+ /// <summary>
+ /// 褰曞叆鏃堕棿
+ /// </summary>
public DateTime EntryTime;
+ /// <summary>
+ /// 鏈�鍚庢洿鏂版椂闂�
+ /// </summary>
+ public string LastChangeTime;
+ /// <summary>
+ /// 銆愰棬閿佷簯绔富閿��,鐢ㄤ簬銆愭坊鍔犻棬閿佸巻鍙层�戞帴鍙d腑鐨凞oorLockId鍙傛暟鍙娿�愬垹闄ら棬閿併�戞帴鍙d腑鐨凱rimaryId鍙傛暟,娉ㄦ剰涓嶆槸缃戝叧涓殑銆愰棬閿両d
+ /// </summary>
+ public string Id;
+ /// <summary>
+ /// 鍒涘缓鏃堕棿
+ /// </summary>
+ public DateTime CreatedOnUtc;
+ }
+
+ /// <summary>
+ /// 鑾峰彇闂ㄩ攣浜戞湇鍔″櫒
+ /// </summary>
+ public static async System.Threading.Tasks.Task<GetDoorLockDataRes> GetDoorLockInfoFromServer(string RequestName, GetDoorLockData getDoorLockData)
+ {
+ return await System.Threading.Tasks.Task.Run((Func<System.Threading.Tasks.Task<GetDoorLockDataRes>>)(async () =>
+ {
+ GetDoorLockDataRes listInfo = null;
+ var revertObj = await SendDoorLockToServer(RequestName, getDoorLockData);
+ if (revertObj != null && revertObj.ResponseData != null)
+ {
+ var result = revertObj.ResponseData.ToString();
+ if (result != null)
+ {
+ listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDoorLockDataRes>(result);
+ }
+ }
+ return listInfo;
+ }));
+ }
+ #endregion
+
+ /// <summary>
+ /// 鍙戦�侀棬閿佹暟鎹埌鏈嶅姟鍣紝鍙洖澶嶇姸鎬侊紝娌℃湁鏁版嵁澶勭悊
+ /// </summary>
+ /// <returns>鑾峰彇浠庢帴鍙i偅閲屽彇鍒扮殑ResponsePack</returns>
+ /// <param name="RequestName">璁块棶鍦板潃</param>
+ /// <param name="obj">涓�涓被</param>
+ public static async Task<ResponsePack> SendDoorLockToServer(string RequestName, object obj)
+ {
+ try
+ {
+ //搴忓垪鍖栧璞�
+ var requestJson = JsonConvert.SerializeObject(obj);
+ var byteData = System.Text.Encoding.UTF8.GetBytes(requestJson);
+ byte[] result1 = null;
+ //璁块棶鎺ュ彛
+ if (UserCenterResourse.UserInfo.AuthorityNo == 1)
+ {
+ result1 = CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync(RequestName, byteData);
+ }
+ else
+ {
+ result1 = CommonPage.Instance.RequestZigbeeHttpsByAdmin(RequestName, byteData);
+ }
+ if (result1 != null)
+ {
+ var result2 = Encoding.UTF8.GetString(result1);
+ if (result2 != null)
+ {
+ var result = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.ResponsePack>(result2);
+ return result;
+ }
+ }
+ return null;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ return null;
+ }
}
/// <summary>
/// 鑾峰彇瀛愯处鎴蜂俊鎭�
- /// </summary>
+ /// </summary>
static List<Shared.Phone.UserCenter.MemberInfoRes> DoorLockAccountList = new List<Shared.Phone.UserCenter.MemberInfoRes> { };
public static async System.Threading.Tasks.Task<List<Shared.Phone.UserCenter.MemberInfoRes>> GetSubAccountByDistributedMark()
{
@@ -78,7 +662,11 @@
return await System.Threading.Tasks.Task.Run((Func<System.Threading.Tasks.Task<List<Shared.Phone.UserCenter.MemberInfoRes>>>)(async () =>
{
var pra = new Shared.Phone.UserCenter.MemberListInfoPra();
- string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", true, pra);
+ string result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
+ if (result == null)
+ {
+ return null;
+ }
var listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Shared.Phone.UserCenter.MemberInfoRes>>(result);
return listInfo;
}));
@@ -97,27 +685,12 @@
}
#endregion
- #region 闂ㄩ攣鏈湴鍙橀噺
- /// <summary>
- /// 闂ㄩ攣鏈湴鐢ㄦ埛鍒楄〃
- /// </summary>
- /// <returns></returns>
- public Dictionary<int, DoorLockProgrammingEventNotificationCommand> localDoorLockUserList = new Dictionary<int, DoorLockProgrammingEventNotificationCommand>();
- public string currentUserDisplayMethod = string.Empty;
-
- #endregion
-
- public async System.Threading.Tasks.Task GetDoorLockAllInfo()
- {
- FingerprintInfo fingerprint = await GetFingerprintAsync();
- var password = GetPasswordAsync();
- var proximity = GetProximityAsync();
- }
-
+ #region 涓庣綉鍏抽�氳鎺ュ彛
#region 闂ㄩ攣鎿嶄綔浜嬩欢閫氱煡
/// <summary>
/// 闂ㄩ攣鎿嶄綔浜嬩欢閫氱煡
/// </summary>
+ [Newtonsoft.Json.JsonIgnore]
public DoorLockOperatingEventNotificationCommand doorLockOperatingEventNotificationCommand;
/// <summary>
/// 闂ㄩ攣鎿嶄綔浜嬩欢閫氱煡
@@ -137,7 +710,7 @@
///涓嶅父鐢細
/// 1:RF(Zigbee鏃犵嚎)锛�2:Manual(鎵嬪姩)锛�255:Indeterminate(涓嶇‘瀹�)
/// </summary>
- public int OperationEventSource;
+ public int OperationEventSoure;
/// <summary>
/// 浜嬩欢鐮�
/// 甯哥敤锛�
@@ -361,13 +934,14 @@
/// Unlock鍛戒护锛歟rror,invalid schedule浜嬩欢
/// </summary>
UnlockInvalidScheduleEvent = 6,
- }
+ }
#endregion
-
+
#region 闂ㄩ攣缂栫▼浜嬩欢閫氱煡
/// <summary>
/// 闂ㄩ攣缂栫▼浜嬩欢閫氱煡
/// </summary>
+ [Newtonsoft.Json.JsonIgnore]
public DoorLockProgrammingEventNotificationCommand doorLockProgrammingEventNotificationCommand;
/// <summary>
/// 闂ㄩ攣缂栫▼浜嬩欢閫氱煡
@@ -388,7 +962,7 @@
/// 淇濈暀
/// </summary>
public int UserStatus;
- /// <summary>
+ /// <summary>
/// 缂栫▼浜嬩欢瑙﹀彂婧�
/// 甯哥敤锛�
/// 0:Keypad(閿洏/瀵嗙爜)锛�3:RFID(灏勯鍗�)锛�15:鎸囩汗
@@ -401,7 +975,7 @@
/// 甯哥敤锛�
/// 閿洏/瀵嗙爜锛屾寚绾广�佹劅搴斿崱锛�1:Lock鍛戒护鎴愬姛浜嬩欢锛�2:Unlock鍛戒护鎴愬姛浜嬩欢
///涓嶅父鐢細
- /// 璇锋煡鐪嬫灇涓�
+ /// 璇锋煡鐪嬫灇涓�
/// </summary>
public int ProgramEventCode;
/// <summary>
@@ -415,16 +989,13 @@
}
#endregion
- /*
- #region 鑾峰彇闂ㄩ攣鏈湴log璁板綍
- ///<summary >
- ///鑾峰彇闂ㄩ攣鏈湴log璁板綍
- ///<para>鑻ュ懡浠や腑鐨凱IN/RFID Code涓庨棬閿佷腑鐨凱IN/RFID Code鐩稿尮閰嶏紝鍒欏皢闂ㄩ攣涓婇攣</para>
- ///<para>command :闂ㄩ攣璁惧璁板綍鐨勭储寮曞彿锛涘彇鍊艰寖鍥达細</para>
- ///<para>1~鈥淣umber of Log Records Supported attribute鈥濓紱</para>
- ///<para>鍊间负0琛ㄧず鑾峰彇璁惧鏈�杩戠殑璁板綍鏁版嵁銆�</para>
- ///</summary>
- public async System.Threading.Tasks.Task<LogRecordResponAllData> LogRecordAsync(int logIndex)
+ #region 鐭闂ㄩ攣鏃堕棿
+ /// <summary>
+ /// 鐭闂ㄩ攣鏃堕棿
+ /// </summary>
+ /// <param name="timestamp"></param>
+ /// <returns></returns>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> RectifyDoorLockTimeAsync(int timestamp)
{
if (Gateway == null)
{
@@ -432,7 +1003,7 @@
}
return await System.Threading.Tasks.Task.Run(async () =>
{
- LogRecordResponAllData dataRes = null;
+ SetWritableValueResponAllData d = null;
Action<string, string> action = (topic, message) =>
{
var gatewayID = topic.Split('/')[0];
@@ -440,542 +1011,81 @@
if (topic == gatewayID + "/" + "Error_Respon")
{
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
if (temp == null)
{
- dataRes = new LogRecordResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
}
else
{
- dataRes = new LogRecordResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
}
}
- if (topic == gatewayID + "/" + "DoorLock/DoorLockGetLogRecordResponseCommand")
+ if (topic == gatewayID + "/" + "SetWritableValue_Respon")
{
- var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<LogRecordResData>(jobject["Data"].ToString());
+ var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString());
if (tempData == null)
{
- dataRes = new LogRecordResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
}
else
{
- dataRes = new LogRecordResponAllData { logRecordResData = tempData };
+ d = new SetWritableValueResponAllData { setWritableValueResponData = tempData };
DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
}
}
};
Gateway.Actions += action;
- DebugPrintLog("DoorLock/DoorLockGetLogRecordResponseCommand_Actions 鍚姩" + System.DateTime.Now.ToString());
+ DebugPrintLog("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
try
{
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 257 }, { "Command", 4 }, { "SendMode", 2 } };
- var data = new JObject { { "LogIndex", logIndex } };
- jObject.Add("Data", data);
- Gateway.Send("DoorLock/test", jObject.ToString());
- }
- catch { }
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (dataRes != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- dataRes = new LogRecordResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- DebugPrintLog("DoorLock/DoorLockGetLogRecordResponseCommand_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return dataRes;
- });
- }
-
- ///<summary >
- ///鑾峰彇闂ㄩ攣鏈湴log璁板綍
- /// </summary>
- public class LogRecordResponAllData
- {
- /// <summary>
- /// 閿欒淇℃伅
- /// </summary>
- public string errorMessageBase;
- /// <summary>
- /// 缃戝叧淇℃伅閿欒鍙嶉
- /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- /// </summary>
- public ErrorResponData errorResponData;
- /// <summary>
- /// 鑾峰彇闂ㄩ攣鏈湴log璁板綍
- /// </summary>
- public LogRecordResData logRecordResData;
- }
-
- ///<summary >
- ///鑾峰彇闂ㄩ攣鏈湴log璁板綍
- /// </summary>
- public class LogRecordResData
- {
- /// <summary>
- /// 浜嬩欢瑙﹀彂
- /// </summary>
- public int OperationEventSoure;
- /// <summary>
- /// 浜嬩欢
- /// </summary>
- public int OperationEventCode;
- /// <summary>
- /// 璁惧褰撳墠鏃堕棿鐨勬椂闂存埑
- /// </summary>
- public int ZigbeeLocalTime;
- }
- #endregion
- */
-
- /* 鑾峰彇缃戝叧闂ㄩ攣淇℃伅锛屾殏涓嶆敮鎸�
- #region 鑾峰彇鎵�鏈夐棬閿佹墍鏈夌敤鎴蜂俊鎭�
- ///<summary >
- ///鑾峰彇鎵�鏈夐棬閿佹墍鏈夌敤鎴蜂俊鎭�
- ///</summary>
- public async System.Threading.Tasks.Task<AlldoorlockUserInfoResponAllData> GetAlldoorlockUserInfoRspAsync()
- {
- if (Gateway == null)
- {
- return null;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- AlldoorlockUserInfoResponAllData dataRes = null;
- Action<string, string> action = (topic, message) =>
- {
- var gatewayID = topic.Split('/')[0];
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- dataRes = new AlldoorlockUserInfoResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
- else
- {
- dataRes = new AlldoorlockUserInfoResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- if (topic == gatewayID + "/" + "Doorlock/GetAlldoorlockUserInfoRsp")
- {
- var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<AlldoorlockUserInfoResData>(jobject["Data"].ToString());
-
- if (tempData == null)
- {
- dataRes = new AlldoorlockUserInfoResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- dataRes = new AlldoorlockUserInfoResponAllData { alldoorlockUserInfoResData = tempData };
- DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- }
- }
- };
- Gateway.Actions += action;
- DebugPrintLog("闂ㄩ攣Doorlock/GetAlldoorlockUserInfoRsp_Actions 鍚姩" + System.DateTime.Now.ToString());
-
- try
- {
- var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 6100 } };
- Gateway.Send("DoorLock/test", jObject.ToString());
- }
- catch { }
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (dataRes != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- dataRes = new AlldoorlockUserInfoResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- DebugPrintLog("闂ㄩ攣Doorlock/GetAlldoorlockUserInfoRsp_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return dataRes;
- });
- }
-
- ///<summary >
- ///鑾峰彇鎵�鏈夐棬閿佹墍鏈夌敤鎴蜂俊鎭�
- /// </summary>
- public class AlldoorlockUserInfoResponAllData
- {
- /// <summary>
- /// 閿欒淇℃伅
- /// </summary>
- public string errorMessageBase;
- /// <summary>
- /// 缃戝叧淇℃伅閿欒鍙嶉
- /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- /// </summary>
- public ErrorResponData errorResponData;
- /// <summary>
- /// 鑾峰彇鎵�鏈夐棬閿佹墍鏈夌敤鎴蜂俊鎭�
- /// </summary>
- public AlldoorlockUserInfoResData alldoorlockUserInfoResData;
- }
-
- ///<summary >
- ///鑾峰彇鎵�鏈夐棬閿佹墍鏈夌敤鎴蜂俊鎭�
- /// </summary>
- public class AlldoorlockUserInfoResData
- {
- /// <summary>
- /// 浜嬩欢瑙﹀彂
- /// </summary>
- public int doorlockUserInfoRecordSum;
- /// <summary>
- /// 浜嬩欢
- /// </summary>
- public int OperationEventCode;
- /// <summary>
- /// 璁惧褰撳墠鏃堕棿鐨勬椂闂存埑
- /// </summary>
- public int ZigbeeLocalTime;
- }
- #endregion
-
- #region 鑾峰彇鍗曚釜闂ㄩ攣鍗曚釜鐢ㄦ埛淇℃伅
- ///<summary >
- ///鑾峰彇鍗曚釜闂ㄩ攣鍗曚釜鐢ㄦ埛淇℃伅
- ///<para>userId:闂ㄩ攣鏈湴鐢ㄦ埛Id</para>
- ///</summary>
- public async System.Threading.Tasks.Task<UserInfoByMACEPUserIdResponAllData> GetdoorlockUserInfoByMACEPUserIdAsync(int userId)
- {
- if (Gateway == null)
- {
- return null;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- UserInfoByMACEPUserIdResponAllData dataRes = null;
- Action<string, string> action = (topic, message) =>
- {
- var gatewayID = topic.Split('/')[0];
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- dataRes = new UserInfoByMACEPUserIdResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
- else
- {
- dataRes = new UserInfoByMACEPUserIdResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- if (topic == gatewayID + "/" + "Doorlock/GetdoorlockUserInfoByMACEPUserIdRsp")
- {
- var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfoByMACEPUserIdRspResData>(jobject["Data"].ToString());
-
- if (tempData == null)
- {
- dataRes = new UserInfoByMACEPUserIdResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- dataRes = new UserInfoByMACEPUserIdResponAllData { userInfoByMACEPUserIdRspResData = tempData };
- DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- }
- }
- };
- Gateway.Actions += action;
- DebugPrintLog("闂ㄩ攣Doorlock/GetdoorlockUserInfoByMACEPUserIdRsp 鍚姩" + System.DateTime.Now.ToString());
-
- try
- {
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 6102 } };
- var data = new JObject { { "UserId", userId } };
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 10 }, { "Command", 120 } };
+ var data = new JObject { { "Undivided", 0 }, { "AttributeId", 0 }, { "AttributeDataType", 226 }, { "AttributeData", timestamp } };
jObject.Add("Data", data);
- Gateway.Send("DoorLock/test", jObject.ToString());
+ Gateway.Send("SetWritableValue", jObject.ToString());
}
catch { }
+
var dateTime = DateTime.Now;
while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
{
await System.Threading.Tasks.Task.Delay(10);
- if (dataRes != null)
+ if (d != null)
{
break;
}
}
if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
{
- dataRes = new UserInfoByMACEPUserIdResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ d = new SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
}
Gateway.Actions -= action;
- DebugPrintLog("闂ㄩ攣Doorlock/GetdoorlockUserInfoByMACEPUserIdRsp 閫�鍑�" + System.DateTime.Now.ToString());
+ DebugPrintLog("SetWritableValue_Actions 閫�鍑�" + System.DateTime.Now.ToString());
- return dataRes;
+ return d;
});
}
+ #endregion
+ #endregion
+
+ #region 涓庤澶囬�氳鎺ュ彛锛堢鏈夊懡浠わ級
+
+ #region 鐢ㄦ埛绠$悊鎺у埗
///<summary >
- ///鑾峰彇鍗曚釜闂ㄩ攣鍗曚釜鐢ㄦ埛淇℃伅
- /// </summary>
- public class UserInfoByMACEPUserIdResponAllData
- {
- /// <summary>
- /// 閿欒淇℃伅
- /// </summary>
- public string errorMessageBase;
- /// <summary>
- /// 缃戝叧淇℃伅閿欒鍙嶉
- /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- /// </summary>
- public ErrorResponData errorResponData;
- /// <summary>
- /// 鑾峰彇鍗曚釜闂ㄩ攣鍗曚釜鐢ㄦ埛淇℃伅
- /// </summary>
- public UserInfoByMACEPUserIdRspResData userInfoByMACEPUserIdRspResData;
- }
-
- ///<summary >
- ///鑾峰彇鎵�鏈夐棬閿佹墍鏈夌敤鎴蜂俊鎭�
- /// </summary>
- public class UserInfoByMACEPUserIdRspResData
- {
- /// <summary>
- /// 浜嬩欢瑙﹀彂
- /// </summary>
- public int OperationEventSoure;
- /// <summary>
- /// 浜嬩欢
- /// </summary>
- public int OperationEventCode;
- /// <summary>
- /// 璁惧褰撳墠鏃堕棿鐨勬椂闂存埑
- /// </summary>
- public int ZigbeeLocalTime;
- }
- #endregion
- */
-
- #region 涓存椂瀵嗙爜淇℃伅
- /// <summary>
- /// 涓存椂瀵嗙爜鏈湴瀛樺偍瀵硅薄
- /// </summary>
- public TempPasswordObj tempPasswordObj = new TempPasswordObj();
- /// <summary>
- /// 涓存椂瀵嗙爜鏈湴瀵硅薄
- /// </summary>
- [System.Serializable]
- public class TempPasswordObj
- {
- /// <summary>
- /// 闂ㄩ攣鏈夋晥鏃堕棿
- /// </summary>
- public int validTime;
- /// <summary>
- /// 闂ㄩ攣鏃堕棿
- /// </summary>
- public int times;
- }
- #endregion
-
- #region 鎸囩汗淇℃伅
- public async System.Threading.Tasks.Task<FingerprintInfo> GetFingerprintAsync()
- {
- FingerprintInfo result = null;
- return result;
- }
-
- /// <summary>
- /// 鐢ㄦ埛鎸囩汗鍒楄〃
- /// </summary>
- public List<FingerprintInfo> fingerprintList = new List<FingerprintInfo>();
-
- /// <summary>
- /// 鐢ㄦ埛鎸囩汗鍒楄〃淇℃伅
- /// </summary>
- [System.Serializable]
- public class FingerprintInfo
- {
- /// <summary>
- /// 鎸囩汗澶囨敞
- /// </summary>
- public string fingerprintRemark = string.Empty;
- /// <summary>
- /// 鎸囩汗鍥剧墖
- /// </summary>
- public string fingerprintImage = string.Empty;
- /// <summary>
- /// 鎸囩汗ID
- /// </summary>
- public int userFingerprintID;
- /// <summary>
- /// 鎸囩汗鐩爣鍒楄〃
- /// </summary>
- public readonly List<string> sceneFingerprintTargetList = new List<string>();
- }
- #endregion
-
- #region 瀵嗙爜淇℃伅
- public PasswordInfo GetPasswordAsync()
- {
- return null;
- }
- /// <summary>
- /// 鐢ㄦ埛瀵嗙爜鍒楄〃
- /// </summary>
- public List<PasswordInfo> passwordList = new List<PasswordInfo>();
-
- /// <summary>
- /// 鐢ㄦ埛瀵嗙爜鍒楄〃淇℃伅
- /// </summary>
- [System.Serializable]
- public class PasswordInfo
- {
- /// <summary>
- /// 瀵嗙爜澶囨敞
- /// </summary>
- public string passwordRemark = string.Empty;
- /// <summary>
- /// 瀵嗙爜鍥剧墖
- /// </summary>
- public string passwordImage = string.Empty;
- /// <summary>
- /// 瀵嗙爜ID
- /// </summary>
- public int userPasswordID;
- /// <summary>
- /// 瀵嗙爜鐩爣鍒楄〃
- /// </summary>
- public readonly List<string> scenePasswordTargetList = new List<string>();
- }
- #endregion
-
- #region 鎰熷簲鍗′俊鎭�
- public ProximityInfo GetProximityAsync()
- {
- return null;
- }
- /// <summary>
- /// 鐢ㄦ埛鎰熷簲鍗″垪琛�
- /// </summary>
- public List<ProximityInfo> proximityList = new List<ProximityInfo>();
-
- /// <summary>
- /// 鐢ㄦ埛鎰熷簲鍗″垪琛ㄤ俊鎭�
- /// </summary>
- [System.Serializable]
- public class ProximityInfo
- {
- /// <summary>
- /// 鎰熷簲鍗″娉�
- /// </summary>
- public string proximityRemark = string.Empty;
- /// <summary>
- /// 鎰熷簲鍗″浘鐗�
- /// </summary>
- public string proximityImage = string.Empty;
- /// <summary>
- /// 鎰熷簲鍗D
- /// </summary>
- public int userProximityID;
- /// <summary>
- /// 鎰熷簲鍗$洰鏍囧垪琛�
- /// </summary>
- public readonly List<string> sceneProximityTargetList = new List<string>();
- }
- #endregion
-
- #region 鍘嗗彶璁板綍
- /// <summary>
- /// 鍘嗗彶璁板綍鍒楄〃
- /// </summary>
- public List<HistoryRecord> historyRecordList = new List<HistoryRecord> { };
- /// <summary>
- /// 闂ㄩ攣鐘舵�佸拰鎶ヨ淇℃伅
- /// </summary>
- [System.Serializable]
- public class HistoryRecord
- {
- /// <summary>
- /// 闂ㄩ攣寮�閿佺被鍨嬪搴�1 2 3 6
- /// </summary>
- public byte type;
-
- /// <summary>
- /// 闂ㄩ攣寮�閿佺敤鎴稩D
- /// </summary>
- public int userID;
-
- /// <summary>
- /// 骞�
- /// </summary>
- public string year;
-
- /// <summary>
- /// 鏈�
- /// </summary>
- public string month;
-
- /// <summary>
- /// 鏃�
- /// </summary>
- public string day;
-
- /// <summary>
- /// 鏃�
- /// </summary>
- public string hour;
-
- /// <summary>
- /// 鍒�
- /// </summary>
- public string minute;
-
- /// <summary>
- /// 绉�
- /// </summary>
- public string second;
- }
- #endregion
-
- #region 绉佹湁鍛戒护
- #region 鍥炲榛樿鍝嶅簲鐨勬帶鍒�
- ///<summary >
- ///榛樿鍝嶅簲鎺у埗
+ ///鐢ㄦ埛绠$悊鎺у埗
/// <para>passData:閫忎紶鏁版嵁</para>
/// </summary>
- public async System.Threading.Tasks.Task<ResponseAllData> DefaultControlAsync(string passData)
+ public async System.Threading.Tasks.Task<DefaultControlResponseAllData> DefaultControlAsync(string passData)
{
- ResponseAllData result = null;
+ DefaultControlResponseAllData result = null;
if (Gateway == null)
{
- result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ result = new DefaultControlResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
return result;
}
return await System.Threading.Tasks.Task.Run(async () =>
@@ -987,43 +1097,44 @@
if (topic == gatewayID + "/" + "Error_Respon")
{
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
if (temp == null)
{
- result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ result = new DefaultControlResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
}
else
{
- result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ result = new DefaultControlResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
}
}
if (topic == gatewayID + "/" + "ZbDataPassthrough")
{
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
- if (gatewayTemp.clientDataPassthroughResponseData == null)
+ if (clientDataPassthroughResponseData == null)
{
- result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ result = new DefaultControlResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
}
else
{
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+ if (clientDataPassthroughResponseData?.PassData != null)
{
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+ var data = clientDataPassthroughResponseData.PassData;
if (data.Length == 16)
{
var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
if (command == "0002")
{
- var tempD = new ResponseData();
- tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
+ var tempD = new DefaultControlResponseData();
+ tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
- result = new ResponseAllData { responseData = tempD };
- DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0402_{ topic}");
+ if (tempD.command == "0450")
+ {
+ result = new DefaultControlResponseAllData { defaultControlResponseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0450_{ topic}");
+ }
}
}
}
@@ -1052,9 +1163,9 @@
break;
}
}
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)
{
- result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ result = new DefaultControlResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
}
Gateway.Actions -= action;
DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
@@ -1062,9 +1173,110 @@
return result;
});
}
- #endregion
- #region 鐢ㄦ埛绠$悊鍙戦�佹暟鎹�
+ /// <summary>
+ /// 鐢ㄦ埛绠$悊鍙戦�佹暟鎹�
+ /// userIdList:涓暟涓嶈兘瓒呰繃10涓�
+ /// </summary>
+ public string FreezeAccountData(List<int> userIdList, AccessType accessType)
+ {
+ string data = "";
+ string dataLength = "";
+ string dataComand1 = "50";
+ string dataComand2 = "04";
+ string dataSerialNum = "01";
+ string addDataLength = "";
+ string delUserTypeStr = "";
+ string userIdStr = "";
+ try
+ {
+ if (userIdList.Count == 0)
+ {
+ return null;
+ }
+ if (userIdList.Count > 9)
+ {
+ return null;
+ }
+ var tempLength = 5 + userIdList.Count * 2;
+ string tempLength1 = Convert.ToString(tempLength, 16);
+ switch (tempLength1.Length)
+ {
+ case 1:
+ dataLength = "0" + tempLength1.ToUpper();
+ break;
+ case 2:
+ dataLength = tempLength1.ToUpper();
+ break;
+ }
+
+ var tempAddDataLength = 1 + userIdList.Count * 2;
+ string tempAddDataLength1 = Convert.ToString(tempAddDataLength, 16);
+ switch (tempAddDataLength1.Length)
+ {
+ case 1:
+ addDataLength = "0" + tempAddDataLength1.ToUpper();
+ break;
+ case 2:
+ addDataLength = tempAddDataLength1.ToUpper();
+ break;
+ }
+
+ switch ((int)accessType)
+ {
+ case 0:
+ delUserTypeStr = "00";
+ break;
+ case 1:
+ delUserTypeStr = "01";
+ break;
+ case 2:
+ delUserTypeStr = "20";
+ break;
+ case 3:
+ delUserTypeStr = "21";
+ break;
+ case 4:
+ delUserTypeStr = "10";
+ break;
+ case 5:
+ delUserTypeStr = "30";
+ break;
+ case 6:
+ delUserTypeStr = "31";
+ break;
+ }
+
+ var sbString = new System.Text.StringBuilder();
+ foreach (var userId in userIdList)
+ {
+ string temp = Convert.ToString(userId, 16);
+ switch (temp.Length)
+ {
+ case 1:
+ userIdStr = "0" + temp + "00";
+ break;
+ case 2:
+ userIdStr = temp + "00";
+ break;
+ case 3:
+ var thirdBit = temp.Substring(temp.Length - 2, 1);
+ userIdStr = temp + "0" + thirdBit;
+ break;
+ case 4:
+ userIdStr = temp;
+ break;
+ }
+ sbString.Append(userIdStr.ToString().ToUpper());
+ }
+ data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+ delUserTypeStr + sbString;
+ }
+ catch { };
+
+ return data;
+ }
+
/// <summary>
/// 鐢ㄦ埛绠$悊鍙戦�佹暟鎹�
/// </summary>
@@ -1122,16 +1334,357 @@
return data;
}
+
+ /// <summary>
+ /// 鐢ㄦ埛绠$悊鍙戦�佹暟鎹洖澶�
+ /// </summary>
+ [System.Serializable]
+ public class DefaultControlResponseAllData
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 鐢ㄦ埛绠$悊鏁版嵁鍥炲
+ /// </summary>
+ public DefaultControlResponseData defaultControlResponseData;
+ }
+
+ /// <summary>
+ /// 鐢ㄦ埛绠$悊鏁版嵁鍥炲
+ /// </summary>
+ [System.Serializable]
+ public class DefaultControlResponseData
+ {
+ /// <summary>
+ ///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛�
+ /// </summary>
+ public string command = "";
+ /// <summary>
+ /// 鐘舵�佸��
+ /// <para>榛樿鍝嶅簲缁撴灉锛�
+ ///<para>0 鎴愬姛</para>
+ ///<para>1 澶辫触</para>
+ ///<para>2 鐢ㄦ埛涓嶅瓨鍦�</para>
+ ///<para>32 鍐荤粨鎴愬姛</para>
+ ///<para>34 鍐荤粨澶辫触</para>
+ ///<para>33 瑙e喕鎴愬姛</para>
+ ///<para>35 瑙e喕澶辫触</para>
+ /// </summary>
+ public int status = -1;
+ }
+
+ public enum AccessType
+ {
+ /// <summary>
+ /// 0x00 鍒犻櫎鍏ㄩ儴涓存椂鐢ㄦ埛
+ /// </summary>
+ DelAllUsers = 0,
+ /// <summary>
+ /// 0x01 鍒犻櫎鎸囧畾鐢ㄦ埛(鎸夌紪鍙�)
+ /// </summary>
+ DelCurrentUser = 1,
+ /// <summary>
+ /// 0x20 鍐荤粨鎸囧畾鐢ㄦ埛
+ /// </summary>
+ DisEnable = 2,
+ /// <summary>
+ /// 0x21 瑙e喕鎸囧畾鐢ㄦ埛
+ /// </summary>
+ Enable = 3,
+ /// <summary>
+ /// 0x10 澶氫釜鎸囧畾鐢ㄦ埛鍒犻櫎
+ /// </summary>
+ DelMoreUsers = 4,
+ /// <summary>
+ /// 0x30 澶氫釜鎸囧畾鐢ㄦ埛鍐荤粨
+ /// </summary>
+ DisEnableMoreUsers = 5,
+ /// <summary>
+ /// 0x31 澶氫釜鎸囧畾鐢ㄦ埛瑙e喕
+ /// </summary>
+ EnableMoreUsers = 6,
+ }
#endregion
- #region 杩滅▼鍙戦�佹暟鎹�
+ #region 楠岃瘉闂ㄩ攣瀵嗙爜
+ ///<summary >
+ ///楠岃瘉闂ㄩ攣瀵嗙爜
+ ///<para>inputPassword:杈撳叆鐨勯棬閿佸瘑鐮�</para>
+ /// </summary>
+ public async System.Threading.Tasks.Task<VerifyPasswordResponseAllData> VerifyPasswordAsync(string inputPassword)
+ {
+ VerifyPasswordResponseAllData result = null;
+ if (Gateway == null)
+ {
+ result = new VerifyPasswordResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ return result;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+ if (temp == null)
+ {
+ result = new VerifyPasswordResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+
+ else
+ {
+ result = new VerifyPasswordResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+ if (topic == gatewayID + "/" + "ZbDataPassthrough")
+ {
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+ if (clientDataPassthroughResponseData == null)
+ {
+ result = new VerifyPasswordResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
+ {
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 12)
+ {
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0454")
+ {
+ var result1 = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
+ result = new VerifyPasswordResponseAllData { result = result1 };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0454_{ topic}");
+ }
+ }
+ }
+ }
+ }
+ };
+
+ Gateway.Actions += action;
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var getPw = await GetkeyPassword();
+ var passData = VerifyPasswordData(inputPassword, getPw);
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+ var data = new JObject { { "PassData", passData } };
+ jObject.Add("Data", data);
+ Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null && result.result == 0)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+ {
+ result = new VerifyPasswordResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return result;
+ });
+ }
+ /// <summary>
+ /// 楠岃瘉闂ㄩ攣瀵嗙爜
+ /// </summary>
+ public string VerifyPasswordData(string keyPassword, int password, int fixedPassword = 0x190605)
+ {
+ string data = "";
+ string dataLength = "08";
+ string dataComand1 = "53";
+ string dataComand2 = "04";
+ string dataSerialNum = "01";
+ string addDataLength = "04";
+ string passwordStr = "";
+ try
+ {
+ int keyPasswordInt = System.Convert.ToInt32(keyPassword, 16);
+ var pawStr = System.Convert.ToString((keyPasswordInt ^ password) + fixedPassword, 16);
+ pawStr = pawStr.PadLeft(8, '0');
+ for (int i = 6; i >= 0; i = i - 2)
+ {
+ passwordStr += pawStr.Substring(i, 2);
+ }
+ data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+ passwordStr;
+ }
+ catch { };
+ return data;
+ }
+
+ /// <summary>
+ /// 鐢ㄦ埛绠$悊鍙戦�佹暟鎹洖澶�
+ /// </summary>
+ [System.Serializable]
+ public class VerifyPasswordResponseAllData
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 鐢ㄦ埛绠$悊鏁版嵁鍥炲
+ /// <para>0:鎴愬姛</para>
+ ///<para>1:澶辫触</para>
+ /// </summary>
+ public int result = -1;
+ }
+ #endregion
+
+ #region 杩滅▼寮�閿�
+ ///<summary >
+ ///杩滅▼寮�閿�
+ ///<para>inputPassword: 杈撳叆瀵嗙爜/para>
+ /// </summary>
+ public async System.Threading.Tasks.Task<RemoteResponseAllData> RemoteControlAsync(string inputPassword)
+ {
+ RemoteResponseAllData result = null;
+ if (Gateway == null)
+ {
+ result = new RemoteResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ return result;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+ if (temp == null)
+ {
+ result = new RemoteResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+
+ else
+ {
+ result = new RemoteResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+ else if (topic == $"{gatewayID}/DoorLock/DoorLockOperatingEventNotificationCommand")
+ {
+ var OperatingEventNotificationDatad = Newtonsoft.Json.JsonConvert.DeserializeObject<ZigBee.Device.DoorLock.DoorLockOperatingEventNotificationCommand>(jobject["Data"].ToString());
+ if (OperatingEventNotificationDatad != null)
+ {
+ if (OperatingEventNotificationDatad.OperationEventSoure == 1 && OperatingEventNotificationDatad.OperationEventCode == 5)
+ {
+ result = new RemoteResponseAllData { IsPawDispear = true };
+ }
+ }
+ }
+ else if (topic == gatewayID + "/" + "ZbDataPassthrough")
+ {
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+ if (clientDataPassthroughResponseData == null)
+ {
+ result = new RemoteResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
+ {
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 16)
+ {
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0002")
+ {
+ var tempD = new RemoteResponseData();
+ tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
+ tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
+ if (tempD.command == "0462")
+ {
+ result = new RemoteResponseAllData { responseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0462_{ topic}");
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+ Gateway.Actions += action;
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var getPw = await GetkeyPassword();
+ var passData = RemoteData(inputPassword, getPw);
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+ var data = new JObject { { "PassData", passData } };
+ jObject.Add("Data", data);
+ Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 5000)// WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result == null)
+ {
+ continue;
+ }
+ if (result.responseData != null && result.responseData.command == "0462")
+ {
+ break;
+ }
+ if (result.IsPawDispear == true)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+ {
+ result = new RemoteResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return result;
+ });
+ }
/// <summary>
/// 杩滅▼鍙戦�佹暟鎹�
/// </summary>
- public string RemoteData(string keyPassword, string password, string fixedPassword = "190605")
+ string RemoteData(string keyPassword, int password, int fixedPassword = 0x190605)
{
string data = "";
- string dataLength = "09";
+ string dataLength = "08";
string dataComand1 = "62";
string dataComand2 = "04";
string dataSerialNum = "01";
@@ -1140,13 +1693,11 @@
try
{
int keyPasswordInt = System.Convert.ToInt32(keyPassword, 16);
- int passwordInt = System.Convert.ToInt32(password, 16);
- var fixedPasswordInt = System.Convert.ToInt32(fixedPassword, 16);
- var pawStr = System.Convert.ToString((keyPasswordInt ^ passwordInt) + fixedPasswordInt, 16);
+ var pawStr = System.Convert.ToString((keyPasswordInt ^ password) + fixedPassword, 16);
pawStr = pawStr.PadLeft(8, '0');
for (int i = 6; i >= 0; i = i - 2)
{
- passwordStr += passwordStr.Substring(i, 2);
+ passwordStr += pawStr.Substring(i, 2);
}
data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
passwordStr;
@@ -1155,16 +1706,160 @@
return data;
}
+
+ /// <summary>
+ /// 杩滅▼鍥炲鏁版嵁
+ /// </summary>
+ [System.Serializable]
+ public class RemoteResponseAllData
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 涓存椂瀵嗙爜鍥炲鏁版嵁
+ /// </summary>
+ public RemoteResponseData responseData;
+ /// <summary>
+ /// 鏄惁瀵嗙爜琚垹闄�
+ /// </summary>
+ public bool IsPawDispear = false;
+ }
+
+ /// <summary>
+ /// 鐢ㄦ埛绠$悊鏁版嵁鍥炲
+ /// </summary>
+ [System.Serializable]
+ public class RemoteResponseData
+ {
+ /// <summary>
+ ///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛�
+ /// </summary>
+ public string command = "";
+ /// <summary>
+ /// 鐘舵�佸��
+ /// <para>榛樿鍝嶅簲缁撴灉锛�
+ ///<para>0 鎴愬姛</para>
+ ///<para>1 澶辫触</para>
+ /// </summary>
+ public int status = -1;
+ }
#endregion
#region 涓存椂瀵嗙爜鍙戦�佹暟鎹�
+ ///<summary >
+ ///涓存椂瀵嗙爜
+ ///<para>inputPassword: 杈撳叆瀵嗙爜/para>
+ /// </summary>
+ public async System.Threading.Tasks.Task<TempPasswordResponseAllData> TempPasswordAsync(string inputPassword, System.DateTime startTime, System.DateTime endTime, string fixedPassword = "190605")
+ {
+ TempPasswordResponseAllData result = null;
+ if (Gateway == null)
+ {
+ result = new TempPasswordResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ return result;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+ if (temp == null)
+ {
+ result = new TempPasswordResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+
+ else
+ {
+ result = new TempPasswordResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+ if (topic == gatewayID + "/" + "ZbDataPassthrough")
+ {
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+ if (clientDataPassthroughResponseData == null)
+ {
+ result = new TempPasswordResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
+ {
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 16)
+ {
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0002")
+ {
+ var tempD = new TempPasswordResponseData();
+ tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
+ tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
+ if (tempD.command == "0463")
+ {
+ result = new TempPasswordResponseAllData { responseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0463_{ topic}");
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ Gateway.Actions += action;
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var getPw = await GetkeyPassword();
+ var passData = TempPasswordData(inputPassword, getPw, startTime, endTime);
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+ var data = new JObject { { "PassData", passData } };
+ jObject.Add("Data", data);
+ Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null && result.responseData != null && result.responseData.command == "0463")
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)
+ {
+ result = new TempPasswordResponseAllData
+ { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return result;
+ });
+ }
/// <summary>
/// 涓存椂瀵嗙爜鍙戦�佹暟鎹�
/// </summary>
- public string TempPasswordData(string keyPassword, string password, System.DateTime startTime, System.DateTime endTime, string fixedPassword = "190605")
+ public string TempPasswordData(string keyPassword, int password, System.DateTime startTime, System.DateTime endTime)
{
string data = "";
- string dataLength = "14";//鍗佽繘鍒舵槸19
+ string dataLength = "10";
string dataComand1 = "63";
string dataComand2 = "04";
string dataSerialNum = "01";
@@ -1175,27 +1870,73 @@
try
{
int keyPasswordInt = System.Convert.ToInt32(keyPassword, 16);
- int passwordInt = System.Convert.ToInt32(password, 16);
- var fixedPasswordInt = System.Convert.ToInt32(fixedPassword, 16);
- var pawStr = System.Convert.ToString((keyPasswordInt ^ passwordInt) + fixedPasswordInt, 16);
+ var pawStr = System.Convert.ToString((keyPasswordInt ^ password) + 0x190605, 16);
pawStr = pawStr.PadLeft(8, '0');
for (int i = 6; i >= 0; i = i - 2)
{
- passwordStr += passwordStr.Substring(i, 2);
+ passwordStr += pawStr.Substring(i, 2);
}
- var startTimeStr = System.Convert.ToString(GetUnixTimeStamp(startTime, false), 16);
- var endTimeStr = System.Convert.ToString(GetUnixTimeStamp(endTime, false), 16);
+
+ var startTimeStr = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetUnixTimeStamp(startTime);
+ var endTimeStr = Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetUnixTimeStamp(endTime);
+ startTimeStr = string.Format("{0:X}", System.Convert.ToInt64(startTimeStr));
+ endTimeStr = string.Format("{0:X}", System.Convert.ToInt64(endTimeStr));
for (int i = 6; i >= 0; i = i - 2)
{
vaildTimeStr += startTimeStr.Substring(i, 2);
invalidTimeStr += endTimeStr.Substring(i, 2);
}
- data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
- passwordStr + vaildTimeStr + vaildTimeStr;
- }
- catch { };
+ data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+ passwordStr + vaildTimeStr + invalidTimeStr;
+ }
+ catch (Exception ex)
+ {
+ var mess = ex.Message;
+ };
return data;
+ }
+
+ /// <summary>
+ /// 涓存椂瀵嗙爜鍥炲鏁版嵁
+ /// </summary>
+ [System.Serializable]
+ public class TempPasswordResponseAllData
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 涓存椂瀵嗙爜鍥炲鏁版嵁
+ /// </summary>
+ public TempPasswordResponseData responseData;
+ }
+
+ /// <summary>
+ /// 涓存椂瀵嗙爜鍥炲鏁版嵁
+ /// </summary>
+ [System.Serializable]
+ public class TempPasswordResponseData
+ {
+ /// <summary>
+ ///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛�
+ /// </summary>
+ public string command = "";
+ /// <summary>
+ /// 鐘舵�佸��
+ /// <para>0--娉ㄥ唽鎴愬姛</para>
+ /// <para>1--娉ㄥ唽澶辫触</para>
+ /// <para>2--鐢ㄦ埛宸插瓨鍦�(閲嶅瀵嗙爜)</para>
+ /// <para>3-- 鐢ㄦ埛宸叉弧(+宸叉弧绫诲瀷鍥炲)</para>
+ /// <para>4--鏈夋晥鏃堕棿閲嶅彔</para>
+ /// </summary>
+ public int status = -1;
}
#endregion
@@ -1205,20 +1946,28 @@
/// <para>鑾峰彇鍔犲瘑鐨勯殢鏈哄瘑閽ワ紝杩斿洖鐨勫瘑閽ョ粡杩囦竴涓畝鍗曠殑鍔犳硶鍔犲瘑鍔犱笂0x190605锛屽洜姝よ幏鍙栫殑瀵嗛挜闇�瑕佸噺涓�0x190605</para>
/// </summary>
/// <returns></returns>
- async System.Threading.Tasks.Task<string> GetkeyPassword()
+ async System.Threading.Tasks.Task<int> GetkeyPassword()
{
+ string passwordStr = "";
var result = await GetKeyPassworAsync();
+ //杩斿洖灏忕
if (result == null || result.keyPassword == null)
{
- return "";
+ return 0;
}
- return result.keyPassword;
+
+ for (int i = 6; i >= 0; i = i - 2)
+ {
+ passwordStr += result.keyPassword.Substring(i, 2);
+ }
+ var keyPasswordInt = System.Convert.ToInt32(passwordStr, 16);
+ return keyPasswordInt - 0x190605;
}
///<summary >
///鑾峰彇闂ㄩ攣瀵嗛挜
/// </summary>
- public async System.Threading.Tasks.Task<KeyPasswordInfo> GetKeyPassworAsync(int keyType = 0)
+ async System.Threading.Tasks.Task<KeyPasswordInfo> GetKeyPassworAsync(int keyType = 0)
{
KeyPasswordInfo result = null;
if (Gateway == null)
@@ -1235,8 +1984,7 @@
if (topic == gatewayID + "/" + "Error_Respon")
{
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
if (temp == null)
{
@@ -1251,19 +1999,18 @@
if (topic == gatewayID + "/" + "ZbDataPassthrough")
{
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
- if (gatewayTemp.clientDataPassthroughResponseData == null)
+ if (clientDataPassthroughResponseData == null)
{
result = new KeyPasswordInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
}
else
{
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+ if (clientDataPassthroughResponseData?.PassData != null)
{
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
- if (data.Length == 14)
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 20)
{
var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
@@ -1272,7 +2019,7 @@
var kType = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
var keyPassword = data[12].ToString() + data[13].ToString() + data[14].ToString() + data[15].ToString() + data[16].ToString() + data[17].ToString() + data[18].ToString() + data[19].ToString();
result = new KeyPasswordInfo { keyType = kType, keyPassword = keyPassword };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0406_{ topic}");
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0460_{ topic}");
}
}
}
@@ -1281,7 +2028,7 @@
};
Gateway.Actions += action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
try
{
@@ -1307,7 +2054,7 @@
result = new KeyPasswordInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
}
Gateway.Actions -= action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
return result;
});
@@ -1380,9 +2127,12 @@
///<summary >
///璇诲彇閿佷笂淇℃伅
/// </summary>
- public async System.Threading.Tasks.Task<DoorlockUserInfo> GetDoorlockUserInfoAsync(int keyType = 0)
+ public async System.Threading.Tasks.Task<DoorlockUserInfo> GetDoorlockUserInfoAsync()
{
DoorlockUserInfo result = null;
+ int totalNum = 0;
+ int currentNum = -1;
+ DoorLockUserDetailData doorLockUserDetailData = new DoorLockUserDetailData { };
if (Gateway == null)
{
result = new DoorlockUserInfo { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
@@ -1390,52 +2140,49 @@
}
return await System.Threading.Tasks.Task.Run(async () =>
{
+ var dateTime = DateTime.Now;
Action<string, string> action = (topic, message) =>
{
var gatewayID = topic.Split('/')[0];
var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- result = new DoorlockUserInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
-
- else
- {
- result = new DoorlockUserInfo { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
if (topic == gatewayID + "/" + "ZbDataPassthrough")
{
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
- if (gatewayTemp.clientDataPassthroughResponseData == null)
+ if (clientDataPassthroughResponseData != null)
{
- result = new DoorlockUserInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+ if (clientDataPassthroughResponseData.PassData != null)
{
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
- if (data.Length == 14)
+ var data = clientDataPassthroughResponseData.PassData;
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0452")
{
- var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
-
- if (command == "0452")
+ dateTime = DateTime.Now;
+ int returnAllLength = 2 + 2 * Convert.ToInt32(data[0].ToString() + data[1].ToString(), 16);
+ int usefulLength = (returnAllLength - 16);
+ int tempCount = 0;
+ var listData = new List<string>();
+ while (tempCount < usefulLength)
{
- //var kType = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
- //var keyPassword = data[12].ToString() + data[13].ToString() + data[14].ToString() + data[15].ToString() + data[16].ToString() + data[17].ToString() + data[18].ToString() + data[19].ToString();
- //result = new DoorlockUserInfo { keyType = kType, keyPassword = keyPassword };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0451_{ topic}");
+ listData.Add(data[16 + tempCount].ToString());
+ tempCount++;
}
+ for (int j = 0; j < listData.Count / 4; j++)
+ {
+ int curIndex = 4 * j;
+ var userInfo = new UserObj();
+ userInfo.UserType = Convert.ToInt32(listData[curIndex + 2].ToString(), 16);
+ userInfo.UserId = Convert.ToInt32(listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16);
+ doorLockUserDetailData.UserObjList.Add(userInfo);
+ }
+ doorLockUserDetailData.userType = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
+ doorLockUserDetailData.totalNum = Convert.ToInt32(data[12].ToString() + data[13].ToString(), 16);
+ doorLockUserDetailData.currentNum = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
+ totalNum = doorLockUserDetailData.totalNum;
+ currentNum = doorLockUserDetailData.currentNum;
+ result = new DoorlockUserInfo { doorLockUserDetailData = doorLockUserDetailData };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0451_{ topic}");
}
}
}
@@ -1443,11 +2190,11 @@
};
Gateway.Actions += action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
try
{
- var passData = KeyPasswordData(keyType);
+ var passData = DoorlockUserData();
var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
var data = new JObject { { "PassData", passData } };
jObject.Add("Data", data);
@@ -1455,21 +2202,21 @@
}
catch { }
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)//WaitReceiveDataTime)
+ //鎺ユ敹涓�涓寘鏈�澶氱瓑3绉掞紝娌℃湁鏀跺埌灏遍��鍑�,鍗曟鏁版嵁鍖呬笉瓒呰繃30涓敤鎴�
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 3000)
{
- await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
+ await System.Threading.Tasks.Task.Delay(100);
+ if (totalNum == currentNum)
{
break;
}
}
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- result = new DoorlockUserInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
+ //if ((DateTime.Now - dateTime).TotalMilliseconds > 3000)
+ //{
+ // result = new DoorlockUserInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ //}
Gateway.Actions -= action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
return result;
});
@@ -1478,7 +2225,7 @@
/// <summary>
/// 璇诲彇閿佷笂淇℃伅
/// </summary>
- string DoorlockUserData(int userType)
+ string DoorlockUserData()
{
string data = "";
string dataLength = "05";
@@ -1486,24 +2233,11 @@
string dataComand2 = "04";
string dataSerialNum = "01";
string addDataLength = "01";
- string keyTypeData = "";
+ string keyTypeData = "01";
try
{
- var tempTypeString = new System.Text.StringBuilder();
- var temp = Convert.ToString(userType, 16);
- switch (temp.Length)
- {
- case 1:
- keyTypeData = "0" + temp;
- break;
- case 2:
- keyTypeData = temp;
- break;
- }
- tempTypeString.Append(keyTypeData.ToString().ToUpper());
- data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
- tempTypeString;
+ data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + keyTypeData;
}
catch { };
@@ -1525,12 +2259,19 @@
/// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
/// </summary>
public ErrorResponData errorResponData;
+ /// <summary>
+ /// 闂ㄩ攣璁惧杩斿洖淇℃伅
+ /// </summary>
+ public DoorLockUserDetailData doorLockUserDetailData;
}
+ /// <summary>
+ /// 闂ㄩ攣璁惧杩斿洖淇℃伅
+ /// </summary>
public class DoorLockUserDetailData
{
/// <summary>
- /// 绫诲瀷
+ /// 绫诲瀷(璇诲彇閿佷笂宸叉湁鐢ㄦ埛)
/// </summary>
public int userType;
/// <summary>
@@ -1541,57 +2282,602 @@
/// 鏁版嵁鍖呭簭鍙�
/// </summary>
public int currentNum;
+
/// <summary>
- /// 鐢ㄦ埛鏁版嵁
+ /// 铏氭嫙椹卞姩淇℃伅
/// </summary>
- public byte userData;
+ public List<UserObj> UserObjList = new List<UserObj>();
+ }
+
+ public class UserObj
+ {
+ /// <summary>
+ /// 闂ㄩ攣鐢ㄦ埛绫诲瀷
+ /// </summary>
+ public int UserType;
+
+ /// <summary>
+ /// 闂ㄩ攣鐢ㄦ埛Id鍙�
+ /// </summary>
+ public int UserId;
}
#endregion
- public enum AccessType
+ #region 闊抽噺
+ ///<summary >
+ ///鑾峰彇闊抽噺
+ /// </summary>
+ public async System.Threading.Tasks.Task<VolumeResponseAllData> GetVolumeAsync()
{
- /// <summary>
- /// 0x00 鍒犻櫎鍏ㄩ儴鍗曟鐢ㄦ埛
- /// </summary>
- DelAllUsers = 0,
- /// <summary>
- /// 0x01 鍒犻櫎鎸囧畾鐢ㄦ埛(鎸夌紪鍙�)
- /// </summary>
- DelCurrentUser = 1,
- /// <summary>
- /// 0x20 鍐荤粨鎸囧畾鐢ㄦ埛
- /// </summary>
- DisEnable = 2,
- /// <summary>
- /// 0x21 瑙e喕鎸囧畾鐢ㄦ埛
- /// </summary>
- Enable = 3,
+ VolumeResponseAllData result = null;
+ if (Gateway == null)
+ {
+ result = new VolumeResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ return result;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+ if (temp == null)
+ {
+ result = new VolumeResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+
+ else
+ {
+ result = new VolumeResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+ if (topic == gatewayID + "/" + "ZbDataPassthrough")
+ {
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+ if (clientDataPassthroughResponseData == null)
+ {
+ result = new VolumeResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
+ {
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 14)
+ {
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0456")
+ {
+ var tempD = new VolumeResponseData();
+ tempD.command = data[10].ToString() + data[11].ToString();
+ tempD.value = Convert.ToInt32(data[12].ToString() + data[13].ToString(), 16);
+ result = new VolumeResponseAllData { volumeResponseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0456_{ topic}");
+ }
+ }
+ }
+ }
+ }
+ };
+
+ Gateway.Actions += action;
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var passData = VolumeData(-1);
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+ var data = new JObject { { "PassData", passData } };
+ jObject.Add("Data", data);
+ Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null && result.volumeResponseData != null)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)
+ {
+ result = new VolumeResponseAllData
+ { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return result;
+ });
+ }
+
+ ///<summary >
+ ///闊抽噺
+ ///<para>鍛戒护鍊�: comandValue</para>
+ ///<para>comandValue: 0-0x64 闊抽噺</para>
+ /// </summary>
+ public async System.Threading.Tasks.Task<DefaultControlResponseAllData> SetVolumeAsync(int comandValue)
+ {
+ DefaultControlResponseAllData result = null;
+ if (Gateway == null)
+ {
+ result = new DefaultControlResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ return result;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+ if (temp == null)
+ {
+ result = new DefaultControlResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+
+ else
+ {
+ result = new DefaultControlResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+ if (topic == gatewayID + "/" + "ZbDataPassthrough")
+ {
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+ if (clientDataPassthroughResponseData == null)
+ {
+ result = new DefaultControlResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
+ {
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 16)
+ {
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0002")
+ {
+ var tempD = new DefaultControlResponseData();
+ tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
+ tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
+ if (tempD.command == "0455")
+ {
+ result = new DefaultControlResponseAllData { defaultControlResponseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0455_{ topic}");
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ Gateway.Actions += action;
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var passData = VolumeData(comandValue);
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+ var data = new JObject { { "PassData", passData } };
+ jObject.Add("Data", data);
+ Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null && result.defaultControlResponseData != null)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)
+ {
+ result = new DefaultControlResponseAllData
+ { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return result;
+ });
}
/// <summary>
- /// 鑾峰彇浠庢牸鏋楀▉娌绘椂闂村埌褰撳墠鏌愪竴鏃跺埢鐨勬�绘绉掓暟
+ /// 闊抽噺鍙戦�佹暟鎹�
+ ///<para>comandValue: 0-100 闊抽噺</para>
/// </summary>
- /// <param name="dateTime">鍖椾含鏃堕棿</param>
- /// <param name="accurateToMilliseconds">绮剧‘鍒版绉掞紝鍚﹀埌绉�</param>
- /// <returns>杩斿洖涓�涓暱鏁存暟鏃堕棿鎴�</returns>
- public static long GetUnixTimeStamp(DateTime dateTime, bool accurateToMilliseconds)
+ public string VolumeData(int comandValue)
{
- DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1, 8, 0, 0));//鍖椾含鎵�鍦ㄤ笢鍏尯
- DateTime endTime = TimeZoneInfo.ConvertTimeToUtc(dateTime);
- return (long)(accurateToMilliseconds ? (endTime - startTime).TotalMilliseconds : (endTime - startTime).TotalSeconds);
+ string data = "";
+ string dataLength = "05";
+ string dataComand1 = "55";
+ string dataComand2 = "04";
+ string dataSerialNum = "01";
+ string addDataLength = "01";
+ string cValue = "";
+ try
+ {
+ if (comandValue >= 1)
+ {
+ cValue = Convert.ToString(comandValue, 16).ToUpper();
+ if (cValue.Length == 1)
+ {
+ cValue = "0" + cValue;
+ }
+ else
+ {
+ cValue = cValue;
+ }
+
+ }
+ else
+ {
+ switch (comandValue)
+ {
+ case -1:
+ cValue = "AA";
+ break;
+ case 0:
+ cValue = "EB";
+ break;
+ }
+ }
+ data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+ cValue;
+ }
+ catch (Exception ex)
+ {
+ var mess = ex.Message;
+ };
+ return data;
}
/// <summary>
- /// 灏哢NIX鏃堕棿鎴宠浆涓哄寳浜椂闂�
+ /// 闊抽噺鍥炲鏁版嵁
/// </summary>
- /// <param name="unixTimeStamp">鏃堕棿鎴�</param>
- /// <param name="accurateToMilliseconds">绮剧‘鍒版绉�,浣涗负绉�</param>
+ [System.Serializable]
+ public class VolumeResponseAllData
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 闊抽噺鍥炲鏁版嵁
+ /// </summary>
+ public VolumeResponseData volumeResponseData;
+ }
+
+ /// <summary>
+ /// 闊抽噺鍥炲鏁版嵁
+ /// </summary>
+ [System.Serializable]
+ public class VolumeResponseData
+ {
+ /// <summary>
+ ///鍛戒护
+ ///<para>0x00 鎺ユ敹鎴愬姛</para>
+ ///<para>0xea 璇煶妯″紡</para>
+ ///<para>0xeb 闈欓煶妯″紡</para>
+ /// </summary>
+ public string command = "";
+ /// <summary>
+ /// 闊抽噺鍊�
+ /// <para>0xf1~0xfe 1-14闊抽噺</para>
+ /// <para>0 鏃犻煶閲忓��</para>
+ /// </summary>
+ public int value = -1;
+ }
+ #endregion
+
+ #region 甯稿紑妯″紡聽聽聽 聽聽聽聽聽
+ /// <summary>
+ /// 璇诲彇甯稿紑妯″紡
+ /// </summary>
/// <returns></returns>
- public static DateTime GetLocalTime(long unixTimeStamp, bool accurateToMilliseconds)
+ public async System.Threading.Tasks.Task<OpenModeResponseAllData> ReadNormallyOpenModeFuncAsync()
{
- DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1, 8, 0, 0));//鍖椾含鎵�鍦ㄤ笢鍏尯
- return (accurateToMilliseconds ? startTime.AddMilliseconds(unixTimeStamp) : startTime.AddSeconds(unixTimeStamp)).ToLocalTime();
+ OpenModeResponseAllData result = null;
+ if (Gateway == null)
+ {
+ result = new OpenModeResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ return result;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+ if (temp == null)
+ {
+ result = new OpenModeResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+
+ else
+ {
+ result = new OpenModeResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+ if (topic == gatewayID + "/" + "ZbDataPassthrough")
+ {
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+ if (clientDataPassthroughResponseData == null)
+ {
+ result = new OpenModeResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
+ {
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 12)
+ {
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0458")
+ {
+ result = new OpenModeResponseAllData();
+ result.command = data[10].ToString() + data[11].ToString();
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0457_{ topic}");
+ }
+ }
+ }
+ }
+ }
+ };
+
+ Gateway.Actions += action;
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var passData = OpenModeData(SwitchMode.Obtain);
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+ var data = new JObject { { "PassData", passData } };
+ jObject.Add("Data", data);
+ Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)
+ {
+ result = new OpenModeResponseAllData
+ { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return result;
+ });
}
+
+ /// <summary>
+ /// 璁剧疆甯稿紑妯″紡
+ /// </summary>
+ /// <param name="IsNormallyOpenMode">鏄惁鎵撳紑甯稿紑妯″紡锛歵rue锛氭墦寮� false锛氬叧闂�</param>
+ /// <returns></returns>
+ public async System.Threading.Tasks.Task<DefaultControlResponseAllData> SetNormallyOpenModeFuncAsync(bool IsNormallyOpenMode)
+ {
+ DefaultControlResponseAllData result = null;
+ if (Gateway == null)
+ {
+ result = new DefaultControlResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ return result;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+ if (temp == null)
+ {
+ result = new DefaultControlResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+
+ else
+ {
+ result = new DefaultControlResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+ if (topic == gatewayID + "/" + "ZbDataPassthrough")
+ {
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+ if (clientDataPassthroughResponseData == null)
+ {
+ result = new DefaultControlResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
+ {
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 16)
+ {
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0002")
+ {
+ var tempD = new DefaultControlResponseData();
+ tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
+ tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
+ if (tempD.command == "0457")
+ {
+ result = new DefaultControlResponseAllData { defaultControlResponseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0457_{ topic}");
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ Gateway.Actions += action;
+ DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var passData = "";
+ if (IsNormallyOpenMode)
+ {
+ passData = OpenModeData(SwitchMode.NormallyOpen);
+ }
+ else
+ {
+ passData = OpenModeData(SwitchMode.NormallyClose);
+ }
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+ var data = new JObject { { "PassData", passData } };
+ jObject.Add("Data", data);
+ Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null && result.defaultControlResponseData != null)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)
+ {
+ result = new DefaultControlResponseAllData
+ { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return result;
+ });
+ }
+
+ /// <summary>
+ /// 甯稿紑妯″紡聽鍙戦�佹暟鎹�
+ /// </summary>
+ public string OpenModeData(SwitchMode switchMode)
+ {
+ string data = "";
+ string dataLength = "05";
+ string dataComand1 = "57";
+ string dataComand2 = "04";
+ string dataSerialNum = "01";
+ string addDataLength = "01";
+ string cValue = "";
+ try
+ {
+ switch (switchMode)
+ {
+ case SwitchMode.Obtain:
+ cValue = "10";
+ break;
+ case SwitchMode.NormallyOpen:
+ cValue = "12";
+ break;
+ case SwitchMode.NormallyClose:
+ cValue = "13";
+ break;
+ }
+ data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+ cValue;
+ }
+ catch (Exception ex)
+ {
+ var mess = ex.Message;
+ };
+ return data;
+ }
+
+ /// <summary>
+ /// 甯稿紑妯″紡聽鍥炲鏁版嵁
+ /// </summary>
+ [System.Serializable]
+ public class OpenModeResponseAllData
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 0x10 甯稿紑宸插紑鍚�
+ /// <para>0x11 甯稿紑宸插叧闂�</para>
+ /// </summary>
+ public string command;
+ }
+
+
+ /// <summary>
+ /// 寮�鍏虫ā寮�
+ /// </summary>
+ public enum SwitchMode
+ {
+ /// <summary>
+ /// 0x10 鏌ヨ甯稿紑鐘舵��
+ /// </summary>
+ Obtain = 0x10,
+ /// <summary>
+ /// 0x12 寮�鍚父寮�
+ /// </summary>
+ NormallyOpen = 0x12,
+ /// <summary>
+ /// 0x13 鍏抽棴甯稿紑
+ /// </summary>
+ NormallyClose = 0x13
+ }
+ #endregion
+
#endregion
}
}
--
Gitblit v1.8.0