WJC
2019-12-30 f1c3921b08bb22ac6f5db22d620e01d7e8e5c49f
ZigbeeApp/Shared/Common/Device.cs
@@ -251,7 +251,7 @@
                //添加缓存
                this.AddDeviceToMemory(ref device);
                //移除存在的设备内存
                //移除存在的设备内存
                string maikey = this.GetDeviceMainKeys(device);
                if (dicExist.ContainsKey(maikey) == true)
                {
@@ -454,6 +454,11 @@
                }
                //备份数据
                await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac名称, newMacName);
                //如果它只有一个回路,则更改端点名字
                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
                {
                    return await this.ReName(device, newMacName);
                }
            }
            return true;
        }
@@ -739,6 +744,20 @@
                return -1;
            });
            return list;
        }
        /// <summary>
        /// 根据MAC地址,获取全部回路的数量
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
        /// <returns></returns>
        public int GetDevicesCountByMac(string DeviceAddr)
        {
            if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
            {
                return 0;
            }
            return dicDeviceEpoint[DeviceAddr].Count;
        }
        /// <summary>
@@ -1505,18 +1524,25 @@
        /// </summary>
        /// <param name="listDevice">需要保存的设备对象</param>
        /// <param name="roomId">需要保存的哪个设备的房间ID</param>
        public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId)
        /// <param name="saveRoadDevice">如果只有一个回路,是否把回路的房间一起修改</param>
        public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true)
        {
            this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
            if (listDevice != null)
            {
                this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
            }
            //保存记录
            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
            UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
            //添加自动备份
            HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
            //如果设备只有一个回路,如果改变了真实设备区域,则它的回路的区域也一起改了
            if (listDevice.Count == 1)
            if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
            {
                Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId);
                Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId, false);
            }
        }