How to: Add the Scheduler Module
- 2 minutes to read
This article describes how to add the Scheduler module to your application.
The Scheduler module implements a List Editor that uses the Scheduler Control to display and manage Event
business objects and resources in XAF applications.
Step-by-Step Instructions
Add the DevExpress.ExpressApp.Scheduler NuGet package to the MySolution.Module project. See the following topic for more information on how to install DevExpress NuGet packages: Install DevExpress Controls Using NuGet Packages.
In the Solution Explorer, go to the MySolution.Module project and open the Module.cs file. Add the Scheduler module to the RequiredModuleTypes collection. Then, add the
Event
andResource
classes to the AdditionalExportedTypes collection://... namespace MySolution.Module; //... public sealed class MySolutionModule : ModuleBase { public MySolutionModule() { //... RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.Scheduler.SchedulerModuleBase)); AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.EF.Event)); AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.EF.Resource)); } //... }
Optional. If you use Entity Framework Core, go to the MySolution.Module\BusinessObjects folder, open the MySolutionDbContext.cs file. Then, register the
Event
andResource
types in the application’sDbContext
://... namespace MyApplication.Module.BusinessObjects; //.. [TypesInfoInitializer(typeof(MySolutionContextInitializer))] public class MySolutionEFCoreDbContext : DbContext { public MySolutionEFCoreDbContext(DbContextOptions<MySolutionEFCoreDbContext> options) : base(options) { } public DbSet<Event> Events { get; set; } public DbSet<Resource> Resources { get; set; } //.. } // ...
Note
If you use Entity Framework Core, any changes to the application’s data model may cause database-related exceptions when you run the application. We recommend that you use migrations to update the database schema. For more information on how to create a migration and update the database, refer to the following topic: Implement a Data Model: Basics.
Add the DevExpress.ExpressApp.Scheduler and DevExpress.ExpressApp.Scheduler.Win NuGet packages to the MySolution.Win project.
In the Startup.cs, call the AddScheduler(IModuleBuilder<IWinApplicationBuilder>, Action<SchedulerOptions>) method to add the Scheduler module to your application:
//... namespace MySolution.Win; public class ApplicationBuilder : IDesignTimeApplicationFactory { public static WinApplication BuildApplication(string connectionString) { var builder = WinApplication.CreateBuilder(); builder.UseApplication<MySolutionWindowsFormsApplication>(); builder.Modules .AddScheduler() //... } //... }
Build the project and run the application. The Scheduler Event item appears in the navigation control.
Tip
XAF has a special Notifications module you can use to set notifications for events. For more information about this module, refer to the following topic: How to: Use Notifications with the Scheduler Event.