具有请求订阅的 EWS 托管 API

发布于 2024-12-26 06:31:14 字数 4178 浏览 0 评论 0原文

我正在编写一个桥接器,通过托管 API 将我们的客户端应用程序与 EWS 同步。

我遇到了很多问题,因为我不知道谁最后更新了我正在使用的约会(Outlook 客户端/owa/我的桥)。

我不希望用户修改某些约会(用类别 [0] = '预订' 标记),但我无法判断它是由用户还是我的桥更新的。

有没有办法可以将约会创建为只读,或者获取约会的旧信息并将其恢复回来?

我试图在下面表达我的意思:

public void TimerCallback(object source, ElapsedEventArgs e)
    {
        FPollTimer.Enabled = false;
        try
        {
            GetEventsResults notificationEvents = FCalendarSubscription.GetEvents();
            EWSMethods.monitorFRM.log("Notification count  = " + FEWSUser + ":" + notificationEvents.AllEvents.Count.ToString()); 

            if (notificationEvents.AllEvents.Count > 0)
            {
                foreach (ItemEvent itemEvent in notificationEvents.ItemEvents)
                {
                    // -- check to see if this is a valid appointment  -- //
                    // -- Echange creates two appts and deletes one of -- //
                    // -- them for any appointment creation            -- //

                    try
                    {
                        //Folder tempFolder = Folder.Bind(FEWSService, itemEvent.ParentFolderId.ToString());
                        EWSMethods.monitorFRM.log("Notification-" + FEWSUser + " : " + itemEvent.EventType.ToString());
                        // -- Is this item in the stack? -- //
                        if (NeedPingPongcheck(itemEvent))
                        {
                            CheckPingPong(itemEvent);
                        }
                        else
                        {
                            Appointment o_appointment = Appointment.Bind(FEWSService, itemEvent.ItemId.ToString());
                            if (o_appointment != null) WriteEventToDB(itemEvent);
                        }
                    }
                    catch (Exception exc2)
                    {
                        EWSMethods.monitorFRM.log("TimerCallBack inner " + exc2.Message);
                    }
                }
            }
        }
        catch (Exception exc)
        {
            EWSMethods.monitorFRM.log("timercallback outer " + exc.Message);
            //MessageBox.Show(e.Message);
        }
        FPollTimer.Enabled = true;
    }




public void WriteEventToDB(ItemEvent item)
    {
        try
        {

            EWSMethods.monitorFRM.log("Attempting write to DB ");
            string s_allday;
            string s_appointmentid;
            //MessageBox.Show(item.ItemId.ToString());

            // -- use the old item id for deleted (moved) appointments -- //
            if (item.EventType == EventType.Moved)
            {
                s_appointmentid = item.OldItemId.ToString();
            }
            else
            {
                s_appointmentid = item.ItemId.ToString();
            }

            // Get all properties of email message
            PropertySet pset = new PropertySet(BasePropertySet.FirstClassProperties);

            // Get the body in text
            pset.RequestedBodyType = Microsoft.Exchange.WebServices.Data.BodyType.Text;

            // -- set up allDay flag -- //
            Appointment o_appointment = Appointment.Bind(FEWSService, item.ItemId.ToString(),pset);

            if ((o_appointment.IsAllDayEvent) & (o_appointment != null))
            {
                s_allday = "Y";
            }
            else
            {
                s_allday = "N";
            }

            // -- 
            if (o_appointment.Categories[0] != "Booking")
            {
                AddInterimEntry(o_appointment,
                                item,
                                s_allday,
                                s_appointmentid,
                                item.EventType.ToString());

            }
            else
            {

                if ((item.EventType == EventType.Modified) || (item.EventType == EventType.Moved)) {
                    EWSMethods.monitorFRM.log("Booking item skipped." + item.OldItemId.ToString());

                }
            }
        }
        catch (Exception e)
        {
            EWSMethods.monitorFRM.log(e.Message);
        }

    }

提前致谢。

I am writing a bridge to synchronise our client application with EWS via the managed API.

I'm running into a lot of problems caused by the fact that I don't know who has last updated the appointment I'm working with(Outlook client/owa/My bridge).

There are certain appointments (tagged with a category[0] = 'Booking') that I don't want the user to modify, but I cant tell whether it was updated by the user or my bridge.

is there a way I can create the appointment as Read-only, or get the old info for the appointment and revert it back ?

I've tried to kind of show what I mean below :

public void TimerCallback(object source, ElapsedEventArgs e)
    {
        FPollTimer.Enabled = false;
        try
        {
            GetEventsResults notificationEvents = FCalendarSubscription.GetEvents();
            EWSMethods.monitorFRM.log("Notification count  = " + FEWSUser + ":" + notificationEvents.AllEvents.Count.ToString()); 

            if (notificationEvents.AllEvents.Count > 0)
            {
                foreach (ItemEvent itemEvent in notificationEvents.ItemEvents)
                {
                    // -- check to see if this is a valid appointment  -- //
                    // -- Echange creates two appts and deletes one of -- //
                    // -- them for any appointment creation            -- //

                    try
                    {
                        //Folder tempFolder = Folder.Bind(FEWSService, itemEvent.ParentFolderId.ToString());
                        EWSMethods.monitorFRM.log("Notification-" + FEWSUser + " : " + itemEvent.EventType.ToString());
                        // -- Is this item in the stack? -- //
                        if (NeedPingPongcheck(itemEvent))
                        {
                            CheckPingPong(itemEvent);
                        }
                        else
                        {
                            Appointment o_appointment = Appointment.Bind(FEWSService, itemEvent.ItemId.ToString());
                            if (o_appointment != null) WriteEventToDB(itemEvent);
                        }
                    }
                    catch (Exception exc2)
                    {
                        EWSMethods.monitorFRM.log("TimerCallBack inner " + exc2.Message);
                    }
                }
            }
        }
        catch (Exception exc)
        {
            EWSMethods.monitorFRM.log("timercallback outer " + exc.Message);
            //MessageBox.Show(e.Message);
        }
        FPollTimer.Enabled = true;
    }




public void WriteEventToDB(ItemEvent item)
    {
        try
        {

            EWSMethods.monitorFRM.log("Attempting write to DB ");
            string s_allday;
            string s_appointmentid;
            //MessageBox.Show(item.ItemId.ToString());

            // -- use the old item id for deleted (moved) appointments -- //
            if (item.EventType == EventType.Moved)
            {
                s_appointmentid = item.OldItemId.ToString();
            }
            else
            {
                s_appointmentid = item.ItemId.ToString();
            }

            // Get all properties of email message
            PropertySet pset = new PropertySet(BasePropertySet.FirstClassProperties);

            // Get the body in text
            pset.RequestedBodyType = Microsoft.Exchange.WebServices.Data.BodyType.Text;

            // -- set up allDay flag -- //
            Appointment o_appointment = Appointment.Bind(FEWSService, item.ItemId.ToString(),pset);

            if ((o_appointment.IsAllDayEvent) & (o_appointment != null))
            {
                s_allday = "Y";
            }
            else
            {
                s_allday = "N";
            }

            // -- 
            if (o_appointment.Categories[0] != "Booking")
            {
                AddInterimEntry(o_appointment,
                                item,
                                s_allday,
                                s_appointmentid,
                                item.EventType.ToString());

            }
            else
            {

                if ((item.EventType == EventType.Modified) || (item.EventType == EventType.Moved)) {
                    EWSMethods.monitorFRM.log("Booking item skipped." + item.OldItemId.ToString());

                }
            }
        }
        catch (Exception e)
        {
            EWSMethods.monitorFRM.log(e.Message);
        }

    }

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文