コード例 #1
0
        private void UploaderPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            LOGGER.Debug($"Received a uploader property changed event for property {e.PropertyName}");

            if (e.PropertyName == nameof(Uploader.State))
            {
                if (Uploader.State == UploaderState.Waiting)
                {
                    LOGGER.Info($"Uploader state changed to waiting -> end if should end afterwards");
                    WatchedProcesses.ProcessesCompleted += ProcessesCompleted;
                    EndIfShouldEnd();
                }
                else if (Uploader.State == UploaderState.Uploading)
                {
                    LOGGER.Info($"Uploader state changed to uploading -> can't end until it's finished or cancelled");
                    WatchedProcesses.ProcessesCompleted -= ProcessesCompleted;
                }
                else if (Uploader.State == UploaderState.NotRunning)
                {
                    LOGGER.Info($"Uploader state changed to not running -> end if should end");
                    DirectoryWatcher.Cancel();
                    EndIfShouldEnd();
                }
            }
        }
コード例 #2
0
        private void EndIfShouldEnd()
        {
            if (EndAfterUpload &&
                WatchedProcesses.AllProcessesCompleted &&
                Uploader.State != UploaderState.Uploading &&
                (Uploader.State != UploaderState.Waiting || !Uploader.Queue.Any(u => u.State == JobState.NotStarted && !u.ShouldBeSkipped)) &&
                Searcher.State != RunningState.Running)
            {
                LOGGER.Info($"Auto uploader should end now");

                Uploader.CancelAll();
                DirectoryWatcher.Cancel();
                RefreshState();
            }
        }
コード例 #3
0
        public void Cancel(bool cancelYoutubeUploader)
        {
            LOGGER.Debug($"Received cancel request");

            if (State == RunningState.Running)
            {
                LOGGER.Info($"Cancelling auto uploader");

                State = RunningState.CancelPending;
                Uploader.StopAfterCompleting = true;
                Searcher.Cancel();
                DirectoryWatcher.Cancel();

                if (cancelYoutubeUploader)
                {
                    LOGGER.Info($"Cancelling youtube uploader");
                    Uploader.CancelAll();
                }

                RefreshState();
            }
        }
コード例 #4
0
        private void OnProcessesCompleted(object sender, System.EventArgs e)
        {
            LOGGER.Debug($"Received a process completed event");

            if (EndAfterUpload && uploader.State != UploaderState.Uploading && uploader.State != UploaderState.CancelPending && Searcher.State == RunningState.NotRunning)
            {
                LOGGER.Info($"Stopping auto uploader");

                if (uploader.State == UploaderState.Waiting)
                {
                    LOGGER.Info($"Stopping youtube uploader");
                    uploader.CancelAll();
                }

                if (DirectoryWatcher.State == RunningState.Running)
                {
                    LOGGER.Info($"Stopping directory watcher");
                    DirectoryWatcher.Cancel();
                }

                RefreshState();
            }
        }