具有pull订阅的EWS托管API

时间:2012-01-12 12:06:21

标签: exchangewebservices pull subscriptions ews-managed-api

我正在编写一个桥梁,通过托管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);
        }

    }

提前致谢。

0 个答案:

没有答案