public void SetCalendarColor() { base.ThrowIfCannotActAsOwner(); int serverColorIndex = CalendarColorManager.GetServerColorIndex((int)base.GetParameter("Idx")); NavigationNodeCollection navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, NavigationNodeGroupSection.Calendar); NavigationNodeFolder[] array = null; OwaStoreObjectId owaStoreObjectId = (OwaStoreObjectId)base.GetParameter("fId"); if (owaStoreObjectId.IsGSCalendar) { array = navigationNodeCollection.FindGSCalendarsByLegacyDN(owaStoreObjectId.MailboxOwnerLegacyDN); } else { array = navigationNodeCollection.FindFoldersById(owaStoreObjectId.StoreObjectId); } if (array == null || (array.Length == 0 && !owaStoreObjectId.IsGSCalendar)) { using (Folder calendarFolder = this.GetCalendarFolder(false)) { NavigationNodeGroupType groupType = NavigationNodeGroupType.MyFoldersGroup; bool flag = base.UserContext.IsInOtherMailbox(calendarFolder); if (flag || Utilities.IsOneOfTheFolderFlagsSet(calendarFolder, new ExtendedFolderFlags[] { ExtendedFolderFlags.SharedIn, ExtendedFolderFlags.ExchangeCrossOrgShareFolder })) { groupType = NavigationNodeGroupType.SharedFoldersGroup; } array = new NavigationNodeFolder[] { navigationNodeCollection.AddFolderToDefaultGroup(base.UserContext, groupType, calendarFolder, flag) }; } } if (array != null) { foreach (NavigationNodeFolder navigationNodeFolder in array) { navigationNodeFolder.NavigationNodeCalendarColor = serverColorIndex; } navigationNodeCollection.Save(base.UserContext.MailboxSession); } }
private bool TryGetNodeFoldersFromNavigationTree(out NavigationNodeFolder[] navigationNodeFolders, out NavigationNodeCollection navigationNodeCollection) { navigationNodeFolders = null; navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(this.UserContext, this.UserContext.MailboxSession, NavigationNodeGroupSection.Calendar); if (navigationNodeCollection != null) { try { if (this.IsGSCalendar) { navigationNodeFolders = navigationNodeCollection.FindGSCalendarsByLegacyDN(this.FolderId.MailboxOwnerLegacyDN); } else { navigationNodeFolders = navigationNodeCollection.FindFoldersById(this.FolderId.StoreObjectId); } if (navigationNodeFolders != null && navigationNodeFolders.Length > 0) { return(true); } } catch (StoragePermanentException ex) { string message = string.Format(CultureInfo.InvariantCulture, "CalendarColorManager.GetCalendarFolderColor. Unable to find tree node related to the given calendar. Exception: {0}.", new object[] { ex.Message }); ExTraceGlobals.CoreCallTracer.TraceDebug(0L, message); } catch (StorageTransientException ex2) { string message2 = string.Format(CultureInfo.InvariantCulture, "CalendarColorManager.GetCalendarFolderColor. Unable to find tree node related to the given calendar. Exception: {0}.", new object[] { ex2.Message }); ExTraceGlobals.CoreCallTracer.TraceDebug(0L, message2); } return(false); } return(false); }