diff --git a/BasicNodes/BasicNodes.en.json b/BasicNodes/BasicNodes.en.json
index db2a7869..1a6acc49 100644
--- a/BasicNodes/BasicNodes.en.json
+++ b/BasicNodes/BasicNodes.en.json
@@ -112,7 +112,11 @@
}
},
"FailFlow": {
- "Description": "Fails a flow immediately, useful if you want a certain path to just fail."
+ "Description": "Fails a flow immediately, useful if you want a certain path to just fail.",
+ "Fields": {
+ "Reason": "Reason",
+ "Reason-Help": "An optional reason to log why this flow is failing."
+ }
},
"FileSize": {
"Description": "Checks if the file size matches the configured parameters. The values are in megabytes.\n\nOutput 1: Matches\nOutput 2: Does not match",
@@ -243,6 +247,14 @@
"UseWorkingFileName-Help": "If current working filename should be used, or if false, the original filename of the incoming file will be used."
}
},
+ "Random": {
+ "Label": "Random",
+ "Description": "Chooses a random output",
+ "Fields": {
+ "Outputs": "Outputs",
+ "Outputs-Help": "The number of outputs available to this flow element."
+ }
+ },
"ReplaceOriginal": {
"Description": "Replaces the original file with the working file.\n\nIf the extension is different on the working file, the original file will be deleted and the working file will be moved to the original with the new extension.\nE.g. from File.avi to File.mkv",
"Outputs": {
diff --git a/BasicNodes/Functions/FailFlow.cs b/BasicNodes/Functions/FailFlow.cs
index 63c96b1d..de68eb6f 100644
--- a/BasicNodes/Functions/FailFlow.cs
+++ b/BasicNodes/Functions/FailFlow.cs
@@ -1,4 +1,5 @@
using FileFlows.Plugin;
+using FileFlows.Plugin.Attributes;
namespace FileFlows.BasicNodes.Functions;
@@ -23,6 +24,12 @@ public class FailFlow : Node
/// Gets the URL for the help page
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/fail-flow";
+
+ ///
+ /// Gets or sets the reason to fail the flow
+ ///
+ [Text(1)]
+ public string Reason { get; set; }
///
/// Executes the node
@@ -31,7 +38,16 @@ public class FailFlow : Node
/// -1 to indicate the flow should fail
public override int Execute(NodeParameters args)
{
- args.Logger.ILog("Failing flow");
+ if (string.IsNullOrWhiteSpace(Reason) == false)
+ {
+ args.Logger.ILog("Failing flow: " + Reason);
+ args.FailureReason = Reason;
+ }
+ else
+ {
+ args.Logger.ILog("Failing flow");
+ }
+
return -1;
}
}
\ No newline at end of file
diff --git a/BasicNodes/Functions/Random.cs b/BasicNodes/Functions/Random.cs
new file mode 100644
index 00000000..227e7e64
--- /dev/null
+++ b/BasicNodes/Functions/Random.cs
@@ -0,0 +1,52 @@
+using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
+using FileFlows.Plugin;
+using FileFlows.Plugin.Attributes;
+
+namespace FileFlows.BasicNodes.Functions;
+
+
+///
+/// A node that choose a random output
+///
+public class Random : Node
+{
+ ///
+ /// Gets the number of input nodes
+ ///
+ public override int Inputs => 1;
+
+ ///
+ /// Gets or sets the number of outputs
+ ///
+ [DefaultValue(3)]
+ [NumberInt(1)]
+ [Range(2, 10)]
+ public new int Outputs { get; set; }
+
+ ///
+ /// Gets the type of node
+ ///
+ public override FlowElementType Type => FlowElementType.Logic;
+ ///
+ /// Gets the icon of the flow
+ ///
+ public override string Icon => "fas fa-dice";
+ ///
+ /// Gets the URL for the help page
+ ///
+ public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/random";
+
+ ///
+ /// Executes the node
+ ///
+ /// the node parameters
+ /// -1 to indicate the flow should fail
+ public override int Execute(NodeParameters args)
+ {
+ var rand = new System.Random(DateTime.UtcNow.Millisecond);
+ int output = rand.Next(1, Outputs + 1);
+ args.Logger?.ILog("Random output selected: " + output);
+ return output;
+ }
+}
\ No newline at end of file
diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll
index 29d801f0..39652f01 100644
Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ
diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb
index efd27326..79fcc822 100644
Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ