- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 C# EWS 2.0 库列出一些事件。
它使用以下代码:
public IEnumerable<AppEvent> ListEvents(CalendarFolder folder, DateTime? startDate, DateTime? endDate)
{
var items = new List<AppEvent>();
var now = DateTime.Now;
if (startDate == null) startDate = DateTime.Now;
if (endDate == null) endDate = now.AddDays(14);
FindItemsResults<Appointment> findResults = null;
ServiceResponseCollection<GetItemResponse> appointments = null;
CalendarView view = null;
view = new CalendarView((DateTime)startDate, (DateTime)endDate);
findResults = folder.FindAppointments(view);
if (findResults.Items.Count() == 0) return items;
appointments = Service.BindToItems(findResults.Select(item => item.Id), AppointmentPropertySet);
foreach (GetItemResponse item in appointments)
{
var appointment = item.Item as Appointment;
try
{
if (appointment.IsCancelled) continue;
}
catch (System.NullReferenceException)
{
continue;
}
var evt = AppEvent.FromEWSAppointment(appointment);
items.Add(evt);
}
return items;
}
而AppointmentPropertySet
如下:
protected PropertySet AppointmentPropertySet = new PropertySet(
AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.IsAllDayEvent,
AppointmentSchema.IsMeeting,
AppointmentSchema.IsRecurring,
AppointmentSchema.IsCancelled,
AppointmentSchema.IsDraft,
AppointmentSchema.Location,
AppointmentSchema.Resources,
AppointmentSchema.RequiredAttendees,
AppointmentSchema.OptionalAttendees,
AppointmentSchema.LegacyFreeBusyStatus,
AppointmentSchema.Organizer,
AppointmentSchema.Body,
AppointmentSchema.Sensitivity,
AppointmentSchema.AppointmentReplyTime,
AppointmentSchema.AppointmentSequenceNumber,
AppointmentSchema.AppointmentState,
AppointmentSchema.AppointmentType,
AppointmentSchema.ConferenceType,
AppointmentSchema.DateTimeCreated,
AppointmentSchema.Duration,
AppointmentSchema.EndTimeZone,
AppointmentSchema.HasAttachments,
AppointmentSchema.ICalDateTimeStamp,
AppointmentSchema.ICalRecurrenceId,
AppointmentSchema.ICalUid,
AppointmentSchema.Id,
AppointmentSchema.Importance,
AppointmentSchema.IsOnlineMeeting,
AppointmentSchema.IsReminderSet,
AppointmentSchema.IsResponseRequested,
AppointmentSchema.IsUnmodified,
AppointmentSchema.LastModifiedTime,
AppointmentSchema.LegacyFreeBusyStatus,
AppointmentSchema.MeetingRequestWasSent,
AppointmentSchema.MyResponseType,
AppointmentSchema.MeetingWorkspaceUrl,
AppointmentSchema.NetShowUrl,
AppointmentSchema.OriginalStart,
AppointmentSchema.ParentFolderId,
AppointmentSchema.Recurrence,
AppointmentSchema.ReminderDueBy,
AppointmentSchema.ReminderMinutesBeforeStart,
AppointmentSchema.StartTimeZone,
AppointmentSchema.WebClientEditFormQueryString,
AppointmentSchema.WebClientReadFormQueryString
);
其中一个事件出现以下错误。如果我从 AppointmentPropertySet
中删除 RequiredAttendees
和 OptionalAttendees
,它工作正常(尽管没有返回任何与会者)。
如何避免此错误,或者如何跳过此事件以便 View 至少返回未中断的约会?
System.ArgumentException: Requested value 'User' was not found.
at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
at Microsoft.Exchange.WebServices.Data.EwsUtilities.Parse[T](String value)
at Microsoft.Exchange.WebServices.Data.EwsXmlReader.ReadElementValue[T]()
at Microsoft.Exchange.WebServices.Data.EmailAddress.TryReadElementFromXml(EwsServiceXmlReader reader)
at Microsoft.Exchange.WebServices.Data.Attendee.TryReadElementFromXml(EwsServiceXmlReader reader)
at Microsoft.Exchange.WebServices.Data.ComplexProperty.InternalLoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName, Func`2 readAction)
at Microsoft.Exchange.WebServices.Data.ComplexProperty.LoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName)
at Microsoft.Exchange.WebServices.Data.Attendee.TryReadElementFromXml(EwsServiceXmlReader reader)
at Microsoft.Exchange.WebServices.Data.ComplexProperty.InternalLoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName, Func`2 readAction)
at Microsoft.Exchange.WebServices.Data.ComplexProperty.LoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName)
at Microsoft.Exchange.WebServices.Data.ComplexPropertyCollection`1.LoadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String localElementName)
at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.InternalLoadFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
at Microsoft.Exchange.WebServices.Data.PropertyBag.LoadFromXml(EwsServiceXmlReader reader, Boolean clear, PropertySet requestedPropertySet, Boolean onlySummaryPropertiesRequested)
at Microsoft.Exchange.WebServices.Data.EwsServiceXmlReader.ReadServiceObjectsCollectionFromXml[TServiceObject](XmlNamespace collectionXmlNamespace, String collectionXmlElementName, GetObjectInstanceDelegate`1 getObjectInstanceDelegate, Boolean clearPropertyBag, PropertySet requestedPropertySet, Boolean summaryPropertiesOnly)
at Microsoft.Exchange.WebServices.Data.GetItemResponse.ReadElementsFromXml(EwsServiceXmlReader reader)
at Microsoft.Exchange.WebServices.Data.ServiceResponse.LoadFromXml(EwsServiceXmlReader reader, String xmlElementName)
at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.ParseResponse(EwsServiceXmlReader reader)
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadResponse(EwsServiceXmlReader ewsXmlReader)
at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponseXml(Stream responseStream)
at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse response)
at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalBindToItems(IEnumerable`1 itemIds, PropertySet propertySet, ServiceErrorHandling errorHandling)
at ExchangeAppService.Utilities.API.ExchangeAPI.ListEvents(CalendarFolder folder, Nullable`1 startDate, Nullable`1 endDate) in c:\Users\Some Guy\Documents\Visual Studio 2013\Projects\ExchangeAppService\ExchangeAppService\Utilities\API\Exchange\ExchangeAPI.cs:line 195
最佳答案
根据异常堆栈跟踪判断,我很确定您的交换服务器正在为一个(或多个)与会者电子邮件地址的 MailboxType 回复一个无效值(“用户”)。
查看 current implementation of the MailboxType enum即使是最新版本,“用户”值似乎也是无效的。
您应该能够通过分析 Exchange 返回给您的 soap 响应、跟踪它(参见 How to: Trace requests and responses to troubleshoot EWS Managed API applications )或使用像 Fiddler 或 Wireshark 这样的网络分析器来进一步确认这一点。
如果是这种情况,我认为唯一的解决办法是在他们的 github repo 上提出问题,并希望他们能为您提供更多信息或可能的解决方案。
关于c# - EWS - 尝试加载与会者时列出日历约会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46303614/
我的目标是将一些受邀者添加到 EKEvent。我已经研究过类似的其他问题,例如 this one , 但所有人都说基本上不可能以编程方式将 EKParticipant 添加到 EKEvent 中。我确
我是一名优秀的程序员,十分优秀!