public static void Subscribe(Node doclibrary, ExchangeService service) { if (service == null) { return; } var address = doclibrary["ListEmail"] as string; if (string.IsNullOrEmpty(address)) { return; } var mailbox = new Mailbox(address); var folderId = new FolderId(WellKnownFolderName.Inbox, mailbox); var servicePath = string.Format(Settings.GetValue <string>(MailHelper.MAILPROCESSOR_SETTINGS, MailHelper.SETTINGS_SERVICEPATH), doclibrary.Path); var watermark = ExchangeHelper.GetWaterMark(doclibrary); var ps = service.SubscribeToPushNotifications(new List <FolderId> { folderId }, new Uri(servicePath), Settings.GetValue(MailHelper.MAILPROCESSOR_SETTINGS, MailHelper.SETTINGS_POLLINGINTERVAL, null, 120), watermark, EventType.NewMail); var loginfo = string.Concat(" - Path:", doclibrary.Path, ", Email:", address, ", Watermark:", watermark, ", SubscriptionId:", ps.Id); SnLog.WriteInformation("Exchange subscription" + loginfo, categories: ExchangeHelper.ExchangeLogCategory); // persist subscription id to doclib, so that multiple subscriptions are handled correctly var user = User.Current; try { AccessProvider.Current.SetCurrentUser(User.Administrator); var retryCount = 3; while (retryCount > 0) { try { doclibrary["ExchangeSubscriptionId"] = ps.Id; doclibrary.Save(); break; } catch (NodeIsOutOfDateException) { retryCount--; doclibrary = Node.LoadNode(doclibrary.Id); } } } finally { AccessProvider.Current.SetCurrentUser(user); } }
public static FindItemsResults <Item> GetItems(ExchangeService service, Node doclibrary) { var address = doclibrary["ListEmail"] as string; if (string.IsNullOrEmpty(address)) { return(null); } var items = ExchangeHelper.GetItems(service, address); return(items); }
public static void Subscribe(Node doclibrary) { var service = ExchangeHelper.CreateConnection(doclibrary["ListEmail"] as string); ExchangeHelper.Subscribe(doclibrary, service); }