| | |
| | | /// <summary> |
| | | /// 主网关 |
| | | /// </summary> |
| | | /// <value>The main gate way.</value> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public static ZbGateway MainGateWay |
| | | { |
| | | get |
| | | { |
| | | return GateWayList.Find((obj) => { return obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId && obj.getGatewayBaseInfo.IsMainGateWay; }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 主网关 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public bool IsMainGateWay |
| | | { |
| | | get |
| | | { |
| | | return getGatewayBaseInfo != null && getGatewayBaseInfo.IsMainGateWay; |
| | | {
|
| | | ZbGateway mainWay = null; |
| | | for (int i = 0; i < GateWayList.Count; i++)
|
| | | {
|
| | | if (GateWayList[i].HomeId == Config.Instance.HomeId)
|
| | | {
|
| | | //2020.07.16变更:别管那么多,如果住宅ID一样,先确定就是它了(不然有时候经常返回null,有可能是刷新不到)
|
| | | mainWay = GateWayList[i];
|
| | | if (mainWay.IsMainGateWay == true)
|
| | | {
|
| | | //然后如果它确实是主网关,直接break
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | return mainWay; |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | get |
| | | { |
| | | var fileName = "Gateway_" + DeviceType.ZbGateway.ToString() + "_" + this.getGatewayBaseInfo?.gwID; |
| | | var fileName = "Gateway_" + DeviceType.ZbGateway.ToString() + "_" + this.GwId; |
| | | return fileName; |
| | | } |
| | | } |
| | |
| | | { |
| | | await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | CommonDevice commonDev = null; |
| | | Action<string, string> action1 = (topic, message) => { }; |
| | | Actions += action1; |
| | | var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 94 } }; |
| | |
| | | /// </summary> |
| | | static Guid currentGuid = Guid.NewGuid(); |
| | | |
| | | public async System.Threading.Tasks.Task SendAesKey()
|
| | | public async Task SendAesKey()
|
| | | {
|
| | | if (PubKey != null)
|
| | | {
|
| | |
| | | } |
| | | } |
| | | |
| | | public async System.Threading.Tasks.Task StartLocalMqtt(string brokerName) |
| | | public async Task StartLocalMqtt(string brokerName) |
| | | {
|
| | | if (localMqttIsConnecting
|
| | | || !Shared.Common.Config.Instance.IsLogin
|
| | | || Shared.Common.Config.Instance.HomeId == ""
|
| | | || localIsConnected)
|
| | | || Shared.Common.Config.Instance.HomeId == ""
|
| | | || localIsConnected)
|
| | | {
|
| | | return;
|
| | | } |
| | |
| | | {
|
| | | DebugPrintLog($" 本地连接成功_网关IP:{brokerName}_网关是否加:{IsEncry}_当前密码:{Password}");
|
| | | IsRemote = false;
|
| | | //Log写入(调试用)
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
|
| | | {
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, "本地连接成功");
|
| | | }
|
| | | }); |
| | | }
|
| | |
|
| | |
| | | }
|
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | {
|
| | | //Log写入(调试用)
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
|
| | | {
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, "本地连接异常:\r\n" + ex.Message);
|
| | | } |
| | | DebugPrintLog($"局域网通讯连接出异常:{ex.Message}"); |
| | | } |
| | | finally |
| | |
| | | }); |
| | | } |
| | | |
| | | class GateWayBaseInfomation |
| | | { |
| | | //public string GatewayUniqueId;//"Emq网关1", <!-- 网关Mac --> |
| | | public bool MqttOnlineStatus;//: true, <!-- 网关在云端Emq是否在线 --> |
| | | public string AesKey;// : "a5d8da8a-ddea-48", <!-- 与此网关在云端Emq通信时,负载加解的16位Aes密钥 --> |
| | | public string MacMark;//: "61eaa0ea-4812-4a7a-86d6-3098c61e64ed" <!-- 网关对应的唯一码 --> |
| | | } |
| | | /// <summary> |
| | | /// 当前有帐号下所有的网关列表及信息 |
| | | /// </summary> |
| | | static Dictionary<string, GateWayBaseInfomation> GateWayBaseInfomations = new Dictionary<string, GateWayBaseInfomation> { }; |
| | | public static Dictionary<string, Shared.Phone.UserCenter.GatewayResult> GateWayBaseInfomations = new Dictionary<string, Shared.Phone.UserCenter.GatewayResult> { }; |
| | | /// <summary> |
| | | /// 获取当前帐号所有的网关信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | static async System.Threading.Tasks.Task initGateWayBaseInfomation() |
| | | static async Task initGateWayBaseInfomation() |
| | | {
|
| | | if (AllowRemoteCtrl == false)
|
| | | {
|
| | |
| | | MainAccountId = Config.Instance.Home.MainUserDistributedMark,
|
| | | SharedHid = Config.Instance.Home.Id
|
| | | };
|
| | |
|
| | | var listNotShow = new List<string>() { "NotSetAgain" };
|
| | | var resultData = await Shared.Phone.UserCenter.UserCenterLogic.GetByteResponseDataByRequestHttps("App/GetSharedHomeApiControl", false, pra, listNotShow);
|
| | | var resultData = Shared.Phone.UserCenter.UserCenterLogic.GetByteResponseDataByRequestHttps("App/GetSharedHomeApiControl", false, pra, new List<string> { "NotCheck" });
|
| | | if (resultData == null)
|
| | | {
|
| | | return;
|
| | |
| | | pra2.ReqDto.LoginAccessToken = loginToken; |
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(pra2)); |
| | | |
| | | var result = await CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/App/GetSingleHomeGatewayPagger", bytes, loginToken);
|
| | | var result = CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/App/GetSingleHomeGatewayPagger", bytes, loginToken);
|
| | | if (result != null)
|
| | | {
|
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(Encoding.UTF8.GetString(result));
|
| | |
| | | var list = JArray.Parse(responseData["PageData"].ToString());
|
| | | foreach (var v in list)
|
| | | {
|
| | | GateWayBaseInfomations[v["GatewayUniqueId"].ToString()] = new GateWayBaseInfomation { AesKey = v["AesKey"].ToString(), MacMark = v["MacMark"].ToString(), MqttOnlineStatus = bool.Parse(v["MqttOnlineStatus"].ToString()) };
|
| | | GateWayBaseInfomations[v["GatewayUniqueId"].ToString()] = new Shared.Phone.UserCenter.GatewayResult { AesKey = v["AesKey"].ToString(), MacMark = v["MacMark"].ToString(), MqttOnlineStatus = bool.Parse(v["MqttOnlineStatus"].ToString()) };
|
| | | //if (RemoteMqttClient.IsConnected)
|
| | | {
|
| | | await RemoteMqttClient.SubscribeAsync($"/ZigbeeGateWayToClient/{v["MacMark"].ToString()}/#", MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce);
|
| | |
| | | public static IMqttClient RemoteMqttClient = new MqttFactory().CreateMqttClient(); |
| | | static bool remoteIsConnected; |
| | | |
| | | /// <summary>
|
| | | /// 远程开始连接的时间点
|
| | | /// </summary> |
| | | private static DateTime RemoteConnectTime = DateTime.Now; |
| | | /// <summary> |
| | | /// 启动远程Mqtt |
| | | /// </summary> |
| | | /// <returns>The start.</returns> |
| | | /// <param name="brokerName">Broker name.</param> |
| | | public static async System.Threading.Tasks.Task StartRemoteMqtt() |
| | | public static async Task StartRemoteMqtt() |
| | | {
|
| | | //追加:没有远程连接的权限
|
| | | if (AllowRemoteCtrl == false
|
| | | || remoteMqttIsConnecting
|
| | | || !Shared.Common.Config.Instance.IsLogin
|
| | | || Shared.Common.Config.Instance.HomeId == ""
|
| | | || remoteIsConnected)
|
| | | {
|
| | | return;
|
| | | } |
| | | await System.Threading.Tasks.Task.Factory.StartNew(async () => |
| | | //如果远程还在连接中 |
| | | if (remoteMqttIsConnecting == true)
|
| | | {
|
| | | //如果这个变量一直处于连接中的状态,但是已经过去了10秒了,还是true的话,说明这里是有点问题的,需要重新创建
|
| | | if ((DateTime.Now - RemoteConnectTime).TotalMilliseconds < 10 * 1000)
|
| | | {
|
| | | return;
|
| | | }
|
| | | } |
| | | //记录起这次远程连接的时间点 |
| | | RemoteConnectTime = DateTime.Now; |
| | | |
| | | await Task.Factory.StartNew(async () => |
| | | { |
| | | try |
| | | { |
| | |
| | | //订阅一个挤下线的主题
|
| | | await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze");
|
| | |
|
| | | await initGateWayBaseInfomation(); |
| | |
|
| | | //没有主网关时主动读取,获取主网关信息
|
| | | var gateWayList = GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId);
|
| | | if (gateWayList.Find(obj => obj.getGatewayBaseInfo.IsMainGateWay == true) == null)
|
| | | //如果这个函数卡久了的话,会接收到云端推送的挤下线主题,不知道为什么
|
| | | new Thread(async () =>
|
| | | {
|
| | | if (gateWayList.Count == 1)
|
| | | await initGateWayBaseInfomation();
|
| | |
|
| | | //没有主网关时主动读取,获取主网关信息
|
| | | var gateWayList = GateWayList.FindAll(obj => obj.HomeId == Shared.Common.Config.Instance.HomeId);
|
| | | if (gateWayList.Find(obj => obj.IsMainGateWay == true) == null)
|
| | | {
|
| | | gateWayList[0].getGatewayBaseInfo.IsMainGateWay = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | for (int i = 0; i < gateWayList.Count; i++)
|
| | | if (gateWayList.Count == 1)
|
| | | {
|
| | | var gateWay = gateWayList[i];
|
| | | var info = await gateWay.GetZbGwInfoAsync();
|
| | | if (info == null || info.getGwData == null)
|
| | | gateWayList[0].IsMainGateWay = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | for (int i = 0; i < gateWayList.Count; i++)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (info.getGwData.IsDominant == 1)
|
| | | {
|
| | | for (int j = 0; j < gateWayList.Count; j++)
|
| | | var gateWay = gateWayList[i];
|
| | | var info = await gateWay.GetZbGwInfoAsync();
|
| | | if (info == null || info.getGwData == null)
|
| | | {
|
| | | if (gateWayList[i].getGatewayBaseInfo.gwID == info.getGwData.GwId)
|
| | | {
|
| | | gateWayList[i].getGatewayBaseInfo.IsMainGateWay = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | gateWayList[i].getGatewayBaseInfo.IsMainGateWay = false;
|
| | | }
|
| | | continue;
|
| | | }
|
| | | break;
|
| | | if (info.getGwData.IsDominant == 1)
|
| | | {
|
| | | for (int j = 0; j < gateWayList.Count; j++)
|
| | | {
|
| | | if (gateWayList[i].GwId == info.getGwData.GwId)
|
| | | {
|
| | | gateWayList[i].IsMainGateWay = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | gateWayList[i].IsMainGateWay = false;
|
| | | }
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | |
| | | }); |
| | | } |
| | | #endregion |
| | |
| | | ["PublishPayloadJsonStr"] = "1"
|
| | | };
|
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(jsonData));
|
| | | result = await CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/GetConnMqttInfo", bytes, Config.Instance.Token);
|
| | | result = CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/GetConnMqttInfo", bytes, Config.Instance.Token);
|
| | | } |
| | | else
|
| | | {
|
| | |
| | | ["PublishPayloadJsonStr"] = "1"
|
| | | };
|
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(jsonData));
|
| | | result = await CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/ShareMemberConnMqttInfo", bytes, Config.Instance.Token);
|
| | | result = CommonPage.Instance.DoRequestZigbeeHttpsInterface("https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/ShareMemberConnMqttInfo", bytes, Config.Instance.Token);
|
| | | } |
| | | if (result != null) |
| | | { |
| | |
| | | AllowRemoteCtrl = false;
|
| | | return;
|
| | | } |
| | | //虽然不知道对挤下线那一块有没有用,不过先这么弄 |
| | | await System.Threading.Tasks.Task.Delay(1500); |
| | | |
| | | var responseData = jobject["ResponseData"]; |
| | | if (responseData != null) |
| | |
| | | /// <summary> |
| | | /// 断开服务器连接 |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task DisConnectLocalMqttClient(string s) |
| | | public async Task DisConnectLocalMqttClient(string s) |
| | | { |
| | | try |
| | | { |
| | | if (localIsConnected)
|
| | | {
|
| | | localIsConnected = false;
|
| | | //这个东西也要弄
|
| | | localMqttIsConnecting = false;
|
| | | DebugPrintLog($"Local主动断开_{s}");
|
| | | //await localMqttClient.DisconnectAsync(new MQTTnet.Client.Disconnecting.MqttClientDisconnectOptions { }, CancellationToken.None);
|
| | | await localMqttClient.DisconnectAsync();
|
| | |
| | | { |
| | | DebugPrintLog($"Local断开通讯连接出异常:{ex.Message}"); |
| | | } |
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 强制断开本地的网关连接 |
| | | /// </summary> |
| | | public async Task CloseLocalConnectionOnForce() |
| | | { |
| | | try |
| | | {
|
| | | await localMqttClient.DisconnectAsync();
|
| | | } |
| | | catch { } |
| | | finally |
| | | {
|
| | | localIsConnected = false;
|
| | | //这个东西也要弄
|
| | | localMqttIsConnecting = false;
|
| | | } |
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 断开远程Mqtt的链接
|
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task DisConnectRemoteMqttClient(string s = "")
|
| | | public static async Task DisConnectRemoteMqttClient(string s = "")
|
| | | {
|
| | | try
|
| | | {
|
| | | if (remoteIsConnected)
|
| | | {
|
| | | remoteIsConnected = false;
|
| | | //这个东西也要弄
|
| | | remoteMqttIsConnecting = false;
|
| | | DebugPrintLog($"Remote主动断开_{s}");
|
| | | //await RemoteMqttClient.DisconnectAsync(new MQTTnet.Client.Disconnecting.MqttClientDisconnectOptions { }, CancellationToken.None);
|
| | | await RemoteMqttClient.DisconnectAsync();
|
| | |
| | | catch (Exception e)
|
| | | { |
| | | DebugPrintLog($"Remote断开通讯连接出异常:{e.Message}");
|
| | | }
|
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 强制断开远程Mqtt的链接
|
| | | /// </summary>
|
| | | /// <returns></returns> |
| | | public static async Task CloseRemoteConnectionOnForce()
|
| | | {
|
| | | try
|
| | | {
|
| | | await RemoteMqttClient.DisconnectAsync();
|
| | | }
|
| | | catch { }
|
| | | finally
|
| | | {
|
| | | remoteIsConnected = false;
|
| | | //这个东西也要弄
|
| | | remoteMqttIsConnecting = false;
|
| | | }
|
| | | } |
| | | |
| | |
| | | { |
| | | try
|
| | | {
|
| | | if (this.getGatewayBaseInfo?.gwID == null || !GateWayBaseInfomations.ContainsKey(this.getGatewayBaseInfo?.gwID))
|
| | | if (this.GwId == string.Empty || !GateWayBaseInfomations.ContainsKey(this.GwId))
|
| | | {
|
| | | return;
|
| | | }
|
| | | var gateWayBaseInfomation = GateWayBaseInfomations[this.getGatewayBaseInfo?.gwID];
|
| | | var gateWayBaseInfomation = GateWayBaseInfomations[this.GwId];
|
| | | message = SecuritySet.AesEncryptBytes(message, gateWayBaseInfomation.AesKey);
|
| | | var topicEncStr = $"/ClientToZigbeeGateWay/{gateWayBaseInfomation.MacMark}/Common/{topicName}";
|
| | | //(6)构建Mqtt需要发布的数据包,发布给云端的MqttBroker
|
| | |
| | | if (Shared.Common.Config.Instance.HomeId == "") |
| | | { |
| | | return; |
| | | }
|
| | |
|
| | | //Log写入(调试用)
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
|
| | | {
|
| | | string text = "远程发送:";
|
| | | if (IsRemote == false) { text = "本地发送:"; }
|
| | | text += topic + "\r\n";
|
| | | text += Encoding.UTF8.GetString(message) + "\r\n";
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, text);
|
| | | } |
| | | |
| | | if (IsRemote) |
| | |
| | | {
|
| | | DebugPrintLog($"局域网——二次发送到网关的主题:{topic}_发送到网关的数据:{System.Text.Encoding.UTF8.GetString(message)}_是否加密:{IsEncry}");
|
| | | await localMqttClient.PublishAsync(new MqttApplicationMessage { Topic = topic, Payload = message, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce, Retain = retain });
|
| | | }
|
| | | //Log写入(调试用)
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
|
| | | {
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, "本地连接异常断开");
|
| | | } |
| | | }
|
| | | }
|
| | |
| | | attrId = topic.Split('/')[5]; |
| | | }
|
| | |
|
| | | //Log写入(调试用)
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSendAndReceveDataToFile == 1)
|
| | | {
|
| | | string text = "网关回复:" + topic + "\r\n";
|
| | | text += message + "\r\n";
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(2, text);
|
| | | }
|
| | |
|
| | | //全局接收网关推送的的逻辑(为了执行速度,尽可能的别加耗时的操作)
|
| | | Shared.Phone.UserCenter.HdlGatewayReceiveLogic.Current.GatewayOverallMsgReceive(gatewayID, topic, reportStatus, message); |
| | | |
| | | var gwa = GateWayList.Find(obj => obj.getGatewayBaseInfo.gwID == gatewayID); |
| | | var gwa = GateWayList.Find(obj => obj.GwId == gatewayID); |
| | | if (gwa == null) |
| | | { |
| | | return; |
| | |
| | | var gwData = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.GetGwData>(jobject["Data"].ToString()); |
| | | if (gwData != null) |
| | | { |
| | | var gwList = GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId); |
| | | var gwList = GateWayList.FindAll(obj => obj.HomeId == Shared.Common.Config.Instance.HomeId); |
| | | for (int i = 0; i < gwList.Count; i++) |
| | | { |
| | | if (gwList[i].getGatewayBaseInfo.gwID == gatewayID)
|
| | | if (gwList[i].GwId == gatewayID)
|
| | | {
|
| | | gwList[i].getGatewayBaseInfo.IsMainGateWay = true;
|
| | | gwList[i].IsMainGateWay = true;
|
| | | } |
| | | else
|
| | | {
|
| | | gwList[i].getGatewayBaseInfo.IsMainGateWay = false;
|
| | | gwList[i].IsMainGateWay = false;
|
| | | } |
| | | } |
| | | } |
| | |
| | | #endregion |
| | | |
| | | #region 设备状态上报 |
| | | else if (topic == gatewayID + "/" + "DeviceStatusReport" + "/" + addr + "/" + epoint + "/" + cluID + "/" + attrId) |
| | | if (topic == gatewayID + "/" + "DeviceStatusReport" + "/" + addr + "/" + epoint + "/" + cluID + "/" + attrId) |
| | | { |
| | | var deviceID = jobject.Value<int>("Device_ID"); |
| | | var deviceAddr = jobject.Value<string>("DeviceAddr"); |
| | |
| | | switch ((DeviceType)(deviceID)) |
| | | { |
| | | case DeviceType.DoorLock: |
| | | var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; |
| | | var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), CurrentGateWayId = gwa.GwId }; |
| | | var OperatingEventNotificationDatad = Newtonsoft.Json.JsonConvert.DeserializeObject<ZigBee.Device.DoorLock.DoorLockOperatingEventNotificationCommand>(jobject["Data"].ToString()); |
| | | if (OperatingEventNotificationDatad != null) |
| | | { |
| | |
| | | switch ((DeviceType)(deviceID)) |
| | | { |
| | | case DeviceType.DoorLock: |
| | | var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID }; |
| | | var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), CurrentGateWayId = gwa.GwId }; |
| | | var ProgrammingEventNotificationData = Newtonsoft.Json.JsonConvert.DeserializeObject<ZigBee.Device.DoorLock.DoorLockProgrammingEventNotificationCommand>(jobject["Data"].ToString()); |
| | | if (ProgrammingEventNotificationData != null) |
| | | { |
| | |
| | | #region 防区被触发时报告 |
| | | else if (topic == gatewayID + "/" + "Security/ZoneTriggerReport") |
| | | { |
| | | var ias = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID }; |
| | | var ias = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.GwId }; |
| | | ias.zoneTriggerReportData = Newtonsoft.Json.JsonConvert.DeserializeObject<Safeguard.ZoneTriggerReportData>(jobject["Data"].ToString()); |
| | | |
| | | if (ias.zoneTriggerReportData == null) |
| | |
| | | #region 逻辑被调用反馈 |
| | | else if (topic == gatewayID + "/" + "Logic/Execute_Respon") |
| | | { |
| | | //var logic = new Logic() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID }; |
| | | //var logic = new Logic() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.GwId }; |
| | | //logic.logicExecuteRespo = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic.ExecuteResponse>(jobject["Data"].ToString()); |
| | | |
| | | //if (logic.logicExecuteRespo == null) |
| | |
| | | #region 时间点条件推迟执行 |
| | | else if (topic == gatewayID + "/" + "Logic/TimingWillArrive") |
| | | { |
| | | //var logic = new Logic() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID }; |
| | | //var logic = new Logic() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.GwId }; |
| | | //logic.timingWillArriveData = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic.TimingWillArriveData>(jobject["Data"].ToString()); |
| | | |
| | | //if (logic.timingWillArriveData == null) |
| | |
| | | #region 模式安防动作被最终激活时发送报警信息 |
| | | else if (topic == gatewayID + "/" + "Security/ModeTriggerReport") |
| | | { |
| | | var ias = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID }; |
| | | var ias = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.GwId }; |
| | | ias.modeTriggerReportData = Newtonsoft.Json.JsonConvert.DeserializeObject<Safeguard.ModeTriggerReportData>(jobject["Data"].ToString()); |
| | | if (ias.modeTriggerReportData == null) |
| | | { |
| | |
| | | #region 通过外部方式布防撤防成功时报告息 |
| | | else if (topic == gatewayID + "/" + "Security/EnOrWithdrawSucceedReport") |
| | | { |
| | | var ias = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID }; |
| | | var ias = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.GwId }; |
| | | ias.enOrWithdrawSucceedReportData = Newtonsoft.Json.JsonConvert.DeserializeObject<Safeguard.EnOrWithdrawSucceedReportData>(jobject["Data"].ToString()); |
| | | if (ias.enOrWithdrawSucceedReportData == null) |
| | | { |
| | |
| | | #region 胁迫密码撤防时短信推送 |
| | | else if (topic == gatewayID + "/" + "Security/PushTargetInfo") |
| | | { |
| | | var ias = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID }; |
| | | var ias = new Safeguard() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.GwId }; |
| | | ias.coercedPWDWithdrawReportData = Newtonsoft.Json.JsonConvert.DeserializeObject<Safeguard.CoercedPWDWithdrawReportData>(jobject["Data"].ToString()); |
| | | if (ias.coercedPWDWithdrawReportData == null) |
| | | { |
| | |
| | | /// </summary> |
| | | public void ReSave() |
| | | { |
| | | if (Shared.Common.Config.Instance.Home.IsShowTemplate == true) |
| | | { |
| | | //展示模板时,不允许保存文件(防止属性上报用的) |
| | | return; |
| | | } |
| | | Global.WriteFileByBytesByHomeId(FilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); |
| | | } |
| | | #endregion |
| | |
| | | #if DEBUG |
| | | if (flage == true) |
| | | { |
| | | if (msg.Contains("DeviceStatusReport") == false) |
| | | //if (msg.Contains("DeviceInfoRespon") == true) |
| | | { |
| | | System.Console.WriteLine(msg + " " + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond); |
| | | } |