Example #1
0
        public String[][][] GetAllFilesAndFolderByUserId(int userId)
        {
            PersistentStorage ps = PersistentStorage.GetInstance();

            List <String[]> metadataListFolder = new List <String[]>();
            //Get the rootFolderId of the user
            int rootFolderId = ps.GetRootFolderId(userId);

            List <Folder> folders = new List <Folder>();

            folders.AddRange(ps.GetFoldersByRootId(rootFolderId));
            Folder currentFolder;

            for (int i = 0; i < folders.Count; i++)
            {
                currentFolder = folders[i];
                String[] metadata = new String[3];
                metadata[0] = currentFolder.id.ToString();
                metadata[1] = currentFolder.name;
                metadata[2] = currentFolder.parentFolderId.ToString();
                metadataListFolder.Add(metadata);
                folders.AddRange(ps.GetFoldersByRootId(currentFolder.id));
            }
            ////////////////////////////////////////////////////////////
            List <String[]> metadataListDocument = new List <String[]>();

            List <Userdocument> userdocs           = new List <Userdocument>();
            List <Userdocument> userdocsFromServer = ps.GetAllUserDocumentsByUserId(userId);

            if (userdocsFromServer != null)
            {
                userdocs.AddRange(userdocsFromServer);
                Document currentDoc;
                foreach (Userdocument ud in userdocs)
                {
                    currentDoc = ps.GetDocumentById(ud.documentId);
                    String[] metadata = new String[3];
                    metadata[0] = ud.documentId.ToString();
                    metadata[1] = ud.folderId.ToString();
                    metadata[2] = currentDoc.name;
                    metadataListDocument.Add(metadata);
                }
            }
            String[][][] returnArray = new String[2][][];
            returnArray[0] = metadataListFolder.ToArray();
            returnArray[1] = metadataListDocument.ToArray();
            return(returnArray);
        }