【发布时间】:2018-01-29 15:26:14
【问题描述】:
我尝试从 Appointment.Details 获取纯文本,而不是 html 文档。
我发现事件是否由 Microsoft 日历供应商创建,例如hotmail,它们的详细信息将显示在 html 文档中,而不是纯文本(顺便说一句,如果事件是由 Gmail 创建的,它们的详细信息是纯文本)。我尝试通过以下方式获取纯文本,但它不起作用。
var appointmentStore = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadWrite);
FindAppointmentsOptions options = new FindAppointmentsOptions { MaxCount = 100 };
options.FetchProperties.Add(AppointmentProperties.Subject);
options.FetchProperties.Add(AppointmentProperties.Details);
options.FetchProperties.Add(AppointmentProperties.DetailsKind);
DateTimeOffset startTime = new DateTimeOffset(new DateTime(2018, 2, 1));
// The UWP api gets the events from the Calendar app of Windows 10 OS.
List<Appointment> evtList =
(await appointmentStore.FindAppointmentsAsync(startTime, new TimeSpan(30, 0, 0, 0), options)).ToList();
foreach (var evt in evtList) {
Debug.WriteLine(evt.Subject);
// I've found if the events were created in Microsoft calendar supplier, e.g. hotmail,
// the details of them would be the html document instead of the plain text.
// I've tried to make the evt.Details presented in the plain text
// instead of the html document, but this way doesn't work.
evt.DetailsKind = AppointmentDetailsKind.PlainText;
Debug.WriteLine(evt.Details);
}
实际上我在 C++ 环境中工作,它也可以使用 UWP API。我习惯测试 并首先验证 C# 中的 API。
另外,遗憾的是,UWP api HtmlUtilities.ConvertToText() 无法满足我的需求。在我的 C++ 项目中,调用HtmlUtilities.ConvertToText() 会导致Static Buffer Overruns。
【问题讨论】: