GetFiles() public method

public GetFiles ( int folderID ) : IEnumerable
folderID int
return IEnumerable
示例#1
0
        public int deleteFolderChain(Folder DeleteMe)
        {
            PAWAContext db = new PAWAContext();
            AlbumGrid toolbelt = new AlbumGrid(dbContext);
            IEnumerable<Folder> listOfInternalFolders = toolbelt.GetFolders(DeleteMe.FolderID);
            IEnumerable<PAWA.Models.File> listOfInternalFiles = toolbelt.GetFiles(DeleteMe.FolderID);

            int nFolderDel = 0;
            int lengthOfInternalFolders;

            if (listOfInternalFolders.Count() > 0)
            {
                lengthOfInternalFolders = listOfInternalFolders.Count();
            }
            else
            {
                lengthOfInternalFolders = 0;
            }

            for (int i = 0; i < lengthOfInternalFolders; i++)
            {
                Folder delFolder = listOfInternalFolders.ElementAt(0);
                nFolderDel += deleteFolderChain(delFolder);
            }

            deleteMultipleFiles(listOfInternalFiles);
            dbContext.Folders.Remove(DeleteMe);
            dbContext.SaveChanges();
            return nFolderDel;
        }
示例#2
0
        public ActionResult MoveImageTo(MoveItemList moveItemList)
        {
            IList<string> selectedItems = new List<string> { };
            if (moveItemList.selected != null)
            {
                selectedItems = moveItemList.selected.Split((new char[] { ',' }), StringSplitOptions.RemoveEmptyEntries);
            }
            int? newFolderID = Convert.ToInt32(moveItemList.destinationFolder);
            int? currentFolder = Convert.ToInt32(moveItemList.sourceFolder);
            if (currentFolder <= 0) { currentFolder = null; }
            IList<Folder> listOfUserFolders;
            IEnumerable<File> listOfUserFiles;
            {
                Tools toolbelt = new Tools();
                listOfUserFolders = toolbelt.getFolders(WebSecurity.CurrentUserId);
            }
            {
                AlbumGrid toolbelt = new AlbumGrid(dbContext);
                listOfUserFiles = toolbelt.GetFiles(currentFolder);
            }

            int amountOfUserFolders = listOfUserFolders.Count;
            IList<File> filesToMove = new List<File>();

            string ReturnValue = "";
            ReturnValue += "Selected Items Count : " + selectedItems.Count + " : " + selectedItems.Count();
            ReturnValue += "\nFolders Count : " + listOfUserFolders.Count + " : " + listOfUserFolders.Count();
            ReturnValue += "\nFiles Count  : " + listOfUserFiles.Count() ;
            if (listOfUserFiles.Count() > 0){ReturnValue += "\nFileID : " + listOfUserFiles.ElementAt(listOfUserFiles.Count()-1).Description;}
            ReturnValue += "\nNew Folder ID : " + newFolderID.ToString();

            for (int i = 0; i < amountOfUserFolders; i++){
                // Go through every folder

                if (listOfUserFolders.ElementAt(i).FolderID == newFolderID){
                    // FolderID(i) == FolderID.FromAJAX
                    // MAKE SURE the folder exists

                    int numberOfFilesInFolder = listOfUserFiles.Count();
                    for (int n = 0; n < numberOfFilesInFolder; n++)
                    {
                        for (int j = 0; j < selectedItems.Count; j++)
                        {
                            int fileIdFromAJAX = -1;

                            /* Catch Bogus Array values*/
                            try { fileIdFromAJAX = Convert.ToInt32(selectedItems.ElementAt(j)); }
                            catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); }

                            if (listOfUserFiles.ElementAt(n).FileID == fileIdFromAJAX)
                            {
                                filesToMove.Add(listOfUserFiles.ElementAt(n));
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < filesToMove.Count; i++)
            {
                MoveFile(filesToMove.ElementAt(i), newFolderID);
                ReturnValue += "\nFilesToMove : " + filesToMove.ElementAt(i).Description;
            }
            return Content(ReturnValue);
        }