Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                if (SessionManager.CountersEnabled)
                {
                    SessionManager.BlogService.IncrementNamedCounter(
                        SessionManager.Ticket, "SiteMap", 1);
                }

                TransitPostQueryOptions options = new TransitPostQueryOptions(0, string.Empty);
                options.PageNumber = 0;
                options.PageSize = 100;
                options.SortDirection = WebServiceQuerySortDirection.Descending;
                options.SortExpression = "Created";
                options.PublishedOnly = true;
                options.DisplayedOnly = true;

                repeater.DataSource = SessionManager.GetCachedCollection<TransitPost>(
                    "GetPosts", SessionManager.PostTicket, options);
                repeater.DataBind();
            }
        }
        catch (Exception ex)
        {
            Response.StatusCode = 400;
            Response.Status = ex.Message;
        }
    }
Exemple #2
0
 public void GetData(object sender, EventArgs e)
 {
     // total number of items
     int total = SessionManager.GetCachedCollectionCount<TransitPost>("GetPostsCount",
         SessionManager.PostTicket, null);
     // number of items left
     int left = total - ((CurrentPageIndex + 1) * PageSize);
     // previous link
     linkPrev.Enabled = (CurrentPageIndex > 0);
     if (CurrentPageIndex > 0)
     {
         linkPrev.Text = string.Format("&#171; Prev {0}", PageSize);
         linkPrev.NavigateUrl = string.Format("ListBlog.aspx?page={0}", CurrentPageIndex - 1);
     }
     // next link
     linkNext.Enabled = (left > 0);
     if (left > 0)
     {
         linkNext.NavigateUrl = string.Format("ListBlog.aspx?page={0}", CurrentPageIndex + 1);
         linkNext.Text = string.Format("Next {0} &#187;", PageSize > left ? left : PageSize);
     }
     TransitPostQueryOptions options = new TransitPostQueryOptions(PageSize, CurrentPageIndex);
     options.SortDirection = WebServiceQuerySortDirection.Descending;
     options.SortExpression = "Created";
     options.PublishedOnly = ! SessionManager.IsAdministrator;
     options.DisplayedOnly = !SessionManager.IsAdministrator;
     grid.DataSource = SessionManager.GetCachedCollection<TransitPost>(
         "GetPosts", SessionManager.PostTicket, options);
     grid.DataBind();
 }
Exemple #3
0
    private void GetPosts(object sender, EventArgs e)
    {
        TransitPostQueryOptions options = new TransitPostQueryOptions();
        options.PageNumber = 0;
        options.PageSize = 25;
        options.SortDirection = WebServiceQuerySortDirection.Descending;
        options.SortExpression = "Created";
        options.PublishedOnly = true;
        options.DisplayedOnly = true;

        Response.ContentType = "application/atom+xml;charset=\"utf-8\"";

        AtomFeed feed = new AtomFeed();
        feed.Title = new AtomTextConstruct(SessionManager.GetSetting("title", "Untitled"));

        List<TransitPost> posts = SessionManager.GetCachedCollection<TransitPost>(
            "GetPosts", SessionManager.PostTicket, options);

        foreach (TransitPost post in posts)
        {
            AtomEntry atomEntry = GetPost(post);
            feed.AddEntry(atomEntry);
        }

        feed.Save(Response.OutputStream);
        Response.End();
    }
Exemple #4
0
    private TransitPostQueryOptions GetOptions()
    {
        TransitPostQueryOptions options = new TransitPostQueryOptions(TopicId, Query, grid.PageSize, grid.CurrentPageIndex);

        options.DateStart = DateStart;
        options.DateEnd = DateEnd;

        options.PublishedOnly = ! SessionManager.IsAdministrator;
        options.DisplayedOnly = ! SessionManager.IsAdministrator;

        options.SortDirection = WebServiceQuerySortDirection.Descending;
        options.SortExpression = string.IsNullOrEmpty(options.Query) ? "Created" : "Rank";

        return options;
    }
Exemple #5
0
 public int GetPostsCount(string ticket, TransitPostQueryOptions options)
 {
     using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
     {
         ISession session = DBlog.Data.Hibernate.Session.Current;
         CountQuery query = new CountQuery(session, typeof(DBlog.Data.Post), "Post");
         if (options != null)
         {
             options.Apply(query);
         }
         if (options != null) options.Apply(query);
         return query.Execute<int>();
     }
 }
Exemple #6
0
        public List<TransitPost> GetPosts(string ticket, TransitPostQueryOptions options)
        {
            using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
            {
                ISession session = DBlog.Data.Hibernate.Session.Current;
                StringCriteria criteria = new StringCriteria(session, "Post", typeof(Post));

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

                IQuery sqlquery = criteria.CreateQuery();

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

                IList list = sqlquery.List();

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

                foreach (Post obj in list)
                {
                    result.Add(new TransitPost(session, obj, ticket));
                }

                return result;
            }
        }