| | |
| | | { |
| | | ///清除之前列表数据 |
| | | Pir.BuottonList.Clear(); |
| | | if (!string.IsNullOrEmpty(name)) |
| | | { |
| | | Control control = new Control(); |
| | | control.name = name; |
| | | control.type = "learn"; |
| | | control.spk = "ir.learn"; |
| | | control.deviceId = Pir.currPir.deviceId; |
| | | ThreadAddControl(control, frame, action); |
| | | |
| | | |
| | | |
| | | } |
| | | Control control = new Control(); |
| | | control.name = name; |
| | | control.type = "learn"; |
| | | control.spk = "ir.learn"; |
| | | control.deviceId = Pir.currPir.deviceId; |
| | | ThreadAddControl(control, frame, action); |
| | | }, false); |
| | | |
| | | } |
| | |
| | | /// <param name="frame"></param> |
| | | public void ThreadAddControl(Control control, FrameLayout frame, Action<Control> action) |
| | | { |
| | | |
| | | DAL.Server.ResponsePackNew responsePackNew = null; |
| | | Loading loading = new Loading(); |
| | | frame.AddChidren(loading); |
| | |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | bool bool_if = false; |
| | | string sid = responsePackNew.Data.ToString(); |
| | | var mqttdate = MqttDate(); |
| | | for (int i = 0; i < mqttdate.objects.Count; i++) { |
| | | var objects = mqttdate.objects[i]; |
| | | if (sid == objects.sid) { |
| | | bool_if = true; |
| | | break; |
| | | } |
| | | } |
| | | if (bool_if) |
| | | var mqttdate = MqttDate(sid); |
| | | if (mqttdate.id!="") |
| | | { |
| | | ///这里:监听MTTP推送下来主题,才知道是否添加成功 |
| | | frame.RemoveFromParent();//添加成功关闭弹窗 |
| | | control.deviceId = mqttdate.id; |
| | | control.sid = sid; |
| | | action(control); |
| | | } |
| | | else |
| | |
| | | /// </summary> |
| | | public static string addcontronsid = ""; |
| | | /// <summary> |
| | | /// |
| | | /// 判断这个主题是否是添加遥控器主题 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Cloud MqttDate() |
| | | public Cloud MqttDate(string sid) |
| | | { |
| | | Cloud cloud = new Cloud(); |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < 5 * 1000) |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < 10 * 1000) |
| | | { |
| | | if (!string.IsNullOrEmpty(addcontronsid)) |
| | | { |
| | | cloud = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(addcontronsid); |
| | | for (int i = 0; i < cloud.objects.Count; i++) |
| | | { |
| | | var objects = cloud.objects[i]; |
| | | if (sid == objects.sid) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } |
| | | return PushData(); |
| | | } |
| | | |
| | | public Cloud PushData() |
| | | { |
| | | Cloud cloud = new Cloud(); |
| | | if (addcontronsid != "") |
| | | { |
| | | //var date = Newtonsoft.Json.JsonConvert.SerializeObject(addcontronsid); |
| | | cloud = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(addcontronsid); |
| | | |
| | | } |
| | | return cloud; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 错误码提示 |
| | |
| | | /// <summary> |
| | | /// 设备id |
| | | /// </summary> |
| | | public string id = string.Empty; |
| | | public string id =""; |
| | | public List<Objects> objects = new List<Objects>(); |
| | | public string time_stamp = string.Empty; |
| | | |