New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace Shared.Phone.UserCenter |
| | | { |
| | | /// <summary> |
| | | /// 门锁历史记录的逻辑 |
| | | /// </summary> |
| | | public class HdlDeviceDoorLockLogic |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 门锁历史记录的逻辑 |
| | | /// </summary> |
| | | private static HdlDeviceDoorLockLogic m_Current = null; |
| | | /// <summary> |
| | | /// 门锁历史记录的逻辑 |
| | | /// </summary> |
| | | public static HdlDeviceDoorLockLogic Current |
| | | { |
| | | get |
| | | { |
| | | if (m_Current == null) |
| | | { |
| | | m_Current = new HdlDeviceDoorLockLogic(); |
| | | } |
| | | return m_Current; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 添加历史记录_______________________ |
| | | |
| | | /// <summary> |
| | | /// 添加历史记录 |
| | | /// </summary> |
| | | /// <param name="i_doorLock">门锁对象</param> |
| | | /// <param name="OtherOpenLockMode">其他开锁方式 9001:常开打开 9002:常开取消 9003:常开持续 9004:常开自动化手动取消</param> |
| | | /// <param name="NormallyOpenContinuedTime">常开持续时间(1~72小时 OtherOpenLockMode=9003的时候有效)</param> |
| | | public void AddDoorHistoryLog(ZigBee.Device.DoorLock i_doorLock, int OtherOpenLockMode, string NormallyOpenContinuedTime) |
| | | { |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | | //获取门锁的主键ID |
| | | var DoorLockId = this.GetDoorHistoryDoorLockId(i_doorLock); |
| | | if (string.IsNullOrEmpty(DoorLockId) == true) |
| | | { |
| | | //网络不通 |
| | | return; |
| | | } |
| | | |
| | | var pra = new AddDoorHistoryLogPra(); |
| | | pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); |
| | | pra.DoorLockId = DoorLockId; |
| | | pra.OtherOpenLockMode = OtherOpenLockMode; |
| | | pra.NormallyOpenContinuedTime = NormallyOpenContinuedTime; |
| | | |
| | | //不检测错误码 |
| | | var listCheck = new List<string>() { "NotCheck" }; |
| | | var result = UserCenterLogic.GetResultStatuByRequestHttps("DoorLock/AddDoorLockHistory", true, pra, listCheck); |
| | | if (result == false) |
| | | { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取添加门锁历史记录的DoorLockId |
| | | /// </summary> |
| | | /// <param name="i_doorLock">门锁对象</param> |
| | | /// <returns></returns> |
| | | private string GetDoorHistoryDoorLockId(ZigBee.Device.DoorLock i_doorLock) |
| | | { |
| | | var pra = new GetDoorIdPra(); |
| | | pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); |
| | | pra.DoorLockId = i_doorLock.DeviceAddr + "_" + i_doorLock.DeviceEpoint; |
| | | //不检测错误码 |
| | | var listCheck = new List<string>() { "NotCheck" }; |
| | | var result = UserCenterLogic.GetResponseDataByRequestHttps("DoorLock/GetDoorLockPager", true, pra, listCheck); |
| | | if (string.IsNullOrEmpty(result) == true) { return null; } |
| | | |
| | | //如果已经创建了,则不再创建 |
| | | var myData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetListIdResult>(result); |
| | | if (myData.PageData.Count > 0) |
| | | { |
| | | return myData.PageData[0].Id; |
| | | } |
| | | |
| | | //如果还没有创建,则虚拟一个特殊的东西出来 |
| | | var pra2 = new AddDoorPra(); |
| | | pra2.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); |
| | | pra2.DoorLockId = i_doorLock.DeviceAddr + "_" + i_doorLock.DeviceEpoint; |
| | | var result2 = UserCenterLogic.GetResponseDataByRequestHttps("DoorLock/AddDoorLock", true, pra2, listCheck); |
| | | //云端是直接返回创建的主键字符串 |
| | | return result2; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加历史记录的参数 |
| | | /// </summary> |
| | | private class AddDoorHistoryLogPra : IfacePraCommon |
| | | { |
| | | /// <summary> |
| | | /// RequestVersion |
| | | /// </summary> |
| | | public string RequestVersion = Common.CommonPage.RequestVersion; |
| | | /// <summary> |
| | | /// LoginAccessToken |
| | | /// </summary> |
| | | public string LoginAccessToken = string.Empty; |
| | | /// <summary> |
| | | /// ZigbeeHomeId |
| | | /// </summary> |
| | | public string HomeId = Common.Config.Instance.Home.Id; |
| | | /// <summary> |
| | | /// 门锁云端主键(在(获取某个住宅门锁分页)接口响应中的Id值) |
| | | /// </summary> |
| | | public string DoorLockId = string.Empty; |
| | | /// <summary> |
| | | /// 其他开锁方式 9001:常开打开 9002:常开取消 9003:常开持续 |
| | | /// </summary> |
| | | public int OtherOpenLockMode = -1; |
| | | /// <summary> |
| | | /// 常开持续时间(1~72小时 OtherOpenLockMode=9003的时候有效) |
| | | /// </summary> |
| | | public string NormallyOpenContinuedTime = string.Empty; |
| | | /// <summary> |
| | | /// 开锁时间(历史记录的时间From-To检索的对象) |
| | | /// </summary> |
| | | public string UnlockTime = DateTime.UtcNow.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取添加门锁历史记录的DoorLockId的参数 |
| | | /// </summary> |
| | | private class GetDoorIdPra : IfacePraCommon |
| | | { |
| | | /// <summary> |
| | | /// RequestVersion |
| | | /// </summary> |
| | | public string RequestVersion = Common.CommonPage.RequestVersion; |
| | | /// <summary> |
| | | /// LoginAccessToken |
| | | /// </summary> |
| | | public string LoginAccessToken = string.Empty; |
| | | /// <summary> |
| | | /// ZigbeeHomeId |
| | | /// </summary> |
| | | public string HomeId = Common.Config.Instance.Home.Id; |
| | | /// <summary> |
| | | /// 填GUID |
| | | /// </summary> |
| | | public string CloudAccountId = Common.Config.Instance.Guid; |
| | | /// <summary> |
| | | /// 这个是门锁的 Mac_端点 |
| | | /// </summary> |
| | | public string DoorLockId = string.Empty; |
| | | /// <summary> |
| | | /// 开锁方式:固定9000 |
| | | /// </summary> |
| | | public int OpenLockMode = 9000; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加门锁的参数 |
| | | /// </summary> |
| | | private class AddDoorPra : IfacePraCommon |
| | | { |
| | | /// <summary> |
| | | /// RequestVersion |
| | | /// </summary> |
| | | public string RequestVersion = Common.CommonPage.RequestVersion; |
| | | /// <summary> |
| | | /// LoginAccessToken |
| | | /// </summary> |
| | | public string LoginAccessToken = string.Empty; |
| | | /// <summary> |
| | | /// ZigbeeHomeId |
| | | /// </summary> |
| | | public string HomeId = Common.Config.Instance.Home.Id; |
| | | /// <summary> |
| | | /// 填GUID |
| | | /// </summary> |
| | | public string CloudAccountId = Common.Config.Instance.Guid; |
| | | /// <summary> |
| | | /// 这个是门锁的 Mac_端点 |
| | | /// </summary> |
| | | public string DoorLockId = string.Empty; |
| | | /// <summary> |
| | | /// 其他开锁方式 固定9000 |
| | | /// </summary> |
| | | public int OpenLockMode = 9000; |
| | | /// <summary> |
| | | /// 录入时间 |
| | | /// </summary> |
| | | public string EntryTime = DateTime.Now.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 接收云端ID的结果 |
| | | /// </summary> |
| | | private class GetListIdResult |
| | | { |
| | | /// <summary> |
| | | /// 云端返回的主键ID |
| | | /// </summary> |
| | | public List<GetIdResult> PageData = new List<GetIdResult>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 接收云端ID的结果 |
| | | /// </summary> |
| | | private class GetIdResult |
| | | { |
| | | /// <summary> |
| | | /// 云端返回的主键ID |
| | | /// </summary> |
| | | public string Id = string.Empty; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |