示例#1
0
        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());
            }
        }
示例#2
0
        internal static int GetNumPhotos(Event ev)
        {
            if (string.IsNullOrEmpty(ev.EventFolder))
            {
                throw new ArgumentNullException("Folder name is empty.");
            }

            // Get number of photos that belong to the event
            return(PagingFileUtils.GetNumFiles(ev.EventFolder, GetImageExts()));
        }
示例#3
0
        internal static int GetNumUnclaimedPhotos(Event ev)
        {
            if (string.IsNullOrEmpty(ev.EventFolder))
            {
                throw new ArgumentNullException("Folder name is empty.");
            }

            // Get number of unclaimed photos belong to the event
            string folder = (ev.EventFolder.EndsWith(Path.DirectorySeparatorChar.ToString()) ? ev.EventFolder : (ev.EventFolder + Path.DirectorySeparatorChar)) + Constants.STR_UNCLAIMED;

            try {
                return(PagingFileUtils.GetNumFiles(folder, GetImageExts()));
            }
            catch (DirectoryNotFoundException) {
                return(0);
            }
        }
示例#4
0
        internal static string GetThumbnailUrl(int eventId, string physicalPath, string virtualPath, FotoShoutDbContext db)
        {
            // Getting the list of photos' extensions
            string imageExts = EventPhotosService.GetImageExts();
            // Get the first photo that belongs to the event's folder
            string filename = PagingFileUtils.GetFirstFileName(physicalPath, imageExts);

            if (!string.IsNullOrEmpty(filename))
            {
                string        folder    = physicalPath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? physicalPath : (physicalPath + Path.DirectorySeparatorChar);
                DirectoryInfo dirInfo   = FotoShoutUtils.Utils.IO.DirectoryUtils.CreateSubFolder(folder, Constants.STR_THUMB);
                bool          succeeded = (dirInfo != null) ? ImageUtils.CreateThumbnailFileIfAny(folder + filename, GetThumbnailPath(folder, filename)) : false;
                if (succeeded)
                {
                    return(GetThumbnailVirtualPath(virtualPath, filename));
                }
            }

            return("");
        }
示例#5
0
        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));
        }