From d0a48d5fb4e41ca45b05b717e1c405f948f13dca Mon Sep 17 00:00:00 2001 From: Luca Pisano Date: Wed, 7 Apr 2021 16:32:29 +0200 Subject: [PATCH] addressed revision suggestions --- .../Activities/BlobExists.cs | 10 +++++----- .../Activities/DeleteBlob.cs | 19 ++++++++++--------- .../Activities/ReadBlob.cs | 19 ++++++++++--------- .../Activities/WriteBlob.cs | 2 ++ 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/activities/Elsa.Activities.BlobStorage/Activities/BlobExists.cs b/src/activities/Elsa.Activities.BlobStorage/Activities/BlobExists.cs index f75675f7f..d334e8864 100644 --- a/src/activities/Elsa.Activities.BlobStorage/Activities/BlobExists.cs +++ b/src/activities/Elsa.Activities.BlobStorage/Activities/BlobExists.cs @@ -24,14 +24,14 @@ namespace Elsa.Activities.BlobStorage } private readonly IBlobStorage _storage; - [ActivityProperty(Hint = "The ID of the blob")] - public string BlobID { get; set; } + [ActivityProperty(Hint = "The Id of the blob")] + public string BlobId { get; set; } protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context) { - if (string.IsNullOrWhiteSpace(BlobID)) - throw new System.Exception($"BlobID must have a value"); - if (await _storage.ExistsAsync(BlobID)) + if (string.IsNullOrWhiteSpace(BlobId)) + throw new System.Exception($"BlobId must have a value"); + if (await _storage.ExistsAsync(BlobId)) return Outcome(OutcomeNames.True); else return Outcome(OutcomeNames.False); diff --git a/src/activities/Elsa.Activities.BlobStorage/Activities/DeleteBlob.cs b/src/activities/Elsa.Activities.BlobStorage/Activities/DeleteBlob.cs index 9e34227ee..99acc7de9 100644 --- a/src/activities/Elsa.Activities.BlobStorage/Activities/DeleteBlob.cs +++ b/src/activities/Elsa.Activities.BlobStorage/Activities/DeleteBlob.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Threading.Tasks; using Elsa.ActivityResults; using Elsa.Attributes; +using Elsa.Design; +using Elsa.Expressions; using Elsa.Services; using Elsa.Services.Models; using Storage.Net.Blobs; @@ -24,18 +26,17 @@ namespace Elsa.Activities.BlobStorage } private readonly IBlobStorage _storage; - [ActivityProperty(Hint = "The ID of the blob")] - public string BlobID { get; set; } - [ActivityProperty(Hint = "The IDs of the blob")] - public List BlobIDs { get; set; } = new List(); + [ActivityProperty(Hint = "The Ids of the blobs", + UIHint = ActivityPropertyUIHints.MultiText, + DefaultSyntax = SyntaxNames.Json, + SupportedSyntaxes = new[] { SyntaxNames.Json, SyntaxNames.JavaScript, SyntaxNames.Liquid })] + public IList BlobIds { get; set; } = new List(); protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context) { - if (string.IsNullOrWhiteSpace(BlobID) && (BlobIDs==default || !BlobIDs.Any())) - throw new System.Exception($"BlobID or BlobIds must have a value"); - if (BlobID != default) - BlobIDs.Add(BlobID); - await _storage.DeleteAsync(BlobIDs); + if (BlobIds==default || !BlobIds.Any()) + throw new System.Exception($"BlobID or BlobIds must have a value"); + await _storage.DeleteAsync(BlobIds); return Done(); } } diff --git a/src/activities/Elsa.Activities.BlobStorage/Activities/ReadBlob.cs b/src/activities/Elsa.Activities.BlobStorage/Activities/ReadBlob.cs index 1e4770ef8..0f5670b1e 100644 --- a/src/activities/Elsa.Activities.BlobStorage/Activities/ReadBlob.cs +++ b/src/activities/Elsa.Activities.BlobStorage/Activities/ReadBlob.cs @@ -24,22 +24,23 @@ namespace Elsa.Activities.BlobStorage } private readonly IBlobStorage _storage; - [ActivityProperty(Hint = "The ID assigned to the blob.")] + [ActivityProperty(Hint = "The Id assigned to the blob.")] [Required] - public string BlobID { get; set; } - [ActivityProperty(Hint = "The bytes")] - public byte[] Bytes { get; set; } - [ActivityProperty(Hint = "The output file path, alternative to Bytes")] + public string BlobId { get; set; } + + [ActivityProperty(Hint = "If set, the output of this activity is written into the specified file, alternatively the outcome contains the bytes of the blob")] public string FilePath { get; set; } protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context) { - if (string.IsNullOrWhiteSpace(BlobID)) - throw new System.Exception($"BlobID must have a value"); + if (string.IsNullOrWhiteSpace(BlobId)) + throw new System.Exception($"BlobId must have a value"); if (!string.IsNullOrWhiteSpace(FilePath)) - await _storage.ReadToFileAsync(BlobID, FilePath, context.CancellationToken); + await _storage.ReadToFileAsync(BlobId, FilePath, context.CancellationToken); else - Bytes = await _storage.ReadBytesAsync(BlobID); + { + Done(await _storage.ReadBytesAsync(BlobId)); + } return Done(); } } diff --git a/src/activities/Elsa.Activities.BlobStorage/Activities/WriteBlob.cs b/src/activities/Elsa.Activities.BlobStorage/Activities/WriteBlob.cs index 1792c3c96..181f93adf 100644 --- a/src/activities/Elsa.Activities.BlobStorage/Activities/WriteBlob.cs +++ b/src/activities/Elsa.Activities.BlobStorage/Activities/WriteBlob.cs @@ -27,8 +27,10 @@ namespace Elsa.Activities.BlobStorage [ActivityProperty(Hint = "The ID to be assigned to the blob. It's needed to retrieve the blob")] [Required] public string BlobID { get; set; } + [ActivityProperty(Hint = "The bytes")] public byte[] Bytes { get; set; } + [ActivityProperty(Hint = "The file path")] public string FilePath { get; set; }