Esempio n. 1
0
        public IEnumerable <FileShareRecord> GetShares(IEnumerable <FileEntry <string> > entries)
        {
            var result = new List <FileShareRecord>();

            var files   = entries.Where(x => x.FileEntryType == FileEntryType.File).ToArray();
            var folders = entries.Where(x => x.FileEntryType == FileEntryType.Folder).ToList();

            if (files.Any())
            {
                var folderIds = files.Select(x => ((File <string>)x).FolderID).Distinct();
                foreach (var folderId in folderIds)
                {
                    GetFoldersForShare(folderId, folders);
                }

                var pureShareRecords = SecurityDao.GetPureShareRecords(files);
                if (pureShareRecords != null)
                {
                    foreach (var pureShareRecord in pureShareRecords)
                    {
                        if (pureShareRecord == null)
                        {
                            continue;
                        }
                        pureShareRecord.Level = -1;
                        result.Add(pureShareRecord);
                    }
                }
            }

            result.AddRange(GetShareForFolders(folders));

            return(result);
        }
Esempio n. 2
0
        protected void SetSharedProperty(IEnumerable <FileEntry <string> > entries)
        {
            SecurityDao.GetPureShareRecords(entries.ToArray())
            //.Where(x => x.Owner == SecurityContext.CurrentAccount.ID)
            .Select(x => x.EntryId).Distinct().ToList()
            .ForEach(id =>
            {
                var firstEntry = entries.FirstOrDefault(y => y.ID.Equals(id));

                if (firstEntry != null)
                {
                    firstEntry.Shared = true;
                }
            });
        }
Esempio n. 3
0
        public IEnumerable <FileShareRecord> GetShares(FileEntry <string> entry)
        {
            var result = new List <FileShareRecord>();

            if (entry == null)
            {
                return(result);
            }


            var folders = new List <FileEntry <string> >();

            if (entry is Folder <string> entryFolder)
            {
                folders.Add(entryFolder);
            }

            if (entry is File <string> file)
            {
                GetFoldersForShare(file.FolderID, folders);

                var pureShareRecords = SecurityDao.GetPureShareRecords(entry);
                if (pureShareRecords != null)
                {
                    foreach (var pureShareRecord in pureShareRecords)
                    {
                        if (pureShareRecord == null)
                        {
                            continue;
                        }
                        pureShareRecord.Level = -1;
                        result.Add(pureShareRecord);
                    }
                }
            }

            result.AddRange(GetShareForFolders(folders));

            return(result);
        }
Esempio n. 4
0
 public IEnumerable <FileShareRecord> GetPureShareRecords(FileEntry <string> entry)
 {
     return(SecurityDao.GetPureShareRecords(entry));
 }