protected override async void OnResume() { try { base.OnResume(); // Refresh Server Data await ETC.CheckServerNetwork(); _ = CheckNetworkData(); } catch (Exception ex) { ETC.LogError(ex, this); } }
private static async Task <bool> CheckEventVersion() { await ETC.CheckServerNetwork(); if (ETC.isServerDown) { return(false); } string localEventVerPath = Path.Combine(ETC.cachePath, "Event", "EventVer.txt"); string serverEventVerPath = Path.Combine(ETC.server, "EventVer.txt"); string tempEventVerPath = Path.Combine(ETC.tempPath, "EventVer.txt"); bool hasEventUpdate = false; if (!File.Exists(localEventVerPath)) { hasEventUpdate = true; } else { using (WebClient wc = new WebClient()) { await wc.DownloadFileTaskAsync(serverEventVerPath, tempEventVerPath); } await Task.Delay(1); using (StreamReader sr1 = new StreamReader(new FileStream(localEventVerPath, FileMode.Open, FileAccess.Read))) using (StreamReader sr2 = new StreamReader(new FileStream(tempEventVerPath, FileMode.Open, FileAccess.Read))) { int localVer = int.Parse(sr1.ReadToEnd().Split(';')[1]); int serverVer = int.Parse(sr2.ReadToEnd().Split(';')[1]); hasEventUpdate = localVer < serverVer; } } return(hasEventUpdate); }
private async Task InitProcess() { await Task.Delay(500); try { // Initialize FindViewById <TextView>(Resource.Id.SplashAppVersion).Text = $"v{AppInfo.VersionString}({AppInfo.BuildString})"; await ETC.AnimateText(statusText, "Initializing"); if (Preferences.Get("CheckInitLowMemory", true)) { CheckDeviceMemory(); } ETC.isLowRAM = Preferences.Get("LowMemoryOption", false); ETC.CheckInitFolder(); // Check DB Update if (!CheckDBFiles()) { await ETC.AnimateText(statusText, "Download DB First"); try { await ETC.CheckServerNetwork(); if (!ETC.isServerDown) { await ETC.UpdateDB(this); } else { throw new Exception("Server is down"); } } catch (Exception ex) { ETC.LogError(ex, this); Toast.MakeText(this, Resource.String.Splash_SkipCheckUpdate, ToastLength.Long).Show(); } } try { int.TryParse(File.ReadAllText(Path.Combine(ETC.systemPath, "DBVer.txt")), out ETC.dbVersion); //using (StreamReader sr = new StreamReader(new FileStream(, FileMode.Open, FileAccess.Read))) //{ // _ = int.TryParse(sr.ReadToEnd(), out ETC.dbVersion); //} } catch { ETC.dbVersion = 0; } // Finalize & Start Main StartActivity(typeof(Main)); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); Finish(); } catch (Exception ex) { ETC.LogError(ex, this); Toast.MakeText(this, Resource.String.InitLoad_Error, ToastLength.Long).Show(); } finally { GC.Collect(GC.MaxGeneration, GCCollectionMode.Default, false, false); } }