From 8983da138cb92e35b0bbeaece1cf1c454a5a79d4 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期二, 01 十二月 2020 16:31:28 +0800
Subject: [PATCH] 20201201

---
 HDL_ON/Entity/Function/Scene.cs |  405 +++++++++++++++++++++++++++------------------------------
 1 files changed, 195 insertions(+), 210 deletions(-)

diff --git a/HDL_ON/Entity/Function/Scene.cs b/HDL_ON/Entity/Function/Scene.cs
index 500f47e..5869434 100644
--- a/HDL_ON/Entity/Function/Scene.cs
+++ b/HDL_ON/Entity/Function/Scene.cs
@@ -1,18 +1,83 @@
 锘縰sing System;
 using System.Collections.Generic;
+using Shared;
 
 namespace HDL_ON.Entity
 {
-    public class Scene : Function
+    public class Scene 
     {
-        public Scene()
+        /// <summary>
+        /// 杩滅鍞竴ID
+        /// </summary>
+        public string userSceneId = "";
+        /// <summary>
+        /// 鍦烘櫙sid
+        /// </summary>
+        public string sid = "";
+        /// <summary>
+        /// 鍦烘櫙鍚嶇О
+        /// </summary>
+        public string name = "";
+        /// <summary>
+        /// 缃戝叧ID
+        /// </summary>
+        public string gatewayId = "";
+        /// <summary>
+        /// 浜戠oss瀛樺偍鍥剧墖鐨勮矾寰�
+        /// </summary>
+        public string image = "";
+        /// <summary>
+        /// 鎵�灞炴埧闂村垪琛�
+        /// </summary>
+        public List<string> roomIds = new List<string>();
+        /// <summary>
+        /// 寤舵椂
+        /// </summary>
+        public int delay = 0;
+        /// <summary>
+        /// 寤舵椂鏄剧ず鐨勬枃鏈�
+        /// </summary>
+        [Newtonsoft.Json.JsonIgnore]
+        public string delayText
         {
+            get
+            {
+                string text = "";
+                switch (delay)
+                {
+                    case 0:
+                        text = Language.StringByID(StringId.NoDelay);
+                        break;
+                    case 30:
+                        text = "30s";
+                        break;
+                    case 60:
+                        text = "1min";
+                        break;
+                    case 120:
+                        text = "2min";
+                        break;
+                    case 300:
+                        text = "5min";
+                        break;
+                }
+                return text;
+            }
         }
 
+        /// <summary>
+        /// 鍦烘櫙鍒嗙粍
+        /// </summary>
+        public string group = "1";
         /// <summary>
         /// 鍦烘櫙绫诲瀷
         /// </summary>
         public SceneType sceneType = SceneType.OrdinaryScenes;
+        /// <summary>
+        /// 鏀惰棌鏍囪
+        /// </summary>
+        public bool collect = false;
+
 
         /// <summary>
         /// 鍦烘櫙鑳屾櫙
@@ -22,7 +87,11 @@
         /// <summary>
         /// 鍦烘櫙鍔熻兘鍒楄〃
         /// </summary>
-        public List<Function> sceneFunctionList = new List<Function>();
+        public List<SceneFunction> functions = new List<SceneFunction>();
+        /// <summary>
+        /// 鍦烘櫙鎺ㄩ�侀厤缃垪琛�
+        /// </summary>
+        public List<ScenePushConfig> pushConfigs = new List<ScenePushConfig>();
 
         /// <summary>
         /// 鐢熸垚鍦烘櫙sid
@@ -53,7 +122,7 @@
                 {
                     sTimeSpan = sTimeSpan.Substring(0, 8);
                 }
-                else 
+                else
                 {
                     sTimeSpan = "00000000";
                 }
@@ -79,213 +148,129 @@
             }
         }
 
+        /// <summary>
+        /// 鑾峰彇璁惧娣诲姞鍒版埧闂寸殑鎴块棿鍚嶇О
+        /// </summary>
+        /// <returns></returns>
+        public string GetRoomListName()
+        {
+            string roomNameList = "";
+            foreach (var roomId in roomIds)
+            {
+                var findRoom = DB_ResidenceData.rooms.Find(obj => obj.sid == roomId);
+                if (findRoom == null)
+                {
+                    continue;
+                }
+                if (roomNameList != "")
+                {
+                    roomNameList += ",";
+                }
+                roomNameList += findRoom.floorName + findRoom.name;
+            }
+            if (roomNameList == "" )
+            {
+                roomNameList = Shared.Language.StringByID(StringId.WholeHouseScene);
+            }
+            return roomNameList;
+        }
+
+        /// <summary>
+        /// 鏁版嵁瀛樺偍鏂囦欢鍚�
+        /// </summary>
+        [Newtonsoft.Json.JsonIgnore]
+        public string savePath
+        {
+            get
+            {
+                return "SceneData_" + sid;
+            }
+        }
+        /// <summary>
+        /// 淇濆瓨鍔熻兘鏁版嵁
+        /// </summary>
+        public void SaveSceneData()
+        {
+            var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
+            FileUtils.WriteFileByBytes(savePath + this.sid, ssd);
+            MainPage.Log($"Save Scene Data : {this.sid}");
+        }
+
+        /// <summary>
+        /// 鏇存柊鏃堕棿
+        /// </summary>
+        public DateTime refreshTime = DateTime.MinValue;
+    }
+    /// <summary>
+    /// 鍦烘櫙鍔熻兘瀵硅薄
+    /// </summary>
+    public class SceneFunction
+    {
+        public string sid = "";
+
+        public List<SceneFunctionStatus> status = new List<SceneFunctionStatus>();
+        /// <summary>
+        /// 鍔熻兘寤舵椂
+        /// </summary>
+        public string delay = "0";
+
+        Function _localFunction;
+        /// <summary>
+        /// 鏈湴瀵瑰簲鐨勫姛鑳�
+        /// </summary>
+        [Newtonsoft.Json.JsonIgnore]
+        public Function localFunction {
+            get
+            {
+                if(_localFunction == null)
+                {
+                    _localFunction = ConvertFunctionObject();
+                }
+                return _localFunction;
+            }
+        }
+
+        /// <summary>
+        /// 杞崲鎴愬姛鑳藉璞�
+        /// </summary>
+        /// <returns></returns>
+        Function ConvertFunctionObject()
+        {
+            var localFunction = DB_ResidenceData.functionList.GetAllDeviceFunctionList().Find((obj) => obj.sid == sid);
+            foreach (var s in status)
+            {
+                localFunction.attributes.Add(new FunctionAttributes() { key = s.key, curValue = s.value, value = new List<string>() { s.value } });
+            }
+            return localFunction;
+        }
+      
     }
 
+    /// <summary>
+    /// 鍦烘櫙鍔熻兘灞炴��
+    /// </summary>
+    public class SceneFunctionStatus
+    {
+        public string key = "";
+        public string value = "";
+    }
+    /// <summary>
+    /// 鍦烘櫙鎺ㄩ�侀厤缃�
+    /// </summary>
+    public class ScenePushConfig
+    {
+        /// <summary>
+        /// 鎺ㄩ�佹柟寮�
+        /// </summary>
+        public string pushMethod = "";
+        /// <summary>
+        /// 鎺ㄩ�佸唴瀹�
+        /// </summary>
+        public string pushContent = "";
+        /// <summary>
+        /// 鎺ㄩ�佺洰鏍囬泦鍚�
+        /// </summary>
+        public List<string> pushTarget = new List<string>();
+    }
 
 }
-//5.1.14鑾峰彇鍦烘櫙鍒楄〃
-//璇锋眰鍙傛暟
-//{
-//	"namespace": "HDL",
-//	"type": "scene",
-//	"command": "get_list"
-//}
-//杩斿洖鍊� json鏍煎紡 鎵�鏈夊満鏅痠d鍙婂満鏅噷鎵ц鐨勭洰鏍囨暟鎹�
-//杩斿洖渚嬪瓙
-//{
-//	"namespace": "HDL",
-//	"command": "get_list_respond",
-//	"type": "scene",
-//	"number": [{
-//		"scene_id": "0001",
-//		"scene_name": "dinner",
-//		"objects": [{
-//			   "sid": "00010019101209000025670100010001",
-//"data_type": "string ",
-//			"value": "on"
-//		  }]
-//	}]
-//}
-//璇存槑 鑾峰彇鍦烘櫙鍒楄〃鍜屽睘鎬э紝鍙紑锛屽彧鍏筹紝鏃㈠紑鍙堝叧
-	
-//5.1.15鍒涘缓鍦烘櫙
-//璇锋眰鍙傛暟
-//{
-//	"namespace": "HDL",
-//	"command": "create",
-//	"type": "scene",
-//	"objects": [{
-//		"scene_name": "Away ",
-//		"status": "single_off"
-//	}]
-//}
-//杩斿洖鍊� json鏍煎紡
-//杩斿洖渚嬪瓙	{
-//	"namespace": "HDL",
-//	"command": "create_respond",
-//	"type": "scene",
-//	"objects": [{
-//		"scene_id": "0004",
-//		"name": "Away",
-//		"status": "single_off"
-//	}]
-//}
-//璇存槑 鍒涘缓鍦烘櫙
-	
-//5.1.16娣诲姞鐩爣鍒板満鏅�
-//璇锋眰鍙傛暟
-//{
-//	"namespace": "HDL",
-//	"command": "add_member",
-//	"type": "scene",
-//	"number": [{
-//		"scene_id": "0001",
-//		"objects": [{
-//			"sid": "00010019101209000025670100010001",
-//			"function": [{
-//				"attri": "switch",
-//"data_type": "string ",
-//				"value": "on"
-//			}]
-
-//		}]
-//	}, {
-//		"scene_id": "0002",
-//		"objects": [{
-//			"sid": "00010019101209000025670200010001",
-//			"function": [{
-//				"attri": "brightness",
-//"data_type": "int",
-//				"value": 50
-//			}]
-//		}]
-//	}]
-//}
-//杩斿洖鍊� json鏍煎紡
-//杩斿洖渚嬪瓙	{
-//	"namespace": "HDL",
-//	"command": "add_member_respond",
-//	"type": "scene",
-//	"scene_id": "0001",
-//	"value": "success"
-//}
-//璇存槑 鎴愬姛娣诲姞鐩爣鐨勫満鏅垪琛�
-	
-//5.1.17鍒犻櫎鍦烘櫙鍛戒护
-//璇锋眰鍙傛暟
-//{
-//	"namespace": "HDL",
-//	"command": "delete",
-//	"type": "scene",
-//	"objects": [{
-//		"scene_id": "0001"
-//	}]
-//}
-//杩斿洖鍊� json鏍煎紡
-//杩斿洖渚嬪瓙	{
-//	"namespace": "HDL",
-//	"command": "delete_respond",
-//	"type": "scene",
-//	"scene_id": "0001",
-//	"value": "success"
-//}
-//璇存槑 鍒犻櫎鍦烘櫙
-	
-//5.1.18鍒犻櫎鍦烘櫙閲岀殑鐩爣
-//璇锋眰鍙傛暟
-//{
-//	"Namespace": "HDL",
-//	"Command": "delete_member",
-//	"type": "scene",
-//	"number": [{
-//		"scene_id": "0001",
-//		"objects": [{
-//			"sid": "00010019101209000025670100010001"
-//		}, {
-//			"sid": "00010019101209000025670100010002"
-//		}]
-//	}]
-//}
-//杩斿洖鍊� json鏍煎紡
-//杩斿洖渚嬪瓙	{
-//	"namespace": "HDL",
-//	"command": "delete_member_respond",
-//	"type": "scene",
-//	"scenesid": "0001",
-//	"sid": "00010019101209000025670100010001",
-//	"value": "success"
-//}
-//璇存槑 鍒犻櫎鍦烘櫙鍐呰澶�
-	
-//5.1.19閰嶇疆鍦烘櫙鍒嗙粍锛堣冻鍐呭満鏅姸鎬佽嚜鍔ㄨ褰曟渶鍚庝竴娆¤褰曪級
-//璇锋眰鍙傛暟	{
-//	"namespace": "HDL",
-//	"command": "group",
-//	"type": "scene",
-//	"objects": [{
-//		"group_id": 1,
-//		"scene_ids": [{
-//			"scene_id": "0001"
-//		}, {
-//			"scene_id": "0002"
-//		}]
-//	}]
-//}
-//杩斿洖鍊� json鏍煎紡
-//杩斿洖渚嬪瓙	{
-//	"namespace": "HDL",
-//	"command": "group_respond",
-//	"type": "scene",
-//	"group_id": "0001",
-//	"value": "success"
-//}
-//璇存槑 鎺у埗鍦烘櫙
-	
-
-//5.1.20璇诲彇鍦烘櫙鍒嗙粍
-//璇锋眰鍙傛暟
-//{
-//	"namespace": "HDL",
-//	"command": "read_group",
-//	"type": "scene",
-//	"objects": [{
-//		"group_id": 1
-//	}]
-//}
-//杩斿洖鍊� json鏍煎紡
-//杩斿洖渚嬪瓙	{
-//	"namespace": "HDL",
-//	"command": "read_group_respond",
-//	"type": "scene",
-//	"objects": [{
-//		"group_id": 1,
-//		"scene_ids": [{
-//			"scene_id": "0001"
-//		}, {
-//			"scene_id": "0002"
-//		}]
-//	}]
-//}
-//璇存槑 鎺у埗鍦烘櫙
-	
-
-//5.1.21鎺у埗鍦烘櫙
-//璇锋眰鍙傛暟
-//{
-//	"namespace": "HDL",
-//	"command": "contrl",
-//	"type": "scene",
-//	"objects": [{
-//		"scene_id": "0001",
-//		"value": 鈥渙n鈥�
-//	}]
-//}
-//杩斿洖鍊� json鏍煎紡
-//杩斿洖渚嬪瓙	{
-//	"namespace": "HDL",
-//	"command": "contrl_respond",
-//	"type": "scene",
-//		"scene_id": "0001",
-//		"value": "success"
-//}
-//璇存槑 鎺у埗鍦烘櫙
\ No newline at end of file

--
Gitblit v1.8.0