예제 #1
0
        public async Task UpdateSupportedRange()
        {
            var rq = new RestRequest("lrr/compat");

            rq.AddParameter("version", Platform.Version.ToString());

            var r = await client.ExecuteGetAsync(rq);

            var result = await r.GetResultInternal <VersionSupportedRange>();

            if (!string.IsNullOrEmpty(r.ErrorMessage))
            {
                ReadVersion();
                return;
            }
            if (result.OK && result.Data != null)
            {
                var range = result.Data;
                MIN_VERSION = range.minSupported;
                MAX_VERSION = range.maxSupported;
                SettingsStorage.StoreObjectLocal("MinVersion", MIN_VERSION.ToString());
                SettingsStorage.StoreObjectLocal("MaxVersion", MAX_VERSION.ToString());
            }
            else
            {
                ReadVersion();
            }
        }
예제 #2
0
        public async Task Startup()
        {
            Animate = false;
            await Service.InitServices();

            if (Updates.CanAutoUpdate() && Settings.AutoUpdate)
            {
                var update = await Updates.CheckForUpdates();

                if (update.Result)
                {
                    Updating = true;
                    // Set wasUpdate in settingstorage
                    SettingsStorage.StoreObjectLocal("WasUpdated", true);
                    var result = await Updates.DownloadAndInstall(new Progress <double>(progress => Progress = progress), update);

                    Updating = false;
                    if (!result.Result)
                    {
                        SettingsStorage.DeleteObjectLocal("WasUpdated");
                        if (result.ErrorMessage != null)
                        {
                            Status = result.ErrorMessage;
                        }
                        StatusSub = Platform.GetLocalizedString("Pages/LoadingPage/UpdateErrorCode").AsFormat(result.ErrorCode);
                        await Task.Delay(TimeSpan.FromSeconds(3));

                        Status    = "";
                        StatusSub = "";
                    }
                }
            }

            bool firstRun = Settings.Profile == null || (!Settings.AutoLogin && Settings.FirstStartup);

            if (firstRun)
            {
                Animate = true;
                await Task.Delay(TimeSpan.FromMilliseconds(500));

                Platform.GoToPage(Pages.FirstRun, PagesTransition.DrillIn);
                return;
            }
            Settings.FirstStartup = false;

            Active = true;
#if !DEBUG
            await Updates.UpdateSupportedRange();
#endif
            await Connect();
        }