| | |
| | | /// 获取逻辑ID列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetLogicIdList(bool isTip = false) |
| | | public List<LogicIdData> GetLogicIdList(bool isTip = false) |
| | | { |
| | | var jObject = new JObject { { "homeId", LogicMethod.Current.HomeId } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_List, "获取逻辑ID列表"); |
| | |
| | | { |
| | | return null; |
| | | } |
| | | return responsePackNew; |
| | | var dateList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicIdData>>(responsePackNew.Data.ToString()); |
| | | return dateList; |
| | | } |
| | | /// <summary> |
| | | /// 获取自动化详情 |
| | | /// </summary> |
| | | /// <param name="listIdList">自动化ID列表</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetLogic(List<string> listIdList, bool isTip = false) |
| | | public ResponsePackNew GetLogic1(List<string> listIdList, bool isTip = false) |
| | | { |
| | | var jArray = new JArray { }; |
| | | for (int i = 0; i < listIdList.Count; i++) |
| | |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取自动化详情 |
| | | /// </summary> |
| | | /// <param name="listIdList">自动化ID列表</param> |
| | | /// <returns></returns> |
| | | public List<Logic> GetLogic(List<string> listIdList, bool isTip = false) |
| | | { |
| | | var jArray = new JArray { }; |
| | | for (int i = 0; i < listIdList.Count; i++) |
| | | { |
| | | jArray.Add(listIdList[i]); |
| | | } |
| | | var jObject = new JObject { { "userLogicIds", jArray } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Info, "获取自动化详情"); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GetLogic(listIdList, isTip); |
| | | } |
| | | if (Check(responsePackNew, isTip) == false) |
| | | { |
| | | return null; |
| | | } |
| | | var logicList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Logic>>(responsePackNew.Data.ToString()); |
| | | return logicList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加自动化命令 |
| | | /// </summary> |
| | |
| | | if (!string.IsNullOrEmpty(dictionary.hold_time)) |
| | | { |
| | | inputTypeJOb.Add("hold_time", dictionary.hold_time); |
| | | } |
| | | if (!string.IsNullOrEmpty(dictionary.detect_type)) |
| | | { |
| | | inputTypeJOb.Add("detect_type", dictionary.detect_type); |
| | | } |
| | | inputTypeJOb.Add("condition_type", dictionary.condition_type); |
| | | if (dictionary.condition_type=="9") { |
| | |
| | | if (!string.IsNullOrEmpty(dictionary.hold_time)) |
| | | { |
| | | inputTypeJOb.Add("hold_time", dictionary.hold_time); |
| | | } |
| | | if (!string.IsNullOrEmpty(dictionary.detect_type)) |
| | | { |
| | | inputTypeJOb.Add("detect_type", dictionary.detect_type); |
| | | } |
| | | inputTypeJOb.Add("condition_type", dictionary.condition_type); |
| | | if (dictionary.condition_type == "9") |
| | |
| | | /// <returns></returns> |
| | | public bool Check(ResponsePackNew r, bool isTip) |
| | | { |
| | | if (r.Code == "0" && r.Data != null && r.Data.ToString() != "") |
| | | { |
| | | return true; |
| | | } |
| | | if (r.Code != "0") |
| | | { |
| | | //失败时是否要提示 |
| | | if (isTip) |
| | | { |
| | | if (r == null) |
| | | { |
| | | r = new ResponsePackNew { message = "没回复,请确认网络是否正常.", Code = "-1", }; |
| | | } |
| | | new LogicView.TipPopView().FlashingBox(r.message + $"({r.Code})"); |
| | | if (r.Code == "0" && r.Data != null && r.Data.ToString() != "") |
| | | { |
| | | return true; |
| | | } |
| | | //失败时是否要提示 |
| | | if (isTip) |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(r.message + $"({r.Code})"); |
| | | } |
| | | return false; |
| | | } |