Exemple #1
0
        public List <DocumentTreeNode> SetTreeNodeDocumentLibrariesAndFolders()
        {
            List <DocumentTreeNode> nodes = new List <DocumentTreeNode>();

            if (RSCUtil.Cache.Contains(_cacheKey))
            {
                //Load Cache
                nodes = RSCUtil.Cache[_cacheKey] as List <DocumentTreeNode>;
            }
            else
            {
                //Create Cache
                LibrariesManager manager = new LibrariesManager();

                //Folder Focused
                if (this.FolderId != Guid.Empty)
                {
                    var album = manager.GetDocumentLibrary(this.LibraryId);
                    if (album != null)
                    {
                        var folders        = manager.GetAllFolders(album);
                        var selectedFolder = folders.FirstOrDefault(x => x.Id == this.FolderId);
                        if (selectedFolder != null)
                        {
                            this.ParseSingleFolder(nodes, manager, album, selectedFolder);
                        }
                        else
                        {
                            throw new Exception("Invalid FolderId Specified or Unable to find folder");
                        }
                    }
                    else
                    {
                        throw new Exception("Invalid LibraryId Specified or Unable to find library");
                    }
                }
                else
                {
                    //Libary Focused
                    var album = manager.GetDocumentLibrary(this.LibraryId);
                    if (album != null)
                    {
                        this.ParseSingleAlbum(nodes, manager, album);
                    }
                    else
                    {
                        throw new Exception("Invalid LibraryId Specified");
                    }
                }

                if (!SystemManager.IsDesignMode && RSCUtil.SfsConfig.CacheTimeoutMinutes > 0)
                {
                    //Add to cache
                    RSCUtil.AddToCache(nodes, _cacheKey, TimeSpan.FromMinutes(RSCUtil.SfsConfig.CacheTimeoutMinutes));
                }
            }

            //Bind to the tree
            return(nodes);
        }
Exemple #2
0
        private void ParseSingleFolder(List <DocumentTreeNode> nodes, LibrariesManager manager, DocumentLibrary album, IFolder folder)
        {
            var folders = manager.GetAllFolders(album);

            DocumentTreeNode folderNode = new DocumentTreeNode();

            folderNode.Title    = folder.Title;
            folderNode.Expanded = this.Expanded;
            this.SetImage(folderNode);
            folderNode.Id        = folder.Id;
            folderNode.IsFolder  = true;
            folderNode.CssClass += " album";
            nodes.Add(folderNode);

            //Get Documents for this Library
            var docsInLibrary = manager.GetDocuments().Where(x => x.Parent.Id == album.Id && x.FolderId == folder.Id).Where(this.FilterExpressionForDocuments);

            foreach (var doc in docsInLibrary)
            {
                DocumentTreeNode docNode = this.CreateDocNode(album, doc);
                folderNode.Nodes.Add(docNode);
            }

            //Load Children
            foreach (var child in folders.Where(x => x.ParentId == folder.Id))
            {
                folderNode.Nodes.Add(this.GetChildNodes(child, folders, album, manager, docsInLibrary));
            }
        }