From 5428935270159bfc42c2934ed7fb1091554fc9a4 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 09 七月 2020 17:12:42 +0800
Subject: [PATCH] 修改了 sokect

---
 ZigbeeApp/Shared/Common/Device.cs |   71 +++++++++++++++++++++++------------
 1 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index a436fb3..9ba510c 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -2179,12 +2179,21 @@
         private void InitRealDeviceRoomId()
         {
             this.dicDeviceRoomId = new Dictionary<string, string>();
-            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
-            var strData = UserCenterLogic.LoadFileContent(fullName);
+            string fullName = DirNameResourse.DeviceRoomIdFile;
+            var strData = HdlFileLogic.Current.ReadFileTextContent(fullName);
             if (strData != null)
             {
                 this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData);
             }
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍏ㄩ儴鐗╃悊璁惧鎵�灞炴埧闂寸殑璁板綍
+        /// </summary>
+        /// <returns></returns>
+        public Dictionary<string, string> GetAllRealDeviceRoomData()
+        {
+            return this.dicDeviceRoomId;
         }
 
         /// <summary>
@@ -2238,8 +2247,7 @@
             if (save == true)
             {
                 //淇濆瓨璁板綍
-                string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
-                UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
+                HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
 
                 //娣诲姞鑷姩澶囦唤
                 HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
@@ -2259,7 +2267,7 @@
                 return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
             }
             var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
-            return HdlRoomLogic.Current.GetFloorRoomName(room);
+            return HdlRoomLogic.Current.GetRoomName(room);
         }
 
         /// <summary>
@@ -2307,8 +2315,7 @@
                 return;
             }
             //淇濆瓨璁板綍
-            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
-            UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
+            HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
 
             //娣诲姞鑷姩澶囦唤
             HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
@@ -2891,23 +2898,17 @@
             else if (mainDevice.Type == DeviceType.OnOffOutput)
             {
                 //2020.05.13鍙樻洿:缁х數鍣ㄩ兘榛樿涓虹伅鍏�
-                //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
-                //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
+                if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�)
                 {
-                    if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�)
+                    mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+                    if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A鐏厜)
                     {
-                        mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
-                        if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A鐏厜)
-                        {
-                            //缁х數鍣ㄩ粯璁や负鐏厜
-                            this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A鐏厜);
-                        }
-                    }
-                    if (mainDevice.IsCustomizeImage == false)
-                    {
-                        mainDevice.IconPath = "Device/Light.png";
+                        //缁х數鍣ㄩ粯璁や负鐏厜
+                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A鐏厜);
                     }
                 }
+                //鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣
+                this.ResetIconPathByDeviceFunctionType(mainDevice);
             }
             //濡傛灉鏄┖姘斿紑鍏崇殑璇�
             else if (mainDevice.Type == DeviceType.AirSwitch)
@@ -2922,10 +2923,8 @@
                         this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A寮�鍏�);
                     }
                 }
-                if (mainDevice.IsCustomizeImage == false)
-                {
-                    mainDevice.IconPath = "Device/Switch.png";
-                }
+                //鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣
+                this.ResetIconPathByDeviceFunctionType(mainDevice);
             }
             //濡傛灉鏄僵鐏殑璇�
             else if (mainDevice.Type == DeviceType.ColorDimmableLight)
@@ -2944,6 +2943,30 @@
         }
 
         /// <summary>
+        /// 鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣
+        /// </summary>
+        /// <param name="device"></param>
+        private void ResetIconPathByDeviceFunctionType(CommonDevice device)
+        {
+            if (device.IsCustomizeImage == true)
+            {
+                return;
+            }
+            if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+            {
+                device.IconPath = "Device/Switch.png";
+            }
+            else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+            {
+                device.IconPath = "Device/Socket1.png";
+            }
+            else
+            {
+                device.IconPath = "Device/Light.png";
+            }
+        }
+
+        /// <summary>
         /// 鏍规嵁璁惧Type鍒涘缓瀵瑰簲鐨勮澶囧璞�
         /// </summary>
         /// <param name="deviceType">璁惧Type</param>

--
Gitblit v1.8.0