Reputation: 1472
I am using the Managed EWS API in C# to implement an email/calendaring client. To process updates I am using pull notifications. I am trying to figure out how to properly process a "delete" event for a recurring series. The event is technically a move event since it shows up as moving the series to the trash folder.
When dealing with a recurring series, the events you get are always for the recurring master. I have successfully implemented the "add" case by using the master ID and the recurrence information to sync down all the individual occurrences I am interested in, but haven't been able to figure out the remove/delete case.
I have investigated two main approaches so far:
1) Try to reuse the change key. In recurring series the change key for all instances is the same. So I tried a lookup in my cache for appointments with a matching change key. However the change key does not match in this scenario, as by the time you get the event the series has been moved to the trash folder and so has a new change key.
2) Use the recurring master from the move/delete event to bind to to the appointments that would be in my cache, and then try to delete based on the unique IDs of these occurrences. This does not work for the same reason as #1. By the time I've got the event, the series has been already moved and the occurrences all have new IDs. So none of the new IDs from the lookup match the old IDs that I have.
For completeness I have played with the OldItemId in the event, but as expected I can't execute any binds on this ID as that item doesn't exist on the server anymore.
So in short I have failed to find any way to link a move-to-trash event for a recurring series to the actual original recurring series. Is this not possible or am I missing something?
I am now going to test some proactive caching of the recurring master IDs for appointments. I.e. for every appointment I sync, I will test whether it is part of a series and load the ID of the recurring master of that series. Then when I get a delete/move event I should be able to link the OldItemId from the event to my cached recurring master state and then delete all the associated occurrences.
Upvotes: 1
Views: 1202
Reputation: 1472
So the last solution I was investigating ended up being the one I used. Now when I sync appointments I check if they are part of a series and lookup their recurring master and cache that state. Then when I see delete/move events I can lookup my map of master appointment IDs to tell if the action is for a series.
I was hoping to avoid doing all this extra state tracking, but I couldn't find anyway to make the linkage from a delete event to the individual occurrences I have synced without it.
Upvotes: 1