Esempio n. 1
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>");
            }
        }