Skip to main content

Handling Raw Data

  • 7 minutes to read

This topic describes how to persist a user event‘s data in the underlying data store manually (bypassing the scheduler storage – TcxSchedulerStorage or TcxSchedulerDBStorage).

The cxSchedulerTable.db table that is described in this topic was created in Paradox® format using the BDE toolset.

The following pieces of information on the scheduled user event are stored in the database:

The following table shows the structure of the cxSchedulerTable.db table that stores the detailed information on the scheduled user event:

Field Name

Type

Size

Value Restriction Rule

1

ActualFinish

TIntegerField

2

ActualStart

TIntegerField

3

Caption

TStringField

255

NULL must be allowed

4

EventType

TIntegerField

5

Finish

TDateTimeField

or TSQLTimeStampField

6

GroupID

TIntegerField

or GUID

7

ID

TIntegerField

(Autoincrement)

or GUID

8

LabelColor

TIntegerField

NULL must be allowed

9

Location

TStringField

255

NULL must be allowed

10

Message

TStringField

255

NULL must be allowed

11

Options

TIntegerField

NULL must be allowed

12

ParentID

TIntegerField

or GUID

13

RecurrenceIndex

TIntegerField

14

RecurrenceInfo

TBlobField

15

ReminderDate

TDateTimeField

or TSQLTimeStampField

NULL must be allowed

16

ReminderMinutesBeforeStart

TIntegerField

NULL must be allowed

17

ReminderResourcesData

TBlobField

NULL must be allowed

18

ResourceID

TIntegerField

or TBlobField

19

Start

TDateTimeField

or TSQLTimeStampField

20

State

TIntegerField

NULL must be allowed

21

TaskCompleteField

TIntegerField

22

TaskIndexField

TIntegerField

23

TaskLinksField

TBlobField

24

TaskStatusField

TIntegerField

You can also add custom fields to the table to store the custom data (to learn how to use custom fields in an application, refer to the Customizing Event and Event recurrence dialogs help topic).

The Options field’s value is a compound value and it’s made up of the omAllDayEvent, omCollapsed, omEnabled, omGroup, and omReminder values. If these flags are set at the same time, use the OR bitwise operator to build up the Options field’s value (see the example below).

The RecurrenceInfo field of the BLOB type stores the TcxSchedulerCustomRecurrenceInfoData record’s data that provides details on the user event recurrence. To transfer the TcxSchedulerCustomRecurrenceInfoData record’s data into a sequence of bytes, use the cxRecurrenceInfoDataToString routine; an example on this is provided later on in this topic.

The RecurrenceInfo field structure corresponds to the TcxSchedulerCustomRecurrenceInfoData record’s structure, as illustrated in the following table:

Record Field

Type

BLOB

Offset

Storage Requirement

(bytes)

Description

Count

Integer

0

4

Specifies the number of occurrences of the recurring user event.

DayNumber

Integer

4

4

Specifies the day number in a month, working week, Saturdays/Sundays in a month, or weekend that the user event will reoccur on (for details refer to the Applying The Recurrence Pattern topic).

DayType

TcxDayType

8

1

Specifies the day type used to calculate the user event’s reoccurrence in the Recurrence pattern.

Finish

TDateTime

9

8

Specifies the end date and time of the user event’s reoccurrences.

OccurDays

TDays

17

1

Specifies the days in a week that the user event reoccurs on.

Periodicity

Integer

18

4

Specifies the frequency with which the user event reoccurs with respect to the time base specified by the Recurrence field.

Recurrence

TcxRecurrence

22

1

Specifies the time base for the frequency of the user event’s reoccurrences.

Start

TDateTime

23

8

Specifies the start date and time for the user event’s reoccurrences.

YearPeriodicity

Integer

31

4

Specifies the frequency with which the user event reoccurs on a yearly basis.

Version

Byte

35

1

Reserved for internal use.

DismissDate

Integer

36

4

Specifies the date when the reminder is switched off for the corresponding occurrence.

The following example shows how to store a new user event in the data store:

// ...
var
  S: string;
  ARecurrenceInfo: TcxSchedulerCustomRecurrenceInfoData;
begin
  FillChar(ARecurrenceInfo, SizeOf(ARecurrenceInfo), 0);
  // the all-day event repeats two days (Thursday and Friday)
  with ARecurrenceInfo do
  begin
    Count := 2;
    DayNumber := 1;
    DayType := cxdtEveryDay;
    Finish := -1;
    OccurDays := [dThursday];
    Periodicity := 1;
    Recurrence := cxreDaily;
    Start := 0;
    YearPeriodicity := 1;
  end;
  // convert the TcxSchedulerCustomRecurrenceInfoData record's data into the binary data contained in the string that serves as a buffer between the record and the RecurrenceInfo dataset field
  S := cxRecurrenceInfoDataToString(ARecurrenceInfo);
  // post it to the dataset
  with SchedulerTable do
  begin
    Append;
    FieldValues['Type'] := Integer(etPattern);
    FieldValues['Start'] := StrToDateTime('10/21/04 00:00');
    FieldValues['Finish'] := StrToDateTime('10/22/04 00:00');
    FieldValues['Options'] := omAllDayEvent or omEnabled;
    FieldValues['Caption'] := 'Birthday';
    FieldValues['RecurrenceIndex'] := -1;
    FieldValues['RecurrenceInfo'] := S;
    FieldValues['ResourceID'] := 1; // if the resource is set up in the scheduler 
    FieldValues['Location'] := 'Sea Food Restaurant';
    FieldValues['Message'] := 'Party';
    FieldValues['State'] := tlsOutOfOffice;
    FieldValues['LabelColor'] := EventLabels.Items[1].Color; // the label is 'important'. To use the EventLabels collection (see description on the TcxSchedulerEventLabels class in the documentation), specify the cxSchedulerUtils unit in the uses clause
    Post;
  end;
end;

To learn how to use resources, refer to the Grouping User Events and Bound Mode help topics.

Note: the example shown above assumes that the ID field in the data store is automatically incremented. If the type of the ID field is defined as GUID (for example, in MS SQL Server) and if it is not generated by the database engine for some reason, then you can use the TGUID type and the CreateGUID function to generate a value for the ID field. It’s best to implement the TDataSet.BeforePost event handler and generate a new GUID in it before the data is posted to the data store, as shown below:

// ...
procedure TCustomDialogsForm.SchedulerTableBeforePost(DataSet: TDataSet);
var
  ASchedulerTableID: TField;
  G: TGuid;
begin
  ASchedulerTableID := DataSet.FieldByName('ID');
  if ASchedulerTableID.IsNull then
  begin
    // generate a new GUID
    CreateGUID(G);
    // assign the newly created GUID to the ID field
    ASchedulerTableID.Value := GUIDToString(G);
  end;
end;

Note

The type of the ID field and the ParentID field’s type must be the same.

See Also