From 1c4904d77f484c075080942d87785481b52b6fb2 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期一, 28 十月 2019 14:58:46 +0800 Subject: [PATCH] Revert "Merge branch 'dev-tzy' into DEV_GXC" --- ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs | 602 ++++++++++------------------------------------------- 1 files changed, 119 insertions(+), 483 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs index 599c3a1..c1bc636 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs @@ -1,6 +1,5 @@ 锘縰sing System; using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -11,7 +10,7 @@ namespace ZigBee.Device { - public class DoorLock : Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo + public class DoorLock : CommonDevice { public DoorLock() { @@ -30,41 +29,43 @@ 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 TempPasswordObject + public class LocaDoorLockObj { /// <summary> - /// 涓存椂瀵嗙爜ID + /// 鐢ㄦ埛id + ///闂ㄩ攣鏈湴褰曞叆鐨勫瘑鐮併�佹寚绾广�佹劅搴斿崱閮芥湁鍞竴瀵瑰簲鐨勭敤鎴稩d /// </summary> - public int UserId; + 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; /// <summary> /// PrimaryId 闂ㄩ攣浜戠涓� 閿�(闈炴洿鏂板瓧娈�,浠ヤ笅鍧囦负鏇存柊瀛楁) -->閿悕 : PrimaryId榛樿鍊�: null /// </summary> - //public string PrimaryId; - /// <summary> - /// 6浣嶆湁鍔ㄦ�佷复鏃跺瘑鐮� - /// </summary> - public string TempPassword; - /// <summary> - /// 闂ㄩ攣鏈夋晥鏃堕棿 - /// </summary> - public DateTime ValidTime; - /// <summary> - /// 闂ㄩ攣澶辨晥鏃堕棿 - /// </summary> - public DateTime InValidTime; + public string PrimaryId = ""; } - #endregion #endregion @@ -95,11 +96,6 @@ /// 闂ㄩ攣鏈湴鐢ㄦ埛Id -->閿悕 : DoorLockLocalUserId /// </summary> public string DoorLockLocalUserId = ""; - - /// <summary> - /// IsOtherAccountCtrl 鏄惁涓哄瓙甯愬彿鎺у埗杩囨潵 -->閿悕 : IsOtherAccountCtrl - /// </summary> - public bool IsOtherAccountCtrl = false; } #endregion @@ -214,263 +210,6 @@ } #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> /// 鑾峰彇闂ㄩ攣 @@ -481,6 +220,10 @@ /// 浜戠甯愬彿Id -->閿悕 : CloudAccountId (鍙��) /// </summary> public string CloudAccountId = ""; + /// <summary> + /// OpenLockMode 寮�閿佹柟寮�(瀵嗙爜銆佹寚绾广�両C鍗�) -->閿悕 : OpenLockMode (鍙��) + /// </summary> + //public int OpenLockMode = 0; } [Serializable] @@ -498,23 +241,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> @@ -534,11 +277,11 @@ /// </summary> public bool IsTempUnlockAuthority; /// <summary> - /// 褰曞叆鏃堕棿 + /// 褰曞叆鏃堕棿 /// </summary> public DateTime EntryTime; /// <summary> - /// 鏈�鍚庢洿鏂版椂闂� + /// 鏈�鍚庢洿鏂版椂闂� /// </summary> public string LastChangeTime; /// <summary> @@ -552,8 +295,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 () => @@ -566,6 +309,7 @@ if (result != null) { listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDoorLockDataRes>(result); + int i = 0; } } return listInfo; @@ -585,27 +329,10 @@ { //搴忓垪鍖栧璞� var requestJson = JsonConvert.SerializeObject(obj); - var byteData = System.Text.Encoding.UTF8.GetBytes(requestJson); - byte[] result1 = null; //璁块棶鎺ュ彛 - 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; + var result = await CommonPage.Instance.RequestHttpsZigbeeAsync(RequestName, System.Text.Encoding.UTF8.GetBytes(requestJson)); + + return result; } catch (Exception ex) { @@ -616,7 +343,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() { @@ -643,7 +370,6 @@ } #endregion - #region 涓庣綉鍏抽�氳鎺ュ彛 #region 闂ㄩ攣鎿嶄綔浜嬩欢閫氱煡 /// <summary> /// 闂ㄩ攣鎿嶄綔浜嬩欢閫氱煡 @@ -918,7 +644,7 @@ /// 淇濈暀 /// </summary> public int UserStatus; - /// <summary> + /// <summary> /// 缂栫▼浜嬩欢瑙﹀彂婧� /// 甯哥敤锛� /// 0:Keypad(閿洏/瀵嗙爜)锛�3:RFID(灏勯鍗�)锛�15:鎸囩汗 @@ -931,7 +657,7 @@ /// 甯哥敤锛� /// 閿洏/瀵嗙爜锛屾寚绾广�佹劅搴斿崱锛�1:Lock鍛戒护鎴愬姛浜嬩欢锛�2:Unlock鍛戒护鎴愬姛浜嬩欢 ///涓嶅父鐢細 - /// 璇锋煡鐪嬫灇涓� + /// 璇锋煡鐪嬫灇涓� /// </summary> public int ProgramEventCode; /// <summary> @@ -945,137 +671,29 @@ } #endregion - #region 鐭闂ㄩ攣鏃堕棿 + #region 涓存椂瀵嗙爜淇℃伅 /// <summary> - /// 鐭闂ㄩ攣鏃堕棿 + /// 涓存椂瀵嗙爜鏈湴瀛樺偍瀵硅薄 /// </summary> - /// <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; - }); - } - + public TempPasswordObj tempPasswordObj = new TempPasswordObj(); /// <summary> - /// 缃戝叧鐗堟湰淇℃伅,缃戝叧鍙嶉淇℃伅 - /// </summary> - public SetWritableValueResponAllData setWritableValueResponAllData; - /// <summary> - /// 缃戝叧鐗堟湰淇℃伅,缃戝叧鍙嶉淇℃伅 + /// 涓存椂瀵嗙爜鏈湴瀵硅薄 /// </summary> [System.Serializable] - public class SetWritableValueResponAllData + public class TempPasswordObj { /// <summary> - /// 閿欒淇℃伅 + /// 闂ㄩ攣鏈夋晥鏃堕棿 /// </summary> - public string errorMessageBase; + public int validTime; /// <summary> - /// 缃戝叧淇℃伅閿欒鍙嶉 - /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> + /// 闂ㄩ攣鏃堕棿 /// </summary> - 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; - + public int times; } #endregion - #endregion - #region 涓庤澶囬�氳鎺ュ彛锛堢鏈夊懡浠わ級 + #region 绉佹湁鍛戒护 #region 鐢ㄦ埛绠$悊鎺у埗 ///<summary > @@ -1132,10 +750,10 @@ if (command == "0002") { var tempD = new DefaultControlResponseData(); - tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); + tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16); tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); result = new DefaultControlResponseAllData { defaultControlResponseData = tempD }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0450_{ topic}"); + DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0402_{ topic}"); } } } @@ -1164,7 +782,7 @@ break; } } - if ((DateTime.Now - dateTime).TotalMilliseconds > 9000) + if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) { result = new DefaultControlResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; } @@ -1264,7 +882,7 @@ /// <summary> ///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛� /// </summary> - public string command = ""; + public int command = -1; /// <summary> /// 鐘舵�佸�� /// <para>榛樿鍝嶅簲缁撴灉锛� @@ -1274,7 +892,7 @@ ///<para>32 鍐荤粨鎴愬姛</para> ///<para>34 鍐荤粨澶辫触</para> ///<para>33 瑙e喕鎴愬姛</para> - ///<para>35 瑙e喕澶辫触</para> + ///<para>35 瑙e喕澶辫触</para> /// </summary> public int status = -1; } @@ -1303,7 +921,7 @@ #region 楠岃瘉闂ㄩ攣瀵嗙爜 ///<summary > ///楠岃瘉闂ㄩ攣瀵嗙爜 - ///<para>inputPassword:杈撳叆鐨勯棬閿佸瘑鐮�</para> + ///<para>inputPassword:杈撳叆鐨勯棬閿佸瘑鐮�</para> /// </summary> public async System.Threading.Tasks.Task<VerifyPasswordResponseAllData> VerifyPasswordAsync(string inputPassword) { @@ -1356,7 +974,7 @@ { var result1 = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16); result = new VerifyPasswordResponseAllData { result = result1 }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0454_{ topic}"); + DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0402_{ topic}"); } } } @@ -1382,7 +1000,7 @@ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime) { await System.Threading.Tasks.Task.Delay(10); - if (result != null && result.result == 0) + if (result != null) { break; } @@ -1450,17 +1068,17 @@ } #endregion - #region 杩滅▼寮�閿� + #region 杩滅▼寮�閿� ///<summary > - ///杩滅▼寮�閿� - ///<para>inputPassword: 杈撳叆瀵嗙爜/para> + ///杩滅▼寮�閿� + ///<para>inputPassword: 杈撳叆瀵嗙爜/para> /// </summary> - public async System.Threading.Tasks.Task<TempPasswordResponseAllData> RemoteControlAsync(string inputPassword) + public async System.Threading.Tasks.Task<ResponseAllData> RemoteControlAsync(string inputPassword) { - TempPasswordResponseAllData result = null; + ResponseAllData result = null; if (Gateway == null) { - result = new TempPasswordResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; + result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; return result; } return await System.Threading.Tasks.Task.Run(async () => @@ -1477,12 +1095,12 @@ if (temp == null) { - result = new TempPasswordResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; + result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; } else { - result = new TempPasswordResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; + result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; } } if (topic == gatewayID + "/" + "ZbDataPassthrough") @@ -1492,7 +1110,7 @@ if (gatewayTemp.clientDataPassthroughResponseData == null) { - result = new TempPasswordResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; + result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; } else { @@ -1504,11 +1122,11 @@ 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(); + var tempD = new ResponseData(); + tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16); tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); - result = new TempPasswordResponseAllData { responseData = tempD }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0462_{ topic}"); + result = new ResponseAllData { responseData = tempD }; + System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0400_{ topic}"); } } } @@ -1534,15 +1152,14 @@ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime) { await System.Threading.Tasks.Task.Delay(10); - if (result != null && result.responseData != null && result.responseData.command == "0462") + if (result != null) { break; } } if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) { - result = new TempPasswordResponseAllData - { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; + result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; } Gateway.Actions -= action; DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); @@ -1582,8 +1199,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") { @@ -1635,10 +1252,10 @@ if (command == "0002") { var tempD = new TempPasswordResponseData(); - tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString(); + tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16); tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16); result = new TempPasswordResponseAllData { responseData = tempD }; - DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0463_{ topic}"); + System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0400_{ topic}"); } } } @@ -1664,12 +1281,12 @@ while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime) { await System.Threading.Tasks.Task.Delay(10); - if (result != null && result.responseData != null && result.responseData.command == "0463") + if (result != null) { break; } } - if ((DateTime.Now - dateTime).TotalMilliseconds > 9000) + if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) { result = new TempPasswordResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; @@ -1701,26 +1318,21 @@ pawStr = pawStr.PadLeft(8, '0'); for (int i = 6; i >= 0; i = i - 2) { - passwordStr += pawStr.Substring(i, 2); + passwordStr += passwordStr.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 + invalidTimeStr; + passwordStr + vaildTimeStr + vaildTimeStr; } - catch (Exception ex) - { - var mess = ex.Message; - }; + catch { }; + return data; } @@ -1755,7 +1367,7 @@ /// <summary> ///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛� /// </summary> - public string command = ""; + public int command = -1; /// <summary> /// 鐘舵�佸�� /// <para>0--娉ㄥ唽鎴愬姛</para> @@ -1778,7 +1390,7 @@ { string passwordStr = ""; var result = await GetKeyPassworAsync(); - //杩斿洖灏忕 + //杩斿洖灏忕 if (result == null || result.keyPassword == null) { return 0; @@ -2090,7 +1702,7 @@ public class DoorLockUserDetailData { /// <summary> - /// 绫诲瀷(璇诲彇閿佷笂宸叉湁鐢ㄦ埛) + /// 绫诲瀷 /// </summary> public int userType; /// <summary> @@ -2122,6 +1734,30 @@ } #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