Reputation: 6222
I am working on a sync client that replicate appointment from and to EWS (Office 365).
In general I am following the documentation provided by MS: https://msdn.microsoft.com/en-us//library/office/dn440952(v=exchg.150).aspx
My problem:
This article https://msdn.microsoft.com/en-us//library/office/dn605828(v=exchg.150).aspx#Arbeiten%20mit%20Bezeichnern shows that the ItemId
of a appointment may change and is not unique.
So investigating I found out that people load cleanGlobalObjectId
from appointment that is unique once and for all.
// unique id for sync that do not change like item id
var cleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x23, MapiPropertyType.Binary);
var psPropSet = new PropertySet(BasePropertySet.FirstClassProperties) { cleanGlobalObjectId };
So I use
var appointment = Appointment.Bind(service, item, psPropSet);
object calIdVal;
appointment.TryGetProperty(cleanGlobalObjectId, out calIdVal);
var syncId = Convert.ToBase64String((byte[])calIdVal);
syncId
is so far I tested unique and works for INSERT and UPDATE appointments into my database.
When I now use SyncFolderItems
from EWS I get a collection of items for create
,update
,delete
.
My problem:
I can not load appointments with Appointment.Bind()
that are deleted.
But I need to load the appointment to get my syncId
.
The SyncFolderItems
collection let me access ItemId.UniqueKey
and ItemId.ChangeKey
.
So if an appointment is moved or deleted in a users calendar I have no chance to identify the correct record in my client database where I save the replicated appointments.
So anyone have some advise or any other approaches? If I forgot to add some details please also provide some feedback so I can add this.
Upvotes: 1
Views: 541
Reputation: 5422
You should save both, the cleanGlobalObjectId as well as the ItemId in your database. This way, you can tackle the removal of an item as well as the event that Exchange recreates your appointment (which doesn't happen all the time, just under certain circumstances).
Upvotes: 1