Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

[EWS] StreamingNotification Calendar FolderEvent instead of ItemEvent ??

$
0
0

Hi,

I created a service that should catch modifications to calendar items. Here is my code :

service.Credentials = new WebCredentials("blablabla", "blablabla", domain);
service.Url = new Uri(ExchangeURL);

FolderId folder1 = new FolderId(WellKnownFolderName.Calendar, new Mailbox("blablabla"));

var trackedEvents = new EventType[] { EventType.Deleted, EventType.Modified, EventType.Moved, EventType.Created };

var folderIds1 = new FolderId[] { folder1 };

StreamingSubscription subscription1 = service.SubscribeToStreamingNotifications(folderIds1, trackedEvents);

StreamingSubscriptionConnection connection = new StreamingSubscriptionConnection(service, 1);

connection.AddSubscription(subscription1);
connection.OnNotificationEvent += new StreamingSubscriptionConnection.NotificationEventDelegate(OnEvent);
connection.OnSubscriptionError += new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnError);
connection.OnDisconnect += new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnDisconnect);
connection.Open();

This is the code for the event :

static void OnEvent(object sender, NotificationEventArgs args) {
    StreamingSubscription subscription = args.Subscription;

    foreach (NotificationEvent notifyEvt in args.Events) {
        if (notifyEvt is ItemEvent) {
            FolderEvent folderEvent = (FolderEvent)notifyEvt;
        }
    }
}

I have 2 questions about this.

The most important: I'm really puzzled why the event I received is a FolderEvent instead of aItemEvent. I would like to have the information about the calendar item, not the folder. There is really nothing usefull on that FolderId. What is important is the Id of the item, so I can bind that to the Appointment. Or in case of a deletion, just to know the Id. But it seems there is no way to achieve this? 

Second question : I noticed that the OnEvent is sometimes not fired, and in case it's fired, there is sometimes a long delay. If not fired and I restart my application and do exactly the same thing, then the event is fired. I feel like it's a bit like unpredicatable.

Many thanks in advance !


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>