mac
2024-07-25 f9181a9c8125136f597add7c30cb2ff508d54ba7
HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs
@@ -47,7 +47,7 @@
        /// 获取逻辑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列表");
@@ -61,14 +61,22 @@
            {
                return null;
            }
            return responsePackNew;
            List<LogicIdData> dateList = new List<LogicIdData>();
            try
            {
                dateList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicIdData>>(responsePackNew.Data.ToString());
            }catch (Exception ex)
            {
                MainPage.Log($"获取逻辑ID列表异常:{ex.Message}");
            }
            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++)
@@ -89,6 +97,35 @@
            }
            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>
@@ -114,6 +151,14 @@
                {
                    var inputTypeJOb = new JObject { };
                    inputTypeJOb.Add("sid", dictionary.sid);
                    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") {
                        inputTypeJOb.Add("identifier", dictionary.identifier);
@@ -241,6 +286,14 @@
                {
                    var inputTypeJOb = new JObject { };
                    inputTypeJOb.Add("sid", dictionary.sid);
                    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")
                    {
@@ -526,7 +579,7 @@
        /// <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 = 8)
        {
            Log($"{DateTime.Now}->发送->{tag}", api_Url,o.ToString());
            var requestJson = HttpUtil.GetSignRequestJson(o);
@@ -565,20 +618,23 @@
        /// <returns></returns>
        public bool Check(ResponsePackNew r, bool isTip)
        {
            if (r == null)
            {
                r = new ResponsePackNew { message = "没回复,请确认网络是否正常.", Code = "-1", };
            }
            if (r.Code == "0" && r.Data != null && r.Data.ToString() != "")
            {
                return true;
            }
            if (r.Code != "0")
            //失败时是否要提示
            if (isTip)
            {
                //失败时是否要提示
                if (isTip)
                {
                    new LogicView.TipPopView().FlashingBox(r.message + $"({r.Code})");
                }
                new LogicView.TipPopView().FlashingBox(r.message + $"({r.Code})");
            }
            return false;
        }
        /// <summary>
        /// 打印日志
        /// </summary>