From e5f843c8718e82e3138e19d2b82b10e9e02ed7d7 Mon Sep 17 00:00:00 2001 From: reven Date: Sat, 1 Jan 2022 14:48:16 +1300 Subject: [PATCH] added goto flow node --- BasicNodes/BasicNodes.en.json | 6 ++++++ BasicNodes/Functions/GotoFlow.cs | 24 ++++++++++++++++++++++++ BasicNodes/Tests/ExecutorTests.cs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 BasicNodes/Functions/GotoFlow.cs create mode 100644 BasicNodes/Tests/ExecutorTests.cs diff --git a/BasicNodes/BasicNodes.en.json b/BasicNodes/BasicNodes.en.json index 09fd88a0..3ae525f9 100644 --- a/BasicNodes/BasicNodes.en.json +++ b/BasicNodes/BasicNodes.en.json @@ -83,6 +83,12 @@ "Code-Help": "return -1 for error and flow to stop\nreturn 0 for flow to complete\nreturn 1 or more for the desired output to be called" } }, + "GotoFlow": { + "Description": "This lets you switch to a different flow to process. This flow will exit and the parameters and working file will be passed into the new Flow", + "Fields": { + "Flow": "Flow" + } + }, "Log": { "Description": "Logs a message to the flow log", "Fields": { diff --git a/BasicNodes/Functions/GotoFlow.cs b/BasicNodes/Functions/GotoFlow.cs new file mode 100644 index 00000000..ab3637de --- /dev/null +++ b/BasicNodes/Functions/GotoFlow.cs @@ -0,0 +1,24 @@ +namespace FileFlows.BasicNodes.Functions +{ + using FileFlows.Plugin; + using FileFlows.Plugin.Attributes; + + public class GotoFlow : Node + { + public override int Inputs => 1; + public override int Outputs => 0; + + public override FlowElementType Type => FlowElementType.Logic; + public override string Icon => "fas fa-sitemap"; + + [Select("FLOW_LIST", 1)] + public ObjectReference Flow { get; set; } + + + public override int Execute(NodeParameters args) + { + args.GotoFlow(Flow); + return 0; + } + } +} \ No newline at end of file diff --git a/BasicNodes/Tests/ExecutorTests.cs b/BasicNodes/Tests/ExecutorTests.cs new file mode 100644 index 00000000..416d3ae3 --- /dev/null +++ b/BasicNodes/Tests/ExecutorTests.cs @@ -0,0 +1,30 @@ +#if(DEBUG) + +namespace BasicNodes.Tests +{ + using FileFlows.BasicNodes.File; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class ExecutorTests + { + [TestMethod] + public void Executor_OutputVariable() + { + var logger = new TestLogger(); + var args = new FileFlows.Plugin.NodeParameters(@"c:\test\testfile.mkv", logger, false, string.Empty); + + Executor node = new Executor(); + string file = @"D:\Videos\dummy.mkv"; + node.FileName = @"C:\utils\ffmpeg\ffmpeg.exe"; + node.Arguments = "-i \"" + file + "\""; + node.OutputVariable = "ExecOutput"; + var result = node.Execute(args); + Assert.IsTrue(args.Variables.ContainsKey("ExecOutput")); + string output = args.Variables["ExecOutput"] as string; + Assert.IsNotNull(output); + } + } +} + +#endif \ No newline at end of file