/// <summary> /// </summary> /// <param name="folderItems"></param> public FolderContentWrapper(DataWrapper folderItems) { Files = folderItems.Entries.OfType<File>().Select(x => new FileWrapper(x)).ToList(); Folders = folderItems.Entries.OfType<Folder>().Select(x => new FolderWrapper(x)).ToList(); Current = new FolderWrapper(folderItems.FolderInfo); PathParts = folderItems.FolderPathParts.Select(x => new { key = x.Key, path = x.Value }); }
/// <summary> /// </summary> /// <param name="folderItems"></param> public FolderContentWrapper(DataWrapper folderItems) { Files = folderItems.Entries.OfType<File>().Select(x => new FileWrapper(x)).ToList(); Folders = folderItems.Entries.OfType<Folder>().Select(x => new FolderWrapper(x)).ToList(); Current = new FolderWrapper(folderItems.FolderInfo); PathParts = folderItems.FolderPathParts; Total = folderItems.Total; }
public DataWrapper GetFolderItems(String parentId, String sfrom, String scount, String sfilter, OrderBy orderBy, String ssubject, String searchText, bool compactView) { var from = Convert.ToInt32(sfrom); var count = Convert.ToInt32(scount); var filter = (FilterType) Convert.ToInt32(sfilter); var subjectId = string.IsNullOrEmpty(ssubject) ? Guid.Empty : new Guid(ssubject); using (var folderDao = GetFolderDao()) using (var tagDao = GetTagDao()) { var parent = folderDao.GetFolder(parentId); ErrorIf(parent == null, FilesCommonResource.ErrorMassage_FolderNotFound); ErrorIf(!FileSecurity.CanRead(parent), FilesCommonResource.ErrorMassage_SecurityException_ViewFolder); ErrorIf(parent.RootFolderType == FolderType.TRASH && !Equals(parent.ID, Global.FolderTrash), FilesCommonResource.ErrorMassage_ViewTrashItem); if (Equals(parent.ID, Global.FolderShare)) orderBy = new OrderBy(SortedByType.DateAndTime, false); int total; var entries = GetEntries(parent, filter, subjectId, orderBy, searchText, from, count, out total); var breadCrumbs = Global.GetBreadCrumbs(parentId, folderDao); var prevVisible = breadCrumbs.ElementAtOrDefault(breadCrumbs.Count() - 2); if (prevVisible != null) { parent.ParentFolderID = prevVisible.ID; } parent.Shareable = (parent.RootFolderType == FolderType.USER && parent.RootFolderCreator == SecurityContext.CurrentAccount.ID) || (parent.RootFolderType == FolderType.COMMON && Global.IsAdministrator); var result = new DataWrapper { Folders = entries.OfType<Folder>().ToList(), Files = entries.OfType<File>().ToList(), Total = total, FolderPathParts = new ItemDictionary<object, String>(breadCrumbs.ToDictionary(f => f.ID, f => f.Title)), FolderInfo = parent }; var newtags = tagDao.GetTags(SecurityContext.CurrentAccount.ID, TagType.New); result.CountNewInShare = newtags.Count(); result.Files.ForEach(f => { if (newtags.Where(t => t.EntryType == FileEntryType.File).Select(t => t.EntryId).Contains(f.ID)) f.FileStatus |= FileStatus.IsNew; }); result.Folders.ForEach(f => { if (newtags.Where(t => t.EntryType == FileEntryType.Folder).Select(t => t.EntryId).Contains(f.ID)) f.NewForMe = true; }); if (newtags.Count(t => t.EntryType == FileEntryType.Folder && Equals(t.EntryId, parent.ID)) > 0) { tagDao.RemoveTags(Tag.New(SecurityContext.CurrentAccount.ID, parent)); result.CountNewInShare--; } var filesSettings = SettingsManager.Instance.LoadSettingsFor<FilesSettings>(SecurityContext.CurrentAccount.ID); filesSettings.ContentOrderBy = orderBy; filesSettings.CompactViewFolder = compactView; SettingsManager.Instance.SaveSettingsFor(filesSettings, SecurityContext.CurrentAccount.ID); return result; } }
public DataWrapper GetFolderItems(String parentId, String sfrom, String scount, String sfilter, OrderBy orderBy, String ssubject, String searchText) { var from = Convert.ToInt32(sfrom); var count = Convert.ToInt32(scount); var filter = (FilterType)Convert.ToInt32(sfilter); var subjectId = string.IsNullOrEmpty(ssubject) ? Guid.Empty : new Guid(ssubject); using (var folderDao = GetFolderDao()) { Folder parent; try { parent = folderDao.GetFolder(parentId); } catch(Exception e) { throw GenerateException(e); } ErrorIf(parent == null, FilesCommonResource.ErrorMassage_FolderNotFound); ErrorIf(!FileSecurity.CanRead(parent), FilesCommonResource.ErrorMassage_SecurityException_ViewFolder); ErrorIf(parent.RootFolderType == FolderType.TRASH && !Equals(parent.ID, Global.FolderTrash), FilesCommonResource.ErrorMassage_ViewTrashItem); if (Equals(parent.ID, Global.FolderShare)) orderBy = new OrderBy(SortedByType.New, false); else if (orderBy.SortedBy == SortedByType.New) orderBy = new OrderBy(SortedByType.DateAndTime, true); int total; IEnumerable<FileEntry> entries; try { entries = EntryManager.GetEntries(folderDao, parent, filter, subjectId, orderBy, searchText, from, count, out total); } catch(Exception e) { throw GenerateException(e); } var breadCrumbs = EntryManager.GetBreadCrumbs(parentId, folderDao); var prevVisible = breadCrumbs.ElementAtOrDefault(breadCrumbs.Count() - 2); if (prevVisible != null) { parent.ParentFolderID = prevVisible.ID; } parent.Shareable = FileSharing.CanSetAccess(parent) || parent.FolderType == FolderType.SHARE; entries = entries.Where(x => { if (x is Folder) return true; var file = (File)x; return (file.FileStatus & FileStatus.IsConverting) != FileStatus.IsConverting; }); var result = new DataWrapper { Total = total, Entries = entries.ToList(), FolderPathParts = new ItemList<object>(breadCrumbs.Select(f => f.ID)), FolderInfo = parent, RootFoldersIdMarkedAsNew = new ItemDictionary<object, int>(FileMarker.GetRootFoldersIdMarkedAsNew()) }; return result; } }