| | |
| | | using System.Text; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared; |
| | | using static HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod; |
| | | |
| | | namespace HDL_ON.UI.Music |
| | | { |
| | |
| | | /// <summary> |
| | | /// 刷新设备状态 |
| | | /// </summary> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <returns></returns> |
| | | public void RefreshDeviceStatus(List<string> functionIds) |
| | | public void RefreshDeviceStatus(List<string> functionIds,TipType tipType = TipType.flicker) |
| | | { |
| | | try |
| | | { |
| | |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceIds", functionIds); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_RefreshDeviceStatus, "刷新设备状态"); |
| | | if (!this.DataChecking(responsePackNew)) |
| | | if (!this.DataChecking(responsePackNew, tipType)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="music">音乐播放器</param> |
| | | /// <param name="action">回调</param> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <returns></returns> |
| | | public void GetCurrentPalyList(Function music, Action action) |
| | | public void GetCurrentPalyList(Function music, Action action, TipType tipType = TipType.flicker) |
| | | { |
| | | try |
| | | { |
| | |
| | | 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 (!this.DataChecking(responsePackNew)) |
| | | if (!this.DataChecking(responsePackNew,tipType)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="music"></param> |
| | | /// <param name="source">音乐源为null,支持多个源获取</param> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <returns></returns> |
| | | public List<GroupList> GetMultipleSourceListName(Function music, string source) |
| | | public List<GroupList> GetMultipleSourceListName(Function music, string source,TipType tipType=TipType.flicker) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | d.Add("deviceInfos", new List<Dictionary<string, object>> { deviceIds }); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupList, "获取列表名列表"); |
| | | if (!this.DataChecking(responsePackNew)) |
| | | if (!this.DataChecking(responsePackNew, tipType)) |
| | | { |
| | | return new List<GroupList>(); |
| | | } |
| | |
| | | return groupList.Count > 0 ? groupList[0] : new GroupList(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="music"></param> |
| | | /// <param name="listName">列表名</param> |
| | | /// <param name="source">音乐源</param> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <returns></returns> |
| | | public List<PalyerSongListInfo> GetMultipleSongListM(Function music, string listName, string source) |
| | | public List<PalyerSongListInfo> GetMultipleSongListM(Function music, string listName, string source, TipType tipType= TipType.flicker) |
| | | { |
| | | try |
| | | { |
| | |
| | | d.Add("sidGroups", new List<Dictionary<string, object>> { d1 }); |
| | | |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupPlayerList, "通过列表名获取歌曲列表"); |
| | | if (!this.DataChecking(responsePackNew)) |
| | | if (!this.DataChecking(responsePackNew, tipType)) |
| | | { |
| | | return new List<PalyerSongListInfo>(); |
| | | } |
| | |
| | | /// <param name="listName">列表名</param> |
| | | /// <param name="source">音乐源</param> |
| | | /// <returns></returns> |
| | | public SongList GetSingleSongList(Function music, string listName, string source) |
| | | public SongList GetSingleSongList(Function music, string listName, string source, TipType tipType= TipType.flicker) |
| | | { |
| | | List<PalyerSongListInfo> listInfos = this.GetMultipleSongListM(music, listName, source); |
| | | List<PalyerSongListInfo> listInfos = this.GetMultipleSongListM(music, listName, source, tipType); |
| | | if (listInfos.Count == 0) |
| | | { |
| | | return new SongList(); |
| | |
| | | return songList; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// <summary> |
| | | /// 检验数据回复成功或者失败 |
| | | /// </summary> |
| | | /// <param name="responsePackNew">回复数据对象</param> |
| | | /// <param name="tipType">是否需要提示</param> |
| | | /// <returns></returns> |
| | | private bool DataChecking(ResponsePackNew responsePackNew) |
| | | private bool DataChecking(ResponsePackNew responsePackNew, TipType tipType) |
| | | { |
| | | if (responsePackNew.Data == null||responsePackNew.Code != "0" || responsePackNew.Data.ToString() == "") |
| | | if (responsePackNew.Data == null || responsePackNew.Code != "0" || responsePackNew.Data.ToString() == "") |
| | | { |
| | | |
| | | if (TipType.flicker == tipType) |
| | | { |
| | | if (responsePackNew == null) |
| | | { |
| | | responsePackNew = new ResponsePackNew { message = "没回复,请确认网络是否正常.", Code = "-1", }; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //new Tip() |
| | | //{ |
| | | // CloseTime = 1, |
| | | // Text = responsePackNew.message + "(" + responsePackNew.Code + ")", |
| | | // Direction = AMPopTipDirection.None, |
| | | //}.Show(MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1)); |
| | | CommonMethod.Current.ShowTip(responsePackNew.message + "(" + responsePackNew.Code + ")", 3); |
| | | }); |
| | | } |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | |
| | | /// <param name="api_Url">请求地址(不是绝对地址)</param> |
| | | /// <param name="tag">标记->描述接口(自定义)</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag, int mTimeout = 15) |
| | | public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag, int mTimeout = 10) |
| | | { |
| | | JObject jobject = JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(o)); |
| | | return UI2.Intelligence.Automation.Send.Current.RequestServerhomeId(jobject, api_Url, tag, mTimeout); |