mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-01-07 12:50:28 -06:00
FF-1276 - added reason to failure flow element
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/fail-flow";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reason to fail the flow
|
||||
/// </summary>
|
||||
[Text(1)]
|
||||
public string Reason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Executes the node
|
||||
@@ -31,7 +38,16 @@ public class FailFlow : Node
|
||||
/// <returns>-1 to indicate the flow should fail</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
52
BasicNodes/Functions/Random.cs
Normal file
52
BasicNodes/Functions/Random.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
|
||||
namespace FileFlows.BasicNodes.Functions;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A node that choose a random output
|
||||
/// </summary>
|
||||
public class Random : Node
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the number of input nodes
|
||||
/// </summary>
|
||||
public override int Inputs => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of outputs
|
||||
/// </summary>
|
||||
[DefaultValue(3)]
|
||||
[NumberInt(1)]
|
||||
[Range(2, 10)]
|
||||
public new int Outputs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of node
|
||||
/// </summary>
|
||||
public override FlowElementType Type => FlowElementType.Logic;
|
||||
/// <summary>
|
||||
/// Gets the icon of the flow
|
||||
/// </summary>
|
||||
public override string Icon => "fas fa-dice";
|
||||
/// <summary>
|
||||
/// Gets the URL for the help page
|
||||
/// </summary>
|
||||
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/random";
|
||||
|
||||
/// <summary>
|
||||
/// Executes the node
|
||||
/// </summary>
|
||||
/// <param name="args">the node parameters</param>
|
||||
/// <returns>-1 to indicate the flow should fail</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user