gxc
2020-01-02 00ab3ddb140ba8bb88b5cf572b004a85e1da85e9
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
@@ -93,6 +93,23 @@
                });
                return;
            }
            else if (topic == "/ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Deleted"
                || topic == "/ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/DeletedShareData")
            {
                if (UserCenterResourse.UserInfo.AuthorityNo == 3)
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        //分享数据已经变更,请重新登陆
                        string msg = Language.StringByID(R.MyInternationalizationString.uShardDataIsChangedPleaseLoginAgain);
                        var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
                        contr.Show();
                        UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
                    });
                }
                return;
            }
            try
            {
                if (HdlGatewayLogic.Current.IsGatewayExist(gatewayId) == false)
@@ -165,6 +182,11 @@
        /// <param name="receiveData"></param>
        private void DeviceAttributeReportPush(JObject receiveData)
        {
            if (this.dicDeviceEvent.Count == 0)
            {
                //没有添加监听
                return;
            }
            var deviceAddr = receiveData.Value<string>("DeviceAddr");
            var deviceEpoint = receiveData.Value<int>("Epoint");
@@ -227,8 +249,13 @@
        /// <param name="receiveData"></param>
        private void DeviceOnlineChangePush (JObject receiveData)
        {
            if (this.dicDeviceEvent.Count == 0)
            {
                //没有添加监听
                return;
            }
            var tempDevice = new CommonDevice() { DeviceAddr = receiveData.Value<string>("DeviceAddr"), DeviceEpoint = receiveData.Value<int>("Epoint") };
            tempDevice.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(receiveData["Data"]["IsOnline"].ToString());
            tempDevice.IsOnline = Convert.ToInt32(receiveData["Data"]["IsOnline"].ToString());
            
            this.DeviceReportPush(tempDevice, ReceiveComandDiv.A设备在线上报);
        }
@@ -391,6 +418,8 @@
        #endregion
        #region ■ 添加设备事件_______________________
        /// <summary>
@@ -470,14 +499,13 @@
        /// <param name="comand"></param>
        private void DeviceReportPush(CommonDevice common, ReceiveComandDiv comand)
        {
            if (this.dicDeviceEvent.Count == 0)
            {
                //没有添加监听
                return;
            }
            lock (this.dicDeviceEvent)
            {
                if (this.dicDeviceEvent.Count == 0)
                {
                    //没有添加监听
                    return;
                }
                var list = new List<Action<CommonDevice>>();
                foreach (string keys in this.dicDeviceEvent.Keys)
                {
@@ -490,23 +518,19 @@
                    list.Add(this.dicDeviceEvent[keys]);
                }
                //有可能在回调函数中移除了事件,导致报错,所以先收集,再调用
                Application.RunOnMainThread(() =>
                foreach (var action in list)
                {
                    foreach (var action in list)
                    try
                    {
                        try
                        {
                            action?.Invoke(common);
                        }
                        catch (Exception ex)
                        {
                            //Log出力
                            string msg = "当前激活的界面[" + UserCenterResourse.NowActionFormID + "]";
                            HdlLogLogic.Current.WriteLog(-1, msg);
                            HdlLogLogic.Current.WriteLog(ex);
                        }
                        action?.Invoke(common);
                    }
                });
                    catch (Exception ex)
                    {
                        //Log出力
                        string msg = "推送错误! 当前激活的界面[" + UserCenterResourse.NowActionFormID + "]";
                        HdlLogLogic.Current.WriteLog(ex, msg);
                    }
                }
            }
        }