Skip to main content
A newer version of this page is available. .

Resources in a Schedule

  • 5 minutes to read

This topic introduces the concept of the Resources feature supported by the Scheduler Module, describes how scheduler events and resources are associated, and details how resources can be assigned to the scheduler events.

What is a Resource?

In real-life scheduling applications where one deals with a large amount of data being scheduled, appointments (scheduler events) are seldom processed “as is”, but are usually assigned to different resources. Resources can be of different kinds, and the decision as to what should be a resource in a particular scheduling application depends upon the specifics of the task performed by this particular application. The following are some examples of scheduling tasks, illustrating what can be an appointment and a resource in these tasks.

  • A Company.

    Resource: Every employee in this company

    Event: Any time interval which is spent by an employee to perform a particular task.

  • A Car Rental Agency.

    Resource: Every car which is owned by this firm and available for rental.

    Event: Any time interval when any of the firm’s cars are rented.

  • An Educational Center.

    Resources: Every teacher who works at this center, or every classroom in this center.

    Event: Any time interval when any of the teachers is delivering a lecture in any of the classrooms in the center.

    Note

    In the latter example, two kinds or resources are possible (teachers and rooms). However, the Scheduler controls do not allow events to belong to resources of a different nature. So, to display this data in a scheduling application, we suggest using two different Event List Views. One Event List View may be used to display teachers as resources, and another Event List View may be used to display rooms as resources, but both should be bound to the same data to assure consistency.

Association Between Resources and Scheduler Events

The Scheduler module works with classes that implement the DevExpress.Persistent.Base.General.IEvent interface and classes that implement the DevExpress.Persistent.Base.General.IResource interface. To support the Resources feature, the IEvent interface exposes the ResourceId property. This property specifies an XML string in which the identifiers of the associated resources are listed. Note that the Scheduler module supports the ResourceSharing strategy. So, several Resources can be assigned to an Event. The following image demonstrates this concept:

Resources_Sharing

The built-in DevExpress.Persistent.BaseImpl.Event class, which implements the IEvent interface, has a Many-to-Many association with the built-in DevExpress.Persistent.BaseImpl.Resource class, which implements the IResource interface. All Resource objects from the Event’s Resources collection are listed in the Event’s IEvent.ResourceId property.

Use Built-in Event and Resource Classes

To use the built-in Event and Resource classes in your application, add the Event class to a module in your solution via the Module Designer. The built-in Resource class will be added automatically. If you use the DevExpress.Persistent.BaseImpl.Event class’ descendant, the built-in DevExpress.Persistent.BaseImpl.Resource class will be added to the process of automatic UI generation as well. This allows you to have an extended Event class, but use the inherited association with the Resource class.

At runtime, you can create and display Resource objects in an ordinal way - by displaying the Resource List View and Detail View. In addition, you can add the required Resource(s) to an Event’s Resources collection in the Event Detail View:

… in a Windows Forms application:

Resources_EventDetailView_Win

… in an ASP.NET application:

Resources_EventDetailView _Web

Resources are also displayed in Event List Views. The following image shows how a collection of two Resources (1 and 2) is displayed in an Event List View:

… in a Windows Forms application:

Resources_EventListView

… in an ASP.NET application:

Resources_EventListView_Web

In this image, you can see the Event that uses both Resources. However, you can display Events for the required Resource only. To do this, use the Resource Navigator in the bottom-right of the Scheduler Control. It is intended for scrolling through resources, and changing the number of resources shown at one time on screen. To learn more, refer to the Navigate through Resources link.

Use a Custom Resource Class

To be supported by the Scheduler module, a Resource class must implement the DevExpress.Persistent.Base.General.IResource interface. The built-in DevExpress.Persistent.BaseImpl.Resource class from the Business Class Library implements this interface. A custom Resource class must implement this interface as well. So, to implement a custom Resource class, inherit from the built-in DevExpress.Persistent.BaseImpl.Resource class or implement the IResource interface from scratch. You can see the sources of the built-in Resource class at: %PROGRAMFILES(x86)%\DevExpress 19.1\Components\\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl\Resource.cs.

Since the built-in Event class is associated with the built-in Resource class, you will have to implement a custom Event class to associate it with the custom Resource class. For this purpose, use the sources of the built-in Event class. They are located at: %PROGRAMFILES(x86)%\DevExpress 19.1\Components\\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl\Event.cs, by default.

The type of the objects that will serve as a resource data source for the Scheduler List Editor must be set to the IModelListViewScheduler.ResourceClass property of the Application Model‘s Views | <ListView> node:

ResourceClassName

The Application Model is extended with this property by the Scheduler module. If you have a single class that implements the IResource interface in your application, this class will be assigned to this property automatically. If you have several classes that implement the IResource interface, you can assign any of them to this property. Otherwise, the first found type will be set.