Stu*_*rla 5 c# exchangewebservices
并抱歉问题的标题很差
我试图从我的交换服务器获得所有免费房间(不是预订的房间).问题是,我也得到了我预订的房间,但没有人接受.
我预订房间后,我想将它们从列表中排除.
这是我用来预订房间的代码
ExchangeService service;
//...code to new-up and config service
var request = new Appointment(service)
{
Subject = booking.Subject,
Start = booking.Start,
End = booking.End,
Location = booking.Room
};
request.RequiredAttendees.Add(booking.Person);
request.RequiredAttendees.Add(booking.Room);
request.Save(SendInvitationsMode.SendOnlyToAll);
Run Code Online (Sandbox Code Playgroud)
要注意我已经尝试在Save()之后直接调用request.Accept()但没有那个"真正预订"房间.在Outlook中按"接受"是唯一的"修复".不用说,我已经尝试了我能找到的关于这个问题的一切(我不经常与Exchange合作).
然后获得免费房间的代码
var rooms = service.GetRooms(locationAddress);
// all the meeting rooms at location
var rooms= rooms.Select(i => new AttendeeInfo { SmtpAddress = i.Address, AttendeeType = MeetingAttendeeType.Room });
// Get all availabilites from all rooms at given locations
var availability = service.GetUserAvailability(rooms, timeframe, AvailabilityData.FreeBusy);
foreach (var a in availability.AttendeesAvailability)
{
// Here we always get all the free rooms
// including the ones we booked earlier
// UNTIL somebody clicks accept in Outlook and then it does not appear here!?
}
Run Code Online (Sandbox Code Playgroud)
我无法看到房间在Outlook中被接受之前有不同的标记,因此我无法区分它们并将它们拉出我不想要的.
我也真的认为那些房间不应该有,所以必须有一些enum/tick/mark我可以在预订之前放在房间但我完全错过了它.
编辑
我真的不明白为什么AvailabilityData没有选项.免费获取GetUserAvailability方法中的枚举(仅限FreeBusy,FreeBusyAndSuggestions和Suggestions但仅限免费!?)
好吧,这相当愚蠢......代码(我继承的)不包含实际删除占用(繁忙)的房间的代码。我只是刚刚注意到这个...
解决这个问题的代码就是这个
var busyRoomToRemove = a.CalendarEvents.ToList().Find(x => x.FreeBusyStatus == LegacyFreeBusyStatus.Busy);
a.CalendarEvents.Remove(busyRoomToRemove);
Run Code Online (Sandbox Code Playgroud)
带来不便敬请谅解 :-)