Ejemplo n.º 1
0
        private FileWrapper <T> GetFileWrapper <T>(File <T> file)
        {
            var result = Get <FileWrapper <T>, T>(file);

            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);
        }
Ejemplo n.º 2
0
        public static void SendShareNotice(FileEntry fileEntry, Dictionary <Guid, FileShare> recipients, string message)
        {
            if (fileEntry == null || recipients.Count == 0)
            {
                return;
            }

            using (var folderDao = Global.DaoFactory.GetFolderDao())
            {
                if (fileEntry is File &&
                    folderDao.GetFolder(((File)fileEntry).FolderID) == null)
                {
                    return;
                }

                String url;
                if (fileEntry is File)
                {
                    url = FilesLinkUtility.GetFileWebPreviewUrl(fileEntry.Title, fileEntry.ID);
                }
                else
                {
                    url = PathProvider.GetFolderUrl(((Folder)fileEntry));
                }

                var recipientsProvider = NotifySource.Instance.GetRecipientsProvider();

                foreach (var recipientPair in recipients)
                {
                    var u       = CoreContext.UserManager.GetUsers(recipientPair.Key);
                    var culture = string.IsNullOrEmpty(u.CultureName)
                                      ? CoreContext.TenantManager.GetCurrentTenant().GetCulture()
                                      : CultureInfo.GetCultureInfo(u.CultureName);

                    var aceString = GetAccessString(recipientPair.Value, culture);
                    var recipient = recipientsProvider.GetRecipient(u.ID.ToString());

                    Instance.SendNoticeAsync(
                        fileEntry is File ? NotifyConstants.Event_ShareDocument : NotifyConstants.Event_ShareFolder,
                        fileEntry.UniqID,
                        recipient,
                        true,
                        new TagValue(NotifyConstants.Tag_DocumentTitle, fileEntry.Title),
                        new TagValue(NotifyConstants.Tag_FolderID, fileEntry.ID),
                        new TagValue(NotifyConstants.Tag_DocumentUrl, CommonLinkUtility.GetFullAbsolutePath(url)),
                        new TagValue(NotifyConstants.Tag_AccessRights, aceString),
                        new TagValue(NotifyConstants.Tag_Message, message.HtmlEncode())
                        );
                }
            }
        }
Ejemplo n.º 3
0
        public static string GetLink(File file)
        {
            var url = file.ViewUrl;

            if (!FileUtility.CanImageView(file.Title))
            {
                url = FilesLinkUtility.GetFileWebPreviewUrl(file.Title, file.ID);
            }

            var linkParams = CreateKey(file.ID.ToString());

            url += "&" + FilesLinkUtility.DocShareKey + "=" + HttpUtility.UrlEncode(linkParams);

            return(CommonLinkUtility.GetFullAbsolutePath(url));
        }
Ejemplo n.º 4
0
        public override SearchResultItem[] Search(string text)
        {
            using (var folderDao = Global.DaoFactory.GetFolderDao())
            {
                var result = SearchFiles(text)
                             .Select(r =>
                {
                    var folders = EntryManager.GetBreadCrumbs(r.FolderID, folderDao);
                    return(new SearchResultItem
                    {
                        Name = r.Title ?? string.Empty,
                        Description = string.Empty,
                        URL = FilesLinkUtility.GetFileWebPreviewUrl(r.Title, r.ID),
                        Date = r.ModifiedOn,
                        Additional = new Dictionary <string, object>
                        {
                            { "Author", r.CreateByString.HtmlEncode() },
                            { "Path", FolderPathBuilder(folders) },
                            { "FullPath", FolderFullPathBuilder(folders) },
                            { "FolderUrl", PathProvider.GetFolderUrl(r.FolderID) },
                            { "Size", FileSizeComment.FilesSizeToString(r.ContentLength) }
                        }
                    });
                });

                var resultFolder = SearchFolders(text)
                                   .Select(f =>
                {
                    var folders = EntryManager.GetBreadCrumbs(f.ID, folderDao);
                    return(new SearchResultItem
                    {
                        Name = f.Title ?? string.Empty,
                        Description = String.Empty,
                        URL = PathProvider.GetFolderUrl(f),
                        Date = f.ModifiedOn,
                        Additional = new Dictionary <string, object>
                        {
                            { "Author", f.CreateByString.HtmlEncode() },
                            { "Path", FolderPathBuilder(folders) },
                            { "FullPath", FolderFullPathBuilder(folders) },
                            { "IsFolder", true }
                        }
                    });
                });

                return(result.Concat(resultFolder).ToArray());
            }
        }
Ejemplo n.º 5
0
        public string GetLink <T>(File <T> file, bool withHash = true)
        {
            var url = file.DownloadUrl;

            if (FileUtility.CanWebView(file.Title))
            {
                url = FilesLinkUtility.GetFileWebPreviewUrl(FileUtility, file.Title, file.ID);
            }

            if (withHash)
            {
                var linkParams = CreateKey(file.ID);
                url += "&" + FilesLinkUtility.DocShareKey + "=" + HttpUtility.UrlEncode(linkParams);
            }

            return(BaseCommonLinkUtility.GetFullAbsolutePath(url));
        }
Ejemplo n.º 6
0
        private static void Redirect(HttpContext context)
        {
            if (!SecurityContext.AuthenticateMe(CookiesManager.GetCookies(CookiesType.AuthKey)))
            {
                context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
                return;
            }
            var urlRedirect = string.Empty;
            int id;
            var folderId = context.Request[FilesLinkUtility.FolderId];

            if (!string.IsNullOrEmpty(folderId) && int.TryParse(folderId, out id))
            {
                try
                {
                    urlRedirect = PathProvider.GetFolderUrl(id);
                }
                catch (ArgumentNullException e)
                {
                    throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
                }
            }

            var fileId = context.Request[FilesLinkUtility.FileId];

            if (!string.IsNullOrEmpty(fileId) && int.TryParse(fileId, out id))
            {
                using (var fileDao = Global.DaoFactory.GetFileDao())
                {
                    var file = fileDao.GetFile(id);
                    if (file == null)
                    {
                        context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                        return;
                    }

                    urlRedirect = FilesLinkUtility.GetFileWebPreviewUrl(file.Title, file.ID);
                }
            }

            if (string.IsNullOrEmpty(urlRedirect))
            {
                throw new HttpException((int)HttpStatusCode.BadRequest, FilesCommonResource.ErrorMassage_BadRequest);
            }
            context.Response.Redirect(urlRedirect);
        }
Ejemplo n.º 7
0
        public SearchResultItem[] Search(string text)
        {
            var folderDao = DaoFactory.GetFolderDao <int>();
            var files     = SearchFiles(text);
            List <SearchResultItem> list = new List <SearchResultItem>();

            foreach (var file in files)
            {
                var searchResultItem = new SearchResultItem
                {
                    Name        = file.Title ?? string.Empty,
                    Description = string.Empty,
                    URL         = FilesLinkUtility.GetFileWebPreviewUrl(FileUtility, file.Title, file.ID),
                    Date        = file.ModifiedOn,
                    Additional  = new Dictionary <string, object>
                    {
                        { "Author", file.CreateByString.HtmlEncode() },
                        { "Path", FolderPathBuilder <int>(EntryManager.GetBreadCrumbs(file.FolderID, folderDao)) },
                        { "Size", FileSizeComment.FilesSizeToString(file.ContentLength) }
                    }
                };
                list.Add(searchResultItem);
            }

            var folders = SearchFolders(text);

            foreach (var folder in folders)
            {
                var searchResultItem = new SearchResultItem
                {
                    Name        = folder.Title ?? string.Empty,
                    Description = string.Empty,
                    URL         = PathProvider.GetFolderUrl(folder),
                    Date        = folder.ModifiedOn,
                    Additional  = new Dictionary <string, object>
                    {
                        { "Author", folder.CreateByString.HtmlEncode() },
                        { "Path", FolderPathBuilder <int>(EntryManager.GetBreadCrumbs(folder.ID, folderDao)) },
                        { "IsFolder", true }
                    }
                };
                list.Add(searchResultItem);
            }

            return(list.ToArray());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// </summary>
        /// <param name="file"></param>
        public FileWrapper(File file)
            : base(file)
        {
            FolderId = file.FolderID;
            if (file.RootFolderType == FolderType.USER &&
                !Equals(file.RootFolderCreator, SecurityContext.CurrentAccount.ID))
            {
                RootFolderType = FolderType.SHARE;
                using (var folderDao = Global.DaoFactory.GetFolderDao())
                {
                    var parentFolder = folderDao.GetFolder(file.FolderID);
                    if (!Global.GetFilesSecurity().CanRead(parentFolder))
                    {
                        FolderId = Global.FolderShare;
                    }
                }
            }

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

            Version           = file.Version;
            VersionGroup      = file.VersionGroup;
            ContentLength     = file.ContentLengthString;
            FileStatus        = file.FileStatus;
            PureContentLength = file.ContentLength;
            Comment           = file.Comment;
            Encrypted         = file.Encrypted;
            try
            {
                ViewUrl = CommonLinkUtility.GetFullAbsolutePath(file.DownloadUrl);

                WebUrl = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebPreviewUrl(file.Title, file.ID));

                if (file.ThumbnailStatus == Thumbnail.Created)
                {
                    ThumbnailUrl = CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileThumbnailUrl(file.ID, file.Version));
                }
            }
            catch (Exception)
            {
                //Don't catch anything here because of httpcontext
            }
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public static void SendDocuSignComplete(File file, string sourceTitle)
        {
            var recipient = NotifySource.Instance.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString());

            Instance.SendNoticeAsync(
                NotifyConstants.Event_DocuSignComplete,
                file.UniqID,
                recipient,
                true,
                new TagValue(NotifyConstants.Tag_DocumentUrl, CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebPreviewUrl(file.Title, file.ID))),
                new TagValue(NotifyConstants.Tag_DocumentTitle, file.Title),
                new TagValue(NotifyConstants.Tag_Message, sourceTitle)
                );
        }
Ejemplo n.º 11
0
        public override FileUploadResult ProcessUpload(HttpContext context)
        {
            var            fileName   = string.Empty;
            MailAttachment attachment = null;

            try
            {
                if (FileToUpload.HasFilesToUpload(context))
                {
                    try
                    {
                        Thread.CurrentThread.CurrentCulture   = CurrentCulture;
                        Thread.CurrentThread.CurrentUICulture = CurrentCulture;

                        var mailId   = Convert.ToInt32(context.Request["messageId"]);
                        var copyToMy = Convert.ToInt32(context.Request["copyToMy"]);

                        if (mailId < 1)
                        {
                            throw new AttachmentsException(AttachmentsException.Types.MessageNotFound, "Message not yet saved!");
                        }

                        var item = MailBoxManager.GetMailInfo(TenantId, Username, mailId, false, false);
                        if (item == null)
                        {
                            throw new AttachmentsException(AttachmentsException.Types.MessageNotFound, "Message not found.");
                        }

                        if (string.IsNullOrEmpty(item.StreamId))
                        {
                            throw new AttachmentsException(AttachmentsException.Types.BadParams, "Have no stream");
                        }

                        var postedFile = new FileToUpload(context);
                        fileName = context.Request["name"];

                        if (copyToMy == 1)
                        {
                            var uploadedFile = FileUploader.Exec(Global.FolderMy.ToString(), fileName, postedFile.ContentLength, postedFile.InputStream, true);
                            return(new FileUploadResult
                            {
                                Success = true,
                                FileName = uploadedFile.Title,
                                FileURL = FilesLinkUtility.GetFileWebPreviewUrl(uploadedFile.Title, uploadedFile.ID),
                                Data = new MailAttachment
                                {
                                    fileId = Convert.ToInt32(uploadedFile.ID),
                                    fileName = uploadedFile.Title,
                                    size = uploadedFile.ContentLength,
                                    contentType = uploadedFile.ConvertedType,
                                    attachedAsLink = true,
                                    tenant = TenantId,
                                    user = Username
                                }
                            });
                        }

                        attachment = new MailAttachment
                        {
                            fileId   = -1,
                            size     = postedFile.ContentLength,
                            fileName = fileName,
                            streamId = item.StreamId,
                            tenant   = TenantId,
                            user     = Username
                        };

                        attachment = MailBoxManager.AttachFile(TenantId, Username, mailId, fileName, postedFile.InputStream);

                        return(new FileUploadResult
                        {
                            Success = true,
                            FileName = attachment.fileName,
                            FileURL = attachment.storedFileUrl,
                            Data = attachment
                        });
                    }
                    catch (AttachmentsException e)
                    {
                        string errorMessage;

                        switch (e.ErrorType)
                        {
                        case AttachmentsException.Types.BadParams:
                            errorMessage = MailScriptResource.AttachmentsBadInputParamsError;
                            break;

                        case AttachmentsException.Types.EmptyFile:
                            errorMessage = MailScriptResource.AttachmentsEmptyFileNotSupportedError;
                            break;

                        case AttachmentsException.Types.MessageNotFound:
                            errorMessage = MailScriptResource.AttachmentsMessageNotFoundError;
                            break;

                        case AttachmentsException.Types.TotalSizeExceeded:
                            errorMessage = MailScriptResource.AttachmentsTotalLimitError;
                            break;

                        case AttachmentsException.Types.DocumentNotFound:
                            errorMessage = MailScriptResource.AttachmentsDocumentNotFoundError;
                            break;

                        case AttachmentsException.Types.DocumentAccessDenied:
                            errorMessage = MailScriptResource.AttachmentsDocumentAccessDeniedError;
                            break;

                        default:
                            errorMessage = MailScriptResource.AttachmentsUnknownError;
                            break;
                        }
                        throw new Exception(errorMessage);
                    }
                    catch (TenantQuotaException)
                    {
                        throw;
                    }
                    catch (Exception)
                    {
                        throw new Exception(MailScriptResource.AttachmentsUnknownError);
                    }
                }
                throw new Exception(MailScriptResource.AttachmentsBadInputParamsError);
            }
            catch (Exception ex)
            {
                return(new FileUploadResult
                {
                    Success = false,
                    FileName = fileName,
                    Data = attachment,
                    Message = ex.Message,
                });
            }
        }
Ejemplo n.º 12
0
        public IEnumerable <SearchItem> Search(string searchText, int projectId = 0)
        {
            var queryResult = DaoFactory.SearchDao.Search(searchText, projectId);

            using (var scope = DIHelper.Resolve())
            {
                var projectSecurity = scope.Resolve <ProjectSecurity>();

                foreach (var r in queryResult)
                {
                    switch (r.EntityType)
                    {
                    case EntityType.Project:
                        var project = (Project)r;
                        if (projectSecurity.CanRead(project))
                        {
                            searchItems.Add(new SearchItem(project));
                        }
                        continue;

                    case EntityType.Milestone:
                        var milestone = (Milestone)r;
                        if (projectSecurity.CanRead(milestone))
                        {
                            searchItems.Add(new SearchItem(milestone));
                        }
                        continue;

                    case EntityType.Message:
                        var message = (Message)r;
                        if (projectSecurity.CanRead(message))
                        {
                            searchItems.Add(new SearchItem(message));
                        }
                        continue;

                    case EntityType.Task:
                        var task = (Task)r;
                        if (projectSecurity.CanRead(task))
                        {
                            searchItems.Add(new SearchItem(task));
                        }
                        continue;

                    case EntityType.Comment:
                        var comment = (Comment)r;
                        var entity  = CommentEngine.GetEntityByTargetUniqId(comment);
                        if (entity == null)
                        {
                            continue;
                        }

                        searchItems.Add(new SearchItem(comment.EntityType,
                                                       comment.ID.ToString(CultureInfo.InvariantCulture), HtmlUtil.GetText(comment.Content),
                                                       comment.CreateOn, new SearchItem(entity)));
                        continue;

                    case EntityType.SubTask:
                        var subtask    = (Subtask)r;
                        var parentTask = TaskEngine.GetByID(subtask.Task);
                        if (parentTask == null)
                        {
                            continue;
                        }

                        searchItems.Add(new SearchItem(subtask.EntityType,
                                                       subtask.ID.ToString(CultureInfo.InvariantCulture), subtask.Title, subtask.CreateOn,
                                                       new SearchItem(parentTask)));
                        continue;
                    }
                }
            }

            try
            {
                // search in files
                var fileEntries = new List <FileEntry>();
                using (var folderDao = FilesIntegration.GetFolderDao())
                    using (var fileDao = FilesIntegration.GetFileDao())
                    {
                        fileEntries.AddRange(folderDao.Search(searchText, true));
                        fileEntries.AddRange(fileDao.Search(searchText, true));

                        var projectIds = projectId != 0
                                         ? new List <int> {
                            projectId
                        }
                                         : fileEntries.GroupBy(f => f.RootFolderId)
                        .Select(g => folderDao.GetFolder(g.Key))
                        .Select(f => f != null ? folderDao.GetBunchObjectID(f.RootFolderId).Split('/').Last() : null)
                        .Where(s => !string.IsNullOrEmpty(s))
                        .Select(int.Parse);

                        var rootProject = projectIds.ToDictionary(id => FilesIntegration.RegisterBunch("projects", "project", id.ToString(CultureInfo.InvariantCulture)));
                        fileEntries.RemoveAll(f => !rootProject.ContainsKey(f.RootFolderId));

                        var security = FilesIntegration.GetFileSecurity();
                        fileEntries.RemoveAll(f => !security.CanRead(f));

                        foreach (var f in fileEntries)
                        {
                            var id      = rootProject[f.RootFolderId];
                            var project = DaoFactory.ProjectDao.GetById(id);

                            if (ProjectSecurity.CanReadFiles(project))
                            {
                                var itemId = f.FileEntryType == FileEntryType.File
                                             ? FilesLinkUtility.GetFileWebPreviewUrl(f.Title, f.ID)
                                             : Web.Files.Classes.PathProvider.GetFolderUrl((Folder)f, project.ID);
                                searchItems.Add(new SearchItem(EntityType.File, itemId, f.Title, f.CreateOn, new SearchItem(project), itemPath: "{2}"));
                            }
                        }
                    }
            }
            catch (Exception err)
            {
                LogManager.GetLogger("ASC").Error(err);
            }
            return(searchItems);
        }
Ejemplo n.º 13
0
        public List <SearchGroup> Search(String searchText, int projectId = 0)
        {
            var queryResult = _searchDao.Search(searchText, projectId);

            var groups = new Dictionary <int, SearchGroup>();

            foreach (var r in queryResult)
            {
                var        projId = 0;
                SearchItem item   = null;

                if (r is Project)
                {
                    var p = (Project)r;
                    if (ProjectSecurity.CanRead(p))
                    {
                        projId = p.ID;
                        if (!groups.ContainsKey(projId))
                        {
                            groups[projId] = new SearchGroup(projId, p.Title);
                        }
                        item = new SearchItem(EntityType.Project, p.ID, p.Title, p.Description, p.CreateOn);
                    }
                }
                else
                {
                    if (r is Milestone)
                    {
                        var m = (Milestone)r;
                        if (ProjectSecurity.CanRead(m))
                        {
                            projId = m.Project.ID;
                            if (!groups.ContainsKey(projId))
                            {
                                groups[projId] = new SearchGroup(projId, m.Project.Title);
                            }
                            item = new SearchItem(EntityType.Milestone, m.ID, m.Title, null, m.CreateOn);
                        }
                    }
                    else if (r is Message)
                    {
                        var m = (Message)r;
                        if (ProjectSecurity.CanReadMessages(m.Project))
                        {
                            projId = m.Project.ID;
                            if (!groups.ContainsKey(projId))
                            {
                                groups[projId] = new SearchGroup(projId, m.Project.Title);
                            }
                            item = new SearchItem(EntityType.Message, m.ID, m.Title, m.Content, m.CreateOn);
                        }
                    }
                    else if (r is Task)
                    {
                        var t = (Task)r;
                        if (ProjectSecurity.CanRead(t))
                        {
                            projId = t.Project.ID;
                            if (!groups.ContainsKey(projId))
                            {
                                groups[projId] = new SearchGroup(projId, t.Project.Title);
                            }
                            item = new SearchItem(EntityType.Task, t.ID, t.Title, t.Description, t.CreateOn);
                        }
                    }
                }
                if (0 < projId && item != null)
                {
                    groups[projId].Items.Add(item);
                }
            }

            try
            {
                // search in files
                var fileEntries = new List <Files.Core.FileEntry>();
                using (var folderDao = FilesIntegration.GetFolderDao())
                    using (var fileDao = FilesIntegration.GetFileDao())
                    {
                        fileEntries.AddRange(folderDao.Search(searchText, Files.Core.FolderType.BUNCH).Cast <Files.Core.FileEntry>());
                        fileEntries.AddRange(fileDao.Search(searchText, Files.Core.FolderType.BUNCH).Cast <Files.Core.FileEntry>());

                        var projectIds = projectId != 0
                                         ? new List <int> {
                            projectId
                        }
                                         : fileEntries.GroupBy(f => f.RootFolderId)
                        .Select(g => folderDao.GetFolder(g.Key))
                        .Select(f => f != null ? folderDao.GetBunchObjectID(f.RootFolderId).Split('/').Last() : null)
                        .Where(s => !string.IsNullOrEmpty(s))
                        .Select(s => int.Parse(s));

                        var rootProject = projectIds.ToDictionary(id => FilesIntegration.RegisterBunch("projects", "project", id.ToString()));
                        fileEntries.RemoveAll(f => !rootProject.ContainsKey(f.RootFolderId));

                        var security = FilesIntegration.GetFileSecurity();
                        fileEntries.RemoveAll(f => !security.CanRead(f));

                        foreach (var f in fileEntries)
                        {
                            var id = rootProject[f.RootFolderId];
                            if (!groups.ContainsKey(id))
                            {
                                var project = _projDao.GetById(id);
                                if (project != null && ProjectSecurity.CanRead(project) && ProjectSecurity.CanReadFiles(project))
                                {
                                    groups[id] = new SearchGroup(id, project.Title);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            var item = new SearchItem
                            {
                                EntityType = EntityType.File,
                                ID         = f is Files.Core.File
                                                    ? FilesLinkUtility.GetFileWebPreviewUrl(f.Title, f.ID)
                                                    : PathProvider.GetFolderUrl((Files.Core.Folder)f),
                                Title    = f.Title,
                                CreateOn = f.CreateOn,
                            };
                            groups[id].Items.Add(item);
                        }
                    }
            }
            catch (Exception err)
            {
                LogManager.GetLogger("ASC.Web").Error(err);
            }
            return(new List <SearchGroup>(groups.Values));
        }