From 1f5636d69332170ea3a41c76c9519f6ff6f0a8d9 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 28 十月 2019 15:40:30 +0800
Subject: [PATCH] 合并了代码
---
ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs | 604 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 484 insertions(+), 120 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
index c1bc636..599c3a1 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
@@ -1,5 +1,6 @@
锘縰sing System;
using System.Collections.Generic;
+using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -10,7 +11,7 @@
namespace ZigBee.Device
{
- public class DoorLock : CommonDevice
+ public class DoorLock : Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo
{
public DoorLock()
{
@@ -29,43 +30,41 @@
public static string RemoteUnlockPassword = string.Empty;//杩滅▼寮�閿佸瘑鐮�
public static DateTime maxValue = DateTime.MaxValue;
public static DateTime minValue = DateTime.MinValue;
+ public string LocalTempPassword = string.Empty;//鏈湴鐢熸垚鐨勪复鏃跺瘑鐮�
+ #region 涓存椂瀵嗙爜淇℃伅
/// <summary>
- /// 闂ㄩ攣缂栫▼浜嬩欢閫氱煡
+ /// 鐢ㄦ埛绠$悊鍙戦�佹暟鎹洖澶�
+ /// </summary>
+ public TempPasswordObject tempPasswordObject;
+ /// <summary>
+ /// 涓存椂瀵嗙爜鏈湴瀵硅薄
/// </summary>
[System.Serializable]
- public class LocaDoorLockObj
+ public class TempPasswordObject
{
/// <summary>
- /// 鐢ㄦ埛id
- ///闂ㄩ攣鏈湴褰曞叆鐨勫瘑鐮併�佹寚绾广�佹劅搴斿崱閮芥湁鍞竴瀵瑰簲鐨勭敤鎴稩d
+ /// 涓存椂瀵嗙爜ID
/// </summary>
- public int UserID;
- /// <summary>
- /// 寮�閿佺被鍨�
- /// 甯哥敤锛�
- /// 0:Keypad(閿洏/瀵嗙爜)锛�3:RFID(灏勯鍗�)锛�15:鎸囩汗
- ///涓嶅父鐢細
- /// 1:RF(Zigbee鏃犵嚎)锛�2:Manual(鎵嬪姩)锛�255:Indeterminate(涓嶇‘瀹�)
- /// </summary>
- public int UnlockType;
- /// <summary>
- /// 鍏宠仈璐︽埛鐨処D
- /// </summary>
- public string ConnectedAccount = string.Empty;
- /// <summary>
- /// 闂ㄩ攣鐢ㄦ埛鍚�
- /// </summary>
- public string UserName = string.Empty;
- /// <summary>
- /// 闂ㄩ攣褰曞叆鐨勬椂
- /// </summary>
- public DateTime EntryTime = System.DateTime.MinValue;
+ public int UserId;
/// <summary>
/// PrimaryId 闂ㄩ攣浜戠涓� 閿�(闈炴洿鏂板瓧娈�,浠ヤ笅鍧囦负鏇存柊瀛楁) -->閿悕 : PrimaryId榛樿鍊�: null
/// </summary>
- public string PrimaryId = "";
+ //public string PrimaryId;
+ /// <summary>
+ /// 6浣嶆湁鍔ㄦ�佷复鏃跺瘑鐮�
+ /// </summary>
+ public string TempPassword;
+ /// <summary>
+ /// 闂ㄩ攣鏈夋晥鏃堕棿
+ /// </summary>
+ public DateTime ValidTime;
+ /// <summary>
+ /// 闂ㄩ攣澶辨晥鏃堕棿
+ /// </summary>
+ public DateTime InValidTime;
}
+ #endregion
#endregion
@@ -96,6 +95,11 @@
/// 闂ㄩ攣鏈湴鐢ㄦ埛Id -->閿悕 : DoorLockLocalUserId
/// </summary>
public string DoorLockLocalUserId = "";
+
+ /// <summary>
+ /// IsOtherAccountCtrl 鏄惁涓哄瓙甯愬彿鎺у埗杩囨潵 -->閿悕 : IsOtherAccountCtrl
+ /// </summary>
+ public bool IsOtherAccountCtrl = false;
}
#endregion
@@ -210,6 +214,263 @@
}
#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>
/// 鑾峰彇闂ㄩ攣
@@ -220,10 +481,6 @@
/// 浜戠甯愬彿Id -->閿悕 : CloudAccountId (鍙��)
/// </summary>
public string CloudAccountId = "";
- /// <summary>
- /// OpenLockMode 寮�閿佹柟寮�(瀵嗙爜銆佹寚绾广�両C鍗�) -->閿悕 : OpenLockMode (鍙��)
- /// </summary>
- //public int OpenLockMode = 0;
}
[Serializable]
@@ -241,23 +498,23 @@
public class CloudDoorLockObj
{
/// <summary>
- /// 闂ㄩ攣Id
+ /// 闂ㄩ攣Id
/// </summary>
public string DoorLockId;
/// <summary>
- /// 浜戠甯愬彿Id
+ /// 浜戠甯愬彿Id
/// </summary>
public string CloudAccountId;
/// <summary>
- /// OpenLockMode 寮�閿佹柟寮�(瀵嗙爜銆佹寚绾广�両C鍗�)
+ /// OpenLockMode 寮�閿佹柟寮�(瀵嗙爜銆佹寚绾广�両C鍗�)
/// </summary>
public int OpenLockMode;
/// <summary>
- /// 闂ㄩ攣鏈湴鐢ㄦ埛Id
+ /// 闂ㄩ攣鏈湴鐢ㄦ埛Id
/// </summary>
public string DoorLockLocalUserId;
/// <summary>
- /// 浣忓畢Id
+ /// 浣忓畢Id
/// </summary>
public byte[] Data;
/// <summary>
@@ -277,11 +534,11 @@
/// </summary>
public bool IsTempUnlockAuthority;
/// <summary>
- /// 褰曞叆鏃堕棿
+ /// 褰曞叆鏃堕棿
/// </summary>
public DateTime EntryTime;
/// <summary>
- /// 鏈�鍚庢洿鏂版椂闂�
+ /// 鏈�鍚庢洿鏂版椂闂�
/// </summary>
public string LastChangeTime;
/// <summary>
@@ -295,8 +552,8 @@
}
/// <summary>
- /// 鑾峰彇闂ㄩ攣缁欎簯鏈嶅姟鍣�
- /// </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 () =>
@@ -309,7 +566,6 @@
if (result != null)
{
listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDoorLockDataRes>(result);
- int i = 0;
}
}
return listInfo;
@@ -329,10 +585,27 @@
{
//搴忓垪鍖栧璞�
var requestJson = JsonConvert.SerializeObject(obj);
+ var byteData = System.Text.Encoding.UTF8.GetBytes(requestJson);
+ byte[] result1 = null;
//璁块棶鎺ュ彛
- var result = await CommonPage.Instance.RequestHttpsZigbeeAsync(RequestName, System.Text.Encoding.UTF8.GetBytes(requestJson));
-
- return result;
+ if (UserCenterResourse.UserInfo.AuthorityNo == 1)
+ {
+ result1 = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync(RequestName, byteData);
+ }
+ else
+ {
+ result1 = await 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)
{
@@ -343,7 +616,7 @@
/// <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()
{
@@ -370,6 +643,7 @@
}
#endregion
+ #region 涓庣綉鍏抽�氳鎺ュ彛
#region 闂ㄩ攣鎿嶄綔浜嬩欢閫氱煡
/// <summary>
/// 闂ㄩ攣鎿嶄綔浜嬩欢閫氱煡
@@ -644,7 +918,7 @@
/// 淇濈暀
/// </summary>
public int UserStatus;
- /// <summary>
+ /// <summary>
/// 缂栫▼浜嬩欢瑙﹀彂婧�
/// 甯哥敤锛�
/// 0:Keypad(閿洏/瀵嗙爜)锛�3:RFID(灏勯鍗�)锛�15:鎸囩汗
@@ -657,7 +931,7 @@
/// 甯哥敤锛�
/// 閿洏/瀵嗙爜锛屾寚绾广�佹劅搴斿崱锛�1:Lock鍛戒护鎴愬姛浜嬩欢锛�2:Unlock鍛戒护鎴愬姛浜嬩欢
///涓嶅父鐢細
- /// 璇锋煡鐪嬫灇涓�
+ /// 璇锋煡鐪嬫灇涓�
/// </summary>
public int ProgramEventCode;
/// <summary>
@@ -671,29 +945,137 @@
}
#endregion
- #region 涓存椂瀵嗙爜淇℃伅
+ #region 鐭闂ㄩ攣鏃堕棿
/// <summary>
- /// 涓存椂瀵嗙爜鏈湴瀛樺偍瀵硅薄
+ /// 鐭闂ㄩ攣鏃堕棿
/// </summary>
- public TempPasswordObj tempPasswordObj = new TempPasswordObj();
+ /// <returns>The writable value async.</returns>
+ /// <param name="timestamp">鐭闂ㄩ攣鐨勬椂闂�</param>
+ public async System.Threading.Tasks.Task<SetWritableValueResponAllData> RectifyDoorLockTimeAsync(int timestamp)
+ {
+ if (Gateway == null)
+ {
+ return null;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ SetWritableValueResponAllData d = 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)
+ {
+ d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+ else
+ {
+ d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+
+ 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"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
+ var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString());
+
+ if (tempData == null)
+ {
+ d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ d = new SetWritableValueResponAllData { setWritableValueResponData = tempData };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+ }
+ }
+ };
+ Gateway.Actions += action;
+ DebugPrintLog("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
+
+ try
+ {
+ 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("SetWritableValue", jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (d != null)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+ {
+ d = new SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ DebugPrintLog("SetWritableValue_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return d;
+ });
+ }
+
/// <summary>
- /// 涓存椂瀵嗙爜鏈湴瀵硅薄
+ /// 缃戝叧鐗堟湰淇℃伅,缃戝叧鍙嶉淇℃伅
+ /// </summary>
+ public SetWritableValueResponAllData setWritableValueResponAllData;
+ /// <summary>
+ /// 缃戝叧鐗堟湰淇℃伅,缃戝叧鍙嶉淇℃伅
/// </summary>
[System.Serializable]
- public class TempPasswordObj
+ public class SetWritableValueResponAllData
{
/// <summary>
- /// 闂ㄩ攣鏈夋晥鏃堕棿
+ /// 閿欒淇℃伅
/// </summary>
- public int validTime;
+ public string errorMessageBase;
/// <summary>
- /// 闂ㄩ攣鏃堕棿
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
/// </summary>
- public int times;
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 缃戝叧鐗堟湰淇℃伅
+ /// </summary>
+ public SetWritableValueResponData setWritableValueResponData;
+ }
+
+ /// <summary>
+ /// 璁剧疆鍙啓灞炴�х殑鍊肩殑鏁版嵁
+ /// </summary>
+ [System.Serializable]
+ public class SetWritableValueResponData
+ {
+ /// <summary>
+ /// 閰嶇疆灞炴�ф墍鍦ㄧ殑cluster
+ /// </summary>
+ public int Cluster;
+ /// <summary>
+ /// 0锛氶厤缃垚鍔燂紙鑻ラ厤缃垚鍔燂紝涓嬮潰鐨凙ttributeId瀛楁涓嶅瓨鍦級
+ ///<para>134锛氫笉鏀寔璇ュ睘鎬�</para>
+ ///<para>135锛氭棤鏁堢殑灞炴�у��</para>
+ ///<para>141锛氭棤鏁堢殑鏁版嵁绫诲瀷</para>
+ /// </summary>
+ public int Status;
+
}
#endregion
+ #endregion
- #region 绉佹湁鍛戒护
+ #region 涓庤澶囬�氳鎺ュ彛锛堢鏈夊懡浠わ級
#region 鐢ㄦ埛绠$悊鎺у埗
///<summary >
@@ -750,10 +1132,10 @@
if (command == "0002")
{
var tempD = new DefaultControlResponseData();
- tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
+ 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 DefaultControlResponseAllData { defaultControlResponseData = tempD };
- DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0402_{ topic}");
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0450_{ topic}");
}
}
}
@@ -782,7 +1164,7 @@
break;
}
}
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)
{
result = new DefaultControlResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
}
@@ -882,7 +1264,7 @@
/// <summary>
///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛�
/// </summary>
- public int command = -1;
+ public string command = "";
/// <summary>
/// 鐘舵�佸��
/// <para>榛樿鍝嶅簲缁撴灉锛�
@@ -892,7 +1274,7 @@
///<para>32 鍐荤粨鎴愬姛</para>
///<para>34 鍐荤粨澶辫触</para>
///<para>33 瑙e喕鎴愬姛</para>
- ///<para>35 瑙e喕澶辫触</para>
+ ///<para>35 瑙e喕澶辫触</para>
/// </summary>
public int status = -1;
}
@@ -921,7 +1303,7 @@
#region 楠岃瘉闂ㄩ攣瀵嗙爜
///<summary >
///楠岃瘉闂ㄩ攣瀵嗙爜
- ///<para>inputPassword:杈撳叆鐨勯棬閿佸瘑鐮�</para>
+ ///<para>inputPassword:杈撳叆鐨勯棬閿佸瘑鐮�</para>
/// </summary>
public async System.Threading.Tasks.Task<VerifyPasswordResponseAllData> VerifyPasswordAsync(string inputPassword)
{
@@ -974,7 +1356,7 @@
{
var result1 = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
result = new VerifyPasswordResponseAllData { result = result1 };
- DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0402_{ topic}");
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0454_{ topic}");
}
}
}
@@ -1000,7 +1382,7 @@
while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
{
await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
+ if (result != null && result.result == 0)
{
break;
}
@@ -1068,17 +1450,17 @@
}
#endregion
- #region 杩滅▼寮�閿�
+ #region 杩滅▼寮�閿�
///<summary >
- ///杩滅▼寮�閿�
- ///<para>inputPassword: 杈撳叆瀵嗙爜/para>
+ ///杩滅▼寮�閿�
+ ///<para>inputPassword: 杈撳叆瀵嗙爜/para>
/// </summary>
- public async System.Threading.Tasks.Task<ResponseAllData> RemoteControlAsync(string inputPassword)
+ public async System.Threading.Tasks.Task<TempPasswordResponseAllData> RemoteControlAsync(string inputPassword)
{
- ResponseAllData result = null;
+ TempPasswordResponseAllData result = null;
if (Gateway == null)
{
- result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ result = new TempPasswordResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
return result;
}
return await System.Threading.Tasks.Task.Run(async () =>
@@ -1095,12 +1477,12 @@
if (temp == null)
{
- result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ result = new TempPasswordResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
}
else
{
- result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ result = new TempPasswordResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
}
}
if (topic == gatewayID + "/" + "ZbDataPassthrough")
@@ -1110,7 +1492,7 @@
if (gatewayTemp.clientDataPassthroughResponseData == null)
{
- result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ result = new TempPasswordResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
}
else
{
@@ -1122,11 +1504,11 @@
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 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);
- result = new ResponseAllData { responseData = tempD };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0400_{ topic}");
+ result = new TempPasswordResponseAllData { responseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0462_{ topic}");
}
}
}
@@ -1152,14 +1534,15 @@
while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
{
await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
+ if (result != null && result.responseData != null && result.responseData.command == "0462")
{
break;
}
}
if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
{
- result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ result = new TempPasswordResponseAllData
+ { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
}
Gateway.Actions -= action;
DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
@@ -1199,8 +1582,8 @@
#region 涓存椂瀵嗙爜鍙戦�佹暟鎹�
///<summary >
- ///杩滅▼寮�閿�
- ///<para>inputPassword: 杈撳叆瀵嗙爜/para>
+ ///杩滅▼寮�閿�
+ ///<para>inputPassword: 杈撳叆瀵嗙爜/para>
/// </summary>
public async System.Threading.Tasks.Task<TempPasswordResponseAllData> TempPasswordAsync(string inputPassword, System.DateTime startTime, System.DateTime endTime, string fixedPassword = "190605")
{
@@ -1252,10 +1635,10 @@
if (command == "0002")
{
var tempD = new TempPasswordResponseData();
- tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
+ 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 TempPasswordResponseAllData { responseData = tempD };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0400_{ topic}");
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0463_{ topic}");
}
}
}
@@ -1281,12 +1664,12 @@
while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
{
await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
+ if (result != null && result.responseData != null && result.responseData.command == "0463")
{
break;
}
}
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)
{
result = new TempPasswordResponseAllData
{ errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
@@ -1318,21 +1701,26 @@
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;
}
@@ -1367,7 +1755,7 @@
/// <summary>
///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛�
/// </summary>
- public int command = -1;
+ public string command = "";
/// <summary>
/// 鐘舵�佸��
/// <para>0--娉ㄥ唽鎴愬姛</para>
@@ -1390,7 +1778,7 @@
{
string passwordStr = "";
var result = await GetKeyPassworAsync();
- //杩斿洖灏忕
+ //杩斿洖灏忕
if (result == null || result.keyPassword == null)
{
return 0;
@@ -1702,7 +2090,7 @@
public class DoorLockUserDetailData
{
/// <summary>
- /// 绫诲瀷
+ /// 绫诲瀷(璇诲彇閿佷笂宸叉湁鐢ㄦ埛)
/// </summary>
public int userType;
/// <summary>
@@ -1734,30 +2122,6 @@
}
#endregion
- /// <summary>
- /// 鑾峰彇浠庢牸鏋楀▉娌绘椂闂村埌褰撳墠鏌愪竴鏃跺埢鐨勬�绘绉掓暟
- /// </summary>
- /// <param name="dateTime">鍖椾含鏃堕棿</param>
- /// <param name="accurateToMilliseconds">绮剧‘鍒版绉掞紝鍚﹀埌绉�</param>
- /// <returns>杩斿洖涓�涓暱鏁存暟鏃堕棿鎴�</returns>
- public static long GetUnixTimeStamp(DateTime dateTime, bool accurateToMilliseconds)
- {
- 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);
- }
-
- /// <summary>
- /// 灏哢NIX鏃堕棿鎴宠浆涓哄寳浜椂闂�
- /// </summary>
- /// <param name="unixTimeStamp">鏃堕棿鎴�</param>
- /// <param name="accurateToMilliseconds">绮剧‘鍒版绉�,浣涗负绉�</param>
- /// <returns></returns>
- public static DateTime GetLocalTime(int unixTimeStamp, bool accurateToMilliseconds)
- {
- DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1, 8, 0, 0));//鍖椾含鎵�鍦ㄤ笢鍏尯
- return (accurateToMilliseconds ? startTime.AddMilliseconds(unixTimeStamp) : startTime.AddSeconds(unixTimeStamp)).ToLocalTime();
- }
#endregion
}
}
--
Gitblit v1.8.0