internal static IEnumerable <PhotoTDO> GetUnclaimedPhotos(Event ev, int page, int pageSize) { HashSet <PhotoTDO> photos = new HashSet <PhotoTDO>(); if (string.IsNullOrEmpty(ev.EventFolder)) { return(photos.AsEnumerable()); } // Getting the list of photos' extensions string imageExts = GetImageExts(); // Get all photos that belong to the event's folder string folder = (ev.EventFolder.EndsWith(Path.DirectorySeparatorChar.ToString()) ? ev.EventFolder : (ev.EventFolder + Path.DirectorySeparatorChar)) + Constants.STR_UNCLAIMED; try { string[] filenames = PagingFileUtils.GetFileNames(folder, imageExts, page, pageSize); foreach (string filename in filenames) { string thumbnail = GetThumbnailVirtualPath(ev.EventVirtualPath, filename); PhotoTDO photo = GenerateUnclaimedTDO(ev, filename, thumbnail); photos.Add(photo); } return(photos.OrderBy(p => p.Created)); } catch (ObjectNotFoundException) { return(photos.AsEnumerable()); } }
internal static IEnumerable <PhotoTDO> GetPhotos(Event ev) { if (string.IsNullOrEmpty(ev.EventFolder)) { throw new ArgumentNullException("Folder name is empty."); } HashSet <PhotoTDO> photos = new HashSet <PhotoTDO>(); // Get all photos that belong to the event string[] filenames = PagingFileUtils.GetFileNames(ev.EventFolder, GetImageExts()); string folder = ev.EventFolder.EndsWith(Path.DirectorySeparatorChar.ToString()) ? ev.EventFolder : (ev.EventFolder + Path.DirectorySeparatorChar); DirectoryInfo dirInfo = FotoShoutUtils.Utils.IO.DirectoryUtils.CreateSubFolder(folder, Constants.STR_THUMB); foreach (string filename in filenames) { bool succeeded = (dirInfo != null) ? ImageUtils.CreateThumbnailFileIfAny(folder + filename, GetThumbnailPath(folder, filename)) : false; string thumbnail = succeeded ? GetThumbnailVirtualPath(ev.EventVirtualPath, filename) : ""; PhotoTDO photo = GenerateTDO(ev, filename, thumbnail); photos.Add(photo); } return(photos.OrderBy(p => p.Filename)); }