Beispiel #1
0
        public FileWrapper <T> Get <T>(File <T> file, List <Tuple <FileEntry <T>, bool> > folders = null)
        {
            var result = GetFileWrapper(file);

            result.FolderId = file.FolderID;
            if (file.RootFolderType == FolderType.USER &&
                !Equals(file.RootFolderCreator, AuthContext.CurrentAccount.ID))
            {
                result.RootFolderType = FolderType.SHARE;
                var           folderDao = DaoFactory.GetFolderDao <T>();
                FileEntry <T> parentFolder;

                if (folders != null)
                {
                    var folderWithRight = folders.FirstOrDefault(f => f.Item1.ID.Equals(file.FolderID));
                    if (folderWithRight == null || !folderWithRight.Item2)
                    {
                        result.FolderId = GlobalFolderHelper.GetFolderShare <T>();
                    }
                }
                else
                {
                    parentFolder = folderDao.GetFolder(file.FolderID);
                    if (!FileSecurity.CanRead(parentFolder))
                    {
                        result.FolderId = GlobalFolderHelper.GetFolderShare <T>();
                    }
                }
            }


            return(result);
        }
Beispiel #2
0
        public FileWrapper <T> Get <T>(File <T> file)
        {
            var result = Get <FileWrapper <T>, T>(file);

            result.FolderId = file.FolderID;
            if (file.RootFolderType == FolderType.USER &&
                !Equals(file.RootFolderCreator, AuthContext.CurrentAccount.ID))
            {
                result.RootFolderType = FolderType.SHARE;
                var folderDao    = DaoFactory.GetFolderDao <T>();
                var parentFolder = folderDao.GetFolder(file.FolderID);
                if (!FileSecurity.CanRead(parentFolder))
                {
                    result.FolderId = GlobalFolderHelper.GetFolderShare <T>();
                }
            }

            result.FileExst = FileUtility.GetFileExtension(file.Title);
            result.FileType = FileUtility.GetFileTypeByExtention(result.FileExst);

            result.Version           = file.Version;
            result.VersionGroup      = file.VersionGroup;
            result.ContentLength     = file.ContentLengthString;
            result.FileStatus        = file.FileStatus;
            result.PureContentLength = file.ContentLength.NullIfDefault();
            result.Comment           = file.Comment;
            result.Encrypted         = file.Encrypted.NullIfDefault();
            result.Locked            = file.Locked.NullIfDefault();
            result.LockedBy          = file.LockedBy;

            try
            {
                result.ViewUrl = CommonLinkUtility.GetFullAbsolutePath(file.DownloadUrl);

                result.WebUrl = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebPreviewUrl(FileUtility, file.Title, file.ID));
            }
            catch (Exception)
            {
                //Don't catch anything here because of httpcontext
            }

            return(result);
        }