wxr
2020-12-02 e3ad42ffa2fa67c8f6cb4519ca626fa275c8947d
HDL_ON/UI/MainPage.cs
@@ -9,15 +9,32 @@
{
    public static class MainPage
    {
        /// <summary>
        /// BaseView
        /// </summary>
        public static FrameLayout BaseView { get; internal set; }
        /// <summary>
        /// BasePageView
        /// </summary>
        public static PageLayout BasePageView { get; set; }
        /// <summary>
        /// DisplayCompleted
        /// </summary>
        public static bool DisplayCompleted = false;
        public static UserInfo LoginUser;
        //public static UserInfo LoginUser;
        /// <summary>
        /// 版本号
        /// </summary>
        public static string VersionString = "1.0.0924";
        ///// <summary>
        ///// 客户端类型
        ///// </summary>
        //public static string ClientType = APIClientType.HDL_ON_PRO.ToString();
        /// <summary>
        ///
        /// </summary>
        public static Entity.CityInfo cityInfo = new Entity.CityInfo();
        /// <summary>
        /// 天气刷新action
@@ -32,12 +49,12 @@
        /// </summary>
        public static bool IsRemote = false;
        /// <summary>
        /// 公司代码
        /// 预留第三方定制标记
        /// 0:HDL
        /// </summary>
        public static int Company = 0;
        ///// <summary>
        ///// 公司代码
        ///// 预留第三方定制标记
        ///// 0:HDL
        ///// </summary>
        //public static int Company = 0;
        /// <summary>
        /// 是否全面屏手机
@@ -66,40 +83,45 @@
                Application.DesignWidth = 375;
                Application.DesignHeight = 667;
                BusSocket.Start(6000);
                CommonPage.InitReceiveEvent();
                BaseView = Application.MainPage;
                Application.MainPage.BackgroundColor = CSS_Color.MainBackgroundColor;
                LoginUser = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo>(System.Text.Encoding.UTF8.GetString(FileUtils.ReadFile("UserInfo_File")));
                //LoginUser = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo>(System.Text.Encoding.UTF8.GetString(FileUtils.ReadFile("UserInfo_File")));
                //判断需不需要登录,有没有登录,或者登录是否过期,
                if (LoginUser == null || !LoginUser.IsLogin)
                if (UserInfo.Current == null || !UserInfo.Current.IsLogin)
                {
                    GoLoginPage(LoginUser);
                    GoLoginPage(UserInfo.Current);
                }
                else
                {
                    new System.Threading.Thread(() =>
                    {
                        var pm = new DAL.Server.HttpServerRequest();
                        pm.RefreshToken();//刷新Token
                        pm.GetHomePager();//刷新住宅信息
                    })
                    { IsBackground = true }.Start();
                    new System.Threading.Thread(() =>
                    {
                        var pm =new DAL.Server.HttpServerRequest();
                        pm.GetUserInfo();//刷新个人信息
                    })
                    { IsBackground = true }.Start();
                    new System.Threading.Thread(() =>
                    {
                        var pm = new DAL.Server.HttpServerRequest();
                        pm.GetHomePager();//刷新住宅信息
                    })
                    { IsBackground = true }.Start();
                    GoUserPage();
                    //启动密码验证
                    new AppUnlockPage().LoadPage();
                    //读取音乐信息
                    UI.Music.A31MusicModel.ReadMusicStates();
                    //搜索网关
#if DEBUG
                    new HDL_ON.DAL.Net.TcpListener().OpenServer(8586);
#endif
                    //Entity.DB_ResidenceData.residenceData.residenceGatewayMAC = "4E47323347591243";
                    //Entity.DB_ResidenceData.residenceData.GatewayType = 0;
                    Entity.DB_ResidenceData.residenceData.residenceGatewayMAC = "123456789AAAAAAA";
                    Entity.DB_ResidenceData.residenceData.GatewayType = 1;
#endif
                    DriverLayer.Control.Ins.SearchLoaclGateway();
                }
            }
            catch (Exception ex)
@@ -117,7 +139,7 @@
        /// <summary>
        /// 进入登录界面
        /// </summary>
        public static void GoLoginPage(UserInfo userInfo =null)
        public static void GoLoginPage(UserInfo userInfo = null)
        {
            BaseView.RemoveAll();
            BaseView.BackgroundColor = CSS_Color.BackgroundColor;
@@ -162,6 +184,26 @@
            BasePageView.PageIndex = 0;
        }
        public static void GetRoomList()
        {
            var pm = new DAL.Server.HttpServerRequest();
            var packNew = pm.GetRoomList();//刷新房间列表
            var floorPack = pm.GetRoomList("FLOOR");
            var rooms = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.RoomApiPack>(packNew.Data.ToString());
            var floors = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.RoomApiPack>(packNew.Data.ToString());
            MainPage.Log(packNew.Data.ToString());
            MainPage.Log(floorPack.Data.ToString());
        }
        public static void GetDeviceList()
        {
            var pm = new DAL.Server.HttpServerRequest();
            var packNew = pm.GetDeviceList();
            var functions = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.DevcieApiPack>(packNew.Data.ToString());
            MainPage.Log(packNew.Data.ToString());
        }
        /// <summary>
        /// 自定义日志输出
        /// </summary>
@@ -171,5 +213,32 @@
            Console.WriteLine(msg);
#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;
        }
    }
}