Beispiel #1
0
        private void PopulateTree(int searchValue)
        {
            FileController fileCtrl = new FileController();
            FileConfigurationController ctrlConfig = new FileConfigurationController();
            var configs = ctrlConfig.GetItems(PortalId) as List<FileConfiguration>;
            if (configs.Count > 0)
            {
                //check for root shared folder
                var rootFolder = fileCtrl.GetRootPortalFolder(PortalId, UserId);

                //if none exists, create
                if (rootFolder == null)
                {
                    rootFolder = fileCtrl.CreateRootSharedFolder(UserId, PortalId);
                }
                configs[0].RootSharedFolderID = rootFolder.ID;

                //check root users folder
                if (configs[0].RootUsersFolderID == 0)
                {
                    //if none exists, create
                    configs[0].RootUsersFolderID = fileCtrl.CreateRootUsersFolder(UserId, PortalId).ID;
                }

                //check root groups folder
                if (configs[0].RootGroupsFolderID == 0)
                {
                    //if none exists, create
                    configs[0].RootGroupsFolderID = fileCtrl.CreateRootGroupsFolder(UserId, PortalId).ID;
                }

                //update config
                ctrlConfig.Update(configs[0]);
            }

            File rootFile = new File();
            rootFile.ID = -1;
            rootFile.Name = "QuickDocsPro";

            List<File> listFiles = fileCtrl.GetItemsByParent(rootFile.ID, UserId, PortalId, PortalSettings.AdministratorRoleId, "Asc") as List<File>;
            System.Web.UI.WebControls.TreeNode rootNode = new System.Web.UI.WebControls.TreeNode(rootFile.Name, rootFile.ID.ToString(), "images/window_16_hot.png");
            rootNode.Expanded = false;

            treeFolders.Nodes.Add(rootNode);
            populateChildren(rootNode, searchValue, configs[0]);

            if (rootNode.Value == searchValue.ToString())
            {
                rootNode.Selected = true;
            }
        }