wxr
2021-07-01 43b0d5870d528f23ecd6aeceb6cfd4325188b46f
HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs
@@ -4,33 +4,11 @@
using HDL_ON.DAL.Server;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using HDL_ON.Entity;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
    public  class Send
    {
        /// <summary>
        /// 调用获取住宅子账号列表
        /// </summary>
        public static List<ResidenceMemberInfo> GetResidenceMemberAccount()
        {
            var responePack = new HttpServerRequest().GetResidenceMemberAccount();
            if (responePack.Code == StateCode.SUCCESS)
            {
                return Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>>(responePack.Data.ToString());
            }
            //失败
            else
            {
                //提示
                IMessageCommon.Current.ShowErrorInfoAlter(responePack.Code);
            }
            return new List<ResidenceMemberInfo>();
        }
        /// <summary>
        /// 获取逻辑ID列表
        /// </summary>
@@ -114,6 +92,7 @@
                {
                    var outputTypeJOb = new JObject { };
                    outputTypeJOb.Add("sid", dictionary.sid);
                    outputTypeJOb.Add("delay", dictionary.delay);
                    outputTypeJOb.Add("target_type", dictionary.target_type);
                    var statusArray = new JArray { };
                    foreach (var dic in dictionary.status)
@@ -127,6 +106,11 @@
                    outputArray.Add(outputTypeJOb);
                }
                var noticeConfigJObject = new JObject();
                noticeConfigJObject.Add("enable", logic.noticeConfig.enable);
                noticeConfigJObject.Add("noticeContent", logic.noticeConfig.noticeContent);
                var pushConfigsArray = new JArray { };
                if (logic.pushConfigs.Count > 0)
                {   // 推送文本
@@ -135,7 +119,6 @@
                       
                        var pushConfigJob = new JObject { };
                        pushConfigJob.Add("pushMethod", pushConfig.pushMethod);
                        pushConfigJob.Add("pushContent", pushConfig.pushContent);
                        var accountArray = new JArray { };
                        foreach (var account in pushConfig.pushTarget)
                        {
@@ -156,24 +139,22 @@
                logicIfon.Add("cycle", cycleJObject);
                logicIfon.Add("input", inputArray);
                logicIfon.Add("output", outputArray);
                logicIfon.Add("noticeConfig", noticeConfigJObject);
                logicIfon.Add("pushConfigs", pushConfigsArray);
                logicjArray.Add(logicIfon);
                var jObject = new JObject { { "homeId", LogicMethod.HomeId }, { "logics", logicjArray } };
                responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add);
                responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add,5);
                //如果是token过期则刷新token
                if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
                {
                    RefreshToken();
                    AddLogic(logic);
                }
            }
            catch (Exception e)
            {
                var dd = e.Message;
            }
            return responsePackNew;
        }
        /// <summary>
@@ -207,7 +188,10 @@
                    {
                        var conditionJOb = new JObject { };
                        conditionJOb.Add("key", dic["key"]);
                        conditionJOb.Add("comparator", dic["comparator"]);
                        var c1 = "";
                        dic.TryGetValue("comparator", out c1);
                        c1 = string.IsNullOrEmpty(c1) ? "" : c1;
                        conditionJOb.TryAdd("comparator", c1);
                        conditionJOb.Add("data_type", dic["data_type"]);
                        conditionJOb.Add("value", dic["value"]);
                        conditionArray.Add(conditionJOb);
@@ -221,6 +205,7 @@
                {
                    var outputTypeJOb = new JObject { };
                    outputTypeJOb.Add("sid", dictionary.sid);
                    outputTypeJOb.Add("delay", dictionary.delay);
                    outputTypeJOb.Add("target_type", dictionary.target_type);
                    var statusArray = new JArray { };
                    foreach (var dic in dictionary.status)
@@ -234,15 +219,19 @@
                    outputArray.Add(outputTypeJOb);
                }
                var noticeConfigJObject = new JObject();
                noticeConfigJObject.Add("enable", logic.noticeConfig.enable);
                noticeConfigJObject.Add("noticeContent", logic.noticeConfig.noticeContent);
                var pushConfigsArray = new JArray { };
                if (logic.pushConfigs.Count > 0)
                {   // 推送文本
                {
                    // 推送文本
                    foreach (var pushConfig in logic.pushConfigs)
                    {
                        var pushConfigJob = new JObject { };
                        pushConfigJob.Add("pushMethod", pushConfig.pushMethod);
                        pushConfigJob.Add("pushContent", pushConfig.pushContent);
                        var accountArray = new JArray { };
                        foreach (var account in pushConfig.pushTarget)
                        {
@@ -264,11 +253,12 @@
                logicIfon.Add("cycle", cycleJObject);
                logicIfon.Add("input", inputArray);
                logicIfon.Add("output", outputArray);
                logicIfon.Add("noticeConfig", noticeConfigJObject);
                logicIfon.Add("pushConfigs", pushConfigsArray);
                logicjArray.Add(logicIfon);
                var jObject = new JObject { { "homeId", LogicMethod.HomeId }, { "logics", logicjArray } };
                responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Update);
                responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Update,5);
                //如果是token过期则刷新token
                if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
                {
@@ -280,8 +270,6 @@
            {
                var dd = e.Message;
            }
            return responsePackNew;
        } 
        /// <summary>