diff --git a/Elsa.sln b/Elsa.sln index da59e9a5ae..6e9135689c 100644 --- a/Elsa.sln +++ b/Elsa.sln @@ -76,14 +76,14 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{986E5482-0482-448C-B9E4-EC67A9474B85}" ProjectSection(SolutionItems) = preProject docker\.dockerignore = docker\.dockerignore + docker\docker-compose-datadog+otel-collector.yml = docker\docker-compose-datadog+otel-collector.yml docker\docker-compose.yml = docker\docker-compose.yml docker\ElsaServer-Datadog.Dockerfile = docker\ElsaServer-Datadog.Dockerfile docker\ElsaServer.Dockerfile = docker\ElsaServer.Dockerfile docker\ElsaServerAndStudio.Dockerfile = docker\ElsaServerAndStudio.Dockerfile docker\ElsaStudio.Dockerfile = docker\ElsaStudio.Dockerfile - docker\otel-collector-config.yaml = docker\otel-collector-config.yaml docker\init-db-postgres.sh = docker\init-db-postgres.sh - docker\docker-compose-datadog+otel-collector.yml = docker\docker-compose-datadog+otel-collector.yml + docker\otel-collector-config.yaml = docker\otel-collector-config.yaml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Elasticsearch", "src\modules\Elsa.Elasticsearch\Elsa.Elasticsearch.csproj", "{3246883E-2FA7-4B4A-BDC5-99039A2869BC}" @@ -310,18 +310,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "migrations", "migrations", scripts\migrations\efcore-3.1.sh = scripts\migrations\efcore-3.1.sh scripts\migrations\efcore-3.2.sh = scripts\migrations\efcore-3.2.sh scripts\migrations\efcore-3.3.sh = scripts\migrations\efcore-3.3.sh - scripts\migrations\README.md = scripts\migrations\README.md scripts\migrations\efcore-3.4.sh = scripts\migrations\efcore-3.4.sh scripts\migrations\efcore-3.5.sh = scripts\migrations\efcore-3.5.sh + scripts\migrations\README.md = scripts\migrations\README.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{AA5ACF15-8647-4AC9-B9F5-73FCB92BE7E3}" ProjectSection(SolutionItems) = preProject scripts\docker\build-and-run-all-in-one-web-docker.sh = scripts\docker\build-and-run-all-in-one-web-docker.sh - scripts\docker\docker-compose.yml = scripts\docker\docker-compose.yml - scripts\docker\docker-run-all-in-one-web.ps1 = scripts\docker\docker-run-all-in-one-web.ps1 scripts\docker\docker-compose-citus.yml = scripts\docker\docker-compose-citus.yml scripts\docker\docker-compose-yugabyte.yml = scripts\docker\docker-compose-yugabyte.yml + scripts\docker\docker-compose.yml = scripts\docker\docker-compose.yml + scripts\docker\docker-run-all-in-one-web.ps1 = scripts\docker\docker-run-all-in-one-web.ps1 EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "elsa-studio", "elsa-studio", "{DFFE6199-B5A7-4BA8-A5E1-77D0426C6468}" @@ -350,18 +350,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Tenants.AspNetCore", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Kafka", "src\modules\Elsa.Kafka\Elsa.Kafka.csproj", "{BF934627-F531-44FB-BEC2-ECA801FF31E7}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sql", "sql", "{A0DC5F8E-5D7F-4E8A-A5DF-B1FC31F7336E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Sql", "src\modules\Elsa.Sql\Elsa.Sql.csproj", "{FD3CD5A8-E9B3-467F-90EB-2B7D5B83F348}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Sql.MySql", "src\modules\Elsa.Sql.MySql\Elsa.Sql.MySql.csproj", "{3BED411B-79B5-4CCC-BD46-9549A427B908}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Sql.PostgreSql", "src\modules\Elsa.Sql.PostgreSql\Elsa.Sql.PostgreSql.csproj", "{6CC5FBC7-D3D7-4FE3-AD08-C67939BDB24D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Sql.Sqlite", "src\modules\Elsa.Sql.Sqlite\Elsa.Sql.Sqlite.csproj", "{FA5E857F-B173-4B5D-8049-B817A210DEF5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Sql.SqlServer", "src\modules\Elsa.Sql.SqlServer\Elsa.Sql.SqlServer.csproj", "{A51F9683-DA9F-45E7-82DE-1E261ACD6D68}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "oracle-setup", "oracle-setup", "{66E2E2CF-967F-4564-89E8-F46FA973C99B}" ProjectSection(SolutionItems) = preProject docker\oracle-setup\setup.sql = docker\oracle-setup\setup.sql @@ -385,9 +373,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "adr", "adr", "{0A04B1FD-06C ProjectSection(SolutionItems) = preProject doc\adr\0001-record-architecture-decisions.md = doc\adr\0001-record-architecture-decisions.md doc\adr\0002-fault-propagation-from-child-to-parent-activities.md = doc\adr\0002-fault-propagation-from-child-to-parent-activities.md - doc\adr\toc.md = doc\adr\toc.md - doc\adr\graph.dot = doc\adr\graph.dot doc\adr\0003-direct-bookmark-management-in-workflowexecutioncontext.md = doc\adr\0003-direct-bookmark-management-in-workflowexecutioncontext.md + doc\adr\graph.dot = doc\adr\graph.dot + doc\adr\toc.md = doc\adr\toc.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bounty", "bounty", "{9B80A705-2E31-4012-964A-83963DCDB384}" @@ -777,26 +765,6 @@ Global {BF934627-F531-44FB-BEC2-ECA801FF31E7}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF934627-F531-44FB-BEC2-ECA801FF31E7}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF934627-F531-44FB-BEC2-ECA801FF31E7}.Release|Any CPU.Build.0 = Release|Any CPU - {FD3CD5A8-E9B3-467F-90EB-2B7D5B83F348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FD3CD5A8-E9B3-467F-90EB-2B7D5B83F348}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FD3CD5A8-E9B3-467F-90EB-2B7D5B83F348}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FD3CD5A8-E9B3-467F-90EB-2B7D5B83F348}.Release|Any CPU.Build.0 = Release|Any CPU - {3BED411B-79B5-4CCC-BD46-9549A427B908}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3BED411B-79B5-4CCC-BD46-9549A427B908}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3BED411B-79B5-4CCC-BD46-9549A427B908}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3BED411B-79B5-4CCC-BD46-9549A427B908}.Release|Any CPU.Build.0 = Release|Any CPU - {6CC5FBC7-D3D7-4FE3-AD08-C67939BDB24D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6CC5FBC7-D3D7-4FE3-AD08-C67939BDB24D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6CC5FBC7-D3D7-4FE3-AD08-C67939BDB24D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6CC5FBC7-D3D7-4FE3-AD08-C67939BDB24D}.Release|Any CPU.Build.0 = Release|Any CPU - {FA5E857F-B173-4B5D-8049-B817A210DEF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FA5E857F-B173-4B5D-8049-B817A210DEF5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FA5E857F-B173-4B5D-8049-B817A210DEF5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FA5E857F-B173-4B5D-8049-B817A210DEF5}.Release|Any CPU.Build.0 = Release|Any CPU - {A51F9683-DA9F-45E7-82DE-1E261ACD6D68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A51F9683-DA9F-45E7-82DE-1E261ACD6D68}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A51F9683-DA9F-45E7-82DE-1E261ACD6D68}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A51F9683-DA9F-45E7-82DE-1E261ACD6D68}.Release|Any CPU.Build.0 = Release|Any CPU {75E08B0E-A41A-425C-9DCA-155505CE41CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {75E08B0E-A41A-425C-9DCA-155505CE41CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {75E08B0E-A41A-425C-9DCA-155505CE41CD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -842,6 +810,7 @@ Global {C9539BD8-D2AE-4A8D-8281-71A05B3FBF31} = {B08B4E00-C2AB-48F3-8389-449F42AEF179} {169E2C9B-6687-427F-A278-30BF849BFEDC} = {B08B4E00-C2AB-48F3-8389-449F42AEF179} {2DD5D66B-85E9-4AF9-911C-C9F963234159} = {B08B4E00-C2AB-48F3-8389-449F42AEF179} + {8A050229-DB79-4E0B-9AFF-7565E87F2954} = {B08B4E00-C2AB-48F3-8389-449F42AEF179} {C237BA1A-3A7D-4AB2-BE09-2696F3C082A4} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09} {80529478-A383-4FEA-B744-C71264969E9A} = {6EF07978-A6D2-40EB-891D-7D70C5F37E76} {39CD855E-83B1-4A96-93F7-01608211EBE3} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09} @@ -949,12 +918,6 @@ Global {2F3E1026-5054-4E1F-899B-F1A7F70F9912} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} {D5720DBC-8C2B-42D5-9D9F-2FF6EAD4001C} = {2F3E1026-5054-4E1F-899B-F1A7F70F9912} {BF934627-F531-44FB-BEC2-ECA801FF31E7} = {DD089B8B-DA73-492A-9010-F772D1C178DA} - {A0DC5F8E-5D7F-4E8A-A5DF-B1FC31F7336E} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} - {FD3CD5A8-E9B3-467F-90EB-2B7D5B83F348} = {A0DC5F8E-5D7F-4E8A-A5DF-B1FC31F7336E} - {3BED411B-79B5-4CCC-BD46-9549A427B908} = {A0DC5F8E-5D7F-4E8A-A5DF-B1FC31F7336E} - {6CC5FBC7-D3D7-4FE3-AD08-C67939BDB24D} = {A0DC5F8E-5D7F-4E8A-A5DF-B1FC31F7336E} - {FA5E857F-B173-4B5D-8049-B817A210DEF5} = {A0DC5F8E-5D7F-4E8A-A5DF-B1FC31F7336E} - {A51F9683-DA9F-45E7-82DE-1E261ACD6D68} = {A0DC5F8E-5D7F-4E8A-A5DF-B1FC31F7336E} {66E2E2CF-967F-4564-89E8-F46FA973C99B} = {986E5482-0482-448C-B9E4-EC67A9474B85} {9DF81143-2F39-4CFB-9DA3-902279010622} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} {75E08B0E-A41A-425C-9DCA-155505CE41CD} = {9DF81143-2F39-4CFB-9DA3-902279010622} @@ -963,7 +926,6 @@ Global {FA2B2B44-7E3E-444B-A157-7526B376E9CA} = {9DF81143-2F39-4CFB-9DA3-902279010622} {DF0CA7E2-F5DF-40ED-91B6-748767084FC7} = {9DF81143-2F39-4CFB-9DA3-902279010622} {DB20B168-CD90-41F2-BE08-3D8C6F142459} = {9DF81143-2F39-4CFB-9DA3-902279010622} - {8A050229-DB79-4E0B-9AFF-7565E87F2954} = {B08B4E00-C2AB-48F3-8389-449F42AEF179} {0A04B1FD-06C0-4271-A910-A08C263DBC44} = {0354F050-3992-4DD4-B0EE-5FBA04AC72B6} {9B80A705-2E31-4012-964A-83963DCDB384} = {0354F050-3992-4DD4-B0EE-5FBA04AC72B6} EndGlobalSection diff --git a/src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj b/src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj index 04a927c5a9..8890b8f700 100644 --- a/src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj +++ b/src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj @@ -18,11 +18,6 @@ - - - - - diff --git a/src/apps/Elsa.Server.Web/Program.cs b/src/apps/Elsa.Server.Web/Program.cs index 63b49f2ff6..b86853fb95 100644 --- a/src/apps/Elsa.Server.Web/Program.cs +++ b/src/apps/Elsa.Server.Web/Program.cs @@ -39,11 +39,6 @@ using Elsa.Server.Web.Extensions; using Elsa.Server.Web.Filters; using Elsa.Server.Web.Messages; -using Elsa.Sql.Extensions; -using Elsa.Sql.MySql; -using Elsa.Sql.PostgreSql; -using Elsa.Sql.Sqlite; -using Elsa.Sql.SqlServer; using Elsa.Tenants.AspNetCore; using Elsa.Tenants.Extensions; using Elsa.Workflows; @@ -479,16 +474,6 @@ if (useCaching) http.UseCache(); }) - .UseSql(options => - { - options.Clients = client => - { - client.Register("MySql"); - client.Register("PostgreSql"); - client.Register("Sqlite"); - client.Register("Sql Server"); - }; - }) .UseEmail(email => email.ConfigureOptions = options => configuration.GetSection("Smtp").Bind(options)) .UseAlterations(alterations => { diff --git a/src/modules/Elsa.Sql.MySql/Elsa.Sql.MySql.csproj b/src/modules/Elsa.Sql.MySql/Elsa.Sql.MySql.csproj deleted file mode 100644 index 54c6148dc7..0000000000 --- a/src/modules/Elsa.Sql.MySql/Elsa.Sql.MySql.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Provides client implementations for interacting with MySql databases. - - elsa module activities sql mysql - - - - - - - - - - - diff --git a/src/modules/Elsa.Sql.MySql/FodyWeavers.xml b/src/modules/Elsa.Sql.MySql/FodyWeavers.xml deleted file mode 100644 index 00e1d9a1c1..0000000000 --- a/src/modules/Elsa.Sql.MySql/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/modules/Elsa.Sql.MySql/MySqlClient.cs b/src/modules/Elsa.Sql.MySql/MySqlClient.cs deleted file mode 100644 index 60669f7d18..0000000000 --- a/src/modules/Elsa.Sql.MySql/MySqlClient.cs +++ /dev/null @@ -1,16 +0,0 @@ -using MySql.Data.MySqlClient; -using Elsa.Sql.Client; -using System.Data.Common; - -namespace Elsa.Sql.MySql; - -/// -/// MySql client implementation. -/// -/// -public class MySqlClient(string connectionString) : BaseSqlClient(connectionString) -{ - protected override DbConnection CreateConnection() => new MySqlConnection(_connectionString); - - protected override DbCommand CreateCommand(string query, DbConnection connection) => new MySqlCommand(query, (MySqlConnection)connection); -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql.PostgreSql/Elsa.Sql.PostgreSql.csproj b/src/modules/Elsa.Sql.PostgreSql/Elsa.Sql.PostgreSql.csproj deleted file mode 100644 index 82a2908504..0000000000 --- a/src/modules/Elsa.Sql.PostgreSql/Elsa.Sql.PostgreSql.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Provides client implementations for interacting with PostgreSql databases. - - elsa module activities sql postgresql - - - - - - - - - - - diff --git a/src/modules/Elsa.Sql.PostgreSql/FodyWeavers.xml b/src/modules/Elsa.Sql.PostgreSql/FodyWeavers.xml deleted file mode 100644 index 00e1d9a1c1..0000000000 --- a/src/modules/Elsa.Sql.PostgreSql/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/modules/Elsa.Sql.PostgreSql/PostgreSqlClient.cs b/src/modules/Elsa.Sql.PostgreSql/PostgreSqlClient.cs deleted file mode 100644 index 5eb5982ba4..0000000000 --- a/src/modules/Elsa.Sql.PostgreSql/PostgreSqlClient.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Npgsql; -using Elsa.Sql.Client; -using System.Data.Common; - -namespace Elsa.Sql.PostgreSql; - -/// -/// PostgreSQL client implementation. -/// -/// -public class PostgreSqlClient(string connectionString) : BaseSqlClient(connectionString) -{ - protected override DbConnection CreateConnection() => new NpgsqlConnection(_connectionString); - - protected override DbCommand CreateCommand(string query, DbConnection connection) => new NpgsqlCommand(query, (NpgsqlConnection)connection); -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql.SqlServer/Elsa.Sql.SqlServer.csproj b/src/modules/Elsa.Sql.SqlServer/Elsa.Sql.SqlServer.csproj deleted file mode 100644 index cab38ce95e..0000000000 --- a/src/modules/Elsa.Sql.SqlServer/Elsa.Sql.SqlServer.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Provides client implementations for interacting with Microsoft SQL Server databases. - - elsa module activities sql mssqlserver sqlserver - - - - - - - - - - - diff --git a/src/modules/Elsa.Sql.SqlServer/FodyWeavers.xml b/src/modules/Elsa.Sql.SqlServer/FodyWeavers.xml deleted file mode 100644 index 00e1d9a1c1..0000000000 --- a/src/modules/Elsa.Sql.SqlServer/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/modules/Elsa.Sql.SqlServer/SqlServerClient.cs b/src/modules/Elsa.Sql.SqlServer/SqlServerClient.cs deleted file mode 100644 index e8780c3594..0000000000 --- a/src/modules/Elsa.Sql.SqlServer/SqlServerClient.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Data.Common; -using Elsa.Sql.Client; -using Microsoft.Data.SqlClient; - -namespace Elsa.Sql.SqlServer; - -/// -/// Microsoft SQL server client implementation. -/// -/// -public class SqlServerClient(string connectionString) : BaseSqlClient(connectionString) -{ - protected override DbConnection CreateConnection() => new SqlConnection(_connectionString); - - protected override DbCommand CreateCommand(string query, DbConnection connection) => new SqlCommand(query, (SqlConnection)connection); -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql.Sqlite/Elsa.Sql.Sqlite.csproj b/src/modules/Elsa.Sql.Sqlite/Elsa.Sql.Sqlite.csproj deleted file mode 100644 index 43bf2bf5a5..0000000000 --- a/src/modules/Elsa.Sql.Sqlite/Elsa.Sql.Sqlite.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Provides client implementations for interacting with Sqlite databases. - - elsa module activities sql sqlite - - - - - - - - - - - diff --git a/src/modules/Elsa.Sql.Sqlite/FodyWeavers.xml b/src/modules/Elsa.Sql.Sqlite/FodyWeavers.xml deleted file mode 100644 index 00e1d9a1c1..0000000000 --- a/src/modules/Elsa.Sql.Sqlite/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/modules/Elsa.Sql.Sqlite/SqliteClient.cs b/src/modules/Elsa.Sql.Sqlite/SqliteClient.cs deleted file mode 100644 index ec43f52452..0000000000 --- a/src/modules/Elsa.Sql.Sqlite/SqliteClient.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Data.Common; -using Elsa.Sql.Client; -using Microsoft.Data.Sqlite; - -namespace Elsa.Sql.Sqlite; - -/// -/// Sqlite client implementation. -/// -/// -public class SqliteClient(string connectionString) : BaseSqlClient(connectionString) -{ - protected override DbConnection CreateConnection() => new SqliteConnection(_connectionString); - - protected override DbCommand CreateCommand(string query, DbConnection connection) => new SqliteCommand(query, (SqliteConnection)connection); -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Activities/SqlCodeOptionsProvider.cs b/src/modules/Elsa.Sql/Activities/SqlCodeOptionsProvider.cs deleted file mode 100644 index f61bad42ff..0000000000 --- a/src/modules/Elsa.Sql/Activities/SqlCodeOptionsProvider.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Reflection; -using Elsa.Workflows.UIHints.CodeEditor; - -// ReSharper disable once CheckNamespace -namespace Elsa.Sql.Activities; - -internal class SqlCodeOptionsProvider : CodeEditorOptionsProviderBase -{ - protected override string GetLanguage(PropertyInfo propertyInfo, object? context) => "sql"; -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Activities/SqlCommand.cs b/src/modules/Elsa.Sql/Activities/SqlCommand.cs deleted file mode 100644 index bc906878d8..0000000000 --- a/src/modules/Elsa.Sql/Activities/SqlCommand.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Runtime.CompilerServices; -using Elsa.Expressions.Models; -using Elsa.Extensions; -using Elsa.Sql.Contracts; -using Elsa.Sql.UIHints; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; -using Elsa.Workflows.UIHints; - -namespace Elsa.Sql.Activities; - -/// -/// Execute given SQL command and returns the number of rows affected. -/// -[Activity("Elsa", "SQL", "Execute given SQL command and returns the number of rows affected.", DisplayName = "SQL Command", Kind = ActivityKind.Task)] -public class SqlCommand : Activity -{ - /// - /// - /// - public SqlCommand([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line) - { - } - - /// - /// Database client to connect with. - /// - [Input( - Description = "Database client.", - UIHint = InputUIHints.DropDown, - UIHandler = typeof(SqlClientsDropDownProvider))] - public Input Client { get; set; } = default!; - - /// - /// Connection string. - /// - [Input( - Description = "Connection string.", - CanContainSecrets = true)] - public Input ConnectionString { get; set; } = default!; - - /// - /// Command to run against the database. - /// - [Input( - Description = "Command to run against the database.", - DefaultSyntax = "Sql", - UIHint = InputUIHints.CodeEditor, - UIHandler = typeof(SqlCodeOptionsProvider) - )] - public Input Command { get; set; } = default!; - - - /// - /// The number of affected rows. - /// - [Output( - Description = "The number of rows affected.")] - public Output Result { get; set; } = default!; - - - /// - /// - /// - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var command = Command.GetOrDefault(context); - - // If no command was specified, there's nothing to do. - if (string.IsNullOrWhiteSpace(command)) - return; - - // Get and execute the SQL evaluator. - var evaluator = context.GetRequiredService(); - var evaluatedQuery = await evaluator.EvaluateAsync(command, context.ExpressionExecutionContext, new ExpressionEvaluatorOptions(), context.CancellationToken); - - // Create client - var factory = context.GetRequiredService(); - var client = factory.CreateClient(Client.GetOrDefault(context), ConnectionString.GetOrDefault(context)); - - // Execute command - var result = await client.ExecuteCommandAsync(evaluatedQuery); - context.Set(Result, result); - - await CompleteAsync(context); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Activities/SqlQuery.cs b/src/modules/Elsa.Sql/Activities/SqlQuery.cs deleted file mode 100644 index 5b721aed81..0000000000 --- a/src/modules/Elsa.Sql/Activities/SqlQuery.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Data; -using System.Runtime.CompilerServices; -using Elsa.Expressions.Models; -using Elsa.Extensions; -using Elsa.Sql.Contracts; -using Elsa.Sql.UIHints; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; -using Elsa.Workflows.UIHints; - -namespace Elsa.Sql.Activities; - -/// -/// Execute given SQL query and return the resulting data. -/// -[Activity("Elsa", "SQL", "Execute given SQL query and return the resulting data.", DisplayName = "SQL Query", Kind = ActivityKind.Task)] -public class SqlQuery : Activity -{ - /// - /// - /// - public SqlQuery([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line) - { - } - - /// - /// Database client to connect with. - /// - [Input( - Description = "Database client.", - UIHint = InputUIHints.DropDown, - UIHandler = typeof(SqlClientsDropDownProvider))] - public Input Client { get; set; } = default!; - - /// - /// Connection string. - /// - [Input( - Description = "Connection string.", - CanContainSecrets = true)] - public Input ConnectionString { get; set; } = default!; - - /// - /// Query to run against the database. - /// - [Input( - Description = "Query to run against the database.", - DefaultSyntax = "Sql", - UIHint = InputUIHints.CodeEditor, - UIHandler = typeof(SqlCodeOptionsProvider) - )] - public Input Query { get; set; } = default!; - - - /// - /// of queried results. - /// - [Output( - Description = "DataSet of queried results.", - IsSerializable = false)] - public Output Results { get; set; } = default!; - - - /// - /// - /// - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var query = Query.GetOrDefault(context); - - // If no query was specified, there's nothing to do. - if (string.IsNullOrWhiteSpace(query)) - return; - - // Get and execute the SQL evaluator. - var evaluator = context.GetRequiredService(); - var evaluatedQuery = await evaluator.EvaluateAsync(query, context.ExpressionExecutionContext, new ExpressionEvaluatorOptions(), context.CancellationToken); - - // Create client - var factory = context.GetRequiredService(); - var client = factory.CreateClient(Client.GetOrDefault(context), ConnectionString.GetOrDefault(context)); - - // Execute query - var results = await client.ExecuteQueryAsync(evaluatedQuery); - context.Set(Results, results); - - await CompleteAsync(context); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Activities/SqlSingleValue.cs b/src/modules/Elsa.Sql/Activities/SqlSingleValue.cs deleted file mode 100644 index 4c05dc44a2..0000000000 --- a/src/modules/Elsa.Sql/Activities/SqlSingleValue.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Runtime.CompilerServices; -using Elsa.Expressions.Models; -using Elsa.Extensions; -using Elsa.Sql.Contracts; -using Elsa.Sql.UIHints; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; -using Elsa.Workflows.UIHints; - -namespace Elsa.Sql.Activities; - -/// -/// Execute given SQL command and return a single result. -/// -[Activity("Elsa", "SQL", "Execute given SQL command and return a single result.", DisplayName = "SQL Single Value", Kind = ActivityKind.Task)] -public class SqlSingleValue : Activity -{ - /// - /// - /// - public SqlSingleValue([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line) - { - } - - /// - /// Database client to connect with. - /// - [Input( - Description = "Database client.", - UIHint = InputUIHints.DropDown, - UIHandler = typeof(SqlClientsDropDownProvider))] - public Input Client { get; set; } = default!; - - /// - /// Connection string. - /// - [Input( - Description = "Connection string.", - CanContainSecrets = true)] - public Input ConnectionString { get; set; } = default!; - - /// - /// Command to run against the database. - /// - [Input( - Description = "Query to run against the database.", - DefaultSyntax = "Sql", - UIHint = InputUIHints.CodeEditor, - UIHandler = typeof(SqlCodeOptionsProvider) - )] - public Input Command { get; set; } = default!; - - - /// - /// Command result. - /// - [Output( - Description = "Command result.")] - public Output Result { get; set; } = default!; - - - /// - /// - /// - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var command = Command.GetOrDefault(context); - - // If no command was specified, there's nothing to do. - if (string.IsNullOrWhiteSpace(command)) - return; - - // Get and execute the SQL evaluator. - var evaluator = context.GetRequiredService(); - var evaluatedQuery = await evaluator.EvaluateAsync(command, context.ExpressionExecutionContext, new ExpressionEvaluatorOptions(), context.CancellationToken); - - // Create client - var factory = context.GetRequiredService(); - var client = factory.CreateClient(Client.GetOrDefault(context), ConnectionString.GetOrDefault(context)); - - // Execute command - var result = await client.ExecuteScalarAsync(evaluatedQuery); - context.Set(Result, result); - - await CompleteAsync(context); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Client/BaseSqlClient.cs b/src/modules/Elsa.Sql/Client/BaseSqlClient.cs deleted file mode 100644 index 9f7cca1138..0000000000 --- a/src/modules/Elsa.Sql/Client/BaseSqlClient.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System.Data; -using System.Data.Common; -using Elsa.Sql.Models; - -namespace Elsa.Sql.Client; - -public abstract class BaseSqlClient : ISqlClient -{ - /// - /// The connection string used to connect with the database. - /// - protected readonly string _connectionString; - - /// - /// The marker used when injecting parameters into a query. - /// Default: "@" - /// - public virtual string ParameterMarker { get; set; } = "@"; - - /// - /// The text following the ParameterMarker when injecting parameters into a query. - /// Default: "param" - /// - public virtual string ParameterText { get; set; } = "p"; - - /// - /// Set to true to add a counter to the end of the parameter string. - /// Default: true - /// - public virtual bool IncrementParameter { get; set; } = true; - - /// - /// Default base implementation for an SQL client. - /// - /// - protected BaseSqlClient(string connectionString) => _connectionString = connectionString; - - /// - /// Create a connection using the client specific connection. - /// - /// - protected abstract DbConnection CreateConnection(); - - /// - /// Create a command using the client specific connection. - /// - /// - /// - /// - protected abstract DbCommand CreateCommand(string query, DbConnection connection); - - /// - /// - /// - public async Task ExecuteCommandAsync(EvaluatedQuery evaluatedQuery) - { - using var connection = CreateConnection(); - connection.Open(); - var command = CreateCommand(evaluatedQuery.Query, connection); - AddCommandParameters(command, evaluatedQuery.Parameters); - - var result = await command.ExecuteNonQueryAsync(); - return result; - } - - /// - /// - /// - public async Task ExecuteScalarAsync(EvaluatedQuery evaluatedQuery) - { - using var connection = CreateConnection(); - connection.Open(); - var command = CreateCommand(evaluatedQuery.Query, connection); - AddCommandParameters(command, evaluatedQuery.Parameters); - - var result = await command.ExecuteScalarAsync(); - return result; - } - - /// - /// - /// - public async Task ExecuteQueryAsync(EvaluatedQuery evaluatedQuery) - { - using var connection = CreateConnection(); - connection.Open(); - var command = CreateCommand(evaluatedQuery.Query, connection); - AddCommandParameters(command, evaluatedQuery.Parameters); - - using var reader = await command.ExecuteReaderAsync(); - return await Task.FromResult(ReadAsDataSet(reader)); - } - - /// - /// Add parameters into the query to prevent SQL injection. - /// - /// Command to add the parameters to - /// Parameters to add - /// - private DbCommand AddCommandParameters(DbCommand command, Dictionary parameters) - { - foreach (var param in parameters) - { - var dbParam = command.CreateParameter(); - dbParam.ParameterName = param.Key; - dbParam.Value = param.Value ?? DBNull.Value; - command.Parameters.Add(dbParam); - } - return command; - } - - /// - /// Returns data as a . - /// - /// Reader to return data from. - /// of data. - private DataSet ReadAsDataSet(IDataReader reader) - { - var dataSet = new DataSet("dataset"); - dataSet.Tables.Add(ReadAsDataTable(reader)); - return dataSet; - } - - /// - /// Returns data as a . - /// - /// Reader to return data from. - /// of data. - private DataTable ReadAsDataTable(IDataReader reader) - { - var data = new DataTable(); - var schemaTable =reader.GetSchemaTable(); - - foreach (DataRow row in schemaTable.Rows) - { - string colName = row.Field("ColumnName"); - Type t = row.Field("DataType"); - data.Columns.Add(colName, t); - } - - while (reader.Read()) - { - var newRow = data.Rows.Add(); - foreach (DataColumn col in data.Columns) - { - newRow[col.ColumnName] = reader[col.ColumnName]; - } - } - return data; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Client/ISqlClient.cs b/src/modules/Elsa.Sql/Client/ISqlClient.cs deleted file mode 100644 index 2cc3eb5b92..0000000000 --- a/src/modules/Elsa.Sql/Client/ISqlClient.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Data; -using Elsa.Sql.Models; - -namespace Elsa.Sql.Client; - -public interface ISqlClient -{ - /// - /// The marker used when injecting parameters into a query. - /// - public string ParameterMarker { get; set; } - - /// - /// The text following the ParameterMarker when injecting parameters into a query. - /// - public string ParameterText { get; set; } - - /// - /// Set to true to add a counter to the end of the parameter string. - /// - public bool IncrementParameter { get; set; } - - /// - /// Asynchronously executes a Transact-SQL statement against the connection and returns the number of rows affected. - /// - /// The evaluated query to execute. - /// The number of rows affected. - public Task ExecuteCommandAsync(EvaluatedQuery evaluatedQuery); - - /// - /// Asynchronously executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored. - /// - /// The evaluated query to execute. - /// The first column of the first row in the result set, or a null reference if the result set is empty. Returns a maximum of 2033 characters. - public Task ExecuteScalarAsync(EvaluatedQuery evaluatedQuery); - - /// - /// Asynchronously executes the query, and returns a dataset of data returned by the query. - /// - /// The evaluated query to execute. - /// DataSet of the queried data - public Task ExecuteQueryAsync(EvaluatedQuery evaluatedQuery); -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Contracts/ISqlClientFactory.cs b/src/modules/Elsa.Sql/Contracts/ISqlClientFactory.cs deleted file mode 100644 index de2d7771c2..0000000000 --- a/src/modules/Elsa.Sql/Contracts/ISqlClientFactory.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Elsa.Sql.Client; - -namespace Elsa.Sql.Contracts; - -public interface ISqlClientFactory -{ - /// - /// Create an instance of the registered client. - /// - /// The name of the registered client to create. This can either be clientName used during registration or the default nameof(client) itself. - /// Connection string. - /// - public ISqlClient CreateClient(string clientName, string connectionString); -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Contracts/ISqlClientNamesProvider.cs b/src/modules/Elsa.Sql/Contracts/ISqlClientNamesProvider.cs deleted file mode 100644 index b1b48eef40..0000000000 --- a/src/modules/Elsa.Sql/Contracts/ISqlClientNamesProvider.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Elsa.Sql.Contracts; - -public interface ISqlClientNamesProvider -{ - /// - /// Returns a dictionary of registered clients. - /// - /// A token to monitor cancellation requests. - /// A of registered client names their . - Task> GetRegisteredSqlClientNamesAsync(CancellationToken cancellationToken); -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Contracts/ISqlEvaluator.cs b/src/modules/Elsa.Sql/Contracts/ISqlEvaluator.cs deleted file mode 100644 index 0817f409bf..0000000000 --- a/src/modules/Elsa.Sql/Contracts/ISqlEvaluator.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Elsa.Expressions.Models; -using Elsa.Sql.Models; -using JetBrains.Annotations; - -namespace Elsa.Sql.Contracts; - -/// -/// Evaluates SQL expressions. -/// -[PublicAPI] -public interface ISqlEvaluator -{ - /// - /// Evaluates a SQL expression. - /// - /// The expression to evaluate. - /// The context in which the expression is evaluated. - /// A set of options. - /// An optional cancellation token. - /// The result. - Task EvaluateAsync( - string expression, - ExpressionExecutionContext context, - ExpressionEvaluatorOptions options, - CancellationToken cancellationToken = default); -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Elsa.Sql.csproj b/src/modules/Elsa.Sql/Elsa.Sql.csproj deleted file mode 100644 index bfb24be1e2..0000000000 --- a/src/modules/Elsa.Sql/Elsa.Sql.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Provides activities to interact with sql databases. - - elsa module activities sql - - - - - - - - diff --git a/src/modules/Elsa.Sql/Expressions/SqlExpressionHandler.cs b/src/modules/Elsa.Sql/Expressions/SqlExpressionHandler.cs deleted file mode 100644 index a3e131f41d..0000000000 --- a/src/modules/Elsa.Sql/Expressions/SqlExpressionHandler.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Elsa.Sql.Contracts; -using Elsa.Expressions.Contracts; -using Elsa.Expressions.Helpers; -using Elsa.Expressions.Models; - -namespace Elsa.Sql.Expressions; - -/// -/// Evaluates SQL expressions. -/// -public class SqlExpressionHandler : IExpressionHandler -{ - private readonly ISqlEvaluator _sqlEvaluator; - - /// - /// Initializes a new instance of the class. - /// - public SqlExpressionHandler(ISqlEvaluator sqlEvaluator) - { - _sqlEvaluator = sqlEvaluator; - } - - /// - public async ValueTask EvaluateAsync(Expression expression, Type returnType, ExpressionExecutionContext context, ExpressionEvaluatorOptions options) - { - var script = expression.Value.ConvertTo() ?? ""; - return await _sqlEvaluator.EvaluateAsync(script, context, options); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Extensions/ModuleExtensions.cs b/src/modules/Elsa.Sql/Extensions/ModuleExtensions.cs deleted file mode 100644 index 4ab8e85e8f..0000000000 --- a/src/modules/Elsa.Sql/Extensions/ModuleExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Elsa.Features.Services; -using Elsa.Sql.Features; - -namespace Elsa.Sql.Extensions; - -/// -/// Provides methods to install and configure SQL client features. -/// -public static class ModuleExtensions -{ - /// - /// Adds the feature to the system. - /// - /// - /// - /// - public static IModule UseSql(this IModule configuration, Action? configure = default) - { - configuration.Configure(configure); - return configuration; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Factory/SqlClientFactory.cs b/src/modules/Elsa.Sql/Factory/SqlClientFactory.cs deleted file mode 100644 index 4422b099b8..0000000000 --- a/src/modules/Elsa.Sql/Factory/SqlClientFactory.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Elsa.Sql.Client; -using Elsa.Sql.Contracts; -using Elsa.Sql.Services; -using Microsoft.Extensions.DependencyInjection; - -namespace Elsa.Sql.Factory; - -/// -/// SQL client factory -/// -public class SqlClientFactory : ISqlClientFactory -{ - private readonly IServiceProvider _serviceProvider; - - public SqlClientFactory(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider; - - /// - /// - /// - public ISqlClient CreateClient(string clientName, string connectionString) - { - if (string.IsNullOrEmpty(clientName)) - { - throw new ArgumentException($"Client name can not be empty or null.", nameof(clientName)); - } - if (string.IsNullOrEmpty(connectionString)) - { - throw new ArgumentException($"Connection string can not be empty or null.", nameof(connectionString)); - } - if (_serviceProvider.GetRequiredService().Clients.TryGetValue(clientName, out var clientType)) - { - try - { - return ActivatorUtilities.CreateInstance(_serviceProvider, clientType, connectionString) as ISqlClient; - } - catch (Exception ex) - { - throw new InvalidOperationException($"Unable to create instance of '{clientName}' of type '{clientType}'.", ex); - } - } - throw new ArgumentException($"No registered SQL client provider for '{clientName}'."); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Features/SqlFeature.cs b/src/modules/Elsa.Sql/Features/SqlFeature.cs deleted file mode 100644 index 882f1c5061..0000000000 --- a/src/modules/Elsa.Sql/Features/SqlFeature.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Elsa.Extensions; -using Elsa.Features.Abstractions; -using Elsa.Features.Services; -using Elsa.Sql.Activities; -using Elsa.Sql.Contracts; -using Elsa.Sql.Factory; -using Elsa.Sql.Providers; -using Elsa.Sql.Services; -using Elsa.Sql.UIHints; -using Elsa.Workflows; -using Microsoft.Extensions.DependencyInjection; - -namespace Elsa.Sql.Features; - -/// -/// Setup SQL client features -/// -public class SqlFeature : FeatureBase -{ - /// - /// Set a callback to configure . - /// - public Action Clients { get; set; } = _ => { }; - - /// - /// - /// - /// - public SqlFeature(IModule module) : base(module) - { - } - - /// - /// - /// - public override void Configure() - { - Module.AddActivitiesFrom(); - } - - /// - /// - /// - public override void Apply() - { - Services - // Services - .AddSingleton(provider => - { - ClientStore clientRegistry = new(); - Clients.Invoke(clientRegistry); - return clientRegistry; - }) - .AddSingleton() - .AddScoped() - - // Providers - .AddExpressionDescriptorProvider() - .AddScoped() - .AddScoped() - .AddScoped(); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/FodyWeavers.xml b/src/modules/Elsa.Sql/FodyWeavers.xml deleted file mode 100644 index 00e1d9a1c1..0000000000 --- a/src/modules/Elsa.Sql/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Models/EvaluatedQuery.cs b/src/modules/Elsa.Sql/Models/EvaluatedQuery.cs deleted file mode 100644 index 1570fab0e8..0000000000 --- a/src/modules/Elsa.Sql/Models/EvaluatedQuery.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Elsa.Sql.Models -{ - /// - /// Represents a safely formatted SQL expression result. - /// - public class EvaluatedQuery - { - /// - /// Query with parameterized values - /// - public string Query { get; set; } - - /// - /// Parameters to inject into the query at execution - /// - public Dictionary Parameters { get; set; } = new Dictionary(); - - /// - /// An evaluated query response. - /// - /// The evaluated query - public EvaluatedQuery(string query) => Query = query; - - /// - /// An evaluated query response. - /// - /// The evaluated query - /// Parameters to pass into the parameterized query - public EvaluatedQuery(string query, Dictionary parameters) - { - Query = query; - Parameters = parameters; - } - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Providers/SqlClientNamesProvider.cs b/src/modules/Elsa.Sql/Providers/SqlClientNamesProvider.cs deleted file mode 100644 index f94aaeefda..0000000000 --- a/src/modules/Elsa.Sql/Providers/SqlClientNamesProvider.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Elsa.Sql.Contracts; -using Elsa.Sql.Services; -using Microsoft.Extensions.DependencyInjection; - -namespace Elsa.Sql.Providers; - -/// -/// Returns registered client names -/// -public class SqlClientNamesProvider : ISqlClientNamesProvider -{ - private readonly IServiceProvider _serviceProvider; - - public SqlClientNamesProvider(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider; - - /// - /// - /// - public Task> GetRegisteredSqlClientNamesAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_serviceProvider.GetRequiredService().Clients); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Providers/SqlExpressionDescriptorProvider.cs b/src/modules/Elsa.Sql/Providers/SqlExpressionDescriptorProvider.cs deleted file mode 100644 index 6ac53e8222..0000000000 --- a/src/modules/Elsa.Sql/Providers/SqlExpressionDescriptorProvider.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Elsa.Expressions.Contracts; -using Elsa.Expressions.Models; -using Elsa.Extensions; -using Elsa.Sql.Expressions; -using Microsoft.Extensions.DependencyInjection; - -namespace Elsa.Sql.Providers; - -/// -/// Provides SQL expression descriptors. -/// -public class SqlExpressionDescriptorProvider : IExpressionDescriptorProvider -{ - /// - /// Gets the name of the expression type. - /// - private const string TypeName = "Sql"; - - public IEnumerable GetDescriptors() - { - yield return new() - { - Type = TypeName, - DisplayName = "SQL", - Properties = new { MonacoLanguage = "sql" }.ToDictionary(), - HandlerFactory = ActivatorUtilities.GetServiceOrCreateInstance - }; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Services/ClientStore.cs b/src/modules/Elsa.Sql/Services/ClientStore.cs deleted file mode 100644 index d76727aea6..0000000000 --- a/src/modules/Elsa.Sql/Services/ClientStore.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Elsa.Sql.Client; - -namespace Elsa.Sql.Services; -public class ClientStore -{ - private readonly Dictionary clients = new(); - - /// - /// Dictionary of registered clients and their type. - /// - public IReadOnlyDictionary Clients => clients; - - /// - /// Registers the specified client type with the store. - /// The client type must inherit from . - /// - /// - /// The type of the client to be registered. The client must be a class that implements the interface. - /// - /// - /// The name of the client to register. If not provided, the name defaults to nameof(TClient). - /// This value is used as a key to identify the client in the store. - /// - /// - /// Thrown when a client with the same name is already registered in the store. - /// - /// - /// This method registers a client type to the store using a unique key. The key is either the provided or the default name derived from . - /// - public void Register(string? name) where TClient : class, ISqlClient - { - var key = string.IsNullOrEmpty(name) ? nameof(TClient) : name; - if (clients.ContainsKey(key)) { throw new InvalidOperationException($"Client with key '{name}' is already registered."); } - clients.Add(key, typeof(TClient)); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/Services/SqlEvaluator.cs b/src/modules/Elsa.Sql/Services/SqlEvaluator.cs deleted file mode 100644 index 10ee5a0df4..0000000000 --- a/src/modules/Elsa.Sql/Services/SqlEvaluator.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Text; -using Elsa.Expressions.Models; -using Elsa.Extensions; -using Elsa.Sql.Contracts; -using Elsa.Sql.Models; -using Elsa.Workflows; - -namespace Elsa.Sql.Services; - -/// -/// A SQL expression evaluator. -/// -/// -/// Initializes a new instance of the class.WS -/// -public class SqlEvaluator() : ISqlEvaluator -{ - private WorkflowExecutionContext executionContext; - private ActivityExecutionContext activityContext; - private ExpressionExecutionContext expressionContext; - - /// - public async Task EvaluateAsync( - string expression, - ExpressionExecutionContext context, - ExpressionEvaluatorOptions options, - CancellationToken cancellationToken = default) - { - if (!expression.Contains("{{")) return new EvaluatedQuery(expression); - - expressionContext = context; - executionContext = context.GetWorkflowExecutionContext(); - activityContext = context.GetActivityExecutionContext(); - - // Create client - var factory = context.GetRequiredService(); - var client = factory.CreateClient(activityContext.ActivityState["Client"].ToString(), activityContext.ActivityState["ConnectionString"].ToString()); - - var sb = new StringBuilder(); - int start = 0; - var parameters = new Dictionary(); - int paramIndex = 0; - - while (start < expression.Length) - { - int openIndex = expression.IndexOf("{{", start); - if (openIndex == -1) - { - sb.Append(expression.AsSpan(start)); - break; - } - - // Append everything before {{ - sb.Append(expression.AsSpan(start, openIndex - start)); - - // Find the closing }} - int closeIndex = expression.IndexOf("}}", openIndex + 2); - if (closeIndex == -1) throw new FormatException("Unmatched '{{' found in SQL expression."); - - // Extract key - string key = expression.Substring(openIndex + 2, closeIndex - openIndex - 2).Trim(); - if (string.IsNullOrEmpty(key)) throw new FormatException("Empty placeholder '{{}}' is not allowed."); - - // Resolve value and replace with parameterized name - var counterValue = client.IncrementParameter ? paramIndex++.ToString() : string.Empty; - string paramName = $"{client.ParameterMarker}{client.ParameterText}{counterValue}"; - parameters[paramName] = ResolveValue(key); - - sb.Append(paramName); - start = closeIndex + 2; - } - - return new EvaluatedQuery(sb.ToString(), parameters); - } - - private object? ResolveValue(string key) - { - return key switch - { - "Workflow.Definition.Id" => executionContext.Workflow.Identity.DefinitionId, - "Workflow.Definition.Version.Id" => executionContext.Workflow.Identity.Id, - "Workflow.Definition.Version" => executionContext.Workflow.Identity.Version, - "Workflow.Instance.Id" => activityContext.WorkflowExecutionContext.Id, - "Correlation.Id" => activityContext.WorkflowExecutionContext.CorrelationId, - "LastResult" => expressionContext.GetLastResult(), - var i when i.StartsWith("Input.") => executionContext.Input.TryGetValue(i.Substring(6), out var v) ? v : null, - var o when o.StartsWith("Output.") => executionContext.Output.TryGetValue(o.Substring(7), out var v) ? v : null, - var v when v.StartsWith("Variables.") => executionContext.Variables.FirstOrDefault(x => x.Name == v.Substring(10), null)?.Value ?? null, - _ => throw new NullReferenceException($"No matching property found for {{{{{key}}}}}.") - }; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Sql/UIHints/SqlClientsDropDownProvider.cs b/src/modules/Elsa.Sql/UIHints/SqlClientsDropDownProvider.cs deleted file mode 100644 index 019271df69..0000000000 --- a/src/modules/Elsa.Sql/UIHints/SqlClientsDropDownProvider.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Reflection; -using Elsa.Sql.Contracts; -using Elsa.Workflows.UIHints.Dropdown; - -namespace Elsa.Sql.UIHints; - -/// -/// Provides registered clients for the Client input field. -/// -/// -public class SqlClientsDropDownProvider(ISqlClientNamesProvider sqlClientNamesProvider) : DropDownOptionsProviderBase -{ - protected override async ValueTask> GetItemsAsync(PropertyInfo propertyInfo, object? context, CancellationToken cancellationToken) - { - var clients = await sqlClientNamesProvider.GetRegisteredSqlClientNamesAsync(cancellationToken); - return clients.Select(x => new SelectListItem(x.Key, x.Key)).ToList(); - } -} \ No newline at end of file