Skip to main content

System Startup, Startup Tasks and Registration Tasks

The platform provides an entry point for handling the complicated tasks of starting up, registering, configuring, updating and shutting down the system. Creating an instance of the Eleflex.SystemStartupShutdown object and calling the Start() or Stop() methods will perform system initialization or termination. These methods would be called in the Application_Start() or Application_End() methods of a web application’s global.asax file or executed within the Main() method of a windows application or service. An example of calling the methods would be the following:


    //Start the system
    Eleflex.SystemStartupShutdown startup = new Eleflex.SystemStartupShutdown();
    startup.Start(null);
    //Shutdown the system
    Eleflex.SystemStartupShutdown shutdown = new Eleflex.SystemStartupShutdown();
    shutdown.Stop(null);

Using a convention over configuration approach similar to the open source project Bootstrapper, the system defines an ordered approach to run various startup tasks, as executed by the Eleflex.SystemStartupShutdown object. The process will automatically find all objects inheriting from either Eleflex.StartupTask or Eleflex.StartupTaskWithRegistration and execute the tasks in order. The system contains the following pre-defined ordered tasks required by the system:

The following example demonstrates how to create a custom startup task. Integrators creating a new startup task can order their task to execute before or after other tasks by setting the Priority property. See the StartupConstants object to get a list of predefined startup order values that can be used.


using Eleflex;
public partial class ExampleStartupTask : StartupTask
{
    public ExampleStartupTask() : base()
    {
        Description = "Example startup task.";
        Priority = StartupConstants.PRIORITY_CUSTOM;
    }
    public override bool Start(ITaskOptions taskOptions)
    {
        //Execute custom logic here!
        return base.Start(taskOptions);
    }
}

Integrators using the Eleflex.StartupTaskWithRegistration object must also define a custom class attribute that registration tasks must decorate with so they can be dynamically discovered and executed when the corresponding startup task executes. The usage is demonstrated when registering object location and object mapping configurations in the next sections.