| | |
| | | logicIfon.Add("pushConfigs", pushConfigsArray); |
| | | logicjArray.Add(logicIfon); |
| | | var jObject = new JObject { { "homeId", LogicMethod.Current.HomeId }, { "logics", logicjArray } }; |
| | | string str = jObject.ToString(); |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add, "添加自动化", 5); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | |
| | | var inputTypeJOb = new JObject { }; |
| | | inputTypeJOb.Add("sid", dictionary.sid); |
| | | inputTypeJOb.Add("condition_type", dictionary.condition_type); |
| | | |
| | | if (dictionary.condition_type == "9") |
| | | { |
| | | inputTypeJOb.Add("identifier", dictionary.identifier); |
| | | } |
| | | var conditionArray = new JArray { }; |
| | | foreach (var dic in dictionary.condition) |
| | | { |
| | |
| | | |
| | | logicjArray.Add(logicIfon); |
| | | var jObject = new JObject { { "homeId", LogicMethod.Current.HomeId }, { "logics", logicjArray } }; |
| | | |
| | | string str = jObject.ToString(); |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Update, "编辑更新自动化", 5); |
| | | //如果是token过期则刷新token |
| | |
| | | /// <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, string tag,int mTimeout = 3) |
| | | public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag,int mTimeout = 3) |
| | | { |
| | | Log($"{DateTime.Now}->发送->{tag}", o.ToString()); |
| | | Log($"{DateTime.Now}->发送->{tag}", api_Url,o.ToString()); |
| | | var requestJson = HttpUtil.GetSignRequestJson(o); |
| | | var r= HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout); |
| | | Log($"{DateTime.Now}->回复->{tag}", Newtonsoft.Json.JsonConvert.SerializeObject(r)); |
| | | Log($"{DateTime.Now}->回复->{tag}", "", Newtonsoft.Json.JsonConvert.SerializeObject(r)); |
| | | return r; |
| | | |
| | | } |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew RequestServer(object o, string api_Url,string tag) |
| | | { |
| | | Log($"发送->{tag}", o.ToString()); |
| | | Log($"发送数据->{tag}", api_Url, o.ToString()); |
| | | var requestJson = HttpUtil.GetSignRequestJson(o); |
| | | var r = HttpUtil.RequestHttpsPost(api_Url, requestJson); |
| | | Log($"回复->{tag}", Newtonsoft.Json.JsonConvert.SerializeObject(r)); |
| | | Log($"回复数据->{tag}", "", Newtonsoft.Json.JsonConvert.SerializeObject(r)); |
| | | return r; |
| | | } |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="tag">打印标记</param> |
| | | /// <param name="content">打印内容</param> |
| | | public void Log(string tag, string content) |
| | | public void Log(string tag,string url, string content) |
| | | { |
| | | #if DEBUG |
| | | Console.WriteLine(tag + $"\r\n数据内容->->{content}"); |
| | | Console.WriteLine(tag + $"\r\n{url}\r\n{content}"); |
| | | #endif |
| | | } |
| | | |