Пример #1
0
        public TransitImage(ISession session, DBlog.Data.Image o, bool withthumbnail, bool withdata, bool hasaccess)
            : base(o.Id)
        {
            Name = o.Name;
            Path = o.Path;

            Counter = TransitCounter.GetAssociatedCounter <DBlog.Data.Image, ImageCounter>(
                session, o.Id);

            if (hasaccess)
            {
                Preferred   = o.Preferred;
                Description = o.Description;
                Modified    = o.Modified;

                CommentsCount = 0;

                // hack: disable comments, using disqus
                //CommentsCount = new CountQuery(session, typeof(ImageComment), "ImageComment")
                //    .Add(Expression.Eq("Image.Id", o.Id))
                //    .Execute<int>();

                if (withthumbnail)
                {
                    Thumbnail = o.Thumbnail;
                }

                if (withdata)
                {
                    Data = o.Data;
                }
            }
        }
Пример #2
0
        public static bool HasAccess(ISession session, DBlog.Data.Image image, string ticket)
        {
            if (image.PostImages == null || image.PostImages.Count == 0)
            {
                return(true);
            }

            foreach (PostImage pi in image.PostImages)
            {
                if (TransitPost.GetAccess(session, pi.Post, ticket))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        public DBlog.Data.Image GetImage(ISession session, bool withdata)
        {
            DBlog.Data.Image image = (Id != 0) ? (DBlog.Data.Image)session.Load(typeof(DBlog.Data.Image), Id) : new DBlog.Data.Image();
            image.Name        = Name;
            image.Description = Description;
            image.Modified    = DateTime.UtcNow;
            image.Path        = Path;
            image.Preferred   = Preferred;

            if (withdata)
            {
                image.Data      = Data;
                image.Thumbnail = Thumbnail;

                if (image.Thumbnail == null && image.Data != null)
                {
                    image.Thumbnail = new ThumbnailBitmap(image.Data).Thumbnail;
                }
            }

            return(image);
        }
Пример #4
0
 public TransitImage(ISession session, DBlog.Data.Image o, bool withthumbnail, bool withdata, string ticket)
     : this(session, o, withthumbnail, withdata, HasAccess(session, o, ticket))
 {
 }
Пример #5
0
 public TransitImage(ISession session, DBlog.Data.Image o, string ticket)
     : this(session, o, false, false, HasAccess(session, o, ticket))
 {
 }