public void StartQueue() { if (!this.QueueTasks.Any(a => a.Status == QueueItemStatus.Waiting || a.Status == QueueItemStatus.InProgress)) { this.errorService.ShowMessageBox( Resources.QueueViewModel_NoPendingJobs, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } var firstOrDefault = this.QueueTasks.FirstOrDefault(s => s.Status == QueueItemStatus.Waiting); if (firstOrDefault != null && !DriveUtilities.HasMinimumDiskSpace(firstOrDefault.Task.Destination, this.userSettingService.GetUserSetting <long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel))) { MessageBoxResult result = this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Warning, MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.No) { return; } } this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); this.IsQueueRunning = true; this.queueProcessor.Start(); }
private bool CheckDiskSpace(QueueTask job) { if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(job.Task.Destination, this.userSettingService.GetUserSetting <long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel))) { this.logService.LogMessage(Resources.PauseOnLowDiskspace); job.Status = QueueItemStatus.Waiting; this.Pause(true); this.BackupQueue(string.Empty); return(true); // Don't start the next job. } return(false); }
private void ProcessNextJob() { QueueTask job = this.GetNextJobForProcessing(); if (job != null) { if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(job.Task.Destination, this.userSettingService.GetUserSetting <long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel))) { this.logService.LogMessage(Resources.PauseOnLowDiskspace); job.Status = QueueItemStatus.Waiting; this.Pause(); this.BackupQueue(string.Empty); return; // Don't start the next job. } job.Status = QueueItemStatus.InProgress; job.Statistics.StartTime = DateTime.Now; this.LastProcessedJob = job; this.IsProcessing = true; this.InvokeQueueChanged(EventArgs.Empty); this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job)); if (!Directory.Exists(Path.GetDirectoryName(job.Task.Destination))) { this.EncodeServiceEncodeCompleted(null, new EncodeCompletedEventArgs(false, null, "Destination Directory Missing", null, null, null, 0)); this.BackupQueue(string.Empty); return; } this.EncodeService.Start(job.Task, job.Configuration, job.SelectedPresetKey); this.BackupQueue(string.Empty); } else { // No more jobs to process, so unsubscribe the event this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted; this.BackupQueue(string.Empty); // Fire the event to tell connected services. this.OnQueueCompleted(new QueueCompletedEventArgs(false)); } }
/// <summary> /// Run through all the jobs on the queue. /// </summary> private void ProcessNextJob() { QueueTask job = this.GetNextJobForProcessing(); if (job != null) { if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(job.Task.Destination, this.userSettingService.GetUserSetting <long>(UserSettingConstants.PauseOnLowDiskspaceLevel))) { LogService.GetLogger().LogMessage(Resources.PauseOnLowDiskspace, LogMessageType.ScanOrEncode, LogLevel.Info); job.Status = QueueItemStatus.Waiting; this.Pause(); return; // Don't start the next job. } this.IsProcessing = true; this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job)); this.EncodeService.Start(job.Task, job.Configuration); } else { // No more jobs to process, so unsubscribe the event this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted; // Fire the event to tell connected services. this.OnQueueCompleted(new QueueCompletedEventArgs(false)); } }
private void CheckDiskSpaceForDirectory(string directory) { if (!string.IsNullOrEmpty(directory) && this.queueService.IsEncoding) { long lowLevel = this.userSettingService.GetUserSetting <long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel); if (!this.storageLowPause && this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(directory, lowLevel)) { this.log.LogMessage( string.Format( Resources.SystemService_LowDiskSpaceLog, lowLevel / 1000 / 1000 / 1000)); this.queueService.Pause(true); this.storageLowPause = true; } } }
private void StorageCheck() { string directory = this.encodeService.GetActiveJob()?.Destination; if (!string.IsNullOrEmpty(directory) && this.encodeService.IsEncoding) { long lowLevel = this.userSettingService.GetUserSetting <long>(UserSettingConstants.PauseEncodeOnLowDiskspaceLevel); if (!this.storageLowPause && this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(directory, lowLevel)) { LogService.GetLogger().LogMessage( string.Format( Resources.SystemService_LowDiskSpaceLog, lowLevel / 1000 / 1000 / 1000), LogMessageType.Application, LogLevel.Info); this.encodeService.Pause(); this.storageLowPause = true; } } }