Skip to content

Commit

Permalink
Update package descriptions and renamed some activities
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmskywalker committed Oct 27, 2019
1 parent 38a4901 commit e162391
Show file tree
Hide file tree
Showing 44 changed files with 790 additions and 658 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ Version 2.0
- [ ] Generic Command & Event Activities
- [ ] Workflow Host REST API
- [ ] Workflow Host gRPC API
- [ ] Workflow Server
- [ ] Distributed Hosting Support (support for multi-node environments)
- [ ] Localization Support
- [ ] More activities
- [ ] Workflow Designer UI improvements
- [ ] Activity Editor UI improvements

Version 3.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
<TargetFramework>netstandard2.0</TargetFramework>
<PackageVersion>1.0.0</PackageVersion>
<LangVersion>latest</LangVersion>
<Authors>Sipke Schoorstra</Authors>
<Description>Elsa is a set of workflowing libraries and tools to enable super-fast workflowing capabilities in any .NET Core application.</Description>
<Authors>Elsa Contributors</Authors>
<Description>
Elsa is a set of workflow libraries and tools that enable super-fast workflowing capabilities in any .NET Core application.
This package provides the following Console activities:

* ReadLine
* WriteLine
</Description>
<Copyright>2019</Copyright>
<PackageProjectUrl>https://github.com/elsa-workflows/elsa-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows, orchard</PackageTags>
<PackageTags>elsa, workflows</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageVersion>1.0.0</PackageVersion>
<LangVersion>latest</LangVersion>
<Authors>Elsa Contributors</Authors>
<Description>
Elsa is a set of workflow libraries and tools that enable super-fast workflowing capabilities in any .NET Core application.
This package provides the following control flow activities:

* ForEach
* Fork
* IfElse
* Join
* Switch
* While
</Description>
<Copyright>2019</Copyright>
<PackageProjectUrl>https://github.com/elsa-workflows/elsa-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<PackageVersion>1.0.0</PackageVersion>
<LangVersion>latest</LangVersion>
<Authors>Sipke Schoorstra</Authors>
<Description>Elsa is a set of workflowing libraries and tools to enable super-fast workflowing capabilities in any .NET Core application.</Description>
<Authors>Elsa Contributors</Authors>
<Description>
Elsa is a set of workflow libraries and tools that enable super-fast workflowing capabilities in any .NET Core application.
This package provides the following Dropbox activities:

* SaveToDropbox
</Description>
<Copyright>2019</Copyright>
<PackageProjectUrl>https://github.com/elsa-workflows/elsa-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows, orchard, dropbox</PackageTags>
<PackageTags>elsa, workflows, dropbox</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
<TargetFramework>netstandard2.0</TargetFramework>
<PackageVersion>1.0.0</PackageVersion>
<LangVersion>latest</LangVersion>
<Authors>Sipke Schoorstra</Authors>
<Description>Elsa is a set of workflowing libraries and tools to enable super-fast workflowing capabilities in any .NET Core application.</Description>
<Authors>Elsa Contributors</Authors>
<Description>
Elsa is a set of workflow libraries and tools that enable super-fast workflowing capabilities in any .NET Core application.
This package provides the following Email activities:

* SendEmail
</Description>
<Copyright>2019</Copyright>
<PackageProjectUrl>https://github.com/elsa-workflows/elsa-core</PackageProjectUrl>
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows, orchard</PackageTags>
<PackageTags>elsa, workflows, email, smtp</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,135 +1,135 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Elsa.Activities.Http.Extensions;
using Elsa.Activities.Http.Models;
using Elsa.Activities.Http.Services;
using Elsa.Attributes;
using Elsa.Design;
using Elsa.Extensions;
using Elsa.Results;
using Elsa.Services;
using Elsa.Services.Models;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json.Linq;

namespace Elsa.Activities.Http.Activities
{
[ActivityDefinition(
Category = "HTTP",
DisplayName = "Receive HTTP Request",
Description = "Receive an incoming HTTP request.",
RuntimeDescription = "x => !!x.state.path ? `Handle <strong>${ x.state.method } ${ x.state.path }</strong>.` : x.definition.description",
Outcomes = new[] { OutcomeNames.Done }
)]
public class HttpRequestEvent : Activity
{
public static Uri GetPath(JObject state)
{
return state.GetState<Uri>(nameof(Path));
}

public static string GetMethod(JObject state)
{
return state.GetState<string>(nameof(Method));
}

private readonly IHttpContextAccessor httpContextAccessor;
private readonly IEnumerable<IContentFormatter> contentFormatters;

public HttpRequestEvent(
IHttpContextAccessor httpContextAccessor,
IEnumerable<IContentFormatter> contentFormatters)
{
this.httpContextAccessor = httpContextAccessor;
this.contentFormatters = contentFormatters;
}

/// <summary>
/// The path that triggers this activity.
/// </summary>
[ActivityProperty(Hint = "The relative path that triggers this activity.")]
public Uri Path
{
get => GetState<Uri>();
set => SetState(value);
}

/// <summary>
/// The HTTP method that triggers this activity.
/// </summary>
[ActivityProperty(
Type = ActivityPropertyTypes.Select,
Hint = "The HTTP method that triggers this activity."
)]
[SelectOptions("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD")]
public string Method
{
get => GetState<string>();
set => SetState(value);
}

/// <summary>
/// A value indicating whether the HTTP request content body should be read and stored as part of the HTTP request model.
/// The stored format depends on the content-type header.
/// </summary>
[ActivityProperty(
Hint =
"A value indicating whether the HTTP request content body should be read and stored as part of the HTTP request model. The stored format depends on the content-type header."
)]
public bool ReadContent
{
get => GetState<bool>();
set => SetState(value);
}

protected override ActivityExecutionResult OnExecute(WorkflowExecutionContext workflowContext)
{
return Halt(true);
}

protected override async Task<ActivityExecutionResult> OnResumeAsync(
WorkflowExecutionContext workflowContext,
CancellationToken cancellationToken)
{
var request = httpContextAccessor.HttpContext.Request;
var model = new HttpRequestModel
{
Path = new Uri(request.Path.ToString(), UriKind.Relative),
QueryString = request.Query.ToDictionary(x => x.Key, x => new StringValuesModel(x.Value)),
Headers = request.Headers.ToDictionary(x => x.Key, x => new StringValuesModel(x.Value)),
Method = request.Method
};

if (ReadContent)
{
if (request.HasFormContentType)
{
model.Form = (await request.ReadFormAsync(cancellationToken)).ToDictionary(
x => x.Key,
x => new StringValuesModel(x.Value)
);
}

var parser = SelectContentParser(request.ContentType);
var content = await request.ReadContentAsBytesAsync(cancellationToken);
model.Body = await parser.ParseAsync(content, request.ContentType);
}

Output["Content"] = model;
workflowContext.CurrentScope.LastResult = model;

return Done();
}

private IContentFormatter SelectContentParser(string contentType)
{
var formatters = contentFormatters.OrderByDescending(x => x.Priority).ToList();
return formatters.FirstOrDefault(
x => x.SupportedContentTypes.Contains(contentType, StringComparer.OrdinalIgnoreCase)
) ?? formatters.Last();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Elsa.Activities.Http.Extensions;
using Elsa.Activities.Http.Models;
using Elsa.Activities.Http.Services;
using Elsa.Attributes;
using Elsa.Design;
using Elsa.Extensions;
using Elsa.Results;
using Elsa.Services;
using Elsa.Services.Models;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json.Linq;

namespace Elsa.Activities.Http.Activities
{
[ActivityDefinition(
Category = "HTTP",
DisplayName = "Receive HTTP Request",
Description = "Receive an incoming HTTP request.",
RuntimeDescription = "x => !!x.state.path ? `Handle <strong>${ x.state.method } ${ x.state.path }</strong>.` : x.definition.description",
Outcomes = new[] { OutcomeNames.Done }
)]
public class ReceiveHttpRequest : Activity
{
public static Uri GetPath(JObject state)
{
return state.GetState<Uri>(nameof(Path));
}

public static string GetMethod(JObject state)
{
return state.GetState<string>(nameof(Method));
}

private readonly IHttpContextAccessor httpContextAccessor;
private readonly IEnumerable<IContentFormatter> contentFormatters;

public ReceiveHttpRequest(
IHttpContextAccessor httpContextAccessor,
IEnumerable<IContentFormatter> contentFormatters)
{
this.httpContextAccessor = httpContextAccessor;
this.contentFormatters = contentFormatters;
}

/// <summary>
/// The path that triggers this activity.
/// </summary>
[ActivityProperty(Hint = "The relative path that triggers this activity.")]
public Uri Path
{
get => GetState<Uri>();
set => SetState(value);
}

/// <summary>
/// The HTTP method that triggers this activity.
/// </summary>
[ActivityProperty(
Type = ActivityPropertyTypes.Select,
Hint = "The HTTP method that triggers this activity."
)]
[SelectOptions("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD")]
public string Method
{
get => GetState<string>();
set => SetState(value);
}

/// <summary>
/// A value indicating whether the HTTP request content body should be read and stored as part of the HTTP request model.
/// The stored format depends on the content-type header.
/// </summary>
[ActivityProperty(
Hint =
"A value indicating whether the HTTP request content body should be read and stored as part of the HTTP request model. The stored format depends on the content-type header."
)]
public bool ReadContent
{
get => GetState<bool>();
set => SetState(value);
}

protected override ActivityExecutionResult OnExecute(WorkflowExecutionContext workflowContext)
{
return Halt(true);
}

protected override async Task<ActivityExecutionResult> OnResumeAsync(
WorkflowExecutionContext workflowContext,
CancellationToken cancellationToken)
{
var request = httpContextAccessor.HttpContext.Request;
var model = new HttpRequestModel
{
Path = new Uri(request.Path.ToString(), UriKind.Relative),
QueryString = request.Query.ToDictionary(x => x.Key, x => new StringValuesModel(x.Value)),
Headers = request.Headers.ToDictionary(x => x.Key, x => new StringValuesModel(x.Value)),
Method = request.Method
};

if (ReadContent)
{
if (request.HasFormContentType)
{
model.Form = (await request.ReadFormAsync(cancellationToken)).ToDictionary(
x => x.Key,
x => new StringValuesModel(x.Value)
);
}

var parser = SelectContentParser(request.ContentType);
var content = await request.ReadContentAsBytesAsync(cancellationToken);
model.Body = await parser.ParseAsync(content, request.ContentType);
}

Output["Content"] = model;
workflowContext.CurrentScope.LastResult = model;

return Done();
}

private IContentFormatter SelectContentParser(string contentType)
{
var formatters = contentFormatters.OrderByDescending(x => x.Priority).ToList();
return formatters.FirstOrDefault(
x => x.SupportedContentTypes.Contains(contentType, StringComparer.OrdinalIgnoreCase)
) ?? formatters.Last();
}
}
}
Loading

0 comments on commit e162391

Please sign in to comment.