Merge pull request #1140 from MilkyWare/elsa-2.0/fileactivities
File Activities
This commit is contained in:
commit
6a835e7681
90
Elsa.sln
90
Elsa.sln
|
|
@ -225,71 +225,83 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Activities.BlobStorage
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "locking", "locking", "{DBBD242E-4437-4BDB-919F-A70839BE75FA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.DistributedLocking.SqlServer", "src\locking\Elsa.DistributedLocking.SqlServer\Elsa.DistributedLocking.SqlServer.csproj", "{B09A6E42-EF42-4693-BA0E-5EE1D7F81FFD}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.DistributedLocking.SqlServer", "src\locking\Elsa.DistributedLocking.SqlServer\Elsa.DistributedLocking.SqlServer.csproj", "{B09A6E42-EF42-4693-BA0E-5EE1D7F81FFD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.DistributedLocking.AzureBlob", "src\locking\Elsa.DistributedLocking.AzureBlob\Elsa.DistributedLocking.AzureBlob.csproj", "{495BE954-E6EA-41A9-8054-A5CA5DD0924E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.DistributedLocking.AzureBlob", "src\locking\Elsa.DistributedLocking.AzureBlob\Elsa.DistributedLocking.AzureBlob.csproj", "{495BE954-E6EA-41A9-8054-A5CA5DD0924E}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "blazor", "blazor", "{D86B94DC-A53C-4A67-A820-828DD359C49B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "aspnetcore", "aspnetcore", "{C869CC72-9A98-4246-9A76-6A50F48AFD85}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElsaDashboard.Samples.AspNetCore.Monolith", "src\samples\dashboard\aspnetcore\ElsaDashboard.Samples.AspNetCore.Monolith\ElsaDashboard.Samples.AspNetCore.Monolith.csproj", "{F1EF5639-021A-4D22-9D4A-73D57C88EBFA}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElsaDashboard.Samples.AspNetCore.Monolith", "src\samples\dashboard\aspnetcore\ElsaDashboard.Samples.AspNetCore.Monolith\ElsaDashboard.Samples.AspNetCore.Monolith.csproj", "{F1EF5639-021A-4D22-9D4A-73D57C88EBFA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.Persistence.YesSql", "src\samples\persistence\Elsa.Samples.Persistence.YesSql\Elsa.Samples.Persistence.YesSql.csproj", "{3A30EFFE-32D8-40B8-9C62-427037BB5424}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.Persistence.YesSql", "src\samples\persistence\Elsa.Samples.Persistence.YesSql\Elsa.Samples.Persistence.YesSql.csproj", "{3A30EFFE-32D8-40B8-9C62-427037BB5424}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Designer.Components.Web", "src\designer\bindings\aspnet\Elsa.Designer.Components.Web\Elsa.Designer.Components.Web.csproj", "{3DF05CFC-AC77-489F-9A42-C4FDB599AA69}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Designer.Components.Web", "src\designer\bindings\aspnet\Elsa.Designer.Components.Web\Elsa.Designer.Components.Web.csproj", "{3DF05CFC-AC77-489F-9A42-C4FDB599AA69}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{D7F75477-D477-4899-BA3B-67D6B56515B0}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docker\docker-compose.yaml = docker\docker-compose.yaml
|
||||
docker\Dockerfile = docker\Dockerfile
|
||||
docker\README.md = docker\README.md
|
||||
docker\Dockerfile-elsa-dashboard = docker\Dockerfile-elsa-dashboard
|
||||
docker\Dockerfile-elsa-dashboard-and-server = docker\Dockerfile-elsa-dashboard-and-server
|
||||
EndProjectSection
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docker\docker-compose.yaml = docker\docker-compose.yaml
|
||||
docker\Dockerfile = docker\Dockerfile
|
||||
docker\Dockerfile-with-npm = docker\Dockerfile-with-npm
|
||||
docker\README.md = docker\README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Persistence.EntityFramework.MySql", "src\persistence\Elsa.Persistence.EntityFramework\Elsa.Persistence.EntityFramework.MySql\Elsa.Persistence.EntityFramework.MySql.csproj", "{D55BC08B-CA82-478A-99F7-EDE90AC33160}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Persistence.EntityFramework.MySql", "src\persistence\Elsa.Persistence.EntityFramework\Elsa.Persistence.EntityFramework.MySql\Elsa.Persistence.EntityFramework.MySql.csproj", "{D55BC08B-CA82-478A-99F7-EDE90AC33160}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.SendHttp", "src\samples\aspnet\Elsa.Samples.SendHttp\Elsa.Samples.SendHttp.csproj", "{775EFD59-F99C-4D38-B54E-9734C9D9649A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Activities.File", "src\activities\Elsa.Activities.File\Elsa.Activities.File.csproj", "{BE284508-9582-4FCB-B0DD-0761AB940AD7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.CustomActivityOutcomes", "src\samples\console\Elsa.Samples.CustomActivityOutcomes\Elsa.Samples.CustomActivityOutcomes.csproj", "{30A9B140-14F5-4D00-84ED-1447F96D13C8}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.ReadLineToFile", "src\samples\console\Elsa.Samples.ReadLineToFile\Elsa.Samples.ReadLineToFile.csproj", "{3EB488DF-3C28-4DAD-B43E-6062E39629AB}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.SendHttp", "src\samples\aspnet\Elsa.Samples.SendHttp\Elsa.Samples.SendHttp.csproj", "{775EFD59-F99C-4D38-B54E-9734C9D9649A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.CustomActivityOutcomes", "src\samples\console\Elsa.Samples.CustomActivityOutcomes\Elsa.Samples.CustomActivityOutcomes.csproj", "{30A9B140-14F5-4D00-84ED-1447F96D13C8}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "aspnetcore", "aspnetcore", "{28C5C63F-2DCF-46BE-9576-1F50A7CFE8C4}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docker\docker-compose.yaml = docker\docker-compose.yaml
|
||||
docker\Dockerfile = docker\Dockerfile
|
||||
docker\Dockerfile-elsa-dashboard = docker\Dockerfile-elsa-dashboard
|
||||
docker\Dockerfile-elsa-dashboard-and-server = docker\Dockerfile-elsa-dashboard-and-server
|
||||
docker\README.md = docker\README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "github", "github", "{3BF2C5A9-AC69-4587-833F-C16CFC97E100}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.github\workflows\publish-latest-dashboard-docker.yml = .github\workflows\publish-latest-dashboard-docker.yml
|
||||
.github\workflows\publish-latest-server-docker.yml = .github\workflows\publish-latest-server-docker.yml
|
||||
.github\workflows\publish-latest-dashboard-and-server-docker.yml = .github\workflows\publish-latest-dashboard-and-server-docker.yml
|
||||
EndProjectSection
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.github\workflows\publish-latest-dashboard-and-server-docker.yml = .github\workflows\publish-latest-dashboard-and-server-docker.yml
|
||||
.github\workflows\publish-latest-dashboard-docker.yml = .github\workflows\publish-latest-dashboard-docker.yml
|
||||
.github\workflows\publish-latest-server-docker.yml = .github\workflows\publish-latest-server-docker.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.SignalApi", "src\samples\aspnet\Elsa.Samples.SignalApi\Elsa.Samples.SignalApi.csproj", "{3E2423CF-50E6-4D2B-8749-17B1EF540FE4}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.SignalApi", "src\samples\aspnet\Elsa.Samples.SignalApi\Elsa.Samples.SignalApi.csproj", "{3E2423CF-50E6-4D2B-8749-17B1EF540FE4}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "caching", "caching", "{9937FB02-72D9-4FCD-B31E-8E60CFF1B37F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Caching.Rebus", "src\caching\Elsa.Caching.Rebus\Elsa.Caching.Rebus.csproj", "{61C16CA0-B190-4642-A81A-5C03705CA2C1}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Caching.Rebus", "src\caching\Elsa.Caching.Rebus\Elsa.Caching.Rebus.csproj", "{61C16CA0-B190-4642-A81A-5C03705CA2C1}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "providers", "providers", "{EC5D4AFD-3F7F-4B51-9C38-F18C60618731}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Providers.Redis", "src\providers\Elsa.Providers.Redis\Elsa.Providers.Redis.csproj", "{9ACA06DA-9AFE-41A2-8109-EFED8B9B14A1}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Providers.Redis", "src\providers\Elsa.Providers.Redis\Elsa.Providers.Redis.csproj", "{9ACA06DA-9AFE-41A2-8109-EFED8B9B14A1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.DistributedLocking.Redis", "src\locking\Elsa.DistributedLocking.Redis\Elsa.DistributedLocking.Redis.csproj", "{D1644D32-AA51-4D10-942E-F2722DB963B4}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.DistributedLocking.Redis", "src\locking\Elsa.DistributedLocking.Redis\Elsa.DistributedLocking.Redis.csproj", "{D1644D32-AA51-4D10-942E-F2722DB963B4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Activities.Conductor", "src\activities\Elsa.Activities.Conductor\Elsa.Activities.Conductor.csproj", "{E62077E1-59F4-4937-B45B-59F86417BCF8}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Activities.Conductor", "src\activities\Elsa.Activities.Conductor\Elsa.Activities.Conductor.csproj", "{E62077E1-59F4-4937-B45B-59F86417BCF8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleClientApp.Web", "src\samples\server\SampleClientApp.Web\SampleClientApp.Web.csproj", "{7756E22A-AD59-46C1-A019-1D28D7217347}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleClientApp.Web", "src\samples\server\SampleClientApp.Web\SampleClientApp.Web.csproj", "{7756E22A-AD59-46C1-A019-1D28D7217347}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElsaDashboard.Web", "src\dashboards\ElsaDashboard\ElsaDashboard.Web.csproj", "{1129868E-BA72-44C4-941C-A28D9001504B}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElsaDashboard.Web", "src\dashboards\ElsaDashboard\ElsaDashboard.Web.csproj", "{1129868E-BA72-44C4-941C-A28D9001504B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElsaDashboard.Samples.BlazorWasm", "src\samples\dashboard\blazor\ElsaDashboard.Samples.BlazorWasm\ElsaDashboard.Samples.BlazorWasm.csproj", "{24A99602-F743-4B1A-AC96-599F34AE916C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElsaDashboard.Samples.BlazorWasm", "src\samples\dashboard\blazor\ElsaDashboard.Samples.BlazorWasm\ElsaDashboard.Samples.BlazorWasm.csproj", "{24A99602-F743-4B1A-AC96-599F34AE916C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "html", "html", "{8E6215AB-FDD3-4011-B598-B6BB63F294BB}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
src\samples\dashboard\html\index.html = src\samples\dashboard\html\index.html
|
||||
src\samples\dashboard\html\package.json = src\samples\dashboard\html\package.json
|
||||
EndProjectSection
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
src\samples\dashboard\html\index.html = src\samples\dashboard\html\index.html
|
||||
src\samples\dashboard\html\package.json = src\samples\dashboard\html\package.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElsaDashboard.Samples.BlazorServer", "src\samples\dashboard\blazor\ElsaDashboard.Samples.BlazorServer\ElsaDashboard.Samples.BlazorServer.csproj", "{6A03B177-09E0-4421-9704-945E6248AB69}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElsaDashboard.Samples.BlazorServer", "src\samples\dashboard\blazor\ElsaDashboard.Samples.BlazorServer\ElsaDashboard.Samples.BlazorServer.csproj", "{6A03B177-09E0-4421-9704-945E6248AB69}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.FaultyWorkflows", "src\samples\aspnet\Elsa.Samples.FaultyWorkflows\Elsa.Samples.FaultyWorkflows.csproj", "{84751112-C2B7-41D4-98F5-D87D7C2E1DAE}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.FaultyWorkflows", "src\samples\aspnet\Elsa.Samples.FaultyWorkflows\Elsa.Samples.FaultyWorkflows.csproj", "{84751112-C2B7-41D4-98F5-D87D7C2E1DAE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -625,6 +637,14 @@ Global
|
|||
{D55BC08B-CA82-478A-99F7-EDE90AC33160}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D55BC08B-CA82-478A-99F7-EDE90AC33160}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D55BC08B-CA82-478A-99F7-EDE90AC33160}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -788,6 +808,8 @@ Global
|
|||
{3A30EFFE-32D8-40B8-9C62-427037BB5424} = {EEBEA8AF-C8A8-4C71-A96C-D5836DE24359}
|
||||
{3DF05CFC-AC77-489F-9A42-C4FDB599AA69} = {8B6B40A8-DF21-4CD2-BABD-474B79D0C3AF}
|
||||
{D55BC08B-CA82-478A-99F7-EDE90AC33160} = {C865B0FD-E505-48F0-BFAF-0D4D7C1B5CA1}
|
||||
{BE284508-9582-4FCB-B0DD-0761AB940AD7} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{3EB488DF-3C28-4DAD-B43E-6062E39629AB} = {FC9F520F-BA51-4AD2-BFEE-EF787798E734}
|
||||
{775EFD59-F99C-4D38-B54E-9734C9D9649A} = {22E75696-6FE9-436A-9097-EE21C603F818}
|
||||
{30A9B140-14F5-4D00-84ED-1447F96D13C8} = {FC9F520F-BA51-4AD2-BFEE-EF787798E734}
|
||||
{3E2423CF-50E6-4D2B-8749-17B1EF540FE4} = {22E75696-6FE9-436A-9097-EE21C603F818}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
[Action(Category = "File",
|
||||
Description = "Deletes file at specified location",
|
||||
Outcomes = new[] { OutcomeNames.Done })]
|
||||
public class DeleteFile : Activity
|
||||
{
|
||||
[ActivityInput(Hint = "Path of the file to delete.")]
|
||||
public string Path { get; set; }
|
||||
|
||||
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)
|
||||
{
|
||||
System.IO.File.Delete(Path);
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class DeleteFileBuilderExtensions
|
||||
{
|
||||
public static IActivityBuilder DeleteFile(this IActivityBuilder builder, Action<ISetupActivity<DeleteFile>> setup, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) => builder.Then(setup, null, lineNumber, sourceFile);
|
||||
|
||||
public static IActivityBuilder DeleteFile(this IActivityBuilder builder, Func<ActivityExecutionContext, string> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.DeleteFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder DeleteFile(this IActivityBuilder builder, Func<ActivityExecutionContext, ValueTask<string>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.DeleteFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder DeleteFile(this IActivityBuilder builder, Func<string> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.DeleteFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder DeleteFile(this IActivityBuilder builder, Func<ValueTask<string>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.DeleteFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder DeleteFile(this IActivityBuilder builder, string path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.DeleteFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class DeleteFileExtensions
|
||||
{
|
||||
public static ISetupActivity<DeleteFile> WithPath(this ISetupActivity<DeleteFile> setup, Func<ActivityExecutionContext, ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<DeleteFile> WithPath(this ISetupActivity<DeleteFile> setup, Func<ActivityExecutionContext, string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<DeleteFile> WithPath(this ISetupActivity<DeleteFile> setup, Func<ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<DeleteFile> WithPath(this ISetupActivity<DeleteFile> setup, Func<string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<DeleteFile> WithPath(this ISetupActivity<DeleteFile> setup, string path) => setup.Set(x => x.Path, path);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
[Action(Category = "File",
|
||||
Description = "Enumerates files in a given folder",
|
||||
Outcomes = new[] { OutcomeNames.Done })]
|
||||
public class EnumerateFiles : Activity
|
||||
{
|
||||
[ActivityInput(Hint = "Path of the folder to enumerate files.")]
|
||||
public string Path { get; set; }
|
||||
|
||||
[ActivityInput(Hint = "Pattern for files to return.")]
|
||||
public string Pattern { get; set; }
|
||||
|
||||
[ActivityInput(Hint = "Ignore inaccessible files.", Label = "Ignore Inaccessible")]
|
||||
public bool IgnoreInaccessible { get; set; } = true;
|
||||
|
||||
[ActivityInput(Hint = "Set case sensitivity.", Label = "Match Casing")]
|
||||
public MatchCasing MatchCasing { get; set; } = MatchCasing.CaseInsensitive;
|
||||
|
||||
[ActivityInput(Hint = "Return files from sub directories", Label = "Sub Directories")]
|
||||
public bool SubDirectories { get; set; } = false;
|
||||
|
||||
[ActivityOutput(Hint = "List of files.")]
|
||||
public IEnumerable<string> Files { get; set; }
|
||||
|
||||
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Pattern))
|
||||
return Done(Directory.EnumerateFiles(Path));
|
||||
|
||||
EnumerationOptions options = new EnumerationOptions()
|
||||
{
|
||||
IgnoreInaccessible = IgnoreInaccessible,
|
||||
MatchCasing = MatchCasing,
|
||||
RecurseSubdirectories = SubDirectories
|
||||
};
|
||||
Files = Directory.EnumerateFiles(Path, Pattern, options);
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class EnumerateFilesBuilderExtensions
|
||||
{
|
||||
public static IActivityBuilder EnumerateFiles(this IBuilder builder, Action<ISetupActivity<EnumerateFiles>> setup, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) => builder.Then(setup, null, lineNumber, sourceFile);
|
||||
|
||||
public static IActivityBuilder EnumerateFiles(this IBuilder builder, Func<ActivityExecutionContext, ValueTask<string>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.EnumerateFiles(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder EnumerateFiles(this IBuilder builder, Func<ActivityExecutionContext, string> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.EnumerateFiles(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder EnumerateFiles(this IBuilder builder, Func<ValueTask<string>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.EnumerateFiles(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder EnumerateFiles(this IBuilder builder, Func<string> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.EnumerateFiles(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder EnumerateFiles(this IBuilder builder, string path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.EnumerateFiles(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class EnumerateFilesExtensions
|
||||
{
|
||||
#region Path
|
||||
public static ISetupActivity<EnumerateFiles> WithPath(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<EnumerateFiles> WithPath(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<EnumerateFiles> WithPath(this ISetupActivity<EnumerateFiles> setup, Func<ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<EnumerateFiles> WithPath(this ISetupActivity<EnumerateFiles> setup, Func<string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<EnumerateFiles> WithPath(this ISetupActivity<EnumerateFiles> setup, string path) => setup.Set(x => x.Path, path);
|
||||
#endregion
|
||||
|
||||
#region Pattern
|
||||
public static ISetupActivity<EnumerateFiles> WithPattern(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, ValueTask<string>> pattern) => setup.Set(x => x.Pattern, pattern);
|
||||
public static ISetupActivity<EnumerateFiles> WithPattern(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, string> pattern) => setup.Set(x => x.Pattern, pattern);
|
||||
public static ISetupActivity<EnumerateFiles> WithPattern(this ISetupActivity<EnumerateFiles> setup, Func<ValueTask<string>> pattern) => setup.Set(x => x.Pattern, pattern);
|
||||
public static ISetupActivity<EnumerateFiles> WithPattern(this ISetupActivity<EnumerateFiles> setup, Func<string> pattern) => setup.Set(x => x.Pattern, pattern);
|
||||
public static ISetupActivity<EnumerateFiles> WithPattern(this ISetupActivity<EnumerateFiles> setup, string pattern) => setup.Set(x => x.Pattern, pattern);
|
||||
#endregion
|
||||
|
||||
#region IgnoreInaccessible
|
||||
public static ISetupActivity<EnumerateFiles> WithIgnoreInaccessible(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, ValueTask<bool>> ignoreInaccessible) => setup.Set(x => x.IgnoreInaccessible, ignoreInaccessible);
|
||||
public static ISetupActivity<EnumerateFiles> WithIgnoreInaccessible(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, bool> ignoreInaccessible) => setup.Set(x => x.IgnoreInaccessible, ignoreInaccessible);
|
||||
public static ISetupActivity<EnumerateFiles> WithIgnoreInaccessible(this ISetupActivity<EnumerateFiles> setup, Func<ValueTask<bool>> ignoreInaccessible) => setup.Set(x => x.IgnoreInaccessible, ignoreInaccessible);
|
||||
public static ISetupActivity<EnumerateFiles> WithIgnoreInaccessible(this ISetupActivity<EnumerateFiles> setup, Func<bool> ignoreInaccessible) => setup.Set(x => x.IgnoreInaccessible, ignoreInaccessible);
|
||||
public static ISetupActivity<EnumerateFiles> WithIgnoreInaccessible(this ISetupActivity<EnumerateFiles> setup, bool ignoreInaccessible) => setup.Set(x => x.IgnoreInaccessible, ignoreInaccessible);
|
||||
#endregion
|
||||
|
||||
#region MatchCasing
|
||||
public static ISetupActivity<EnumerateFiles> WithMatchCasing(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, ValueTask<MatchCasing>> matchCasing) => setup.Set(x => x.MatchCasing, matchCasing);
|
||||
public static ISetupActivity<EnumerateFiles> WithMatchCasing(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, MatchCasing> matchCasing) => setup.Set(x => x.MatchCasing, matchCasing);
|
||||
public static ISetupActivity<EnumerateFiles> WithMatchCasing(this ISetupActivity<EnumerateFiles> setup, Func<ValueTask<MatchCasing>> matchCasing) => setup.Set(x => x.MatchCasing, matchCasing);
|
||||
public static ISetupActivity<EnumerateFiles> WithMatchCasing(this ISetupActivity<EnumerateFiles> setup, Func<MatchCasing> matchCasing) => setup.Set(x => x.MatchCasing, matchCasing);
|
||||
public static ISetupActivity<EnumerateFiles> WithMatchCasing(this ISetupActivity<EnumerateFiles> setup, MatchCasing matchCasing) => setup.Set(x => x.MatchCasing, matchCasing);
|
||||
#endregion
|
||||
|
||||
#region SubDirectories
|
||||
public static ISetupActivity<EnumerateFiles> WithSubDirectories(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, ValueTask<bool>> subDirectories) => setup.Set(x => x.SubDirectories, subDirectories);
|
||||
public static ISetupActivity<EnumerateFiles> WithSubDirectories(this ISetupActivity<EnumerateFiles> setup, Func<ActivityExecutionContext, bool> subDirectories) => setup.Set(x => x.SubDirectories, subDirectories);
|
||||
public static ISetupActivity<EnumerateFiles> WithSubDirectories(this ISetupActivity<EnumerateFiles> setup, Func<ValueTask<bool>> subDirectories) => setup.Set(x => x.SubDirectories, subDirectories);
|
||||
public static ISetupActivity<EnumerateFiles> WithSubDirectories(this ISetupActivity<EnumerateFiles> setup, Func<bool> subDirectories) => setup.Set(x => x.SubDirectories, subDirectories);
|
||||
public static ISetupActivity<EnumerateFiles> WithSubDirectories(this ISetupActivity<EnumerateFiles> setup, bool subDirectories) => setup.Set(x => x.SubDirectories, subDirectories);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
[Action(Category = "File",
|
||||
Description = "Checks if a file exists",
|
||||
Outcomes = new[] { OutcomeNames.True, OutcomeNames.False })]
|
||||
public class FileExists : Activity
|
||||
{
|
||||
[ActivityInput(Hint = "Path of the file to delete.")]
|
||||
public string Path { get; set; }
|
||||
|
||||
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)
|
||||
{
|
||||
var exists = System.IO.File.Exists(Path);
|
||||
if (exists)
|
||||
return Outcome(OutcomeNames.True);
|
||||
else
|
||||
return Outcome(OutcomeNames.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class FileExistsBuilderExtensions
|
||||
{
|
||||
public static IActivityBuilder FileExists(this IActivityBuilder builder, Action<ISetupActivity<FileExists>> setup, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) => builder.Then(setup, null, lineNumber, sourceFile);
|
||||
|
||||
public static IActivityBuilder FileExists(this IActivityBuilder builder, Func<ActivityExecutionContext, string> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.FileExists(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder FileExists(this IActivityBuilder builder, Func<ActivityExecutionContext, ValueTask<string>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.FileExists(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder FileExists(this IActivityBuilder builder, Func<string> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.FileExists(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder FileExists(this IActivityBuilder builder, Func<ValueTask<string>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.FileExists(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder FileExists(this IActivityBuilder builder, string path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.FileExists(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class FileExistsExtensions
|
||||
{
|
||||
public static ISetupActivity<FileExists> WithPath(this ISetupActivity<FileExists> setup, Func<ActivityExecutionContext, ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<FileExists> WithPath(this ISetupActivity<FileExists> setup, Func<ActivityExecutionContext, string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<FileExists> WithPath(this ISetupActivity<FileExists> setup, Func<ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<FileExists> WithPath(this ISetupActivity<FileExists> setup, Func<string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<FileExists> WithPath(this ISetupActivity<FileExists> setup, string path) => setup.Set(x => x.Path, path);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public enum CopyMode
|
||||
{
|
||||
Append,
|
||||
Overwrite,
|
||||
CreateNew
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Design;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
[Action(Category = "File",
|
||||
Description = "Output input value to specified location",
|
||||
Outcomes = new[] { OutcomeNames.Done })]
|
||||
public class OutFile : Activity
|
||||
{
|
||||
[ActivityInput(Hint = "Bytes to write to file.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript }, DefaultSyntax = SyntaxNames.JavaScript)]
|
||||
public byte[] Bytes { get; set; }
|
||||
|
||||
[ActivityInput(Hint = "Path to create file at.", UIHint = ActivityInputUIHints.SingleLine, SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
|
||||
public string Path { get; set; }
|
||||
|
||||
[ActivityInput(Hint = "How the output file should be written to.", UIHint = ActivityInputUIHints.Dropdown)]
|
||||
public CopyMode Mode { get; set; } = CopyMode.CreateNew;
|
||||
|
||||
protected async override ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
|
||||
{
|
||||
FileMode fileMode;
|
||||
FileAccess fileAccess;
|
||||
switch (Mode)
|
||||
{
|
||||
case CopyMode.Append:
|
||||
fileMode = FileMode.Append;
|
||||
fileAccess = FileAccess.Write;
|
||||
break;
|
||||
case CopyMode.Overwrite:
|
||||
fileMode = FileMode.Create;
|
||||
fileAccess = FileAccess.ReadWrite;
|
||||
break;
|
||||
case CopyMode.CreateNew:
|
||||
fileMode = FileMode.CreateNew;
|
||||
fileAccess = FileAccess.ReadWrite;
|
||||
break;
|
||||
default:
|
||||
throw new ApplicationException("Unsupported copy mode");
|
||||
}
|
||||
|
||||
using (var fs = new FileStream(Path, fileMode, fileAccess))
|
||||
{
|
||||
await fs.WriteAsync(Bytes);
|
||||
await fs.FlushAsync();
|
||||
}
|
||||
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class OutFileBuilderExtensions
|
||||
{
|
||||
public static IActivityBuilder OutFile(this IBuilder builder, Action<ISetupActivity<OutFile>> setup, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) => builder.Then(setup, null, lineNumber, sourceFile);
|
||||
|
||||
public static IActivityBuilder OutFile(this IBuilder builder, Func<ActivityExecutionContext, byte[]> bytes, Func<ActivityExecutionContext, string> path, Func<ActivityExecutionContext, CopyMode> mode, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Bytes, bytes)
|
||||
.Set(x => x.Path, path)
|
||||
.Set(x => x.Mode, mode),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder OutFile(this IBuilder builder, Func<ActivityExecutionContext, ValueTask<byte[]>> bytes, Func<ActivityExecutionContext, ValueTask<string>> path, Func<ActivityExecutionContext, ValueTask<CopyMode>> mode, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Bytes, bytes)
|
||||
.Set(x => x.Path, path)
|
||||
.Set(x => x.Mode, mode),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder OutFile(this IBuilder builder, Func<byte[]> bytes, Func<string> path, Func<CopyMode> mode, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Bytes, bytes)
|
||||
.Set(x => x.Path, path)
|
||||
.Set(x => x.Mode, mode),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder OutFile(this IBuilder builder, Func<ValueTask<byte[]>> bytes, Func<ValueTask<string>> path, Func<ValueTask<CopyMode>> mode, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Bytes, bytes)
|
||||
.Set(x => x.Path, path)
|
||||
.Set(x => x.Mode, mode),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder OutFile(this IBuilder builder, byte[] bytes, string path, CopyMode mode, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Bytes, bytes)
|
||||
.Set(x => x.Path, path)
|
||||
.Set(x => x.Mode, mode),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class OutFileExtensions
|
||||
{
|
||||
#region Bytes
|
||||
public static ISetupActivity<OutFile> WithBytes(this ISetupActivity<OutFile> setup, Func<ActivityExecutionContext, ValueTask<byte[]>> bytes) => setup.Set(x => x.Bytes, bytes);
|
||||
public static ISetupActivity<OutFile> WithBytes(this ISetupActivity<OutFile> setup, Func<ActivityExecutionContext, byte[]> bytes) => setup.Set(x => x.Bytes, bytes);
|
||||
public static ISetupActivity<OutFile> WithBytes(this ISetupActivity<OutFile> setup, Func<ValueTask<byte[]>> bytes) => setup.Set(x => x.Bytes, bytes);
|
||||
public static ISetupActivity<OutFile> WithBytes(this ISetupActivity<OutFile> setup, Func<byte[]> bytes) => setup.Set(x => x.Bytes, bytes);
|
||||
public static ISetupActivity<OutFile> WithBytes(this ISetupActivity<OutFile> setup, byte[] bytes) => setup.Set(x => x.Bytes, bytes);
|
||||
#endregion
|
||||
|
||||
#region Path
|
||||
public static ISetupActivity<OutFile> WithPath(this ISetupActivity<OutFile> setup, Func<ActivityExecutionContext, ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<OutFile> WithPath(this ISetupActivity<OutFile> setup, Func<ActivityExecutionContext, string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<OutFile> WithPath(this ISetupActivity<OutFile> setup, Func<ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<OutFile> WithPath(this ISetupActivity<OutFile> setup, Func<string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<OutFile> WithPath(this ISetupActivity<OutFile> setup, string path) => setup.Set(x => x.Path, path);
|
||||
#endregion
|
||||
|
||||
#region Mode
|
||||
public static ISetupActivity<OutFile> WithMode(this ISetupActivity<OutFile> setup, Func<ActivityExecutionContext, ValueTask<CopyMode>> mode) => setup.Set(x => x.Mode, mode);
|
||||
public static ISetupActivity<OutFile> WithMode(this ISetupActivity<OutFile> setup, Func<ActivityExecutionContext, CopyMode> mode) => setup.Set(x => x.Mode, mode);
|
||||
public static ISetupActivity<OutFile> WithMode(this ISetupActivity<OutFile> setup, Func<ValueTask<CopyMode>> mode) => setup.Set(x => x.Mode, mode);
|
||||
public static ISetupActivity<OutFile> WithMode(this ISetupActivity<OutFile> setup, Func<CopyMode> mode) => setup.Set(x => x.Mode, mode);
|
||||
public static ISetupActivity<OutFile> WithMode(this ISetupActivity<OutFile> setup, CopyMode mode) => setup.Set(x => x.Mode, mode);
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Design;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
[Action(Category = "File",
|
||||
Description = "Output input value to specified location",
|
||||
Outcomes = new[] { OutcomeNames.Done })]
|
||||
public class ReadFile : Activity
|
||||
{
|
||||
[ActivityInput(Hint = "Path to read content from.", UIHint = ActivityInputUIHints.SingleLine, SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
|
||||
public string Path { get; set; }
|
||||
|
||||
[ActivityOutput(Hint = "Bytes of the file read.")]
|
||||
public byte[] Bytes { get; set; }
|
||||
|
||||
public async override ValueTask<IActivityExecutionResult> ExecuteAsync(ActivityExecutionContext context)
|
||||
{
|
||||
var Bytes = await System.IO.File.ReadAllBytesAsync(Path);
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class ReadFileBuilderExtensions
|
||||
{
|
||||
public static IActivityBuilder ReadFile(this IBuilder builder, Action<ISetupActivity<OutFile>> setup, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) => builder.Then(setup, null, lineNumber, sourceFile);
|
||||
|
||||
public static IActivityBuilder ReadFile(this IBuilder builder, Func<ActivityExecutionContext, string> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder ReadFile(this IBuilder builder, Func<ActivityExecutionContext, ValueTask<string>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder ReadFile(this IBuilder builder, Func<string> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder ReadFile(this IBuilder builder, Func<ValueTask<string>> path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
|
||||
public static IActivityBuilder ReadFile(this IBuilder builder, string path, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) =>
|
||||
builder.OutFile(activity => activity
|
||||
.Set(x => x.Path, path),
|
||||
lineNumber,
|
||||
sourceFile);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
using Elsa.Builders;
|
||||
using Elsa.Services.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class ReadFileExtensions
|
||||
{
|
||||
public static ISetupActivity<ReadFile> WithPath(this ISetupActivity<ReadFile> setup, Func<ActivityExecutionContext, ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<ReadFile> WithPath(this ISetupActivity<ReadFile> setup, Func<ActivityExecutionContext, string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<ReadFile> WithPath(this ISetupActivity<ReadFile> setup, Func<ValueTask<string>> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<ReadFile> WithPath(this ISetupActivity<ReadFile> setup, Func<string> path) => setup.Set(x => x.Path, path);
|
||||
public static ISetupActivity<ReadFile> WithPath(this ISetupActivity<ReadFile> setup, string path) => setup.Set(x => x.Path, path);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
[Action(Category = "File",
|
||||
Description = "Created a temporary file and returns its path",
|
||||
Outcomes = new[] { OutcomeNames.Done })]
|
||||
public class TempFile : Activity
|
||||
{
|
||||
[ActivityOutput(Hint = "Path of the created temporary file.")]
|
||||
public string Path { get; set; }
|
||||
|
||||
protected override IActivityExecutionResult OnExecute()
|
||||
{
|
||||
Path = System.IO.Path.GetTempFileName();
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using Elsa.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Elsa.Activities.File
|
||||
{
|
||||
public static class TempFileBuilderExtensions
|
||||
{
|
||||
public static IActivityBuilder TempFile(this IBuilder builder, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string? sourceFile = default) => builder.Then<TempFile>(null, lineNumber, sourceFile);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Description>Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application.
|
||||
This package provides the following File activities:
|
||||
|
||||
* DeleteFile
|
||||
* EnumerteFiles
|
||||
* FileExists
|
||||
* OutFile
|
||||
* ReadFile
|
||||
* TempFile</Description>
|
||||
<PackageTags>elsa, workflows</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ConfigureAwait.Fody" Version="3.3.1" />
|
||||
<PackageReference Include="Fody" Version="6.5.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\core\Elsa.Core\Elsa.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using Elsa;
|
||||
using Elsa.Activities.File;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddFileActivities(this IServiceCollection services)
|
||||
{
|
||||
return services;
|
||||
}
|
||||
|
||||
public static ElsaOptionsBuilder AddFileActivities(this ElsaOptionsBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
builder.AddActivity<DeleteFile>()
|
||||
.AddActivity<EnumerateFiles>()
|
||||
.AddActivity<FileExists>()
|
||||
.AddActivity<OutFile>()
|
||||
.AddActivity<ReadFile>()
|
||||
.AddActivity<TempFile>();
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
src/activities/Elsa.Activities.File/FodyWeavers.xml
Normal file
3
src/activities/Elsa.Activities.File/FodyWeavers.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ConfigureAwait ContinueOnCapturedContext="false" />
|
||||
</Weavers>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Activities.File.Models
|
||||
{
|
||||
public class FileSystemChanged
|
||||
{
|
||||
public FileSystemChanged()
|
||||
{ }
|
||||
|
||||
public FileSystemChanged(WatcherChangeTypes changeType, string directory, string fileName, string fullPath)
|
||||
{
|
||||
ChangeType = changeType;
|
||||
Directory = directory;
|
||||
FileName = fileName;
|
||||
FullPath = fullPath;
|
||||
TimeStamp = DateTime.Now;
|
||||
}
|
||||
|
||||
public WatcherChangeTypes ChangeType { get; set; }
|
||||
|
||||
public string Directory { get; set; }
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string FullPath { get; set; }
|
||||
|
||||
public string Pattern { get; set; }
|
||||
|
||||
public DateTime TimeStamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\activities\Elsa.Activities.File\Elsa.Activities.File.csproj" />
|
||||
<ProjectReference Include="..\..\..\core\Elsa\Elsa.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Program.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
using Elsa.Activities.Console;
|
||||
using Elsa.Activities.File;
|
||||
using Elsa.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Samples.FileWatcher
|
||||
{
|
||||
public class FileWatcherWorkflow : IWorkflow
|
||||
{
|
||||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder.Add<WatchDirectory>(setup =>
|
||||
{
|
||||
setup.Set(x => x.ChangeType, WatcherChangeTypes.Created);
|
||||
setup.Set(x => x.Directory, "C:\\Temp\\FileWatcher");
|
||||
setup.Set(x => x.Pattern, "*.txt");
|
||||
})
|
||||
.WriteLine("FileWatcherWorkflow received file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using Elsa.Activities.Console;
|
||||
using Elsa.Activities.File;
|
||||
using Elsa.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Samples.FileWatcher
|
||||
{
|
||||
public class FileWatcherWorkflowIgnore : IWorkflow
|
||||
{
|
||||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder.Add<WatchDirectory>(setup =>
|
||||
{
|
||||
setup.Set(x => x.Directory, "C:\\Temp\\FileWatcher2");
|
||||
setup.Set(x => x.ChangeType, WatcherChangeTypes.Created);
|
||||
})
|
||||
.WriteLine("FileWatcherWorkflowSkip received file");
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/samples/console/Elsa.Samples.FileWatcher/Program.cs
Normal file
32
src/samples/console/Elsa.Samples.FileWatcher/Program.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using Elsa.Activities.File.Options;
|
||||
using Elsa.Activities.File.Services;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Samples.FileWatcher
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public async static Task Main(string[] args)
|
||||
{
|
||||
await Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
var configuration = context.Configuration;
|
||||
services.AddElsa(configure => configure
|
||||
.AddConsoleActivities()
|
||||
.AddFileActivities(configuration.GetSection("Elsa")
|
||||
.GetSection("FileWatcher")
|
||||
.Bind)
|
||||
.AddWorkflow<FileWatcherWorkflow>()
|
||||
.AddWorkflow<FileWatcherWorkflowIgnore>()
|
||||
);
|
||||
})
|
||||
.RunConsoleAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:50285/",
|
||||
"sslPort": 44393
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Elsa.Samples.FileWatcher": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Elsa": {
|
||||
"FileWatcher": {
|
||||
"Path": "C:\\Temp\\FileWatcher",
|
||||
"Pattern": "*.txt"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\activities\Elsa.Activities.File\Elsa.Activities.File.csproj" />
|
||||
<ProjectReference Include="..\..\..\core\Elsa\Elsa.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
50
src/samples/console/Elsa.Samples.ReadLineToFile/Program.cs
Normal file
50
src/samples/console/Elsa.Samples.ReadLineToFile/Program.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using Elsa.Models;
|
||||
using Elsa.Persistence;
|
||||
using Elsa.Persistence.Specifications;
|
||||
using Elsa.Persistence.Specifications.WorkflowInstances;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elsa.Samples.ReadLineToFile
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
var services = new ServiceCollection()
|
||||
.AddElsa(configure => configure
|
||||
.AddConsoleActivities()
|
||||
.AddFileActivities())
|
||||
.AddAutoMapperProfiles<Program>()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Run startup actions (not needed when registering Elsa with a Host).
|
||||
var startupRunner = services.GetRequiredService<IStartupRunner>();
|
||||
await startupRunner.StartupAsync();
|
||||
|
||||
// Get a workflow runner.
|
||||
var workflowRunner = services.GetRequiredService<IBuildsAndStartsWorkflow>();
|
||||
|
||||
// Run the workflow.
|
||||
await workflowRunner.BuildAndStartWorkflowAsync<ReadLineToFileWorkflow>();
|
||||
|
||||
var store = services.GetRequiredService<IWorkflowInstanceStore>();
|
||||
|
||||
var results = await store.FindManyAsync(
|
||||
new WorkflowDefinitionIdSpecification(nameof(ReadLineToFileWorkflow)),
|
||||
OrderBySpecification.OrderByDescending<WorkflowInstance>(x => x.CreatedAt),
|
||||
Paging.Page(1, 2));
|
||||
|
||||
var count = await store.CountAsync(new WorkflowDefinitionIdSpecification(nameof(ReadLineToFileWorkflow)));
|
||||
|
||||
Console.WriteLine(count);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
Console.WriteLine(result.CreatedAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
using Elsa.Activities.Console;
|
||||
using Elsa.Activities.File;
|
||||
using Elsa.Activities.Primitives;
|
||||
using Elsa.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Elsa.Samples.ReadLineToFile
|
||||
{
|
||||
public class ReadLineToFileWorkflow : IWorkflow
|
||||
{
|
||||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.WriteLine("Enter text to write to file")
|
||||
.ReadLine()
|
||||
.WithName("ReadLine")
|
||||
.TempFile()
|
||||
.WithName("TempFile")
|
||||
.OutFile(setup =>
|
||||
{
|
||||
setup.WithBytes(async context => Encoding.UTF8.GetBytes(await context.GetNamedActivityPropertyAsync<ReadLine, string>("ReadLine", x => x.Output)));
|
||||
setup.WithPath(async context => await context.GetNamedActivityPropertyAsync<TempFile, string>("TempFile", x => x.Path));
|
||||
setup.WithMode(CopyMode.Overwrite);
|
||||
})
|
||||
.WriteLine(setup => setup.WithText(async context => await context.GetNamedActivityPropertyAsync<TempFile, string>("TempFile", x => x.Path)))
|
||||
.WriteLine("Press any key to continue")
|
||||
.ReadLine()
|
||||
.DeleteFile(setup => setup.WithPath(async context => await context.GetNamedActivityPropertyAsync<TempFile, string>("TempFile", x => x.Path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue