private async Task LoadDb() { Settings = SettingsRepo.Load().Result; SetThrottleSpeed( Settings.ThrottleSpeed == 0 || Settings.ThrottleSpeed == -1 ? "-1" : (Convert.ToDouble(Settings.ThrottleSpeed) / 1000000).ToString()); var initialFilesCount = await MusicFileRepo.CountAll(); var issueCount = await MusicFileRepo.CountIssues(); var uploadsCount = await MusicFileRepo.CountUploaded(); await RegistrySettings.SetStartWithWindows(Settings.StartWithWindows); SetStartWithWindows(Settings.StartWithWindows); SetDiscoveredFilesLabel(InitialFilesCount.ToString()); await BindWatchFoldersList(); await InitialiseFolderWatchers(); InitialFilesCount = Task.FromResult(initialFilesCount).Result; SetIssuesLabel(Task.FromResult(issueCount).Result.ToString()); SetUploadedLabel(Task.FromResult(uploadsCount).Result.ToString()); RunDebugCommands(); }
public void RepopulateAmountLables(bool includeDiscoveredFiles = false) { SetIssuesLabel(MusicFileRepo.CountIssues().Result.ToString()); SetUploadedLabel(MusicFileRepo.CountUploaded().Result.ToString()); if (includeDiscoveredFiles) { InitialFilesCount = MusicFileRepo.CountAll().Result; SetDiscoveredFilesLabel(InitialFilesCount.ToString()); } }
public void StartMainProcess(bool restarting = false) { IdleProcessor.Paused = true; // Only perform at start up if (!DatabaseIntegrityCheckDone) { SetStatusMessage("Checking database integrity", "Checking database integrity"); Database.Maintenance.CheckAndCopyDatabaseFile(); DatabaseIntegrityCheckDone = true; } Logger.LogInfo("StartMainProcess", "Main process thread starting"); _scanAndUploadThread = new Thread((ThreadStart) delegate { if (restarting) { if (WatchFolders.Count == 0) { MusicFileRepo.DeleteAll().Wait(); SetDiscoveredFilesLabel("0"); SetIssuesLabel("0"); SetUploadedLabel("0"); } } MainProcess(restarting); int retryIssuesCount = 0; while (MusicFileRepo.CountIssues().Result > 0) { ThreadHelper.SafeSleep(10000); retryIssuesCount++; if (retryIssuesCount < Global.YTMusicIssuesMainProcessRetry) { MainProcess(); } else { break; } } }) { IsBackground = true }; _scanAndUploadThread.Start(); }
private async Task LoadDb() { Settings = SettingsRepo.Load().Result; SetThrottleSpeed( Settings.ThrottleSpeed == 0 || Settings.ThrottleSpeed == -1 ? "-1" : (Convert.ToDouble(Settings.ThrottleSpeed) / 1000000).ToString()); await RegistrySettings.SetStartWithWindows(Settings.StartWithWindows); SetStartWithWindows(Settings.StartWithWindows); SetAlsoUploadPlaylists(Settings.UploadPlaylists); await BindWatchFoldersList(); await InitialiseFolderWatchers(); if (WatchFolders.Count == 0) { SetAmountLabelsToZero(); } int initialFilesCount = await MusicFileRepo.CountAll(); int issueCount = await MusicFileRepo.CountIssues(); int uploadsCount = await MusicFileRepo.CountUploaded(); InitialFilesCount = Task.FromResult(initialFilesCount).Result; SetDiscoveredFilesLabel(InitialFilesCount.ToString()); SetIssuesLabel(Task.FromResult(issueCount).Result.ToString()); SetUploadedLabel(Task.FromResult(uploadsCount).Result.ToString()); Logger.ClearHistoricLogs(); RunDebugCommands(); EnableOptionButtons(true); }