我的代码突然中断了,我将其调试为两种导致这种情况的方法。我已注释/删除了一些代码,使其再次起作用。具体是以下方法:
GetAgentCalendar():
private Folder GetAgentCalendar(ExchangeService service, SAFEAgent agent) {
string username = agent.EmailAddress;
var calendar = SendExchangeRequest(() => Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, username)));
// if(!HasCalendarEditorPermissions(calendar, SC01_SID))
// throw new InvalidOperationException("Agent has not assigned editor permissions");
agent.ExchangeSyncronizationSettings.HasCalendarEditorPermission = true;
return calendar;
}
HasCalendarEditorPermissions()
private bool HasCalendarEditorPermissions(Folder calendar, string userSID) {
if(calendar == null)
throw new ArgumentNullException("calendar");
if(calendar.GetLoadedPropertyDefinitions().Contains(FolderSchema.Permissions))
SendExchangeRequest(() => calendar.Load(new PropertySet(FolderSchema.Permissions)));
return calendar.Permissions.Any(p => p.UserId.SID == userSID &&
p.DisplayPermissionLevel == FolderPermissionLevel.Editor);
}
正在调用此特定错误:
} catch(Exception ex) {
if(ex.InnerException != null) {
if(ex.InnerException is InvalidOperationException) {
if(ex.InnerException.Message == "Agent has not assigned editor permissions") {
a.ExchangeSyncronizationSettings.HasCalendarEditorPermission = false;
a.ExchangeSyncronizationSettings.Save(conn);
Console.WriteLine("Rettigheder til kalender mangler for " + a.Initials);
permissionEx.Add(a.Initials);
} else
exceptions.Add(ex.InnerException);