适用于团队会议的Office365日历Events

时间:2016-05-03 03:55:30

标签: c# asp.net exchange-server office365

我正在使用office365 REST API在ASP.NET中开发一个应用程序。我需要在office365安排团队活动,但在安排该活动之前,我需要检查所有团队成员的可用时间。如果一个插槽是空闲的,那么我只需要为团队设置一个事件。

假设我有3个成员团队,如user1 @ someone.com,user2 @ someone.com,user3 @ clientone.com。我需要检查团队中所有成员的可用时间,并且需要仅显示可比较的时间。让我们假设user1在上午9:00 - 上午9:30举行了一次日程安排会议,然后我需要隐藏那段时间,因为user1没有空闲时间。

我该怎么做?有什么想法吗?

2 个答案:

答案 0 :(得分:0)

查找会议时间(= Exchange FreeBusy)处于预览https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations#Findmeetingtimespreview,但您应该可以通过https://outlook.office.com/api/beta

使用它

干杯 格伦

答案 1 :(得分:0)

最后我尝试使用忙/闲代码。我的代码如下......我正在遵循这个程序,但我不知道它是否正确。我有office365帐户,并通过静默传递凭据我正在创建Exchange服务器服务。之后,我将不同的域参与者信息作为ORGANIZER传递,并且如下所示。但它返回的所有值都没有为这些用户跳过任何预定的会议。

假设user1@domain.com是ORGANIZER,并且user2@anotherdomain.com需要会议。 User1的会议安排在每天下午7:00-7:30但是当我执行以下脚本时,它会在7:00-7:30pm显示我可用于会议。它应该阻止那个时间。你能否建议对代码进行一些更改,并且我正在以正确的方式进行?

private static void GetSuggestedMeetingTimes(ExchangeService service)
    {


        List<AttendeeInfo> attendees = new List<AttendeeInfo>();

        attendees.Add(new AttendeeInfo()
        {
            SmtpAddress = "user1@mydomain.com",
            AttendeeType = MeetingAttendeeType.Organizer
        });

        attendees.Add(new AttendeeInfo()
        {
            SmtpAddress = "user2@anotherdomain.com",
            AttendeeType = MeetingAttendeeType.Required
        });

        // Specify options to request free/busy information and suggested meeting times.
        AvailabilityOptions availabilityOptions = new AvailabilityOptions();
        availabilityOptions.GoodSuggestionThreshold = 49;
        availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 0;
        availabilityOptions.MaximumSuggestionsPerDay = 40;
        // Note that 60 minutes is the default value for MeetingDuration, but setting it explicitly for demonstration purposes.
        availabilityOptions.MeetingDuration = 30;
        availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Good;
        availabilityOptions.DetailedSuggestionsWindow = new TimeWindow(DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));
        availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;

        // Return free/busy information and a set of suggested meeting times. 
        // This method results in a GetUserAvailabilityRequest call to EWS.
        GetUserAvailabilityResults results = service.GetUserAvailability(attendees,
                                                                         availabilityOptions.DetailedSuggestionsWindow,
                                                                         AvailabilityData.FreeBusyAndSuggestions,
                                                                         availabilityOptions);
        // Display suggested meeting times. 
        Console.WriteLine("Availability for {0} and {1}", attendees[0].SmtpAddress, attendees[1].SmtpAddress);
        Console.WriteLine();

        foreach (Suggestion suggestion in results.Suggestions)
        {
            Console.WriteLine("Suggested date: {0}\n", suggestion.Date.ToShortDateString());
            Console.WriteLine("Suggested meeting times:\n");
            foreach (TimeSuggestion timeSuggestion in suggestion.TimeSuggestions)
            {
                Console.WriteLine("\t{0} - {1}\n",
                                  timeSuggestion.MeetingTime.ToShortTimeString(),
                                  timeSuggestion.MeetingTime.Add(TimeSpan.FromMinutes(availabilityOptions.MeetingDuration)).ToShortTimeString());



            }
        }

        int i = 0;

        // Display free/busy times.
        foreach (AttendeeAvailability availability in results.AttendeesAvailability)
        {
            Console.WriteLine("Availability information for {0}:\n", attendees[i].SmtpAddress);

            foreach (CalendarEvent calEvent in availability.CalendarEvents)
            {
                Console.WriteLine("\tBusy from {0} to {1} \n", calEvent.StartTime.ToString(), calEvent.EndTime.ToString());
            }

            i++;
        }