Esempio n. 1
0
    void images_OnGetDataSource(object sender, EventArgs e)
    {
        int pid = GetId("pid");

        List<TransitPostImage> list = null;
        if (pid > 0)
        {
            TransitPostImageQueryOptions options = new TransitPostImageQueryOptions(
                    pid, images.PageSize, images.CurrentPageIndex);
            options.PreferredOnly = PreferredOnly;

            string sortexpression = Request.Params["SortExpression"];
            string sortdirection = Request.Params["SortDirection"];

            if (!string.IsNullOrEmpty(sortexpression)) options.SortExpression = sortexpression;
            if (!string.IsNullOrEmpty(sortdirection)) options.SortDirection = (WebServiceQuerySortDirection)Enum.Parse(
                typeof(WebServiceQuerySortDirection), sortdirection);

            list = SessionManager.GetCachedCollection<TransitPostImage>(
                "GetPostImagesEx", SessionManager.PostTicket, options);
        }
        else
        {
            TransitImage image = SessionManager.GetCachedObject<TransitImage>(
                "GetImageById", SessionManager.PostTicket, RequestId);
            TransitPostImage postimage = new TransitPostImage();
            postimage.Image = image;
            postimage.Post = null;
            postimage.Id = RequestId;
            list = new List<TransitPostImage>();
            list.Add(postimage);
        }

        linkBack.NavigateUrl = ReturnUrl;

        if (list.Count > 0)
        {
            PostImage = list[0];
            /*
            linkComment.NavigateUrl = string.Format("EditImageComment.aspx?sid={0}&r={1}",
                PostImage.Image.Id, Renderer.UrlEncode(UrlPathAndQuery));
             */
        }

        GetEXIFData(sender, e);
        GetDataComments(sender, e);

        images.DataSource = list;
    }
Esempio n. 2
0
        public List<TransitPostImage> GetPostImagesEx(string ticket, TransitPostImageQueryOptions options)
        {
            using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
            {
                ISession session = DBlog.Data.Hibernate.Session.Current;

                StringBuilder q = new StringBuilder();

                q.AppendLine("SELECT {PostImage.*} FROM Post, PostImage {PostImage}, Image");
                if (options.Counters) q.AppendLine(", ImageCounter, Counter");
                q.AppendLine("WHERE Post.Post_Id = {PostImage}.Post_Id AND {PostImage}.Image_Id = Image.Image_Id");
                if (options.Counters) q.AppendLine("AND Image.Image_Id = ImageCounter.Image_Id AND ImageCounter.Counter_Id = Counter.Counter_Id");

                if (options != null && options.PostId > 0)
                {
                    q.AppendLine(string.Format("AND Post.Post_Id = {0}", options.PostId));
                }

                if (options != null && options.PreferredOnly)
                {
                    q.AppendLine("AND Image.Preferred = 1");
                }

                //if (options != null && !string.IsNullOrEmpty(options.SortExpression))
                //{
                //    q.AppendLine(string.Format("ORDER BY {0} {1}",
                //        Renderer.SqlEncode(options.SortExpression),
                //        options.SortDirection == WebServiceQuerySortDirection.Ascending ? string.Empty : "DESC"));
                //}

                IQuery query = session.CreateSQLQuery(q.ToString(), "PostImage", typeof(PostImage));

                if (options != null)
                {
                    options.Apply(query);
                }

                IList list = query.List();

                List<TransitPostImage> result = new List<TransitPostImage>(list.Count);
                int index = (options != null) ? options.FirstResult : 0;

                foreach (PostImage obj in list)
                {
                    TransitPostImage tpi = new TransitPostImage(session, obj, ticket);
                    tpi.Index = index;
                    index++;
                    result.Add(tpi);
                }

                return result;
            }
        }
Esempio n. 3
0
 public string GetImageUri(TransitPostImage ti)
 {
     StringBuilder result = new StringBuilder();
     result.AppendFormat("ShowImage.aspx?id={0}&pid={1}&index={2}",
         ti.Image.Id, ti.Post.Id, ti.Index);
     if (PreferredOnly) result.Append("&PreferredOnly=true");
     if (!string.IsNullOrEmpty(Request.Params["SortExpression"])) result.AppendFormat("&SortExpression={0}", Request.Params["SortExpression"]);
     if (!string.IsNullOrEmpty(Request.Params["SortDirection"])) result.AppendFormat("&SortDirection={0}", Request.Params["SortDirection"]);
     return result.ToString();
 }
Esempio n. 4
0
        public List<TransitPostImage> GetPostImages(string ticket, TransitPostImageQueryOptions options)
        {
            using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
            {
                ISession session = DBlog.Data.Hibernate.Session.Current;

                ICriteria cr = session.CreateCriteria(typeof(PostImage));

                if (options != null)
                {
                    options.Apply(cr);
                }

                IList<PostImage> list = cr.List<PostImage>();

                List<TransitPostImage> result = new List<TransitPostImage>(list.Count);

                int index = (options != null) ? options.FirstResult : 0;
                foreach (PostImage obj in list)
                {
                    TransitPostImage tpi = new TransitPostImage(session, obj, ticket);
                    tpi.Index = index;
                    index++;
                    result.Add(tpi);
                }

                return result;
            }
        }