示例#1
0
        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);
            }
        }
示例#2
0
 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);
 }
        public void AddFilterToFavorites()
        {
            string text = ((string)base.GetParameter("fltrSbj")).Trim();

            if (text.Length == 0)
            {
                throw new OwaEventHandlerException("User did not provide name for new folder", LocalizedStrings.GetNonEncoded(-41080803), true);
            }
            if (text.Length > 256)
            {
                text = text.Substring(0, 256);
            }
            base.BindToFolder();
            try
            {
                if (Utilities.IsDefaultFolder(base.ContextFolder, DefaultFolderType.DeletedItems) || Utilities.IsItemInDefaultFolder(base.ContextFolder, DefaultFolderType.DeletedItems) || Utilities.IsFavoritesFilterFolder(base.UserContext, base.ContextFolder))
                {
                    throw new OwaInvalidRequestException("Only normal folder or Outlook search folder can be filtered.");
                }
                if (base.FilteredFolder != null)
                {
                    NavigationNodeCollection navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, NavigationNodeGroupSection.First);
                    if (navigationNodeCollection.FindFoldersById(base.FilteredFolder.Id.ObjectId).Length > 0)
                    {
                        throw new OwaEventHandlerException("Filtered view has already been added.", LocalizedStrings.GetNonEncoded(-44763698), true);
                    }
                    int num = 0;
                    foreach (NavigationNodeFolder navigationNodeFolder in navigationNodeCollection[0].Children)
                    {
                        if (navigationNodeFolder.IsValid && navigationNodeFolder.IsFilteredView)
                        {
                            num++;
                        }
                    }
                    if (num >= Globals.MaximumFilteredViewInFavoritesPerUser)
                    {
                        string description = string.Format(base.UserContext.UserCulture, LocalizedStrings.GetNonEncoded(-529843556), new object[]
                        {
                            Globals.MaximumFilteredViewInFavoritesPerUser
                        });
                        throw new OwaEventHandlerException("Filtered view exceeds budget.", description, true);
                    }
                    base.FilteredFolder[FolderSchema.SearchFolderAllowAgeout] = false;
                    base.FilteredFolder.DisplayName = text;
                    FolderSaveResult folderSaveResult = base.FilteredFolder.Save();
                    if (folderSaveResult.OperationResult != OperationResult.Succeeded)
                    {
                        if (Utilities.IsFolderNameConflictError(folderSaveResult))
                        {
                            throw new OwaEventHandlerException("Folder name exists", LocalizedStrings.GetNonEncoded(-1782850773), OwaEventHandlerErrorCode.FolderNameExists, true);
                        }
                        throw new OwaEventHandlerException("Fail to save folder properties.", LocalizedStrings.GetNonEncoded(-920350130), true);
                    }
                    else
                    {
                        base.FilteredFolder.Load(FolderList.FolderTreeQueryProperties);
                        NavigationNodeFolder navigationNodeFolder2 = navigationNodeCollection.AppendFolderToFavorites(base.FilteredFolder);
                        navigationNodeFolder2.SetFilterParameter(base.FilterCondition.SourceFolderId.StoreObjectId, base.FilterCondition.GetBooleanFlags(), base.FilterCondition.GetCategories(), base.FilterCondition.From, base.FilterCondition.To);
                        navigationNodeCollection.Save(base.UserContext.MailboxSession);
                        navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, NavigationNodeGroupSection.First);
                        NavigationHost.RenderFavoritesAndNavigationTrees(this.Writer, base.UserContext, null, new NavigationNodeGroupSection[]
                        {
                            NavigationNodeGroupSection.First
                        });
                    }
                }
            }
            finally
            {
                this.EndProcessEvent();
            }
        }
示例#4
0
        public void AddNewFolder()
        {
            base.ThrowIfCannotActAsOwner();
            string text = ((string)base.GetParameter("SB")).Trim();

            if (text.Length == 0)
            {
                throw new OwaEventHandlerException("User did not provide name for new folder", LocalizedStrings.GetNonEncoded(-41080803), true);
            }
            NavigationNodeGroupSection navigationNodeGroupSection = (NavigationNodeGroupSection)base.GetParameter("GS");
            StoreObjectType            folderType;
            string            className;
            DefaultFolderType defaultFolderType;

            switch (navigationNodeGroupSection)
            {
            case NavigationNodeGroupSection.Calendar:
                folderType        = StoreObjectType.CalendarFolder;
                className         = "IPF.Appointment";
                defaultFolderType = DefaultFolderType.Calendar;
                break;

            case NavigationNodeGroupSection.Contacts:
                folderType        = StoreObjectType.ContactsFolder;
                className         = "IPF.Contact";
                defaultFolderType = DefaultFolderType.Contacts;
                break;

            case NavigationNodeGroupSection.Tasks:
                folderType        = StoreObjectType.TasksFolder;
                className         = "IPF.Task";
                defaultFolderType = DefaultFolderType.Tasks;
                break;

            default:
                throw new OwaInvalidRequestException("Invalid group section: " + navigationNodeGroupSection.ToString());
            }
            StoreObjectId            nodeId = (StoreObjectId)base.GetParameter("pid");
            NavigationNodeCollection navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection);
            int num = navigationNodeCollection.FindChildByNodeId(nodeId);

            if (num < 0)
            {
                throw new OwaEventHandlerException("The parent group doesn't exist.", LocalizedStrings.GetNonEncoded(-289549140), true);
            }
            using (Folder folder = Utilities.CreateSubFolder(Utilities.GetDefaultFolderId(base.UserContext, base.UserContext.MailboxSession, defaultFolderType), folderType, text, base.UserContext))
            {
                folder.ClassName = className;
                try
                {
                    folder.Save();
                }
                catch (ObjectExistedException)
                {
                    throw;
                }
                catch (StoragePermanentException innerException)
                {
                    throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892), innerException);
                }
                folder.Load(FolderList.FolderTreeQueryProperties);
                StoreObjectId objectId = folder.Id.ObjectId;
                navigationNodeCollection.AddFolderToGroup(num, folder, base.UserContext, folder.DisplayName, NavigationNodeType.NormalFolder);
                navigationNodeCollection.Save(base.UserContext.MailboxSession);
                navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection);
                NavigationFolderTreeNode navigationFolderTreeNode  = new NavigationFolderTreeNode(base.UserContext, navigationNodeCollection.FindFoldersById(objectId)[0], folder);
                NavigationFolderTreeNode navigationFolderTreeNode2 = navigationFolderTreeNode;
                navigationFolderTreeNode2.CustomAttributes += " _NF=1";
                this.Writer.Write("<div id=ntn>");
                navigationFolderTreeNode.RenderUndecoratedNode(this.Writer);
                this.Writer.Write("</div>");
            }
        }