[英]Get events of a specific time range
我正在使用Office365 Outlook日歷API。 我需要獲取特定時間范圍內的事件。 我試圖比較foreach命令中的DateTimeTimeZone值,但似乎它僅支持==運算符:
if ( calendarEvent.Start >= new DateTimeTimeZone()
{
TimeZone = TimeZoneInfo.Local.Id,
DateTime = DateTime.Now.ToString("s")
})
此代碼段失敗,並顯示以下錯誤:無法將運算符'> ='應用於類型為'Microsoft.Office365.OutlookServices.DateTimeTimeZone'和'Microsoft.Office365.OutlookServices.DateTimeTimeZone'的操作數
還有其他方法可以獲取特定時間范圍內的事件,例如將來的事件嗎?
到目前為止,這是我的GetEvents()方法:
[Route("GetEvents")]
public async Task GetEvents()
{
//Get client
OutlookServicesClient client = await this.GetClient();
//Get events
var events = await client.Me.Events
.Take(10)
.ExecuteAsync();
foreach (var calendarEvent in events.CurrentPage)
{
//
if ( calendarEvent.Subject == "Test 1" )
{
System.Diagnostics.Debug.WriteLine("Event '{0}'.", calendarEvent.Subject) ;
}
}
}
您應該使用CalendarView
獲取某個時間范圍內的事件。
DateTimeOffset startDateTime, endDateTime;
var events = client.Me.GetCalendarView(startDateTime, endDateTime);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.