23 changed files with 439 additions and 60 deletions
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RootNamespace /> |
|||
<Nullable>Enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Elsa.Core" Version="$(ElsaPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.BlobStoring" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpElsaModule), |
|||
typeof(AbpBlobStoringModule))] |
|||
public class AbpElsaActivitiesBlobStoringModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
using Volo.Abp.BlobStoring; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
|
|||
[BlobContainerName("elsa-container")] |
|||
public class AbpElsaBlobContainer |
|||
{ |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using Elsa; |
|||
using Elsa.ActivityResults; |
|||
using Elsa.Attributes; |
|||
using Elsa.Services; |
|||
using Elsa.Services.Models; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.BlobStoring; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
|
|||
[Action(Category = "Blob", |
|||
Description = "Check if a blob exists.", |
|||
Outcomes = new[] { OutcomeNames.True, OutcomeNames.False })] |
|||
public class BlobExists : Activity |
|||
{ |
|||
private readonly IBlobContainer<AbpElsaBlobContainer> _container; |
|||
|
|||
[ActivityInput(Hint = "Path of the oss.")] |
|||
public string? Path { get; set; } |
|||
|
|||
public BlobExists(IBlobContainer<AbpElsaBlobContainer> container) |
|||
{ |
|||
_container = container; |
|||
} |
|||
|
|||
protected async override ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) |
|||
{ |
|||
var exists = await _container.ExistsAsync(Path, context.CancellationToken); |
|||
if (exists) |
|||
{ |
|||
return Outcome(OutcomeNames.True); |
|||
} |
|||
return Outcome(OutcomeNames.False); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
using Elsa; |
|||
using Elsa.ActivityResults; |
|||
using Elsa.Attributes; |
|||
using Elsa.Services; |
|||
using Elsa.Services.Models; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.BlobStoring; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
|
|||
[Action(Category = "Blob", |
|||
Description = "Deletes blob at specified location", |
|||
Outcomes = new[] { OutcomeNames.Done })] |
|||
public class DeleteBlob : Activity |
|||
{ |
|||
private readonly IBlobContainer<AbpElsaBlobContainer> _container; |
|||
|
|||
[ActivityInput(Hint = "Path of the blob to be deleted.")] |
|||
public string? Path { get; set; } |
|||
|
|||
public DeleteBlob(IBlobContainer<AbpElsaBlobContainer> container) |
|||
{ |
|||
_container = container; |
|||
} |
|||
|
|||
protected async override ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) |
|||
{ |
|||
await _container.DeleteAsync(Path, context.CancellationToken); |
|||
|
|||
return Done(); |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using Elsa; |
|||
using Elsa.ActivityResults; |
|||
using Elsa.Attributes; |
|||
using Elsa.Services; |
|||
using Elsa.Services.Models; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.BlobStoring; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
|
|||
[Action(Category = "Blob", |
|||
Description = "Reads a blob.", |
|||
Outcomes = new[] { OutcomeNames.Done })] |
|||
public class ReadBlob : Activity |
|||
{ |
|||
private readonly IBlobContainer<AbpElsaBlobContainer> _container; |
|||
|
|||
[ActivityInput(Hint = "Path of the blob.")] |
|||
public string? Path { get; set; } |
|||
|
|||
[ActivityOutput] |
|||
public byte[]? Output { get; set; } |
|||
|
|||
public ReadBlob(IBlobContainer<AbpElsaBlobContainer> container) |
|||
{ |
|||
_container = container; |
|||
} |
|||
|
|||
protected async override ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) |
|||
{ |
|||
Output = await _container.GetAllBytesAsync(Path, context.CancellationToken); |
|||
|
|||
return Done(); |
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
using Elsa; |
|||
using Elsa.ActivityResults; |
|||
using Elsa.Attributes; |
|||
using Elsa.Expressions; |
|||
using Elsa.Services; |
|||
using Elsa.Services.Models; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.BlobStoring; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
|
|||
[Action(Category = "Blob", |
|||
Description = "Save a blob.", |
|||
Outcomes = new[] { OutcomeNames.Done })] |
|||
public class WriteBlob : Activity |
|||
{ |
|||
private readonly IBlobContainer<AbpElsaBlobContainer> _container; |
|||
|
|||
[ActivityInput(Hint = "Path of the blob.")] |
|||
public string? Path { get; set; } |
|||
|
|||
[ActivityInput(Hint = "Blob exists whether overwrite")] |
|||
public bool Overwrite { get; set; } |
|||
|
|||
[ActivityInput(Hint = "The bytes to write.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript }, DefaultSyntax = SyntaxNames.JavaScript)] |
|||
public byte[]? Bytes { get; set; } |
|||
|
|||
public WriteBlob(IBlobContainer<AbpElsaBlobContainer> container) |
|||
{ |
|||
_container = container; |
|||
} |
|||
|
|||
protected async override ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) |
|||
{ |
|||
await _container.SaveAsync(Path, Bytes, Overwrite, context.CancellationToken); |
|||
|
|||
return Done(); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Elsa.Attributes; |
|||
using Elsa.Options; |
|||
using Elsa.Services.Startup; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
|
|||
[Feature("BlobStoring")] |
|||
public class Startup : StartupBase |
|||
{ |
|||
public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration) |
|||
{ |
|||
elsa.AddBlobStoringActivities(); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using Elsa.Options; |
|||
using LINGYUN.Abp.Elsa.Activities.BlobStoring; |
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection; |
|||
|
|||
public static class BlobStoringServiceCollectionExtensions |
|||
{ |
|||
public static ElsaOptionsBuilder AddBlobStoringActivities(this ElsaOptionsBuilder options) |
|||
{ |
|||
options |
|||
.AddActivity<WriteBlob>() |
|||
.AddActivity<ReadBlob>() |
|||
.AddActivity<BlobExists>() |
|||
.AddActivity<DeleteBlob>(); |
|||
|
|||
return options; |
|||
} |
|||
} |
|||
@ -0,0 +1,2 @@ |
|||
@using Microsoft.Extensions.Configuration |
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|||
Loading…
Reference in new issue