JLChen
2021-02-02 c90de55be7a33e196029c1f4a1bb7f84ea449f29
HDL_ON/UI/MainPage.cs
@@ -26,7 +26,7 @@
        /// <summary>
        /// 版本号
        /// </summary>
        public static string VersionString = "1.0.1222";
        public static string VersionString = "1.1.0119";
        ///// <summary>
        ///// 客户端类型
        ///// </summary>
@@ -44,10 +44,6 @@
        /// 无登录模式
        /// </summary>
        public static bool NoLoginMode = false;
        ///// <summary>
        ///// 远程模式
        ///// </summary>
        //public static bool IsRemote = false;
        /// <summary>
        /// 网络连接状态
        /// 0:无网络
@@ -95,6 +91,12 @@
                BaseView = Application.MainPage;
                Application.MainPage.BackgroundColor = CSS_Color.MainBackgroundColor;
                //#region 测试
                //var ddd = new UI.test.TestDialog();
                //ddd.InitView();
                //return;
                //#endregion
                if (string.IsNullOrEmpty(OnAppConfig.Instance.LastLoginUserId))
                {
@@ -169,7 +171,6 @@
                addResidencePage.LoadView();
                return;
            }
            new System.Threading.Thread(() =>
            {
                try
@@ -180,6 +181,7 @@
                    Application.RunOnMainThread(() =>
                    {
                        waitPage.Hide();
                        waitPage.RemoveFromParent();
                        BaseView.RemoveAll();
                        BasePageView = new PageLayout();
                        BasePageView.ScrollEnabled = false;
@@ -206,11 +208,14 @@
                        };
                        BaseView.AddChidren(BasePageView);
                        //跳转页面----
                        var userPage = new UserPage();
                        BasePageView.AddChidren(userPage);
                        userPage.LoadPage();
                        var UserBasePage = new UserPage();
                        BasePageView.AddChidren(UserBasePage);
                        UserBasePage.LoadPage();
                        BasePageView.PageIndex = 0;
                        if (isFirstOpen)
                        {
@@ -227,56 +232,71 @@
                    MainPage.Log($"GoUserPage : {ex.Message}");
                }finally
                {
                    //Application.RunOnMainThread(() =>
                    //{
                    //    ///初始化app数据
                    //    Common.ApiUtlis.Ins.DownloadData();
                    //});
                    Application.RunOnMainThread(() =>
                    {
                        if (downloadData)
                        {
                            ///初始化app数据
                            Common.ApiUtlis.Ins.DownloadData();
                        };
                    });
                }
            }).Start();
        }
        /// <summary>
        /// 初始化app所需要的数据
        /// 后退事件
        /// 0:后退
        /// 1:有等待界面
        /// 2:无法再后退,可以执行退到桌面
        /// </summary>
        public static void InitializationData1()
        public static int LoadEvent_BackAction()
        {
            //new System.Threading.Thread(() =>
            //{
            //    int count = 0;
            //    while (count< 10)
            //    {
            //        if (Entity.DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull() )//|| Entity.DB_ResidenceData.residenceData.HomeGateway == null)
            //        {
            //            System.Threading.Thread.Sleep(200);
            //        }
            //        else
            //        {
            //            break;
            //        }
            //        count++;
            //    }
            //    if(Entity.DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull())
            //    {
            //        return;
            //    }
            //    //System.Threading.Thread.Sleep(2000);
            //    #region 读取云端数据--
            //    //todo数据覆盖处理
            //    //读取云端房间、楼层数据
            //    Entity.SpatialInfo.CurrentSpatial.DownloadRoomList();
            //    //读取云端设备数据
            //    Entity.FunctionList.List.DownloadFunctionList();
            //    //读取云端场景数据
            //    Entity.FunctionList.List.DownloadSceneList();
            //    //读取逻辑列表
            //    UI.UI2.Intelligence.Automation.MainView.GetLogicList();
            //    #endregion
            //})
            //{ IsBackground = true }.Start();
            int result = 0;
            Application.RunOnMainThread(() =>
            {
                if (BaseView.ChildrenCount>1)
                {
                    var view = BaseView.GetChildren(BaseView.ChildrenCount - 1);
                    if(view.GetType() == typeof(Loading))
                    {
                        var loading  = view as Loading;
                        if (loading.CurStatus == false)//有一些等待界面隐藏了,但是没有移除到,需要先移除
                        {
                            loading.RemoveFromParent();
                            result = LoadEvent_BackAction();
                        }
                        else
                        {
                            result = 1;//正在等待某些操作
                        }
                    }
                }
                else
                {
                    if (BasePageView.ChildrenCount > 1)
                    {
                        int index = BasePageView.ChildrenCount - 1;
                        var view = BasePageView.GetChildren(index);
                        if (view != null)
                        {
                            view.RemoveFromParent();
                        }
                    }
                    else
                    {
                        result = 2;//无法再后退,可以执行退到桌面
                    }
                }
            });
            return result;
        }
        /// <summary>
        /// 自定义日志输出
@@ -288,30 +308,6 @@
#endif
        }
        /// <summary>
        /// 生成13位时间戳
        /// </summary>
        /// <param name="value">时间</param>
        /// <returns></returns>
        public static long GetTimestamp13bit(DateTime value)
        {
            return new DateTimeOffset(value).ToUnixTimeSeconds();
        }
        /// <summary>
        /// 获取时间
        /// </summary>
        /// <param name="timestamp"></param>
        /// <returns></returns>
        public static DateTime GetDateTime (long timestamp)
        {
            long begtime = timestamp * 10000000;
            DateTime dt_1970 = new DateTime(1970, 1, 1, 0, 0, 0);
            long tricks_1970 = dt_1970.Ticks;//1970年1月1日刻度
            long time_tricks = tricks_1970 + begtime;//日志日期刻度
            DateTime dt = new DateTime(time_tricks);//转化为DateTime
            return dt;
        }
    }