黄学彪
2020-04-15 23532fa8ad34c89b6d24b01eaef6475fd0aad898
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
@@ -93,10 +93,36 @@
                });
                return;
            }
            else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Deleted"
                || topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/DeletedShareData")
            else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Home.Id + "_" + Common.Config.Instance.Guid + "/PrimaryUserDelYou")
            {
                if (UserCenterResourse.UserInfo.AuthorityNo == 3)
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //分享住宅已更改,请联系管理员!
                    string msg = Language.StringByID(R.MyInternationalizationString.uShardResidenceHadDeletePleaseTakeToAdmin);
                    var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
                    contr.Show();
                    UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
                });
                return;
            }
            else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Update")
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //您的权限已经变更,请重新登陆
                    string msg = Language.StringByID(R.MyInternationalizationString.uYouAccessHadChangedPleaseTakeToAdmin);
                    var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
                    contr.Show();
                    UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
                });
                return;
            }
            else if (UserCenterResourse.UserInfo.AuthorityNo == 3)
            {
                if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Deleted"
                || topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/DeletedShareData")
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
@@ -107,9 +133,10 @@
                        UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
                    });
                    return;
                }
                return;
            }
            try
            {
                if (HdlGatewayLogic.Current.IsGatewayExist(gatewayId) == false)
@@ -131,7 +158,7 @@
                //门锁上报
                else if (topic == gatewayId + "/Alarms/SendAlarmInform")
                {
                    this.DoorLockDeviceReportPush(null);
                    this.DoorLockDeviceReportPush(JObject.Parse(msgData));
                }
                //通过外部方式布防撤防成功时报告
                else if (topic == gatewayId + "/Security/EnOrWithdrawSucceedReport")
@@ -290,6 +317,24 @@
                            //已经接收到状态
                            locadevice.HadReadDeviceStatu = true;
                        }
                        else if (attData.AttributeId == 4097)
                        {
                            //过虑网清洗标志:42
                            ((AC)locadevice).CleanStatu = attData.AttriButeData == 42;
                        }
                        else if (attData.AttributeId == 4099)
                        {
                            //转换为二进制
                            var value = Convert.ToString(attData.AttriButeData, 2).PadLeft(16, '0');
                            //这五个设置是放在后面的
                            value = value.Substring(value.Length - 5, 5);
                            for (int i = 0; i < value.Length; i++)
                            {
                                //自定义的空调模式
                                ((AC)locadevice).listSupportMode[i] = Convert.ToInt32(value[i].ToString());
                            }
                            locadevice.ReSave();
                        }
                    }
                }
                //空调数据
@@ -312,6 +357,16 @@
                            //已经接收到状态
                            locadevice.HadReadDeviceStatu = true;
                        }
                        else if (attData.AttributeId == 4097)
                        {
                            //转换为二进制
                            var value = Convert.ToString(attData.AttriButeData, 2).PadLeft(16, '0');
                            //这个设置是放在后面的
                            value = value.Substring(value.Length - 1, 1);
                            //启用摆风功能
                            ((AC)locadevice).UseSwingFunction = value == "1";
                            locadevice.ReSave();
                        }
                    }
                }
                #endregion
@@ -321,7 +376,7 @@
                else if (report.DeviceStatusReport.CluterID == 8)
                {
                    locadevice.DeviceStatusReport = report.DeviceStatusReport;
                    if (report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
                    if (locadevice.Type == DeviceType.DimmableLight && report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
                    {
                        //此属性表明当前亮度程度
                        ((DimmableLight)locadevice).Level = report.DeviceStatusReport.AttriBute[0].AttriButeData;
@@ -442,9 +497,25 @@
        /// <param name="receiveData"></param>
        private void DoorLockDeviceReportPush(JObject receiveData)
        {
            //保存门锁信息到本地
            //HdlAlarmsLogic.Current.SaveDoorLockAlarmInfo(receiveData);
            //只有徐梅的门锁界面没有打开的情况下,才会处理这个东西
            if (ControlCommonResourse.IsDoorLockPageOpen == false)
            {
                var device = Common.LocalDevice.Current.GetDevice(receiveData.Value<string>("DeviceAddr"), receiveData.Value<int>("Epoint"));
                if ((device is ZigBee.Device.DoorLock) == false)
                {
                    //它不是门锁
                    return;
                }
                var info = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLockAlarmsResult>(receiveData["Data"].ToString());
                if (info.Clusterid == 257)
                {
                    //常开模式开启
                    if (info.AlarmCode == 216)
                    {
                        DoorLock.DoorLockCommonInfo.NomallyOpenModeInvalidDialog((ZigBee.Device.DoorLock)device, DoorLock.DoorLockCommonInfo.DoorLockMessType.ServicePush, null);
                    }
                }
            }
            //显示有新消息的特效
            this.ShowHadNewMessageAppeal();
        }
@@ -744,19 +815,23 @@
                //没有添加监听
                return;
            }
            lock (this.dicDeviceEvent)
            //lock (this.dicDeviceEvent)
            {
                var list = new List<Action<CommonDevice>>();
                foreach (string keys in this.dicDeviceEvent.Keys)
                try
                {
                    if (this.dicCommandDiv[keys] != comand)
                    foreach (string keys in this.dicDeviceEvent.Keys)
                    {
                        //命令区分不一致,则不调用回调函数
                        continue;
                        if (this.dicCommandDiv[keys] != comand)
                        {
                            //命令区分不一致,则不调用回调函数
                            continue;
                        }
                        //命令区分一致时,则调用回调函数
                        list.Add(this.dicDeviceEvent[keys]);
                    }
                    //命令区分一致时,则调用回调函数
                    list.Add(this.dicDeviceEvent[keys]);
                }
                catch { return; }
                //有可能在回调函数中移除了事件,导致报错,所以先收集,再调用
                foreach (var action in list)
                {