Esempio n. 1
0
        public FolderContentWrapper <T> Get <T>(DataWrapper <T> folderItems, int startIndex)
        {
            var result = new FolderContentWrapper <T>
            {
                Files   = folderItems.Entries.OfType <File <T> >().Select(FileWrapperHelper.Get).ToList(),
                Folders = folderItems.Entries
                          .Where(r => r.FileEntryType == FileEntryType.Folder)
                          .Select(r =>
                {
                    FileEntryWrapper wrapper = null;
                    if (r is Folder <int> fol1)
                    {
                        wrapper = FolderWrapperHelper.Get(fol1);
                    }
                    if (r is Folder <string> fol2)
                    {
                        wrapper = FolderWrapperHelper.Get(fol2);
                    }

                    return(wrapper);
                }
                                  ).ToList(),
                PathParts  = folderItems.FolderPathParts,
                StartIndex = startIndex
            };

            result.Current = FolderWrapperHelper.Get(folderItems.FolderInfo);
            result.Count   = result.Files.Count + result.Folders.Count;
            result.Total   = folderItems.Total;

            return(result);
        }
Esempio n. 2
0
        public FolderContentWrapper <T> Get <T>(DataWrapper <T> folderItems, int startIndex)
        {
            var foldersIntWithRights    = GetFoldersIntWithRights <int>();
            var foldersStringWithRights = GetFoldersIntWithRights <string>();

            var result = new FolderContentWrapper <T>
            {
                Files = folderItems.Entries
                        .Where(r => r.FileEntryType == FileEntryType.File)
                        .Select(r =>
                {
                    FileEntryWrapper wrapper = null;
                    if (r is File <int> fol1)
                    {
                        wrapper = FileWrapperHelper.Get(fol1, foldersIntWithRights);
                    }
                    if (r is File <string> fol2)
                    {
                        wrapper = FileWrapperHelper.Get(fol2, foldersStringWithRights);
                    }

                    return(wrapper);
                }
                                )
                        .ToList(),
                Folders = folderItems.Entries
                          .Where(r => r.FileEntryType == FileEntryType.Folder)
                          .Select(r =>
                {
                    FileEntryWrapper wrapper = null;
                    if (r is Folder <int> fol1)
                    {
                        wrapper = FolderWrapperHelper.Get(fol1, foldersIntWithRights);
                    }
                    if (r is Folder <string> fol2)
                    {
                        wrapper = FolderWrapperHelper.Get(fol2, foldersStringWithRights);
                    }

                    return(wrapper);
                }
                                  ).ToList(),
                PathParts  = folderItems.FolderPathParts,
                StartIndex = startIndex
            };

            result.Current = FolderWrapperHelper.Get(folderItems.FolderInfo);
            result.Count   = result.Files.Count + result.Folders.Count;
            result.Total   = folderItems.Total;
            result.New     = folderItems.New;

            return(result);


            List <Tuple <FileEntry <T1>, bool> > GetFoldersIntWithRights <T1>()
            {
                var folderDao = DaoFactory.GetFolderDao <T1>();
                var folders   = folderDao.GetFolders(folderItems.Entries.OfType <FileEntry <T1> >().Select(r => r.FolderID).Distinct().ToList());

                return(FileSecurity.CanRead(folders));
            }
        }