加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 我创建的DateTime对象和DateTime.Now之间的差异

发布时间:2020-12-15 18:22:52 所属栏目:百科 来源:网络整理
导读:我正在尝试使用Exchange 2007 API查询特定用户的日历可用性.我的示例代码产生以下异常: The time duration specified for FreeBusyViewOptions.TimeWindow is invalid. 这是示例代码: ExchangeService service = new ExchangeService(ExchangeVersion.Exch
我正在尝试使用Exchange 2007 API查询特定用户的日历可用性.我的示例代码产生以下异常:

The time duration specified for FreeBusyViewOptions.TimeWindow is
invalid.

这是示例代码:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

service.AutodiscoverUrl("email@domain.com");

DateTime startTime = new DateTime(2012,1,6,7,0);

TimeWindow tw = new TimeWindow(startTime,startTime.AddHours(8));

GetUserAvailabilityResults result = service.GetUserAvailability(new List<AttendeeInfo> { new AttendeeInfo("email@domain.com") },tw,AvailabilityData.FreeBusyAndSuggestions);

奇怪的是,如果我用以下内容替换我的startTime赋值它可以工作:

DateTime startTime = DateTime.Now;

我创建的DateTime对象与DateTime.Now生成的对象之间有什么区别.我在调试时仔细检查了它们,但找不到区别.

有任何想法吗?

解决方法

这实际上似乎是GetUserAvailability方法中的一个问题,而不是任何DateTime操作.

根据MSDN documentation:

The GetUserAvailability(Generic,TimeWindow,AvailabilityData,AvailabilityOptions) method supports only time periods that are a minimum of 24 hours long and that begin and end at 12:00a.m. To restrict the results of the method to a shorter time period,you must filter the results on the client.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读