Управляемый API EWS с подписками по запросу - PullRequest
1 голос
/ 12 января 2012

Я пишу мост для синхронизации нашего клиентского приложения с EWS через управляемый API.

У меня много проблем, связанных с тем, что я не знаю, кто в последний раз обновил встречу, с которой я работаю (клиент Outlook / owa / My bridge).

Существуют определенные встречи (помеченные категорией [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);
        }

    }

Заранее спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...