Back to Devexpress

AppointmentSynchronizer.AppointmentSynchronizing Event

corelibraries-devexpress-dot-xtrascheduler-dot-exchange-dot-appointmentsynchronizer-4cc3aae1.md

latest10.3 KB
Original Source

AppointmentSynchronizer.AppointmentSynchronizing Event

Allows you to cancel the synchronization process for an appointment.

Namespace : DevExpress.XtraScheduler.Exchange

Assembly : DevExpress.XtraScheduler.v25.2.Core.dll

NuGet Package : DevExpress.Scheduler.Core

Declaration

csharp
public event AppointmentSynchronizingEventHandler AppointmentSynchronizing
vb
Public Event AppointmentSynchronizing As AppointmentSynchronizingEventHandler

Event Data

The AppointmentSynchronizing event's data class is AppointmentSynchronizingEventArgs. The following properties provide information specific to this event:

PropertyDescription
AppointmentGets the appointment for which the event was raised. Inherited from AppointmentEventArgs.
CancelGets or sets whether the operation performed on the processed event should be cancelled. Inherited from AppointmentCancelEventArgs.
OperationSpecifies what type of synchronization operation should be performed.

Remarks

The AppointmentSynchronizing event is raised before synchronization begins and allows you to cancel the process. The event parameter’s AppointmentEventArgs.Appointment property identifies the processed appointment, the AppointmentSynchronizingEventArgs.Operation property specifies the operation to perform. To skip it, set the AppointmentCancelEventArgs.Cancel property to true.

Handling the event enables you to make a decision based on the current item properties. You can leave the item intact, modify it or perform other actions that suit your synchronization model.

By analyzing the AppointmentSynchronizingEventArgs.Operation value and AppointmentEventArgs.Appointment properties, you can implement virtually any appointment conflict resolution scenario. If the target calendar application contains both previous and new appointments, and you want to leave the existing appointments intact, you can set Cancel to true to stop the operation when AppointmentSynchronizingEventArgs.Operation is equal to SynchronizeOperation.Replace.

Other scenarios may require modifying the operation type within the AppointmentSynchronizing event handler. Instead of SynchronizeOperation.Replace you may choose to SynchronizeOperation.Delete the calendar item. This can be easily accomplished by changing the AppointmentSynchronizingEventArgs.Operation value.

Example

Note

WARNING: If you call the SchedulerStorageBase.SynchronizeOutlookWithStorage method, all data in your MS Outlook will be lost. We suggest that you backup all your data prior to running this example.

The following example demonstrates how to synchronize appointments data in the SchedulerStorage with the data already stored in the MS Outlook database, and vice versa in one step.

To perform an easy synchronization, use the SchedulerStorageBase.SynchronizeStorageWithOutlook and SchedulerStorageBase.SynchronizeOutlookWithStorage methods.

Before synchronizing the SchedulerStorage with MS Outlook, create an additional field in your database. This field should be of the string type with a length of at least 50 characters, and intended to store the Outlook Entry Id for each appointment that is to be synchronized. Assuming the field is called “OutlookEntryId”, you can then use the following code to synchronize the Scheduler Storage with MS Outlook and vice versa.

csharp
private void button1_Click(object sender, System.EventArgs e) {
    schedulerControl1.Storage.SynchronizeStorageWithOutlook("OutlookEntryId");
}

private void button2_Click(object sender, System.EventArgs e) {
    schedulerControl1.Storage.SynchronizeOutlookWithStorage("OutlookEntryId");
}
vb
Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
    SchedulerControl1.Storage.SynchronizeStorageWithOutlook("OutlookEntryId")
End Sub

Private Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click
    SchedulerControl1.Storage.SynchronizeOutlookWithStorage("OutlookEntryId")
End Sub

For this example to work correctly, the Scheduler’s data source should provide a field to store the Outlook Entry ID. The filed should be mapped to a custom appointment field, as illustrated below.

csharp
schedulerStorage.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("OutlookId", "OutlookEntryId"));
vb
schedulerStorage.CustomFieldMappings.Add(New AppointmentCustomFieldMapping("OutlookId", "OutlookEntryId"))

Note

If your purpose is to unite all data from the SchedulerStorage and MS Outlook, use the SchedulerStorageBase.ExportToOutlook and SchedulerStorageBase.ImportFromOutlook methods instead. To set custom rules when synchronizing appointments, use the AppointmentExportSynchronizer and the AppointmentImportSynchronizer classes.

The following code snippets (auto-collected from DevExpress Examples) contain references to the AppointmentSynchronizing event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-scheduler-sync-outlook-calendars/CS/SyncWithOutlook/OutlookSynchronizerHelper.cs#L73

csharp
private void SubscribeToStorageEvents() {
    if(importSynchronizer != null) importSynchronizer.AppointmentSynchronizing += Synchronizer_AppointmentSynchronizing;
    if(exportSynchronizer != null) exportSynchronizer.AppointmentSynchronizing += Synchronizer_AppointmentSynchronizing;

winforms-scheduler-sync-with-outlook/CS/SyncWithOutlook/Form1.cs#L50

csharp
// The AppointmentSynchronizing event allows you to control the operation for an individual appointment.
synchronizer.AppointmentSynchronizing += new AppointmentSynchronizingEventHandler(exportSynchronizer_AppointmentSynchronizing);
// The AppointmentSynchronized event indicates that the operation for a particular appointment is complete.

winforms-scheduler-sync-outlook-calendars/VB/SyncWithOutlook/OutlookSynchronizerHelper.vb#L99

vb
If importSynchronizer IsNot Nothing Then
    AddHandler importSynchronizer.AppointmentSynchronizing, AddressOf Synchronizer_AppointmentSynchronizing
End If

winforms-scheduler-sync-with-outlook/VB/SyncWithOutlook/Form1.vb#L51

vb
' The AppointmentSynchronizing event allows you to control the operation for an individual appointment.
AddHandler synchronizer.AppointmentSynchronizing, AddressOf exportSynchronizer_AppointmentSynchronizing
' The AppointmentSynchronized event indicates that the operation for a particular appointment is complete.

See Also

Synchronization with Microsoft Outlook

AppointmentSynchronizer Class

AppointmentSynchronizer Members

DevExpress.XtraScheduler.Exchange Namespace