DevExpress-Examples / xaf-how-to-create-custom-event-and-resource-classes-for-scheduler

This repository contains examples of custom Event and Resource classes for Scheduler in XAF applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XAF - Create Custom Event and Resource Classes for XAF Scheduler

Scheduler List Views work with events (IEvent objects) and resources (IResource objects).

XAF's Business Class Library implements these interfaces in Event and Resource classes. In some cases, you may need to extend these classes or even implement their corresponding interfaces from scratch.

The example in this repository implements the following scenarios:

  1. Use custom event and resource objects.

  2. Use ApplicationUser as a resource.

  3. Create an event with a single resource.

NOTE
Instructions below describe classes specific to Entity Framework Core ORM. For XPO-specific classes refer to the following files:

  • "c:\Program Files\DevExpress 2X.Y\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.Xpo\Event.cs"
  • "c:\Program Files\DevExpress 2X.Y\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.Xpo\Resource.cs"

Implement Custom Events and Resources

  1. Create a new event class and add properties. See the #region Base Properties section in the source code. It contains all IEvent properties except ResourceId.

  2. Implement a resource object. See the #region Resources section in the source code.

    The IEvent interface requires a string ResourceId property that stores a collection of resources in an XML string (required by the Scheduler control). In XAF, we recommend that you add an associated collection of objects instead. Add the ResourceId string property and the Resources collection property and set up synchronization between them.

  3. Implement IRecurrentEvent. See the #region IRecurrentEvent section in the source code.

  4. Implement IReminderEvent. See the #region IReminderEvent section in the source code.

    Note Reminders are currently not supported in XAF Scheduler Module for ASP.NET Core Blazor. Skip this section for ASP.NET Core Blazor applications.

  5. Add Blazor compatibility options. See the #region Blazor compatibility section in the source code. Skip this step if you do not plan to implement the Event class in an ASP.NET Core Blazor application.

  6. Implement object construction. See the #region Construction section in the source code.

    If you need to initialize a property (for example the StartOn or EndOn property) when XAF creates a new CustomEvent, override the OnCreated event.

  7. If you want to add validation, see the #region Validation section in the source code.

    To use the Validation Module, add validation rules to your object. For example, you can demand that the StartOn date always precedes the EndOn date.

Implement the IResource Interface in the ApplicationUser Class

  1. Implement the IResource interface in the ApplicationUser class.

    Note
    In this example, we implement IResource.Id explicitly because ApplicationUser already has an ID property. This implicit implementation causes an ambiguous exception in Windows Forms applications that use Entity Framework Core ORM. To resolve this issue, remap the Scheduler to the ID property directly instead of the IResource.Id property. For implementation details, refer to CustomEventWithUserResourcesController.cs.

  2. If you implement IResource in multiple classes, specify a Resource class for the corresponding Scheduler List View. For more information, refer to the following topic: Use a Custom Resource Class.

Use Application Model to Customize Objects in Scheduler

  1. Enable drag-and-drop in Scheduler.

    By default, Scheduler does not allow to edit objects. You need to set the AllowEdit property to true in the Model.DesignedDiffs.xafml file.

  2. Customize the Start and End properties to show time.

    By default, DateTime property editors only display date. Change DisplayFormat and EditMask to show and edit time. For details, see the Model.DesignedDiffs.xafml file.

Create an Event with a Single Resource

  1. If you want to create a One-to-Many relationship between a resource and events, change ResourceId implementation. For details, see the following source file: CustomEventWithCustomResource.cs.

  2. Create a custom Resource class and implement the IResource interface. For implementation details, see the following source file: CustomResource.cs.

Files to Review

Documentation

About

This repository contains examples of custom Event and Resource classes for Scheduler in XAF applications

License:Other


Languages

Language:C# 84.3%Language:HTML 15.0%Language:CSS 0.7%