/// <summary> /// Loads the events from json. /// </summary> /// <param name="jsonEventsArray">The json events array.</param> /// <param name="service">The service.</param> private void LoadEventsFromJson(object[] jsonEventsArray, ExchangeService service) { foreach (JsonObject jsonEvent in jsonEventsArray) { this.newWatermark = jsonEvent.ReadAsString(XmlElementNames.Watermark); EventType eventType = jsonEvent.ReadEnumValue <EventType>(JsonNames.NotificationType); if (eventType == EventType.Status) { continue; } NotificationEvent notificationEvent; if (jsonEvent.ContainsKey(XmlElementNames.FolderId)) { notificationEvent = new FolderEvent( eventType, service.ConvertUniversalDateTimeStringToLocalDateTime(jsonEvent.ReadAsString(XmlElementNames.TimeStamp)).Value); } else { notificationEvent = new ItemEvent( eventType, service.ConvertUniversalDateTimeStringToLocalDateTime(jsonEvent.ReadAsString(XmlElementNames.TimeStamp)).Value); } notificationEvent.LoadFromJson(jsonEvent, service); this.events.Add(notificationEvent); } }
/// <summary> /// Loads a notification event from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="eventElementName">Name of the event XML element.</param> /// <param name="eventType">Type of the event.</param> private void LoadNotificationEventFromXml( EwsServiceXmlReader reader, string eventElementName, EventType eventType) { DateTime timestamp = reader.ReadElementValue <DateTime>(XmlNamespace.Types, XmlElementNames.TimeStamp); NotificationEvent notificationEvent; reader.Read(); if (reader.LocalName == XmlElementNames.FolderId) { notificationEvent = new FolderEvent(eventType, timestamp); } else { notificationEvent = new ItemEvent(eventType, timestamp); } notificationEvent.LoadFromXml(reader, eventElementName); this.events.Add(notificationEvent); }
/// <summary> /// Loads a notification event from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="eventElementName">Name of the event XML element.</param> /// <param name="eventType">Type of the event.</param> /// <param name="notifications">Collection of notifications</param> private void LoadNotificationEventFromXml( EwsServiceXmlReader reader, string eventElementName, EventType eventType, NotificationGroup notifications) { DateTime timestamp = reader.ReadElementValue<DateTime>(XmlNamespace.Types, XmlElementNames.TimeStamp); NotificationEvent notificationEvent; reader.Read(); if (reader.LocalName == XmlElementNames.FolderId) { notificationEvent = new FolderEvent(eventType, timestamp); } else { notificationEvent = new ItemEvent(eventType, timestamp); } notificationEvent.LoadFromXml(reader, eventElementName); notifications.Events.Add(notificationEvent); }