public override void DisplayError(object owner, IProcessWorker host) { DispatcherHelper.CheckBeginInvokeOnUI(() => { _dialogService.ShowDialog(owner as INotifyPropertyChanged, _uiFactory.CreateError(host)); }); }
public void Execute(IJobExecutionContext context) { JobDataMap dataMap = context.JobDetail.JobDataMap; IProcessWorker processWorker = (IProcessWorker)dataMap["processWorker"]; processWorker.GetFacebookConversationsAndManage(); }
public static void Instance(Window parent, IProcessWorker host) { FFmpegErrorWindow F = new FFmpegErrorWindow(); F.Owner = parent; F.Title = (host.LastCompletionStatus == CompletionStatus.Timeout ? "Timeout: " : "Failed: ") + host.Options.Title; F.OutputText.Text = host.CommandWithArgs + Environment.NewLine + Environment.NewLine + host.Output; F.Show(); }
public FFmpegErrorViewModel(IProcessWorker host) { if (host == null) { throw new ArgumentNullException(nameof(host)); } Title = (host.LastCompletionStatus == CompletionStatus.Timeout ? "Timeout: " : "Failed: ") + host.Options.Title; OutputText = host.CommandWithArgs + Environment.NewLine + Environment.NewLine + host.Output; }
public void Stop() { _worker.StopProcessing = true; _workerThread.Join(1000 * 60 * 5); if (_workerThread.IsAlive) { _workerThread.Abort(); } _workerThread = null; _worker = null; }
/// <summary> /// Feeds a sample output into a mock process. /// </summary> /// <param name="p">The process manager to feed data into..</param> /// <param name="output">The sample output to feed.</param> public static void FeedOutputToProcess(IProcessWorker p, string output) { var MockP = Mock.Get <IProcess>(p.WorkProcess); using (StringReader sr = new StringReader(output)) { string line; while ((line = sr.ReadLine()) != null) { MockP.Raise(x => x.ErrorDataReceived += null, CreateMockDataReceivedEventArgs(line)); } } MockP.Raise(x => x.ErrorDataReceived += null, CreateMockDataReceivedEventArgs(null)); }
/// <summary> /// Runs vspipe with specified source file. The output will be discarded. /// </summary> /// <param name="path">The path to the script to run.</param> /// <param name="options">The options for starting the process.</param> /// <param name="callback">A method that will be called after the process has been started.</param> /// <returns>The process completion status.</returns> public CompletionStatus RunVapourSynth(string path, ProcessOptionsEncoder options = null, ProcessStartedEventHandler callback = null) { if (string.IsNullOrEmpty(path)) { throw new ArgumentException("Path cannot be null or empty.", nameof(path)); } if (!fileSystem.Exists(factory.Config.VsPipePath)) { throw new System.IO.FileNotFoundException($@"File ""{factory.Config.VsPipePath}"" specified by Config.VsPipePath is not found."); } string Args = $@"""{path}"" ."; IProcessWorker Manager = factory.Create(options, callback); CompletionStatus Result = Manager.Run(factory.Config.VsPipePath, Args); return(Result); }
private CompletionStatus ExecuteComplex(string src, string dst) { var dstEncode = GetPathWithoutExtension(dst) + "_.mp4"; var dstExtract = GetPathWithoutExtension(dst) + "_.mkv"; var dstAac = GetPathWithoutExtension(dst) + "_.aac"; s_jobId++; CompletionStatus result; _uiManager.Start(this, s_jobId, "Encoding to H264/AAC (Complex)"); var optionsMain = new ProcessOptionsEncoder(s_jobId, "", true); IProcessWorker processMain = null; var taskMain = Task.Run(() => _encoder.EncodeFFmpeg(src, dstEncode, "h264", null, "", optionsMain)); var options = new ProcessOptionsEncoder(s_jobId, "Extracting Audio", false); result = _muxer.ExtractAudio(src, dstExtract, options); if (result == CompletionStatus.Success) { options.Title = "Encoding Audio"; result = _encoder.EncodeFFmpeg(dstExtract, dstAac, null, "aac", null, options, (s, p) => processMain = p.ProcessWorker); } if (result != CompletionStatus.Success) { processMain?.Cancel(); } taskMain.Wait(); var result2 = taskMain.Result; if (result == CompletionStatus.Success && result2 == CompletionStatus.Success) { options.Title = "Muxing Audio and Video"; result = _muxer.Muxe(dstEncode, dstAac, dst, options); } File.Delete(dstEncode); File.Delete(dstExtract); File.Delete(dstAac); _uiManager.Close(s_jobId); return(GetStatus(result, result2)); }
private CompletionStatus ExecuteComplex(string src, string dst) { string DstEncode = GetPathWithoutExtension(dst) + "_.mp4"; string DstExtract = GetPathWithoutExtension(dst) + "_.mkv"; string DstAac = GetPathWithoutExtension(dst) + "_.aac"; jobId++; CompletionStatus Result; ffmpegManagerUI.Start(jobId, "Encoding to H264/AAC (Complex)"); ProcessOptionsEncoder OptionsMain = new ProcessOptionsEncoder(jobId, "", true); IProcessWorker ProcessMain = null; Task <CompletionStatus> TaskMain = Task.Run(() => encoder.EncodeFFmpeg(src, DstEncode, "h264", null, "", OptionsMain)); ProcessOptionsEncoder Options = new ProcessOptionsEncoder(jobId, "Extracting Audio", false); Result = muxer.ExtractAudio(src, DstExtract, Options); if (Result == CompletionStatus.Success) { Options.Title = "Encoding Audio"; Result = encoder.EncodeFFmpeg(DstExtract, DstAac, null, "aac", null, Options, (s, p) => ProcessMain = p.ProcessWorker); } if (Result != CompletionStatus.Success) { ProcessMain?.Cancel(); } TaskMain.Wait(); CompletionStatus Result2 = TaskMain.Result; if (Result == CompletionStatus.Success && Result2 == CompletionStatus.Success) { Options.Title = "Muxing Audio and Video"; Result = muxer.Muxe(DstEncode, DstAac, dst, Options); } File.Delete(DstEncode); File.Delete(DstExtract); File.Delete(DstAac); ffmpegManagerUI.Stop(jobId); return(Result); }
/// <summary> /// Runs avs2pipemod with specified source file. The output will be discarded. /// </summary> /// <param name="path">The path to the script to run.</param> /// <param name="options">The options for starting the process.</param> /// <param name="callback">A method that will be called after the process has been started.</param> /// <returns>The process completion status.</returns> public CompletionStatus RunAvisynth(string path, ProcessOptionsEncoder options = null, ProcessStartedEventHandler callback = null) { if (string.IsNullOrEmpty(path)) { throw new ArgumentException("Path cannot be null or empty.", nameof(path)); } if (!fileSystem.Exists(factory.Config.Avs2PipeMod)) { throw new System.IO.FileNotFoundException($@"File ""{factory.Config.Avs2PipeMod}"" specified by Config.Avs2PipeModPath is not found."); } string Args = $@"""{path}"" -rawvideo > NUL"; IProcessWorker Manager = factory.Create(options, callback); Manager.OutputType = ProcessOutput.Error; string Cmd = $@"""{factory.Config.Avs2PipeMod}"" {Args}"; CompletionStatus Result = Manager.RunAsCommand(Cmd); return(Result); }
/// <summary> /// Displays a process to the user. /// </summary> /// <param name="host">The process worker to display.</param> public void Display(IProcessWorker host) { if (!AppExited) { UIItem UI = null; if (host.Options.JobId != null) { UI = UIList.FirstOrDefault(u => u.JobId.Equals(host.Options.JobId)); } if (UI != null) { UI.Value.DisplayTask(host); } else { string Title = !string.IsNullOrEmpty(host.Options.Title) ? host.Options.Title : "Process Running"; CreateUI(Title, true).DisplayTask(host); } } }
public static void Start(IProcessWorker processWorker) { IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler(); scheduler.Start(); IJobDetail job = JobBuilder.Create <ProcessJob>().Build(); job.JobDataMap["processWorker"] = processWorker; ITrigger trigger = TriggerBuilder.Create() .WithIdentity("trigger1", "group1") .StartNow() .WithSimpleSchedule(x => x .WithIntervalInSeconds(10) .RepeatForever()) .Build(); scheduler.ScheduleJob(job, trigger); }
/// <summary> /// Displays a process to the user. /// </summary> /// <param name="owner">The owner to set for the window.</param> /// <param name="host">The process worker to display.</param> public void Display(object?owner, IProcessWorker host) { host.CheckNotNull(nameof(host)); if (!AppExited) { UIItem?ui = null; if (host.Options.JobId != null) { ui = _uiList.FirstOrDefault(u => u.JobId.Equals(host.Options.JobId)); } if (ui != null) { ui.Value.DisplayTask(host); } else { var title = !string.IsNullOrEmpty(host.Options.Title) ? host.Options.Title : "Process Running"; CreateUI(owner, title, true).DisplayTask(host); } } }
public void DisplayTask(IProcessWorker taskArg) { Dispatcher.Invoke(() => { if (taskArg.Options.IsMainTask) { host = taskArg; hostFFmpeg = host as IProcessWorkerEncoder; if (hostFFmpeg != null) { hostFFmpeg.FileInfoUpdated += FFmpeg_InfoUpdated; hostFFmpeg.ProgressReceived += FFmpeg_StatusUpdated; } host.ProcessCompleted += FFmpeg_Completed; PercentText.Text = 0.ToString("p1"); SetPageTitle(PercentText.Text); } else { task = taskArg; TaskStatusText.Text = task.Options.Title; task.ProcessCompleted += (sender, e) => { ProcessWorker Proc = (ProcessWorker)sender; Dispatcher.Invoke(() => { if (e.Status == CompletionStatus.Failed && !Proc.WorkProcess.StartInfo.FileName.EndsWith("avs2pipemod.exe")) { FFmpegErrorWindow.Instance(Owner, Proc); } TaskStatusText.Text = ""; task = null; if (autoClose) { this.Close(); } }); }; } }); }
public void AttachProcessWorker(object?owner, IProcessWorker worker, ProcessOptions options) { if (worker == null) { throw new ArgumentNullException(nameof(worker)); } worker.ProcessStarted += (s, e) => { if (options.DisplayMode == ProcessDisplayMode.Interface) { Display(owner, worker); } }; worker.ProcessCompleted += (s, e) => { if ((e.Status == CompletionStatus.Failed || e.Status == CompletionStatus.Timeout) && (options.DisplayMode == ProcessDisplayMode.ErrorOnly || options.DisplayMode == ProcessDisplayMode.Interface)) { DisplayError(owner, worker); } }; }
public void Truncate_Valid_Success(string source, string destExt, TimeSpan?startPos, TimeSpan?duration) { var src = AppPaths.GetInputFile(source); var dest = AppPaths.PrepareDestPath("Truncate", source, destExt); var muxer = SetupMuxer(); IProcessWorker manager = null; void Started(object s, ProcessStartedEventArgs e) { manager = e.ProcessWorker; _feed.RunCallback(s, e); } var result = muxer.Truncate(src, dest, startPos, duration, null, Started); Assert.Equal(CompletionStatus.Success, result); Assert.True(File.Exists(dest)); var fileInfo = GetFileInfo(dest); if (duration.HasValue) { Assert.True(Math.Abs((duration.Value - fileInfo.FileDuration).TotalSeconds) < .1, "Truncate did not produce expected file duration."); } }
public TestController(IProcessWorker processWorker) { _processWorker = processWorker; }
//public ProcessStartedEventArgs() { } public ProcessStartedEventArgs(IProcessWorker processWorker) { ProcessWorker = processWorker; }
/// <summary> /// When implemented in a derived class, displays an error window. /// </summary> /// <param name="owner">The owner to set for the window.</param> /// <param name="host">The task throwing the error.</param> public abstract void DisplayError(object?owner, IProcessWorker host);
/// <summary> /// When implemented in a derived class, displays an error window. /// </summary> /// <param name="host">The task throwing the error.</param> public abstract void DisplayError(IProcessWorker host);
public BaseProcManager(IProcessWorker procWorker) { _worker = procWorker; }
public override void DisplayError(IProcessWorker host) { Application.Current.Dispatcher.Invoke(() => FFmpegErrorWindow.Instance(parent, host)); }
public override void DisplayError(IProcessWorker host) { }
public IFFmpegErrorViewModel CreateError(IProcessWorker host) { return(new FFmpegErrorViewModel(host)); }
public override void DisplayError(object owner, IProcessWorker host) { }