Exemplo n.º 1
0
            private StreamingSubscriptionConnection StartNewConnection()
            {
                return(_exchangeServiceManager.ExecutePrivate(_room.RoomAddress, svc =>
                {
                    log.DebugFormat("Opening subscription to {0}", _room.RoomAddress);
                    var calId = new FolderId(WellKnownFolderName.Calendar, new Mailbox(_room.RoomAddress));
                    var sub = svc.SubscribeToStreamingNotifications(
                        new[] { calId },
                        EventType.Created,
                        EventType.Deleted,
                        EventType.Modified,
                        EventType.Moved,
                        EventType.Copied,
                        EventType.FreeBusyChanged);

                    // Create a streaming connection to the service object, over which events are returned to the client.
                    // Keep the streaming connection open for 30 minutes.
                    var connection = new StreamingSubscriptionConnection(svc, 30);
                    connection.AddSubscription(sub);
                    connection.OnNotificationEvent += OnNotificationEvent;
                    connection.OnDisconnect += OnDisconnect;
                    connection.Open();
                    _meetingCacheService.ClearUpcomingAppointmentsForRoom(_room.RoomAddress);
                    log.DebugFormat("Opened subscription to {0} via {1} with {2}", _room.RoomAddress, svc.GetHashCode(), svc.CookieContainer.GetCookieHeader(svc.Url));
                    IsActive = true;
                    return connection;
                }));
            }