Add project files.

This commit is contained in:
Behzad Alizadeh
2025-07-02 16:25:46 +03:30
parent 7391bb6626
commit d58167d24a
137 changed files with 85333 additions and 0 deletions
@@ -0,0 +1,72 @@
using Caspian.WorkflowFramework.Contracts;
using Caspian.WorkflowFramework.Services;
using Elsa.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Elsa.EntityFrameworkCore.Extensions;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.Email;
using MongoLogger;
using MongoLogger.Models;
namespace Caspian.WorkflowFramework;
public static class DependencyInjectionq
{
public static void AddWorkflowFramework(this IHostApplicationBuilder builder, string connectionString)
{
builder.Services.AddMongoLogger<LogModel>(builder.Configuration);
builder.Services.AddElsa(elsa =>
{
// Configure Management layer to use EF Core.
elsa.UseWorkflowManagement(management => management
.UseEntityFrameworkCore(ef => ef.UseSqlServer(connectionString)));
// Configure Runtime layer to use EF Core.
elsa.UseWorkflowRuntime(runtime => runtime
.UseEntityFrameworkCore(ef => ef.UseSqlServer(connectionString)));
// Expose Elsa API endpoints.
elsa.UseWorkflowsApi();
// Enable C# workflow expressions
elsa.UseCSharp();
// Enable JavaScript workflow expressions
elsa.UseJavaScript(options => options.AllowClrAccess = true);
});
//// Configure CORS to allow designer app hosted on a different origin to invoke the APIs.
//builder.Services.AddCors(cors => cors
// .AddDefaultPolicy(policy => policy
// .AllowAnyOrigin() // For demo purposes only. Use a specific origin instead.
// .AllowAnyHeader()
// .AllowAnyMethod()
// .WithExposedHeaders("x-elsa-workflow-instance-id"))); // Required for Elsa Studio in order to support running workflows from the designer. Alternatively, you can use the `*` wildcard to expose all headers.
// Add Health Checks.
builder.Services.AddHealthChecks();
builder.Services.AddScoped<IWorkflowService, WorkflowService>();
}
public static void UseWorkflowFramework(this IApplicationBuilder app)
{
try
{
app.UseMongoLogger<LogModel>();
}
catch (Exception ex)
{
var d = ex;
}
//app.UseWorkflowsApi(); // Use Elsa API endpoints.
app.UseWorkflows(); // Use Elsa middleware to handle HTTP requests mapped to HTTP Endpoint activities.
}
}