using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace FileFlows.BasicNodes.Functions;
///
/// Flow element that moves a file for reprocessing
///
public class Reprocess : Node
{
///
public override int Inputs => 1;
///
public override int Outputs => 0;
///
public override FlowElementType Type => FlowElementType.Process;
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/reprocess";
///
public override string Icon => "fas fa-redo";
///
/// Gets or sets the flow to execute
///
[Select("NODE_LIST_ANY", 1)]
public ObjectReference? Node { get; set; }
///
/// Gets or sets the number of minutes to hold the file for reprocessing
///
[NumberInt(1)]
public int? HoldMinutes { get; set; }
///
public override int Execute(NodeParameters args)
{
bool holding = HoldMinutes is > 0;
bool onNode = Node is not null && Node.Uid != Guid.Empty;
if (holding == false && onNode == false)
{
args.FailureReason = "Must select at least one of Hold Minutes or Reprocess Node.";
args.Logger?.ELog(args.FailureReason);
return -1;
}
if (holding == false && Node.Uid == args.Node.Uid)
{
args.FailureReason = "Cannot reprocess on the same node without holding.";
args.Logger?.ELog(args.FailureReason);
return -1;
}
if (holding)
{
args.Logger?.ILog($"Holding for {HoldMinutes} minutes");
args.Reprocess.HoldForMinutes = HoldMinutes;
}
if (onNode)
{
args.Logger?.ILog($"Reprocessing on node '{Node.Name}'");
args.ReprocessNode = Node;
}
return 0;
}
}