コード例 #1
0
        internal static IEnumerable <PhotoTDO> GetPublishAuthorizedPhotos(Event ev, FotoShoutDbContext db)
        {
            IEnumerable <Photo> photos           = ev.Photos.Where(p => (p.Status == (byte)PhotoStatus.Submitted));
            HashSet <PhotoTDO>  authorizedPhotos = new HashSet <PhotoTDO>();

            foreach (Photo photo in photos)
            {
                GuestPhoto gp = photo.GuestPhotos.Where(g => g.AuthorizePublish == false).FirstOrDefault();
                if (gp == null)
                {
                    authorizedPhotos.Add(EventPhotosService.GenerateTDO(ev, photo));
                }
            }

            return(authorizedPhotos);
        }
コード例 #2
0
        internal static IEnumerable <PhotoTDO> GetUnauthorizedPhotos(Event ev, FotoShoutDbContext db)
        {
            IEnumerable <Photo> photos             = ev.Photos.Where(p => (p.Status == (byte)PhotoStatus.Submitted));
            HashSet <PhotoTDO>  unauthorizedPhotos = new HashSet <PhotoTDO>();

            foreach (Photo photo in photos)
            {
                IEnumerable <GuestPhoto> gps = photo.GuestPhotos.Where(g => g.AuthorizePublish == false);
                if (gps != null && gps.Any())
                {
                    unauthorizedPhotos.Add(EventPhotosService.GenerateTDO(ev, photo));
                }
            }

            return(unauthorizedPhotos);
        }
コード例 #3
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("");
        }
コード例 #4
0
        internal static IEnumerable <PhotoTDO> GetProcessedPhotos(Event ev, string created, int page, int pageSize, FotoShoutDbContext db)
        {
            Func <Photo, Boolean> func;

            if (string.IsNullOrEmpty(created))
            {
                func = p => (p.Status == (byte)PhotoStatus.Submitted || p.Status == (byte)PhotoStatus.PendingPublish || p.Status == (byte)PhotoStatus.Published);
            }
            else
            {
                created = DateTime.Parse(created).ToShortDateString();
                func    = p => (p.Created.ToShortDateString().Equals(created, StringComparison.InvariantCultureIgnoreCase) && (p.Status == (byte)PhotoStatus.Submitted || p.Status == (byte)PhotoStatus.PendingPublish || p.Status == (byte)PhotoStatus.Published));
            }
            IEnumerable <Photo> photos = ev.Photos.Where(func).OrderBy(p => p.Created);

            if (page > 0 && pageSize > 0 && (photos.Count() > pageSize))
            {
                photos = photos.Skip((page - 1) * pageSize).Take(pageSize);
            }

            HashSet <PhotoTDO> tdos = new HashSet <PhotoTDO>();

            if (!photos.Any())
            {
                return(tdos);
            }

            foreach (Photo photo in photos)
            {
                PhotoTDO tdo = EventPhotosService.GenerateTDO(ev, photo);
                tdo.Guests = PhotoAnnotationService.GetGuestTDOs(photo, true);
                tdos.Add(tdo);
            }

            return(tdos);
        }