xm
2020-05-07 c1de48884fa145a16a0f8bcee93274dcfaa0ff82
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
old mode 100755 new mode 100644
@@ -93,6 +93,32 @@
                });
                return;
            }
            else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Home.Id + "_" + Common.Config.Instance.Guid + "/PrimaryUserDelYou")
            {
                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"
@@ -102,19 +128,6 @@
                    {
                        //分享数据已经变更,请重新登陆
                        string msg = Language.StringByID(R.MyInternationalizationString.uShardDataIsChangedPleaseLoginAgain);
                        var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
                        contr.Show();
                        UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
                    });
                    return;
                }
                else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Home.Id + "_" + Common.Config.Instance.Guid + "/PrimaryUserDelYou")
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        //分享住宅已更改,请联系管理员!
                        string msg = Language.StringByID(R.MyInternationalizationString.uShardResidenceHadDeletePleaseTakeToAdmin);
                        var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
                        contr.Show();
@@ -175,7 +188,7 @@
                //逻辑触发上报
                else if (topic == gatewayId + "/Logic/Execute_Respon")
                {
                    this.LogicExecutePush(null);
                    this.LogicExecutePush(JObject.Parse(msgData));
                }
                //场景触发上报
                else if (topic == gatewayId + "/Scene/Exec_Respon")
@@ -261,7 +274,7 @@
                }
                #endregion
                #region ■ 空调数据
                #region ■ 空调和新风数据
                //空调数据
                else if (report.DeviceStatusReport.CluterID == 513)
                {
@@ -330,29 +343,59 @@
                    locadevice.DeviceStatusReport = report.DeviceStatusReport;
                    foreach (var attData in report.DeviceStatusReport.AttriBute)
                    {
                        if (attData.AttributeId == 0)
                        //区分是空调还是新风
                        var device = Shared.Common.LocalDevice.Current.GetDevice(report.DeviceAddr, report.DeviceEpoint);
                        if (device.Type == DeviceType.FreshAir)
                        {
                            //风扇模式
                            ((AC)locadevice).currentFanMode = attData.AttriButeData;
                            //已经接收到状态
                            locadevice.HadReadDeviceStatu = true;
                            if (attData.AttributeId == 0)
                            {
                                switch (attData.AttriButeData)
                                {
                                    case 0:
                                    case 4:
                                        ((FreshAir)locadevice).currentFanStatus = attData.AttriButeData;
                                        break;
                                    case 1:
                                    case 2:
                                    case 3:
                                        ((FreshAir)locadevice).currentFanSpeed = attData.AttriButeData;
                                        break;
                                    case 5:
                                    case 15:
                                        ((FreshAir)locadevice).currentFanMode = attData.AttriButeData;
                                        break;
                                }
                                //已经接收到状态
                                locadevice.HadReadDeviceStatu = true;
                            }
                        }
                        else if (attData.AttributeId == 4096)
                        else
                        {
                            //风扇扫风
                            ((AC)locadevice).currentFanSwingMode = attData.AttriButeData;
                            //已经接收到状态
                            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();
                            if (attData.AttributeId == 0)
                            {
                                //风扇模式
                                ((AC)locadevice).currentFanMode = attData.AttriButeData;
                                //已经接收到状态
                                locadevice.HadReadDeviceStatu = true;
                            }
                            else if (attData.AttributeId == 4096)
                            {
                                //风扇扫风
                                ((AC)locadevice).currentFanSwingMode = attData.AttriButeData;
                                //已经接收到状态
                                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();
                            }
                        }
                    }
                }
@@ -464,6 +507,8 @@
            if (locadevice != null)
            {
                ((IASZone)locadevice).iASInfo = ias.iASInfo;
                //如果接收到上报,即说明这个传感器是在线的
                locadevice.IsOnline = 1;
                //记录回复时间
                locadevice.LastDateTime = DateTime.Now;
            }
@@ -485,10 +530,10 @@
        private void DoorLockDeviceReportPush(JObject receiveData)
        {
            //只有徐梅的门锁界面没有打开的情况下,才会处理这个东西
            if (ControlCommonResourse.IsDoorLockPageOpen == false)
            if (ControlCommonResourse.IsDoorLockPageOpen == false && UserCenterResourse.UserInfo.AuthorityNo == 1)
            {
                var device = Common.LocalDevice.Current.GetDevice(receiveData.Value<string>("DeviceAddr"), receiveData.Value<int>("Epoint"));
                if ((device is ZigBee.Device.DoorLock) == false)
                if (device.Type != DeviceType.DoorLock)
                {
                    //它不是门锁
                    return;
@@ -496,10 +541,21 @@
                var info = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLockAlarmsResult>(receiveData["Data"].ToString());
                if (info.Clusterid == 257)
                {
                    //常开模式开启
                    if (info.AlarmCode == 216)
                    //常开模式关闭
                    if (info.AlarmCode == 217 || info.AlarmCode == 219)
                    {
                        DoorLock.DoorLockCommonInfo.NomallyOpenModeInvalidDialog((ZigBee.Device.DoorLock)device, DoorLock.DoorLockCommonInfo.DoorLockMessType.ServicePush, null);
                        HdlThreadLogic.Current.RunThread(async () =>
                        {
                            //温居城的要网关中是否有逻辑存在
                            //参数:2-常开自动化;3-失效时间自动化
                            var result = await Shared.Phone.Device.Logic.SkipView.Exist(2);
                            HdlThreadLogic.Current.RunMain(() =>
                            {
                                //弹出徐梅的那个窗口
                                DoorLock.DoorLockCommonInfo.NomallyOpenModeInvalidDialog((ZigBee.Device.DoorLock)device, DoorLock.DoorLockCommonInfo.DoorLockMessType.ServicePush,
                                    result != 0 ? true : false, null);
                            });
                        });
                    }
                }
            }
@@ -515,7 +571,7 @@
        /// 设备在线状态更新反馈
        /// </summary>
        /// <param name="receiveData"></param>
        private void DeviceOnlineChangePush (JObject receiveData)
        private void DeviceOnlineChangePush(JObject receiveData)
        {
            if (this.dicDeviceEvent.Count == 0)
            {
@@ -692,10 +748,30 @@
        /// <param name="receiveData"></param>
        private void LogicExecutePush(JObject receiveData)
        {
            //目前不处理逻辑上报内容
            //显示有新消息的特效
            this.ShowHadNewMessageAppeal();
            //这个东西暂时不处理
            ////只有徐梅的门锁界面没有打开的情况下,才会处理这个东西
            //if (ControlCommonResourse.IsDoorLockPageOpen == false && UserCenterResourse.UserInfo.AuthorityNo == 1)
            //{
            //    var device = Common.LocalDevice.Current.GetDevice(receiveData.Value<string>("DeviceAddr"), receiveData.Value<int>("Epoint"));
            //    if (device.Type != DeviceType.DoorLock)
            //    {
            //        return;
            //    }
            //    //自动化执行 常开关闭
            //    var data = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicPushResult>(receiveData["Data"].ToString());
            //    if (data.ActionData != null && data.ActionData.Actiontype == 8
            //        && data.ActionData.PassDataString == "055704010113")
            //    {
            //        HdlThreadLogic.Current.RunMain(() =>
            //        {
            //            //弹出徐梅的那个窗口
            //            DoorLock.DoorLockCommonInfo.NomallyOpenModeInvalidDialog((ZigBee.Device.DoorLock)device, DoorLock.DoorLockCommonInfo.DoorLockMessType.ServicePush, null);
            //        });
            //    }
            //}
        }
        #endregion
@@ -802,19 +878,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)
                {