From 5ec581e5d37b108fc9d59e89afd8e94e21b32080 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期二, 17 十月 2023 17:33:36 +0800
Subject: [PATCH] 2023年10月17日17:33:33

---
 HDL_ON/DAL/DriverLayer/Control.cs |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index c9f3c21..6955fab 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -626,6 +626,10 @@
             {
                 foreach (var temp in functions)
                 {
+                    if((temp.trait_on_off.state.ToString() ==  "on" && open)|| temp.trait_on_off.state.ToString() == "off"&& !open)
+                    {
+                        continue;
+                    }
                     var apiControlData = temp.GetApiControlData(d);
                     actionObjs.Add(apiControlData);
                     count++;
@@ -637,7 +641,10 @@
                         System.Threading.Thread.Sleep(100);
                     }
                 }
-                var pack = pm.ControlDevice(actionObjs);
+                if (actionObjs.Count > 0)
+                {
+                    var pack = pm.ControlDevice(actionObjs);
+                }
             }
         }
 
@@ -725,8 +732,18 @@
                 }
                 else
                 {
-                    var pm = new DAL.Server.HttpServerRequest();
-                    var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId });
+                    var pm = new HttpServerRequest();
+                    try
+                    {
+                        pm.RefreshDeviceStatus(new List<string>() { function.deviceId });
+                    }catch(Exception ex)
+                    {
+                        MainPage.Log($"杩滅▼璇诲彇璁惧鐘舵�佸紓甯�:{ex.Message}");
+                    }
+                    finally
+                    {
+                        pm = null;
+                    }
                 }
             }
         }
@@ -863,7 +880,7 @@
                         },
                     time_stamp = Utlis.GetTimestamp()
                 };
-                var aLinkJson = Newtonsoft.Json.JsonConvert.SerializeObject(aLinkData);
+                var aLinkJson = JsonConvert.SerializeObject(aLinkData);
                 var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlScene, aLinkJson);
                 new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id, 0);
             }
@@ -1305,16 +1322,6 @@
                         }
                         MainPage.Log(localFunction.name);
 
-                        if (Ins.GatewayOnline_Local && isCloudData)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�
-                        {
-                            if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains(localFunction.spk))
-                            {
-                                //MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�........");
-
-                                return;
-                            }
-                        }
-
                         //if (SPK.MusicSpkList().Contains(localFunction.spk))
                         //{
                         //    if (updateTemp.status.Count < 3)
@@ -1335,6 +1342,11 @@
                         {
                             localFunction.online = updateTemp.online;
                         }
+                        if (SPK.LightSpkList().Contains(localFunction.spk))
+                        {
+                            localFunction.updateTime = DateTime.Now;
+                        }
+                       
 
                         //鏇存柊鐣岄潰鐘舵��
                         switch (localFunction.spk)
@@ -1599,6 +1611,7 @@
                                 break;
                         }
 
+                        
                         HomePage.UpdataFunctionStates(localFunction);
                         RoomPage.UpdataStates(localFunction);
                         FunctionPage.UpdataStates(localFunction);

--
Gitblit v1.8.0