mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-30 12:19:32 -06:00
added sleep node
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>FileFlows.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
<Authors>John Andrews</Authors>
|
||||
|
||||
@@ -245,6 +245,16 @@
|
||||
"CsvFile-Help": "Will append to this file the original name and the renamed file. Useful when using ''Log Only'' to test the renamer before changing files."
|
||||
}
|
||||
},
|
||||
"Sleep": {
|
||||
"Description": "Pauses the flow",
|
||||
"Outputs": {
|
||||
"1": "Flow resumed"
|
||||
},
|
||||
"Fields": {
|
||||
"Milliseconds": "Milliseconds",
|
||||
"Milliseconds-Help": "How long to sleep the flow for. Must be between 1 millisecond and 1 hour"
|
||||
}
|
||||
},
|
||||
"Touch": {
|
||||
"Description": "Touches a file or directory and sets the last write time to now.",
|
||||
"Outputs": {
|
||||
|
||||
@@ -1,51 +1,48 @@
|
||||
namespace FileFlows.BasicNodes.Functions
|
||||
using System.ComponentModel;
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
|
||||
namespace FileFlows.BasicNodes.Functions;
|
||||
|
||||
public class Function : Node
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
using System.Text;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.Json;
|
||||
public override int Inputs => 1;
|
||||
public override FlowElementType Type => FlowElementType.Logic;
|
||||
public override string Icon => "fas fa-code";
|
||||
public override bool FailureNode => true;
|
||||
|
||||
public class Function : Node
|
||||
public override string HelpUrl => "https://docs.fileflows.com/plugins/basic-nodes/function";
|
||||
|
||||
[DefaultValue(1)]
|
||||
[NumberInt(1)]
|
||||
public new int Outputs { get; set; }
|
||||
|
||||
[Required]
|
||||
[DefaultValue("// Custom javascript code that you can run against the flow file.\n// Flow contains helper functions for the Flow.\n// Variables contain variables available to this node from previous nodes.\n// Logger lets you log messages to the flow output.\n\n// return 0 to complete the flow.\n// return -1 to signal an error in the flow\n// return 1+ to select which output node will be processed next\n\nif(Variables.file.Size === 0)\n\treturn -1;\n\nreturn 1;")]
|
||||
[Code(2)]
|
||||
public string Code { get; set; }
|
||||
|
||||
delegate void LogDelegate(params object[] values);
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
public override int Inputs => 1;
|
||||
public override FlowElementType Type => FlowElementType.Logic;
|
||||
public override string Icon => "fas fa-code";
|
||||
public override bool FailureNode => true;
|
||||
if (string.IsNullOrEmpty(Code))
|
||||
return -1; // no code, flow cannot continue doesnt know what to do
|
||||
|
||||
public override string HelpUrl => "https://docs.fileflows.com/plugins/basic-nodes/function";
|
||||
|
||||
[DefaultValue(1)]
|
||||
[NumberInt(1)]
|
||||
public new int Outputs { get; set; }
|
||||
|
||||
[Required]
|
||||
[DefaultValue("// Custom javascript code that you can run against the flow file.\n// Flow contains helper functions for the Flow.\n// Variables contain variables available to this node from previous nodes.\n// Logger lets you log messages to the flow output.\n\n// return 0 to complete the flow.\n// return -1 to signal an error in the flow\n// return 1+ to select which output node will be processed next\n\nif(Variables.file.Size === 0)\n\treturn -1;\n\nreturn 0;")]
|
||||
[Code(2)]
|
||||
public string Code { get; set; }
|
||||
|
||||
delegate void LogDelegate(params object[] values);
|
||||
public override int Execute(NodeParameters args)
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(Code))
|
||||
return -1; // no code, flow cannot continue doesnt know what to do
|
||||
|
||||
try
|
||||
return args.ScriptExecutor.Execute(new FileFlows.Plugin.Models.ScriptExecutionArgs
|
||||
{
|
||||
|
||||
return args.ScriptExecutor.Execute(new FileFlows.Plugin.Models.ScriptExecutionArgs
|
||||
{
|
||||
Args = args,
|
||||
Code = Code
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
args.Logger?.ELog("Failed executing function: " + ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
return -1;
|
||||
}
|
||||
Args = args,
|
||||
Code = Code
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
args.Logger?.ELog("Failed executing function: " + ex.Message + Environment.NewLine + ex.StackTrace);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
35
BasicNodes/Functions/Sleep.cs
Normal file
35
BasicNodes/Functions/Sleep.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace FileFlows.BasicNodes.Functions;
|
||||
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
/// <summary>
|
||||
/// Node that sleeps for a given time
|
||||
/// </summary>
|
||||
public class Sleep : Node
|
||||
{
|
||||
public override int Inputs => 1;
|
||||
public override int Outputs => 1;
|
||||
public override FlowElementType Type => FlowElementType.Logic;
|
||||
public override string Icon => "fas fa-clock";
|
||||
public override string HelpUrl => "https://docs.fileflows.com/plugins/basic-nodes/sleep";
|
||||
|
||||
|
||||
[NumberInt(1)]
|
||||
[Range(1, 3_600_000)]
|
||||
[DefaultValue(1000)]
|
||||
public int Milliseconds{ get; set; }
|
||||
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
if (Milliseconds < 1 || Milliseconds > 3_600_000)
|
||||
{
|
||||
args.Logger.ELog("Milliseconds must be between 1 and 3,600,000");
|
||||
return -1;
|
||||
}
|
||||
Thread.Sleep(Milliseconds);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
<Authors>John Andrews</Authors>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>FileFlows.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
<Authors>John Andrews</Authors>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>FileFlows.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>FileFlows.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>FileFlows.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>FileFlows.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
<Authors>John Andrews</Authors>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<FileVersion>0.8.4.88</FileVersion>
|
||||
<ProductVersion>0.8.4.88</ProductVersion>
|
||||
<FileVersion>0.8.5.94</FileVersion>
|
||||
<ProductVersion>0.8.5.94</ProductVersion>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<Company>FileFlows</Company>
|
||||
<Authors>John Andrews</Authors>
|
||||
|
||||
Reference in New Issue
Block a user