private TransitPostImageQueryOptions GetOptions() { TransitPostImageQueryOptions options = new TransitPostImageQueryOptions(); options.PageNumber = images.CurrentPageIndex; options.PageSize = images.PageSize; options.SortExpression = "Counter.Count"; options.SortDirection = WebServiceQuerySortDirection.Descending; options.Counters = true; return options; }
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; }
public void GetDataImages(object sender, EventArgs e) { images.CurrentPageIndex = 0; int pid = GetId("pid"); int index = GetId("index"); if (RequestId > 0) { if (pid > 0) { TransitPostImageQueryOptions options = new TransitPostImageQueryOptions(pid); options.PreferredOnly = PreferredOnly; images.CurrentPageIndex = index; images.VirtualItemCount = SessionManager.GetCachedCollectionCount<TransitImage>( "GetPostImagesCountEx", SessionManager.PostTicket, options); } else { images.VirtualItemCount = 1; } } images_OnGetDataSource(sender, e); images.DataBind(); panelImages.Update(); }
void images_OnGetDataSource(object sender, EventArgs e) { string sortexpression = Request.Params["SortExpression"]; string sortdirection = Request.Params["SortDirection"]; TransitPostImageQueryOptions options = new TransitPostImageQueryOptions( Post.Id, images.PageSize, images.CurrentPageIndex); options.SortDirection = string.IsNullOrEmpty(sortdirection) ? WebServiceQuerySortDirection.Ascending : (WebServiceQuerySortDirection)Enum.Parse(typeof(WebServiceQuerySortDirection), sortdirection); options.SortExpression = string.IsNullOrEmpty(sortexpression) ? "Image.Image_Id" : sortexpression; options.PreferredOnly = PreferredOnly; images.DataSource = SessionManager.GetCachedCollection<TransitPostImage>( "GetPostImagesEx", SessionManager.PostTicket, options); }
void GetImagesData(object sender, EventArgs e) { TransitPost post = Post; TransitPostImageQueryOptions imagesoptions = new TransitPostImageQueryOptions(Post.Id); imagesoptions.PreferredOnly = PreferredOnly; images.Visible = (post.ImagesCount > 1); images.CurrentPageIndex = 0; images.VirtualItemCount = SessionManager.GetCachedCollectionCount<TransitPostImage>( "GetPostImagesCountEx", SessionManager.PostTicket, imagesoptions); images_OnGetDataSource(sender, e); images.DataBind(); }
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; } }
public int GetPostImagesCountEx(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 COUNT(i) FROM Post p, PostImage pi, Image i"); if (options.Counters) q.AppendLine(", ImageCounter ic, Counter c"); q.AppendLine("WHERE p.Id = pi.Post.Id AND pi.Image.Id = i.Id"); if (options.Counters) q.AppendLine("AND i.Id = ic.Image.Id AND ic.Counter.Id = c.Id"); if (options != null && options.PostId > 0) { q.AppendLine(string.Format("AND p.Id = {0}", options.PostId)); } if (options != null && options.PreferredOnly) { q.AppendLine("AND i.Preferred = 1"); } IQuery query = session.CreateQuery(q.ToString()); if (options != null) { options.Apply(query); } return (int) query.UniqueResult<long>(); } }
public int GetPostImagesCount(string ticket, TransitPostImageQueryOptions options) { using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection())) { ISession session = DBlog.Data.Hibernate.Session.Current; CountQuery query = new CountQuery(session, typeof(DBlog.Data.PostImage), "PostImage"); if (options != null) options.Apply(query); return query.Execute<int>(); } }
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; } }