From c484347d42f8c14f03f498e689069a14a45abc93 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期五, 03 二月 2023 17:56:45 +0800 Subject: [PATCH] 2023年02月03日17:56:24 --- HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs | 114 +++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 87 insertions(+), 27 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs index fc0f09e..2c1ce82 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Music/SendMethod.cs @@ -86,7 +86,7 @@ d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); d.Add("deviceIds", functionIds); var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_RefreshDeviceStatus, "鍒锋柊璁惧鐘舵��"); - if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") + if (!this.dataChecking(responsePackNew)) { return; } @@ -110,11 +110,11 @@ } /// <summary> - /// 鑾峰彇闊充箰鍒楄〃 + /// 鑾峰彇褰撳墠鎾斁闊充箰鍒楄〃 /// </summary> - /// <param name="music"></param> + /// <param name="music">闊充箰鎾斁鍣�</param> /// <returns></returns> - public void GetPalyList(Function music) + public void GetCurrentPalyList(Function music) { try { @@ -122,21 +122,21 @@ d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); d.Add("deviceIds", new List<string> { music.deviceId }); var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_PlayerList, "鑾峰彇闊充箰鍒楄〃"); - if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") + if (!this.dataChecking(responsePackNew)) { return; } //鏁版嵁杩斿簭鍒楀寲涓篎unction瀵硅薄 var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data); - var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PalyListInfo>>(str); + var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PalyerSongListInfo>>(str); if (palyLists == null) { - palyLists =new List<PalyListInfo>(); + palyLists = new List<PalyerSongListInfo>(); } if (palyLists.Count > 0) { ///榛樿鎷跨涓�涓垪琛� - A31MusicModel.Current.palyLists = palyLists[0].playlist; + A31MusicModel.Current.CurrentPlayMusicInfoList = palyLists[0].playlist; } } catch @@ -145,20 +145,27 @@ } /// <summary> - /// 鑾峰彇鍒楄〃鍚嶅垪琛� + /// 鑾峰彇銆愬涓煶涔愭簮銆戝垪琛ㄥ悕鍒楄〃 /// </summary> /// <param name="music"></param> + /// <param name="source">闊充箰婧愪负null,鏀寔澶氫釜婧愯幏鍙�</param> /// <returns></returns> - public List<GroupList> GetListName(Function music) + public List<GroupList> GetMultipleSourceListName(Function music, string source) { try { Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId); - d.Add("deviceIds", new List<string> { music.deviceId }); + Dictionary<string, object> deviceIds = new Dictionary<string, object>(); + deviceIds.Add("deviceId", music.deviceId); + if (!string.IsNullOrEmpty(source)) + { + deviceIds.Add("source", source); + } + d.Add("deviceInfos", new List<Dictionary<string, object>> { deviceIds }); var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupList, "鑾峰彇鍒楄〃鍚嶅垪琛�"); - if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") + if (!this.dataChecking(responsePackNew)) { return new List<GroupList>(); } @@ -176,13 +183,35 @@ return new List<GroupList>(); } } + /// <summary> - /// 鑾峰彇鍒楄〃闊充箰 + /// 鑾峰彇銆愬崟涓煶涔愭簮銆戝垪琛ㄥ悕鍒楄〃(榛樿鍙栧畾鍒楄〃涓竴涓�) + /// </summary> + /// <param name="music"></param> + /// <param name="source">闊充箰婧�</param> + /// <returns></returns> + public GroupList GetSingleSourceListNameList(Function music, string source) + { + List<GroupList> groupList = this.GetMultipleSourceListName(music, source); + if (groupList.Count == 0) + { + return new GroupList(); + } + ////榛樿鍙栧畾鍒楄〃涓竴涓� + return groupList.Count > 0 ? groupList[0] : new GroupList(); + } + + + + + /// <summary> + /// 閫氳繃鍒楄〃鍚嶈幏鍙栥�愬涓瓕鏇插垪琛ㄣ�� /// </summary> /// <param name="music"></param> /// <param name="listName">鍒楄〃鍚�</param> + /// <param name="source">闊充箰婧�</param> /// <returns></returns> - public PalyList GetListMusic(Function music, string listName) + public List<PalyerSongListInfo> GetMultipleSongListM(Function music, string listName, string source) { try { @@ -193,34 +222,65 @@ d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId); d2.Add("group", listName); d1.Add("sid", music.sid); + if (!string.IsNullOrEmpty(source)) + { + d1.Add("source", source); + } d1.Add("groupList", new List<Dictionary<string, object>> { d2 }); d.Add("sidGroups", new List<Dictionary<string, object>> { d1 }); - var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupPlayerList, "鑾峰彇鍒楄〃闊充箰"); - if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") + var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupPlayerList, "閫氳繃鍒楄〃鍚嶈幏鍙栨瓕鏇插垪琛�"); + if (!this.dataChecking(responsePackNew)) { - return new PalyList(); + return new List<PalyerSongListInfo>(); } //鏁版嵁杩斿簭鍒楀寲涓篎unction瀵硅薄 var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data); - var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PalyListInfo>>(str); + var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PalyerSongListInfo>>(str); if (palyLists == null) { - palyLists = new List<PalyListInfo>(); + return new List<PalyerSongListInfo>(); } - if (palyLists.Count == 0) - { - return new PalyList(); - } - //榛樿绗竴涓垪琛ㄩ噷闈㈢涓�涓煶涔愬垪琛� - return palyLists[0].playlist.Count > 0 ? palyLists[0].playlist[0] : new PalyList(); + return palyLists; } catch { - return new PalyList(); + return new List<PalyerSongListInfo>(); } + } + /// <summary> + /// 閫氳繃鍒楄〃鍚嶈幏鍙栥�愬崟涓瓕鏇插垪琛ㄣ��(榛樿鍙栧畾鍒楄〃涓竴涓瓕鏇插垪琛�) + /// </summary> + /// <param name="music"></param> + /// <param name="listName">鍒楄〃鍚�</param> + /// <param name="source">闊充箰婧�</param> + /// <returns></returns> + public SongList GetSingleSongList(Function music, string listName, string source) + { + List<PalyerSongListInfo> listInfos = this.GetMultipleSongListM(music, listName, source); + if (listInfos.Count == 0) + { + return new SongList(); + } + ////榛樿绗竴涓垪琛ㄩ噷闈㈢涓�涓煶涔愬垪琛� + SongList songList = listInfos[0].playlist.Count > 0 ? listInfos[0].playlist[0] : new SongList(); + return songList; + + } + /// <summary> + /// 妫�楠屾暟鎹洖澶嶆垚鍔熸垨鑰呭け璐� + /// </summary> + /// <param name="responsePackNew">鍥炲鏁版嵁瀵硅薄</param> + /// <returns></returns> + private bool dataChecking(ResponsePackNew responsePackNew) + { + if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") + { + return false; + } + return true; } /// <summary> @@ -232,7 +292,7 @@ /// <returns></returns> public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag, int mTimeout = 5) { - JObject jobject = JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(o)); + JObject jobject = JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(o)); return UI2.Intelligence.Automation.Send.Current.RequestServerhomeId(jobject, api_Url, tag, mTimeout); } } -- Gitblit v1.8.0