2

リマインダーを現在の時刻に設定したアプリの予定を取得するために、Exchenge にクエリを実行しようとしています。
近い将来に開始される予定を 1 つ返す単純なメソッドを作成しました。

    public Appointment getMyAppointments()
    {
        try
        {
            CalendarFolder cfolder = CalendarFolder.Bind(service, WellKnownFolderName.Calendar);
            CalendarView calendarView = new CalendarView(DateTime.Now, DateTime.Now.AddHours(1));every appointment in one hour
            calendarView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Subject, ItemSchema.Categories);
            FindItemsResults<Appointment> findResults = cfolder.FindAppointments(calendarView);

            List<Item> items = new List<Item>();

            if (findResults.Items.Count > 0) // Prevent the exception
            {
                items.AddRange(findResults.Cast<Item>());
            }
            else
            {
                return null;
            }
            service.LoadPropertiesForItems(items, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Subject, ItemSchema.Categories, ItemSchema.Body));
            return findResults.Items[0];
        }
        catch (Exception e)
        {
            return null;
        }
    }

これにより、最も近い将来に開始され、現在の時間にアクティブな上位 1 つの予定が返されます。

14:00 に開始して 14:30 に終了する予定を計画する場合、メソッドは 13:01 に開始するとその予定を返しますが、14:22 に開始するとその予定も返します。

そのメソッドを変更して、現在の時刻より前にリマインダーを設定し、開始されなかったすべての会議を返すようにします。

したがって、15:00 に予定を立てて、リマインダーを 15 分に設定し、14:45 にメソッドを呼び出すと、その予定を取得できます。

私のアイデアは、すべての予定を 8 時間で取得し、それらを繰り返し処理して、予定があるかどうかを確認し、現在の時間よりも小さいIsReminderSetかどうかを確認することでした。StartReminderMinutesBeforeStart

編集 - これは私の一時的な解決策です

    public OWAAppointment GetMyAppointments(int minutes)
    {
        try
        {
            CalendarFolder cfolder = CalendarFolder.Bind(service, WellKnownFolderName.Calendar);
            CalendarView calendarView = new CalendarView(DateTime.Now, DateTime.Now.AddHours(10));
            calendarView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Subject, ItemSchema.Categories);
            FindItemsResults<Appointment> findResults = cfolder.FindAppointments(calendarView);

            List<Item> items = new List<Item>();

            if (findResults.Items.Count > 0)
            {
                items.AddRange(findResults.Cast<Item>());
            }
            else
            {
                return null;
            }

            service.LoadPropertiesForItems(items, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Subject, ItemSchema.Categories, ItemSchema.Body, ItemSchema.ReminderDueBy, ItemSchema.ReminderMinutesBeforeStart));


            var appointment = findResults.Items
            .Where(item => item.Start >= DateTime.Now)
            .FirstOrDefault(item => item.Start.AddMinutes(-1*minutes) < DateTime.Now);

            return appointment // this will return appointment or null
        }
        catch (Exception e)
        {
            return null;
        }
    }

しかし、これは EWS で簡単に実行できるでしょうか?

4

1 に答える 1

1

はい、これは簡単に行うことができます。EWS (EWS マネージ API ではない) の GetReminders 操作は、Exchange 2013 で導入されました。情報は、GetReminders 操作で確認できます。現在のリマインダーをすべて取得するには、ReminderType を All に設定し、EndTime を現在の時刻に設定します。

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
           xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
           xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
           xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2013" />
  </soap:Header>
  <soap:Body>
   <m:GetReminders>
      <m:EndTime>2014-05-06T21:00:00Z</m:EndTime>
      <m:ReminderType>All</m:ReminderType>
    </m:GetReminders>
  </soap:Body>
</soap:Envelope>
于 2014-05-06T16:43:28.550 に答える