From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期四, 25 七月 2024 17:25:59 +0800 Subject: [PATCH] 2024年07月25日17:24:45 --- HDL_ON/Entity/Function/Scene.cs | 392 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 324 insertions(+), 68 deletions(-) diff --git a/HDL_ON/Entity/Function/Scene.cs b/HDL_ON/Entity/Function/Scene.cs index 75742dc..9b57845 100644 --- a/HDL_ON/Entity/Function/Scene.cs +++ b/HDL_ON/Entity/Function/Scene.cs @@ -3,6 +3,7 @@ using HDL_ON.Common; using HDL_ON.DAL.Server; using HDL_ON.UI; +using HDL_ON.UI.UI2.Intelligence.Automation; using Shared; namespace HDL_ON.Entity @@ -14,7 +15,7 @@ { get { - if(_ScenePack == null) + if (_ScenePack == null) { _ScenePack = new SceneApiPack(); } @@ -24,7 +25,7 @@ } - public class Scene + public class Scene { public Scene() { @@ -50,10 +51,6 @@ /// 缃戝叧ID /// </summary> public string gatewayId = ""; - /// <summary> - /// 浜戠oss瀛樺偍鍥剧墖鐨勮矾寰� - /// </summary> - public string image = ""; /// <summary> /// 鎵�灞炴埧闂村垪琛� /// </summary> @@ -90,11 +87,24 @@ /// 鏄惁鍏佽鍒犻櫎 /// </summary> public bool can_delete = true; + /// <summary> + /// 鏄惁鍏佽缂栬緫 + /// </summary> + public bool can_edit = true; + /// <summary> + /// 鏄惁鏄綉鍏虫湰鍦板満鏅� + /// </summary> + public bool local = false; /// <summary> /// 鍒涘缓璇ュ満鏅殑鐢ㄦ埛ID /// </summary> public string userId = UserInfo.Current.ID; + + /// <summary> + /// 浜戠oss瀛樺偍鍥剧墖鐨勮矾寰� + /// </summary> + public string image = "Intelligence/Gallery/scenebg1.png"; ///// <summary> ///// 鍦烘櫙鑳屾櫙 @@ -103,21 +113,117 @@ { get { - if (string.IsNullOrEmpty(image)) + //if (string.IsNullOrEmpty(image)) + //{ + // return "Intelligence/Gallery/scenebg1.png"; + //} + //else + //{ + // return image; + //} + if(image == "") { - return "Intelligence/Gallery/scenebg1.png"; + image = "Intelligence/Gallery/scenebg1.png"; + } + + if (image.Contains("Intelligence/Gallery/scenebg")) + { + return image; } else { + var sceneImageInfo = OssSceneImages.Find((obj) => obj.defaultIconUrl == image); + if (sceneImageInfo != null) + { + return sceneImageInfo.localUrl; + } return image; } } set { - image = value; + var sceneImageInfo = OssSceneImages.Find((obj) => "Intelligence/Gallery/" + obj.defaultIconName + ".png" == value); + if (sceneImageInfo != null) + { + image = sceneImageInfo.defaultIconUrl; + } + else + { + image = value; + } } } - + + /// <summary> + /// 浜戠鍦烘櫙榛樿鍥惧簱鏁版嵁 + /// 2022-08-03 10:57:31 wxr + /// 閰嶅悎璞嗚眴淇敼浜戠鏁版嵁 + /// 璋冭瘯瀹濄�乷n pro鍜屽钩鍙板搴� + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public List<SceneImageInfo> OssSceneImages = new List<SceneImageInfo>() + { + new SceneImageInfo + { + defaultIconName = "scenebg1", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/781c397f-611a-48a2-a3ed-2520ffb971bb.png", + localUrl = "Intelligence/Gallery/scenebg1.png", + }, + new SceneImageInfo + { + defaultIconName = "scenebg2", + localUrl = "Intelligence/Gallery/scenebg2.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/be2a7c63-a6c0-427a-bb6d-f5c06f5b2f05.png" + }, + new SceneImageInfo + { + defaultIconName = "scenebg3", + localUrl = "Intelligence/Gallery/scenebg3.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/5d801aca-03fb-4ef3-88ec-75ade3aa1c94.png" + }, + new SceneImageInfo + { + defaultIconName = "scenebg4", + localUrl = "Intelligence/Gallery/scenebg4.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/a205306c-4fcd-4ea1-8e88-e84282dc0d54.png" + }, + new SceneImageInfo + { + defaultIconName = "scenebg5", + localUrl = "Intelligence/Gallery/scenebg5.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/93a0acdc-14be-4776-a9fd-e0fc6f13c909.png" + }, + new SceneImageInfo + { + defaultIconName = "scenebg6", + localUrl = "Intelligence/Gallery/scenebg6.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/45074923-2227-422a-be33-e37e6c3f9d23.png" + }, + new SceneImageInfo + { + defaultIconName = "scenebg7", + localUrl = "Intelligence/Gallery/scenebg7.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/28b3e459-041e-4ea1-9ff9-57053c5357f4.png" + }, + new SceneImageInfo + { + defaultIconName = "scenebg8", + localUrl = "Intelligence/Gallery/scenebg8.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/d470b979-cc06-4701-a2bd-7301856c9195.png" + }, + new SceneImageInfo + { + defaultIconName = "scenebg9", + localUrl = "Intelligence/Gallery/scenebg9.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/1a130d03-86b2-4174-b986-6f6c312a959f.png" + }, + new SceneImageInfo + { + defaultIconName = "scenebg10", + localUrl = "Intelligence/Gallery/scenebg10.png", + defaultIconUrl = "http://hdl-hz-prod.oss-cn-hangzhou.aliyuncs.com/20/2022/07/54c1c7ab-9b63-4487-a77d-d5d3dadd9801.png" + } + }; /// <summary> /// 鍦烘櫙鍔熻兘鍒楄〃 @@ -205,7 +311,7 @@ } roomNameList += findRoom.floorName + findRoom.roomName; } - if (roomNameList == "" ) + if (roomNameList == "") { roomNameList = Shared.Language.StringByID(StringId.WholeZone); } @@ -330,10 +436,11 @@ { //閲嶇疆鎵ц鍊掕鏃� this.countdownTime = 0; - if(MainPage.NoLoginMode) + if (MainPage.NoLoginMode) { var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); + return revPack.Code; } var scenes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(revPack.Data.ToString()); var tempScene = scenes.Find((obj) => obj.sid == sid); @@ -351,7 +458,7 @@ /// </summary> public string UpdateScene() { - if(MainPage.NoLoginMode) + if (MainPage.NoLoginMode) { var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); @@ -380,8 +487,8 @@ public string GetDelayText() { var delayInt = 0; - int.TryParse(delay,out delayInt); - if(delayInt == 0) + int.TryParse(delay, out delayInt); + if (delayInt == 0) { return Language.StringByID(StringId.NoDelay); } @@ -389,7 +496,8 @@ if (delayInt > 60) { text = (delayInt / 60) + Language.StringByID(StringId.m) + (delayInt % 60) + Language.StringByID(StringId.s); - }else + } + else { text = delayInt + Language.StringByID(StringId.s); } @@ -462,8 +570,24 @@ /// <returns></returns> private Function ConvertFunctionObject() { - var localFunction = FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.sid == sid); - return localFunction; + Function temp = null; + if (type == "7") + { + var logic = Logic.LogicList.Find((obj) => obj.sid == sid); + if (logic != null) { + temp = new Function(); + temp.name = logic.name; + } + } + else + { + temp = FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.sid == sid); + if (temp == null) + { + temp = FunctionList.List.groupControls.Find((obj) => obj.sid == sid); + } + } + return temp; } @@ -474,58 +598,121 @@ public string GetFunctionScnenInfo() { var sceneFunctionInfo = ""; - foreach (var sfs in status) + if (type == "7") { - if (sfs.key == FunctionAttributeKey.OnOff) + foreach (var sfs in status) { - if (sfs.value == "off") + if (sfs.key == "enable") { - return Language.StringByID(StringId.Close); + if (sfs.value == "true") + return Language.StringByID(StringId.OpenArm); + else + { + return Language.StringByID(StringId.Close); + } } } } - sceneFunctionInfo += Language.StringByID(StringId.Open) + " "; + else + { + foreach (var sfs in status) + { + if (sfs.key == FunctionAttributeKey.OnOff) + { + if (sfs.value == "off") + { + return Language.StringByID(StringId.Close); + } + } + } + sceneFunctionInfo += Language.StringByID(StringId.Open) + " "; - var modeState = status.Find((obj) => obj.key == FunctionAttributeKey.Mode); - var tempState = status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp); - var fanState = status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed); - if (modeState != null) - { - sceneFunctionInfo += modeState.GetValueText() + " "; - } - if (tempState != null) - { - sceneFunctionInfo += tempState.GetValueText() + " "; - sceneFunctionInfo += tempState.GetUintString(); - } - if (fanState != null) - { - sceneFunctionInfo += fanState.GetValueText() + " "; - } - var briState = status.Find((obj) => obj.key == FunctionAttributeKey.Brightness); - if (briState != null) - { - sceneFunctionInfo += briState.value + "%" + " "; - } - var perState = status.Find((obj) => obj.key == FunctionAttributeKey.Percent); - if (perState != null) - { - sceneFunctionInfo += perState.value + "%" + " "; - } - var cctState = status.Find((obj) => obj.key == FunctionAttributeKey.CCT); - if(cctState != null) - { - sceneFunctionInfo += cctState.value + "K" + " "; - } - var rgbState = status.Find((obj) => obj.key == FunctionAttributeKey.RGB); - if(rgbState!=null) - { - //sceneFunctionInfo += new cctState.value + "%" + " "; + var modeState = status.Find((obj) => obj.key == FunctionAttributeKey.Mode); + var tempState = status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp); + var fanState = status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed); + ////娴蜂俊鐢佃鐘舵�� + //var hisenseTvState = status.Find((obj) => obj.key == "wol"); + //if(hisenseTvState != null) + //{ + //} + if (modeState != null) + { + sceneFunctionInfo += modeState.GetValueText() + " "; + } + if (tempState != null) + { + sceneFunctionInfo += tempState.GetValueText(); + sceneFunctionInfo += tempState.GetUintString() + " "; + } + if (fanState != null) + { + sceneFunctionInfo += fanState.GetValueText() + " "; + } + var briState = status.Find((obj) => obj.key == FunctionAttributeKey.Brightness); + if (briState != null) + { + sceneFunctionInfo += briState.value + "%" + " "; + } + var perState = status.Find((obj) => obj.key == FunctionAttributeKey.Percent); + if (perState != null) + { + sceneFunctionInfo += perState.value + "%" + " "; + } + var cctState = status.Find((obj) => obj.key == FunctionAttributeKey.CCT); + if (cctState != null) + { + sceneFunctionInfo += cctState.value + "K" + " "; + } + var rgbState = status.Find((obj) => obj.key == FunctionAttributeKey.RGB); + if (rgbState != null) + { + //sceneFunctionInfo += new cctState.value + "%" + " "; + } + + + var perAngle = status.Find((obj) => obj.key == FunctionAttributeKey.Angle); + if (perAngle != null) + { + sceneFunctionInfo += " " + perAngle.value + "掳"; + } + + var perSetVolume = status.Find((obj) => obj.key == FunctionAttributeKey.SetVolume); + if (perSetVolume != null) + { + sceneFunctionInfo += " " + perSetVolume.value; + } + + var perSignal = status.Find((obj) => obj.key == FunctionAttributeKey.Signal); + if (perSignal != null) + { + var p = new HDL_ON.UI.UI2.Intelligence.Automation.PublicInterface(); + string key = p.GetKey(p.GetHisenseSignalSourceDic(), perSignal.value); + sceneFunctionInfo += " " + key; + } + + var perVolume = status.Find((obj) => obj.key == FunctionAttributeKey.Volume); + if (perVolume != null) + { + sceneFunctionInfo += " " + perVolume.value; + } + + var perSongName = status.Find((obj) => obj.key == FunctionAttributeKey.SongName); + if (perSongName != null) + { + sceneFunctionInfo += " " + perSongName.value; + } } return sceneFunctionInfo; } - + /// <summary> + /// 璁惧 + /// 鍦烘櫙 =scene + /// 缇ゆ帶=5 + /// 鑷姩鍖�=7 + /// + /// </summary> + public string type = "0"; } /// <summary> @@ -542,6 +729,7 @@ /// <summary> /// 灞炴�х殑鍊煎垪琛� /// </summary> + [Newtonsoft.Json.JsonIgnore] public List<string> valueList = new List<string>(); /// <summary> /// 灞炴�у悕绉版樉绀烘枃鏈� @@ -559,7 +747,7 @@ text = Language.StringByID(StringId.Brightness); break; case FunctionAttributeKey.RGB: - text = Language.StringByID(StringId.ColorValue); + text = "RGB";// Language.StringByID(StringId.ColorValue); break; case FunctionAttributeKey.Mode: text = Language.StringByID(StringId.Mode); @@ -585,22 +773,42 @@ case FunctionAttributeKey.FadeTime: text = Language.StringByID(StringId.FadeSpeed); break; + case "angle": + text = Language.StringByID(StringId.Angle); + break; + case "security": + text = Language.StringByID(StringId.DeploymentStatus); + break; + case FunctionAttributeKey.SetVolume: + text = Language.StringByID(StringId.yinliang); + break; + case FunctionAttributeKey.Signal: + text = Language.StringByID(StringId.xinhaoyuan); + break; + case FunctionAttributeKey.Volume: + text = Language.StringByID(StringId.yinliang); + break; + case FunctionAttributeKey.SongName: + text = Language.StringByID(StringId.tishiyin); + break; } return text; } + [Newtonsoft.Json.JsonIgnore] + public string UintString = ""; /// <summary> /// 灞炴�у�煎崟浣� /// </summary> - public string GetUintString(string inputKey = "") + public string GetUintString() { + if (!string.IsNullOrEmpty(UintString) && UintString != "{}") + { + return UintString; + } var us = ""; var swithchString = key; - if(!string.IsNullOrEmpty(inputKey)) - { - swithchString = inputKey; - } switch (swithchString) { case FunctionAttributeKey.SetTemp: @@ -614,6 +822,9 @@ case FunctionAttributeKey.CCT: us = "K"; break; + case FunctionAttributeKey.Angle: + us = "掳"; + break; } return us; } @@ -626,22 +837,28 @@ public string GetValueText(string temp = "") { string catchString = value; - if(temp!= "") + if (temp != "") { catchString = temp; } string text = ""; switch (key) { + case FunctionAttributeKey.Security: + text = catchString == "true" ? Language.StringByID(StringId.Defense) : Language.StringByID(StringId.Undefense); + break; case FunctionAttributeKey.OnOff: + case FunctionAttributeKey.Colorful: text = catchString == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF); break; case FunctionAttributeKey.SetTemp: case FunctionAttributeKey.RoomTemp: case FunctionAttributeKey.Brightness: case FunctionAttributeKey.Percent: + case FunctionAttributeKey.CCT: + case FunctionAttributeKey.Angle: int outT = 0; - int.TryParse(catchString,out outT); + int.TryParse(catchString, out outT); if (outT < 0) catchString = "0"; if (catchString == "") @@ -720,6 +937,20 @@ case "auto": text = Language.StringByID(StringId.Auto); break; + case FunctionAttributeKey.Signal: + var p = new UI.UI2.Intelligence.Automation.PublicInterface(); + var dic = p.GetHisenseSignalSourceDic(); + text = p.GetKey(dic, value); + break; + case FunctionAttributeKey.SetVolume: + text = value; + break; + case FunctionAttributeKey.Volume: + text = value; + break; + case FunctionAttributeKey.SongName: + text = value; + break; } return text; } @@ -745,4 +976,29 @@ public List<string> pushTarget = new List<string>(); } -} + public class SceneImageInfoList + { + //public Dictionary<string, string> Dic_SceneImages; + + //public SceneImageInfoList() + //{ + // Dic_SceneImages = new Dictionary<string, string>(); + // foreach(var sceneImage in sceneImages) + // { + // Dic_SceneImages.Add(sceneImage.defaultIconName, sceneImage.defaultIconUrl); + // } + //} + + + } + + public class SceneImageInfo + { + public string defaultIconName; + public string defaultIconUrl; + public string localUrl; + + } + + +} \ No newline at end of file -- Gitblit v1.8.0