wei
2020-12-23 d814c978efc068425c500a553cf7ec6b4f628219
HDL_ON/Entity/Function/Scene.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using HDL_ON.Common;
using HDL_ON.DAL.Server;
using Shared;
@@ -35,7 +36,7 @@
        /// <summary>
        /// 云端唯一ID
        /// </summary>
        public string userSceneId = "";
        public string userSceneId = null;
        /// <summary>
        /// 场景sid
        /// </summary>
@@ -64,36 +65,10 @@
        /// 延时
        /// </summary>
        public string delay = "0";
        ///// <summary>
        ///// 延时显示的文本
        ///// </summary>
        //[Newtonsoft.Json.JsonIgnore]
        //public string delayText
        //{
        //    get
        //    {
        //        string text = "";
        //        switch (delay)
        //        {
        //            case 0:
        //                text = Language.StringByID(StringId.NoDelay);
        //                break;
        //            case 30:
        //                text = "30s";
        //                break;
        //            case 60:
        //                text = "1min";
        //                break;
        //            case 120:
        //                text = "2min";
        //                break;
        //            case 300:
        //                text = "5min";
        //                break;
        //        }
        //        return text;
        //    }
        //}
        /// <summary>
        /// 场景的最好一次执行时间
        /// </summary>
        public string LastExecutionTime = "";
        /// <summary>
        /// 场景分组
@@ -223,7 +198,7 @@
            }
            if (roomNameList == "" )
            {
                roomNameList = Shared.Language.StringByID(StringId.WholeHouseScene);
                roomNameList = Shared.Language.StringByID(StringId.WholeZone);
            }
            return roomNameList;
        }
@@ -237,6 +212,51 @@
            get
            {
                return "SceneData_" + sid;
            }
        }
        /// <summary>
        /// 场景执行\倒计时
        /// </summary>
        /// <param name="btnShowDelay"></param>
        public void SceneCountDown(Button btnShowDelay)
        {
            //场景正在倒计时执行中
            if (LastExecutionTime != "" && Convert.ToDouble(LastExecutionTime) + Convert.ToDouble(delay) > Convert.ToDouble(Utlis.GetTimestamp(false)))
            {
                int time = 0;
                int.TryParse(Convert.ToInt32(
                    Convert.ToDouble(LastExecutionTime) + Convert.ToDouble(delay) - Convert.ToDouble(Utlis.GetTimestamp(false))
                    ).ToString(), out time);
                if (time > 0)
                {
                    new System.Threading.Thread(() =>
                    {
                        if (time > 0)
                        {
                            while (time > 0)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    if (time > 60)
                                    {
                                        btnShowDelay.Text = (time / 60).ToString() + "min" + time % 60 + "s";
                                    }
                                    else
                                    {
                                        btnShowDelay.Text = time.ToString() + "s";
                                    }
                                });
                                System.Threading.Thread.Sleep(1000);
                                time--;
                            }
                            Application.RunOnMainThread(() =>
                            {
                                btnShowDelay.Text = "";
                            });
                        }
                    })
                    { IsBackground = true, Priority = System.Threading.ThreadPriority.BelowNormal }.Start();
                }
            }
        }
@@ -260,19 +280,30 @@
        /// 收藏场景
        /// </summary>
        /// <returns></returns>
        public string CollectScene()
        public void CollectScene()
        {
            var pm = new HttpServerRequest();
            if (this.collect)
            var result = StateCode.SUCCESS;
            new System.Threading.Thread(() =>
            {
                var revPack = pm.CollectScene(this.userSceneId);
                return revPack;
            }
            else
            {
                var revPack = pm.CancelCollectScene(this.userSceneId);
                return revPack;
            }
                if (collect)
                {
                    result = ApiUtlis.Ins.HttpRequest.CollectScene(userSceneId);
                }
                else
                {
                    result = ApiUtlis.Ins.HttpRequest.CancelCollectScene(userSceneId);
                }
                //提示错误
                if (result != StateCode.SUCCESS)
                {
                    Application.RunOnMainThread(() =>
                    {
                        collect = !collect;
                        IMessageCommon.Current.ShowErrorInfoAlter(result);
                    });
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>