黄学彪
2020-06-18 2450c12c825ad4d78d1572da2fa421706db2df2f
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs
@@ -15,7 +15,7 @@
        /// <summary>
        /// 新上报的设备
        /// </summary>
        private Dictionary<string, List<CommonDevice>> dicNewDevice = new Dictionary<string, List<CommonDevice>>();
        private List<CommonDevice> listNewDevice = new List<CommonDevice>();
        /// <summary>
        /// 显示设备线程是否已经开启
        /// </summary>
@@ -106,6 +106,7 @@
            //进度条
            this.btnProgressBar = new ProgressRowBar(559, 29);
            btnProgressBar.ProgressBarGoback = false;
            btnProgressBar.Gravity = Gravity.CenterHorizontal;
            btnProgressBar.Y = Application.GetRealHeight(861);
            bodyFrameLayout.AddChidren(btnProgressBar);
@@ -154,50 +155,42 @@
                return;
            }
            lock (this.dicNewDevice)
            var jobject = Newtonsoft.Json.Linq.JObject.Parse(resultData);
            CommonDevice.DeviceInfoData info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(jobject["Data"].ToString());
            if (info.DriveCode != 0)
            {
                var jobject = Newtonsoft.Json.Linq.JObject.Parse(resultData);
                CommonDevice.DeviceInfoData info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(jobject["Data"].ToString());
                if (info.DriveCode != 0)
                {
                    //不需要虚拟设备
                    return;
                }
                //根据设备Type创建对应的设备对象
                var device = Common.LocalDevice.Current.NewDeviceObjectByDeviceId((DeviceType)jobject.Value<int>("Device_ID"));
                if (device == null)
                {
                    return;
                }
                device.DeviceInfo = info;
                //给新设备设置主键属性
                Common.LocalDevice.Current.SetNewDeviceMainKeys(device, jobject);
                device.CurrentGateWayId = this.realGateway.GwId;
                //将DeviceInfo的属性设置到主属性中
                Common.LocalDevice.Current.SetDeviceInfoToMain(device, device);
                //添加设备的缓存
                device.IsOnline = 1;
                Common.LocalDevice.Current.AddDeviceToMemory(ref device);
                if (this.dicNewDevice.ContainsKey(device.DeviceAddr) == false)
                {
                    this.dicNewDevice[device.DeviceAddr] = new List<CommonDevice>();
                }
                //刷新超时时间
                this.waitDeviceTimeOut = 20;
                //获取设备的固定属性
                HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device);
                //不需要200端点的那个设备  2020.01.13 变更:ota也加进来
                this.dicNewDevice[device.DeviceAddr].Add(device);
                //有新设备,开启显示设备信息界面的线程(里面会等待三秒这样)
                this.StartShowDeviceAddSuccessFormThread();
                //不需要虚拟设备
                return;
            }
            //根据设备Type创建对应的设备对象
            var device = Common.LocalDevice.Current.NewDeviceObjectByDeviceId((DeviceType)jobject.Value<int>("Device_ID"));
            if (device == null)
            {
                return;
            }
            device.DeviceInfo = info;
            //给新设备设置主键属性
            Common.LocalDevice.Current.SetNewDeviceMainKeys(device, jobject);
            device.CurrentGateWayId = this.realGateway.GwId;
            //将DeviceInfo的属性设置到主属性中
            Common.LocalDevice.Current.SetDeviceInfoToMain(device, device);
            //添加设备的缓存
            device.IsOnline = 1;
            Common.LocalDevice.Current.AddDeviceToMemory(ref device);
            //刷新超时时间
            this.waitDeviceTimeOut = 20;
            //获取设备的固定属性
            HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device);
            //不需要200端点的那个设备  2020.01.13 变更:ota也加进来
            this.listNewDevice.Add(device);
            //有新设备,开启显示设备信息界面的线程(里面会等待三秒这样)
            this.StartShowDeviceAddSuccessFormThread();
        }
        #endregion
@@ -231,22 +224,25 @@
                //目前就弄一个
                Application.RunOnMainThread(() =>
                {
                    foreach (var listDevice in this.dicNewDevice.Values)
                    var listDevice = new List<CommonDevice>();
                    for (int i = 0; i < this.listNewDevice.Count; i++)
                    {
                        //重新变更UI
                        foreach (var device in listDevice)
                        var device = this.listNewDevice[i];
                        if (device.DeviceAddr != this.listNewDevice[0].DeviceAddr)
                        {
                            if (device is OTADevice)
                            {
                                continue;
                            }
                            device.IconPath = string.Empty;
                            device.ReSave();
                            continue;
                        }
                        //显示设备信息画面
                        this.ShowDeviceAddSuccessForm(listDevice);
                        break;
                        listDevice.Add(device);
                        //重新变更UI
                        if (device is OTADevice)
                        {
                            continue;
                        }
                        device.IconPath = string.Empty;
                        device.ReSave();
                    }
                    //显示设备信息画面
                    this.ShowDeviceAddSuccessForm(listDevice);
                });
            });
        }