LibAICORE 1.1.57-alpha-g3293dd9c81

Copyright (C) Coredata Inc - All Rights Reserved - The source code of this package is proprietary and confidential, and unauthorized copies of the source code are strictly prohibited

A corejob is a task that is:

  • asynchronous, may take seconds, minutes, or hours
  • transient, variables not in db/files/etc are deleted on finish
  • streaming, files may be GB or TB so files are edited one row at a time (do not import everything into RAM!!)
  • authenticated, users must be checked for permissions before every action - this is done with keycloak (auth.aicore.ca)
  • private + sandboxed, users should have absolutely no access to any information (files, DB, corejobs) from other companies (customers) - any files outside of /AICORE/Customers/[company] should be inaccessible

In an API controller, corejobs can be called either with POST, which has a chance of timing out and only returns log messages at the end of execution in an ActionResult - or with SSE, which returns each log message asynchronously with server-sent events as it is made, and will not time out as long as the API client/web browser has keepalive enabled (?). This is why logs are async.

This library was made for ASP.NET Core 6 using reflection and dependency injection - please read up on both if you want to edit the library

To call corejobs made with the AICORE low-code JSON system, a function ExecuteCMD has been provided - try to keep API calls in appsettings in case they need to be moved to this later, since the JSON system will be the primary way customers can change the software configuration

Full example:

public class TestController : ControllerBase
{
    private readonly CorejobRegistry _corejobs;

    public TestController(CorejobRegistry corejobs)
    {
        _corejobs = corejobs;
    }
	
    [HttpPost]
    [Route("test_registry")]
    [Produces("application/json")]
    public async Task Test()
    {
        await _corejobs.RunCorejobPost("test_registry", null);
    }
	
    [HttpPost]
    [Route("test_registry_sse")]
    public async Task TestSSE()
    {
        await _corejobs.RunCorejobSSE("test_registry", null);
    }
}

public class CorejobRegistryTest : CorejobRegistryBase
{
    // Has access to all services a controller does:
    private readonly ExampleDBContext _db;
    public CorejobRegistryTest(IHttpContextAccessor httpContextAccessor, ILogger<CorejobRegistryTest> logger, IConfiguration configuration, ExampleDBContext db) : base(httpContextAccessor, logger, configuration)
    {
        _db = db;
    }

    [Corejob("test_registry")]
    [Customer("coredata")]
    public async Task<IResultBase> TestRegistry()
    {
        string? username = GetUserName();
        var user = await _db.Users.Where(u => u.username == username).FirstOrDefaultAsync();
        string customer_folder = await GetCustomerRoot();
        await LogInformation("Current user: " + username + " (" + user.email + ")    Customer folder: " + customer_folder);

        // Low-code JSON corejob
        await ExecuteCMD("bf9fb9b6-8c42-495f-a6e6-2da9ed4a8909", new() {
            ["date"] = DateTime.Now.ToString()
        });

        string? customer = GetCustomerName();
        return Result.Ok().WithSuccess("Successfully ran test_registry for customer " + customer);

        // Any exceptions will automatically be caught and replaced with a Result.Fail() with the exception message; no try/catch needed
    }
}

Remember to add this line in Program.cs:

builder.Services.AddCorejobs();

LibAICORE also has a settings format. Here is the usual block that needs to be added to appsettings:

{
    "AICORE": {
        "api-urls": {
            "ExecuteCMD": "https://aicoreio.coredata.ca/ExecuteCMD/ExecuteCMD/ExecuteCMD",
            "CSVtoDB": "https://aicoreio.coredata.ca/CSVToDB/CSVToDB",
            .
            .
            .
        },
        "keycloak": {
            "realm": "coredata",
            "auth-server-url": "https://auth.aicore.ca/",
            "resource": "aicore",
            "verify-token-audience": false,
            "credentials": {
                "secret": "..."
            }
        },
        "user": {
            "username": "...",
            "password": "..."
        },
        "token-mode": "ForwardFromAPICall"
    }
}

Note the keycloak and user sections not needed if the token mode is ForwardFromAPICall, which means if any RunCorejob is called from an API controller, LibAICORE just gets the token from the call to the controller.

If the token mode is set to LoginAsUser instead, LibAICORE will automatically log in using the credentials under "user" and the keycloak settings under "keycloak" before running the corejob.

No packages depend on LibAICORE.

Version Downloads Last updated
1.2.37-alpha-g5bd296be23 36 09/26/2026
1.2.35-alpha-g98acf12e92 36 08/12/2026
1.2.34-alpha-g19212d144e 37 07/06/2026
1.2.32-alpha-g9d081aa2bd 34 05/07/2026
1.2.31-alpha-g99c5ffdaec 24 05/07/2026
1.2.30-alpha-g0db28f7786 25 05/07/2026
1.2.28-alpha-g4b64ed6ddc 58 08/13/2025
1.2.27-alpha-gfc8760def2 53 08/11/2025
1.2.25-alpha-gb1913ea3e8 63 01/14/2025
1.2.21-alpha-gbabeba456d 59 12/11/2024
1.2.18-alpha-g90b8ba953c 56 12/06/2024
1.2.17-alpha-g3be3442f04 89 12/03/2024
1.2.16-alpha-g8dd4b5d542 62 11/27/2024
1.2.15-alpha-g18195b9aa6 57 11/20/2024
1.2.14-alpha-g137bab6a23 63 11/20/2024
1.2.13-alpha-g8f06d48f79 55 11/20/2024
1.2.12-alpha-g94835e8111 66 10/19/2024
1.2.11-alpha-gf518a6e68d 53 08/14/2024
1.2.10-alpha-gb698fdc405 45 08/14/2024
1.2.9-alpha-g7d4b574a88 66 08/12/2024
1.2.8-alpha-g1d9aa3aaa3 62 08/12/2024
1.2.7-alpha-geadfde9bf6 65 08/06/2024
1.2.6-alpha-ge83d37f49e 53 08/06/2024
1.2.5-alpha-g4f8bc05636 49 08/06/2024
1.2.4-alpha-gd918c1e3fa 50 08/06/2024
1.2.3-alpha-g52eb945744 52 08/06/2024
1.2.2-alpha-gb7cdc63e57 51 08/06/2024
1.2.1-alpha-g02ebe3c8a6 66 07/04/2024
1.1.59-alpha-ga23cb6a1f7 48 07/02/2024
1.1.58-alpha-g737c5fc5cc 55 06/06/2024
1.1.57-alpha-g3293dd9c81 60 06/06/2024
1.1.55-alpha-g6e01950464 48 06/05/2024
1.1.54-alpha-g5d726e75eb 50 06/05/2024
1.1.53-alpha-gc625116210 48 06/05/2024
1.1.52-alpha-ga382c9de4e 56 06/04/2024
1.1.51-alpha-g7aa32cf052 55 05/30/2024
1.1.50-alpha-g671aa1ddb6 57 03/29/2024
1.1.49-alpha-g52ed983c51 54 03/29/2024
1.1.48-alpha-g7600133b25 61 03/28/2024
1.1.47-alpha-gbdc3fcaab9 58 03/19/2024
1.1.46-alpha-g43988be0b3 56 03/19/2024
1.1.45-alpha-gb461cdbead 57 03/18/2024
1.1.44-alpha-g2965cc70cc 63 03/18/2024
1.1.43-alpha-gd8844bf21b 52 03/18/2024
1.1.42-alpha-g618b7561a5 53 03/18/2024
1.1.41-alpha-gf164276ac6 51 03/18/2024
1.1.40-alpha-g43a3f07c8b 51 03/12/2024
1.1.39-alpha-g0ada0164a0 58 03/12/2024
1.1.38-alpha-g24a85d878d 51 03/05/2024
1.1.37-alpha-g1bf4e889bf 53 03/05/2024
1.1.36-alpha-g6b4dd1e943 63 03/05/2024
1.1.35-alpha-g224786f9be 63 03/04/2024
1.1.34-alpha-g16a9665225 55 03/02/2024
1.1.32-alpha-g0905098db4 57 02/29/2024
1.1.31-alpha-g41b279f224 62 02/28/2024
1.1.30-alpha-ga3f59b4728 53 02/28/2024
1.1.29-alpha-g6239f3c232 53 02/28/2024
1.1.28-alpha-gf6015f79e0 49 02/28/2024
1.1.27-alpha-g99b57c4f7e 58 02/28/2024
1.1.26-alpha-g3aad192cc3 51 02/24/2024
1.1.25-alpha-gd5c6144537 47 02/23/2024
1.1.24-alpha-gf15dc0cdfc 54 02/23/2024
1.1.23-alpha-gfc025e1ba4 53 02/22/2024
1.1.18-alpha-g20ffcb8b6b 47 02/22/2024
1.1.17-alpha-g389f191b69 50 02/21/2024
1.1.11-alpha-ge694af15d2 51 02/17/2024
1.1.10-alpha-g19850a3f14 53 02/17/2024
1.1.9-alpha-g4d2dbe4e41 55 02/16/2024
1.1.8-alpha-ga6d88e1b1c 62 02/16/2024
1.1.7-alpha-g977a204511 55 02/16/2024
1.1.6-alpha-g0dddc477b5 50 02/16/2024
1.1.5-alpha-gb937332e73 51 02/16/2024
1.1.4-alpha-gf81b1bf205 58 02/16/2024
1.1.2-alpha-g599cc04df5 56 02/16/2024