PullNotifcation Exchange Web 服务“水印无效”例外

发布于 2024-12-11 18:29:34 字数 1957 浏览 0 评论 0原文

如果出现任何通知,我必须并行观看五个日历。它工作正常,但在几次通知或一段时间后,我会收到此异常“水印无效”。 我有一个我想要查看的邮箱列表(仅日历文件夹)。触发器每隔几秒启动一次,该方法会检查是否有通知。 如果我创建一些约会,并且任何时候都会抛出异常“水印无效”。它出现在我获取事件的行中。

 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

平生欢 2024-12-18 18:29:34

我找到了原因:
我的订阅列表不是线程安全的。
我将其添加到我的代码中并且工作正常:

lock (_subList)
                {
                     events = p.GetEvents();
                }

I found the reason:
My List of subscription was not thread safe.
I added this to my code and it works fine:

lock (_subList)
                {
                     events = p.GetEvents();
                }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文