| | |
| | | using System.Text; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.Entity; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.UI.Music |
| | | { |
| | | public class SendMethod |
| | | { |
| | | private static SendMethod s_Current= null; |
| | | private static SendMethod s_Current = null; |
| | | public static SendMethod Current |
| | | { |
| | | get |
| | |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | DriverLayer.Control.Ins.SendWriteCommand(function, dic,false,0); |
| | | DriverLayer.Control.Ins.SendWriteCommand(function, dic, false, 0); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceIds", functionIds); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_RefreshDeviceStatus); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_RefreshDeviceStatus, "刷新设备状态"); |
| | | if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") |
| | | { |
| | | return; |
| | |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceIds", new List<string> { music.deviceId }); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_PlayerList); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_PlayerList, "获取音乐列表"); |
| | | if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") |
| | | { |
| | | return; |
| | |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId); |
| | | d.Add("deviceIds", new List<string> { music.deviceId }); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupList); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupList, "获取列表名列表"); |
| | | if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") |
| | | { |
| | | return new List<GroupList>(); |
| | |
| | | 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); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupPlayerList, "获取列表音乐"); |
| | | if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") |
| | | { |
| | | return new PalyList(); |
| | | } |
| | | //数据返序列化为Function对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data); |
| | | var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<PalyList>(str); |
| | | var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PalyListInfo>>(str); |
| | | if (palyLists == null) |
| | | { |
| | | palyLists = new PalyList(); |
| | | palyLists = new List<PalyListInfo>(); |
| | | } |
| | | return palyLists; |
| | | |
| | | if (palyLists.Count == 0) |
| | | { |
| | | return new PalyList(); |
| | | } |
| | | //默认第一个列表里面第一个音乐列表 |
| | | return palyLists[0].playlist.Count > 0 ? palyLists[0].playlist[0] : new PalyList(); |
| | | |
| | | } |
| | | catch |
| | | { |
| | |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | | /// </summary> |
| | | /// <param name="o">发送数据</param> |
| | | /// <param name="api_Url">请求地址(不是绝对地址)</param> |
| | | /// <param name="tag">标记->描述接口(自定义)</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew RequestServerhomeId(object o, string api_Url, int mTimeout = 5) |
| | | public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag, int mTimeout = 5) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(o); |
| | | return HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout); |
| | | |
| | | JObject jobject = JObject.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(o)); |
| | | return UI2.Intelligence.Automation.Send.Current.RequestServerhomeId(jobject, api_Url, tag, mTimeout); |
| | | } |
| | | } |
| | | } |