2017-02-25 7 views
0

私は本質的に予定リストを取得し、それらをフィルタリングしてレポートを作成するUWPプログラムを持っています。C#UWP AppointmentStore.FindAppointmentsAsyncがPC上で動作していません

私はHow to retrieve appointments in UWP from a Windows 10 calendar using C#

私が遭遇した問題ごとにAppointmentManager.RequestStoreAsyncとAppointmentStore.FindAppointmentsAsyncを使用していますが、それは、Windows 10 PC上のWindows 10のモバイルデバイス上で正常に動作しますが、ではないということです。両方とも同じカレンダーに同期します。

マイコード:

AppointmentStore appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly); 

      DayOfWeek weekStart = DayOfWeek.Monday; 
      DateTimeOffset startingDate = DateTimeOffset.Now; 

      while (startingDate.DayOfWeek != weekStart) 
       startingDate = startingDate.AddDays(-1); 

      DateTimeOffset currentPayStart = startingDate.AddDays(-14); 

      var date = currentPayStart; 
      var timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now); 
      var startTime = new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, timeZoneOffset); 

      TimeSpan duration = TimeSpan.FromDays(7); 

      FindAppointmentsOptions options = new FindAppointmentsOptions(); 
      options.MaxCount = 100; 
      options.FetchProperties.Add(AppointmentProperties.Subject); 
      options.FetchProperties.Add(AppointmentProperties.Location); 
      options.FetchProperties.Add(AppointmentProperties.AllDay); 
      options.FetchProperties.Add(AppointmentProperties.StartTime); 
      options.FetchProperties.Add(AppointmentProperties.Duration); 
      options.FetchProperties.Add(AppointmentProperties.Details); 
      options.FetchProperties.Add(AppointmentProperties.DetailsKind); 

      IReadOnlyList<Appointment> appointments = await appointmentStore.FindAppointmentsAsync(startTime, duration, options); 

私はまだPC上で正常に動作古いWPFコードを持っています。 (しかし、それはモバイルに実装されませんでした)

コードは:

var outlookApp = new Outlook.Application(); 
      var calFolder = outlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder; 

      DayOfWeek weekStart = DayOfWeek.Monday; 
      DateTime startingDate = DateTime.Today; 

      while (startingDate.DayOfWeek != weekStart) 
       startingDate = startingDate.AddDays(-1); 

      DateTime previousWeekStart = startingDate.AddDays(-7); 
      DateTime previousWeekEnd = startingDate.AddDays(0); 

      Outlook.Items rangeAppts = GetAppointmentsInRange(calFolder, previousWeekStart, previousWeekEnd); 

私の既存のOutlook.Items(WPFコード)に対し、PCに展開するときIReadOnlyListは常に空であることを思わ正常に動作します。

上記のように、コードはモバイルで正常に動作します。そのため、私は本質的にUWPにアップグレードしたかったのですが、今はデスクトップではありません。

私は、私は非常に基本的な何かが欠けていると感じ

...

+0

あなたのPC上でOutlookやカレンダーアプリを使用していますか? –

+0

PCはOutlookを使用しており、モバイルは標準カレンダーアプリを使用しています。両方とも同じ見通し交換口座に同期します。私のUWPアプリは両方で動作しますが、PC上ではIReadOnlyList のリストには何も表示されません。私はvar ct = new MessageDialog(appointments.Count.ToString())を実行することでこれをチェックしました。 ct.ShowAsync();を待ちます。 – Geo

+0

AppointmentStoreは、Exchangeと通信するAPIではありませんが、システム上のデータではありません。私はOutlookアプリがカレンダーアプリのようにシステム内の交換からデータを入れるためにこのAPIを使用するとは思わない。だから2つのソリューション:あなたのPC上のデータを取得するには、カレンダーアプリを設定するか、交換のAPIを使用してデータを取得する –

答えて

0

AppointmentStoreはなく、システム上のデータと、交流と通信APIをイマイチ。私はOutlookアプリがカレンダーアプリのようにシステム内の交換からデータを入れるためにこのAPIを使用するとは思わない。したがって、2つのソリューション:カレンダーアプリを設定してPC上のデータを取得するか、交換用APIを使用してデータを取得してください

+0

これは確かに役に立ちます_how_を説明して、カレンダーアプリを設定してデータを取得する場合は、この提案は誰もがなければ役に立たない。 –

関連する問題