I’m currently using a scheduler control to save and restore scheduled appointment data from a SQL database within my application. The scheduler control itself is configured to use a couple of custom fields, like so:
private DevExpress.XtraScheduler.SchedulerControl _SchedulerControl;
private DevExpress.XtraScheduler.SchedulerControl StandingSchedulerControl
{
get
{
if (_SchedulerControl == null)
{
_SchedulerControl = new DevExpress.XtraScheduler.SchedulerControl();
BindingSource bs = new BindingSource();
bs.DataSource = StandingOrderList;
_SchedulerControl.Storage = new SchedulerStorage(this.components);
_SchedulerControl.Storage.Appointments.AutoReload = true;
_SchedulerControl.Storage.Appointments.Mappings.Subject = "Description";
_SchedulerControl.Storage.Appointments.Mappings.RecurrenceInfo = "RecurrenceInfo";
_SchedulerControl.Storage.Appointments.Mappings.Type = "Type";
_SchedulerControl.Storage.Appointments.CustomFieldMappings.Add(new DevExpress.XtraScheduler.AppointmentCustomFieldMapping("Inactive", "Inactive"));
_SchedulerControl.Storage.Appointments.CustomFieldMappings.Add(new DevExpress.XtraScheduler.AppointmentCustomFieldMapping("StandingOrderKEY", "StandingOrderKEY"));
_SchedulerControl.Storage.Appointments.DataSource = bs;
_SchedulerControl.EditRecurrentAppointmentFormShowing += new EditRecurrentAppointmentFormEventHandler(_SchedulerControl_EditRecurrentAppointmentFormShowing);
}
return _SchedulerControl;
}
}
Where “StandingOrderList” is defined as a list of StandingOrder business objects. This saves and restores correctly, but it is possible within the application to only have a value of “StandingOrderKEY,” and need to obtain the Appointment object within the storage from this value. Until now, my solution was this:
private Appointment GetAppointmentByStandingOrderKEY(Guid standingOrderKEY)
{
Appointment findAppointment = StandingSchedulerControl.Storage.Appointments.Items.Find(appointment => (Guid)appointment.CustomFields["StandingOrderKEY"] == standingOrderKEY);
return findAppointment;
}
However, it appears that StandingSchedulerControl.Storage.Appointments.Items only contains Appointments that have types of Normal or Pattern, which means if the StandingOrderKEY is associated with a saved ChangedOccurrence or a DeletedOccurrence, the related appointment won’t be found.
I’ve verified that the BindingSource created from the list does, in fact, contain the exceptions for all Appointments. It seems that when it is set as the DataSource for the AppointmentStorage, exceptions are housed “within” their Pattern appointment, and are only obtainable by first getting a reference to the parent appointment and then calling GetExceptions() on that appointment, and searching the resulting collection for the StandingOrderKEY. This is a problem, however, as currently we don’t have the “parent” appointment’s identifying information, only the one for the exception.
And so, my question(s) are as follows (roughly in order of preferability):
- Is there a way to obtain an Appointment object from the Appointment storage by Custom Field value, ignoring the type of the appointment? Is there a collection that contains both exceptions AND normal/pattern Appointments?
- We know that the Appointment is going to be an Exception up front, because the Type of the appointment is already stored. Is there a way to search ALL exceptions for this particular custom field value?
- Is there a way to obtain an Appointment object from the Appointment storage by a datasource reference? The BindingSource used as the DataSource contains the exception appointments. Is there a way, given an item in the BindingSource collection, to associated it with the item in the Storage?
Any other suggestions are welcome. Thanks for your attention!
The eventual solution that I came to was maintaining my own mapping of standing order objects to appointments, as seen in this DevExpress solution here: http://www.devexpress.com/Support/Center/p/E3143.aspx
This allowed me to obtain the appointment object from the source object, as in question 3 above.