为什么Windows.ApplicationModel.Appointments.Appointment的被邀请者/详细信息为空

时间:2015-01-28 07:09:24

标签: c# windows-phone-8.1 appointment

我正在使用Windows Phone 8.1应用程序,此应用程序希望从日历中获取会议。 我使用Windows运行时API来获得所有这样的约会:

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

IReadOnlyList<Windows.ApplicationModel.Appointments.Appointment> appointments = await appointmentStore.FindAppointmentsAsync(DateTime.Now, TimeSpan.FromHours(24)); ;
        foreach (var appointment in appointments)
        {
            var persistentId = appointment.RoamingId;
            var details = appointment.Details;//the details is empty, why
            var invitees = appointment.Invitees;//the invitees is also empty, why?
        }

实际上,我尝试过Microsoft Phone api,我可以获取详细信息和与会者(被邀请者)。但是,Microsoft Phone api无法获得预约ID。任何人都可以告诉我如何获得预约ID和详细信息/被邀请者?谢谢!

Appointments appts = new Appointments();

            //Identify the method that runs after the asynchronous search completes.
            appts.SearchCompleted += new EventHandler<AppointmentsSearchEventArgs>(Calendar_SearchCompleted);

            DateTime start = DateTime.Now;
            DateTime end = start.AddDays(1);
            int max = 100;
            appts.SearchAsync(start, end, max, "test");

private async void Calendar_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
    {
        foreach (Microsoft.Phone.UserData.Appointment appt in e.Results)
        {
            var details = appt.Details;//I can get the details

            var participants = new ObservableCollection<Person>();
            var attendees = appt.Attendees;
            if (attendees != null)
            {
                foreach (var attende in attendees)
                {
                    Person attendPerson = new Person()
                    {
                        Email = attende.EmailAddress,
                        FullName = attende.DisplayName,
                        PersonID = attende.EmailAddress
                    };

                    participants.Add(attendPerson);
                }

            }



            ....
        }
    }

1 个答案:

答案 0 :(得分:2)

您需要添加FindAppointments选项以获取您想要的任何详细信息,请尝试下面的代码

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

        FindAppointmentsOptions options = new FindAppointmentsOptions();
        options.MaxCount = 100;
        options.FetchProperties.Add(AppointmentProperties.Subject);
        options.FetchProperties.Add(AppointmentProperties.Location);
        options.FetchProperties.Add(AppointmentProperties.Invitees);
        options.FetchProperties.Add(AppointmentProperties.Details);
        options.FetchProperties.Add(AppointmentProperties.StartTime);
        options.FetchProperties.Add(AppointmentProperties.ReplyTime);
        IReadOnlyList<Windows.ApplicationModel.Appointments.Appointment> appointments = await appointmentStore.FindAppointmentsAsync(DateTime.Now, TimeSpan.FromHours(24), options);
        foreach (var appointment in appointments)
        {
            var persistentId = appointment.RoamingId;
            var details = appointment.Details;//the details is empty, why
            var invitees = appointment.Invitees;//the invitees is also empty, why?
        }