PullNotifcation Exchange Web 服务“水印无效”例外
如果出现任何通知,我必须并行观看五个日历。它工作正常,但在几次通知或一段时间后,我会收到此异常“水印无效”。 我有一个我想要查看的邮箱列表(仅日历文件夹)。触发器每隔几秒启动一次,该方法会检查是否有通知。 如果我创建一些约会,并且任何时候都会抛出异常“水印无效”。它出现在我获取事件的行中。
public Notification(ExchangeService _server1, string[] _mailboxName1)
{
_server = _server1;
_listOfList = _listOfList1;
_mailboxName = _mailboxName1;
foreach (Mailbox m in _mailboxName)
{
FolderId _Id = new FolderId(WellKnownFolderName.Calendar, m);
PullSubscription pullSub = _server.SubscribeToPullNotifications(new FolderId[] { _Id }, 5, null, EventType.Copied, EventType.Created, EventType.Deleted, EventType.Modified, EventType.Moved);
_subList.Add(pullSub);
}
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
AppSettingsReader config = new AppSettingsReader();
int time = Convert.ToInt16(config.GetValue("TimerInterval", typeof(string)));
aTimer.Interval = time;
aTimer.Enabled = false;
aTimer.Start();
}
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
Console.WriteLine("Timer");
bool noteWatch = false;
foreach (PullSubscription p in _subList)
{
string type = null;
ItemId eventId = null;
//Exception the watermark is invalid!!
GetEventsResults events = p.GetEvents();
foreach (ItemEvent itemEvent in events.ItemEvents)
{
switch (itemEvent.EventType)
{
case EventType.Created:
noteWatch = true;
eventId = itemEvent.ItemId;
type = "Created";
break;
}
}
}
}
I have to watch five calendars parallel if any notification appears. It works fine but anytime after a few notifications or a period of time I got this Exception "The Watermark is invalid".
I have a list of mailboxes which I want to watch ( only the Calendar Folder). The trigger starts every few seconds and the method look whether there is a notification or not.
If I create a few appointments and anytime the exception "The Watermark is invalid" was thrown. It appears in the Line where i get the Events.
public Notification(ExchangeService _server1, string[] _mailboxName1)
{
_server = _server1;
_listOfList = _listOfList1;
_mailboxName = _mailboxName1;
foreach (Mailbox m in _mailboxName)
{
FolderId _Id = new FolderId(WellKnownFolderName.Calendar, m);
PullSubscription pullSub = _server.SubscribeToPullNotifications(new FolderId[] { _Id }, 5, null, EventType.Copied, EventType.Created, EventType.Deleted, EventType.Modified, EventType.Moved);
_subList.Add(pullSub);
}
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
AppSettingsReader config = new AppSettingsReader();
int time = Convert.ToInt16(config.GetValue("TimerInterval", typeof(string)));
aTimer.Interval = time;
aTimer.Enabled = false;
aTimer.Start();
}
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
Console.WriteLine("Timer");
bool noteWatch = false;
foreach (PullSubscription p in _subList)
{
string type = null;
ItemId eventId = null;
//Exception the watermark is invalid!!
GetEventsResults events = p.GetEvents();
foreach (ItemEvent itemEvent in events.ItemEvents)
{
switch (itemEvent.EventType)
{
case EventType.Created:
noteWatch = true;
eventId = itemEvent.ItemId;
type = "Created";
break;
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了原因:
我的订阅列表不是线程安全的。
我将其添加到我的代码中并且工作正常:
I found the reason:
My List of subscription was not thread safe.
I added this to my code and it works fine: