gxc
2019-10-29 ed2f4a97aa48cdb4a013d2a389877f52eb3eccdf
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
@@ -95,12 +95,11 @@
            //初始化搜索控件
            this.InitSearchControl();
            new System.Threading.Thread(() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                //初始化设备列表控件
                this.InitDeviceListControl();
            })
            { IsBackground = true }.Start();
            });
        }
        #endregion
@@ -304,7 +303,10 @@
        private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device)
        {
            var rowInfo = this.dicRowInfo[device.DeviceAddr];
            rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>();
            if (rowInfo.dicDetailRow == null)
            {
                rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>();
            }
            //行控件
            var rowDevice = new DeviceRoomControl(device, frame.rowSpace / 2);
@@ -315,6 +317,8 @@
            rowDevice.frameTable.AddBottomLine();
            //右箭头
            rowDevice.frameTable.AddRightArrow();
            //在线状态
            rowDevice.isOnline = device.IsOnline == 1;
            //保存控件
            string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
@@ -416,7 +420,7 @@
            }
            string selectGwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
            new System.Threading.Thread(() =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                ZbGateway zbGateway = HdlGatewayLogic.Current.GetLocalGateway(selectGwId);
                if (zbGateway == null)
@@ -436,8 +440,7 @@
                        this.StartDeviceListControlThread(online);
                    }
                });
            })
            { IsBackground = true }.Start();
            });
        }
        /// <summary>
@@ -519,33 +522,32 @@
                return;
            }
            string gwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
            new System.Threading.Thread(async () =>
            HdlThreadLogic.Current.RunThread(async () =>
            {
                //这里主要只是获取在线状态
                var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId);
                var result = await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, this.ReceiveDeviceStatuPush);
            })
            { IsBackground = true }.Start();
                var result = await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
            });
        }
        /// <summary>
        /// 接受设备在线推送(网关在线推送即在线)
        /// 接受设备在线推送
        /// </summary>
        /// <param name="device"></param>
        private void ReceiveDeviceStatuPush(CommonDevice device)
        {
            lock (dicRowInfo)
            {
                if (device == null || this.Parent == null)
                if (this.Parent == null)
                {
                    return;
                }
                DeviceObjectControl row = null;
                DeviceObjRowInfo rowInfo = null;
                if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true)
                {
                    row = this.dicRowInfo[device.DeviceAddr].MenuRow;
                    rowInfo = this.dicRowInfo[device.DeviceAddr];
                }
                if (row == null)
                if (rowInfo == null || rowInfo.MenuRow == null)
                {
                    return;
                }
@@ -564,11 +566,18 @@
                    localDevice.ReSave();
                }
                Application.RunOnMainThread(() =>
                HdlThreadLogic.Current.RunMain(() =>
                {
                    if (row != null)
                    if (rowInfo != null)
                    {
                        row.isOnline = device.IsOnline == 1;
                        rowInfo.MenuRow.isOnline = device.IsOnline == 1;
                        if (rowInfo.dicDetailRow != null)
                        {
                            foreach (var detailRow in rowInfo.dicDetailRow.Values)
                            {
                                detailRow.isOnline = rowInfo.MenuRow.isOnline;
                            }
                        }
                    }
                });
            }
@@ -604,7 +613,7 @@
        /// <param name="list">ota设备</param>
        private void CheckDeviceNewVersion(List<OTADevice> list)
        {
            new System.Threading.Thread(async () =>
            HdlThreadLogic.Current.RunThread(async () =>
            {
                await System.Threading.Tasks.Task.Delay(2000);
                foreach (var ota in list)
@@ -644,8 +653,7 @@
                        }
                    });
                }
            })
            { IsBackground = true }.Start();
            });
        }
        #endregion
@@ -711,11 +719,9 @@
        /// <param name="listDevice"></param>
        private void MargeAllDeviceByMac(List<CommonDevice> listDevice)
        {
            //设备排序
            List<CommonDevice> listSort = Common.LocalDevice.Current.SortDeviceList(listDevice);
            //根据Mac全部分组
            var dic = new Dictionary<string, List<CommonDevice>>();
            foreach (CommonDevice device in listSort)
            foreach (CommonDevice device in listDevice)
            {
                if (device == null || device.DeviceAddr == null)
                {
@@ -762,11 +768,11 @@
        /// <summary>
        /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
        /// </summary>
        public override void FormActionAgainEvent()
        public override int FormActionAgainEvent()
        {
            if (this.nowActionDeviceMac == null)
            {
                return;
                return 1;
            }
            var rowInfo = this.dicRowInfo[nowActionDeviceMac];
            //检测这个设备是否被删除
@@ -795,6 +801,8 @@
            this.nowActionDeviceMac = null;
            //网关控件刷新
            this.gatewayViewRow.RefreshControl();
            return 1;
        }
        #endregion