Dev Log Date 25.07.06 - Listings 2.0

I've started work on the Listings 2.0 CS page.  This page will use Community Server completly, so it'll be made open source at the end of the project, so you can add bits to it to make it better.

For my 1st post, lets take a look at the new listings object provider class, new in 2.0.

The Listings Object Provider consits of 2 parts, the listing class, which is just a definition of wat the listing has in it, and the listingsdata class, which is a list of listings.

Listing.vb

Public Class listing

    Private _title, _url, _body, _build, _version, _versionlink As String
    Private _postid As Integer

    Public ReadOnly Property PostId() As Integer
        Get
            Return _postid
        End Get
    End Property

    Public Property title() As String
        Get
            Return _title
        End Get
        Set(ByVal value As String)
            _title = value
        End Set
    End Property

    Public Property body() As String
        Get
            Return _body
        End Get
        Set(ByVal value As String)
            _body = value
        End Set
    End Property

    Public Property url() As String
        Get
            Return _url
        End Get
        Set(ByVal value As String)
            _url = value
        End Set
    End Property

    Public Property build() As String
        Get
            Return _build
        End Get
        Set(ByVal value As String)
            _build = value
        End Set
    End Property

    Public ReadOnly Property version() As String
        Get
            Return _version
        End Get
    End Property

    Public ReadOnly Property versionLink() As String
        Get
            Return _version
        End Get
    End Property

    Public Sub New(ByVal Title As String, ByVal Body As String, ByVal URL As String, ByVal Build As String, ByVal PostId As Integer)
        Dim row As DS.nb_CsBuildsRow = CommonFunctions.getBuildDetails(Build)
        _title = Title
        _url = URL
        _body = Body
        _build = Build
        _postid = PostId
        _version = row.BuildVersion
        _versionlink = row.BuildDocsLink
    End Sub

End Class

ListingsData.vb

Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports CommunityServer
Imports CommunityServer.Components
Imports CommunityServer.Blogs.Components

Public Class ListingsData

    Public Function GetAllListings() As List(Of listing)
        Dim listings As New List(Of listing)
        Try
            For Each p As WeblogPost In CommonFunctions.getBlogPosts(56).Threads
                listings.Add(New listing(p.Subject, CommonFunctions.FilterBody(p.Body), CommonFunctions.FilterUrl(p.Body), CommonFunctions.FilterBuild(p.Body), p.PostID))
            Next
        Catch e As SqlException
            ' Handle exception.
        End Try

        Return listings
    End Function

End Class

The 2nd class is quite simple at the moment, but this will change as the project goes on.

Right, here's wat the CommonFunctions.VB class currently looks like

 Imports CommunityServer
Imports System.Text.RegularExpressions

Public Class CommonFunctions


    Public Shared Function getBuildDetails(ByVal build As String) As DS.nb_CsBuildsRow
        Dim aptlist As New DSTableAdapters.nb_CsBuildsTableAdapter
        aptlist.Connection.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("SiteSQLServer").ConnectionString
        Return aptlist.GetBuild(build)(0)
    End Function

    Public Shared Function getBlogPosts(ByVal SectionId As Integer) As Components.ThreadSet
        Dim query As New Blogs.Components.BlogThreadQuery()
        query.SectionID = SectionId
        query.PageSize = 9999999
        query.BlogPostType = Blogs.Components.BlogPostType.Post
        Return Blogs.Components.WeblogPosts.GetBlogThreads(query, False, False)
    End Function

    Public Shared Function FilterUrl(ByVal Body As String) As String
        Try
            Dim str As String() = Regex.Split(Body, "(\[site:)|(\])|(\[\/site])", RegexOptions.IgnoreCase Or RegexOptions.ECMAScript)
            Return str(4)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Public Shared Function FilterBuild(ByVal Body As String) As String
        Try
            Dim str As String() = Regex.Split(Body, "(\[site:)|(\])|(\[\/site])", RegexOptions.IgnoreCase Or RegexOptions.ECMAScript)
            Return str(2)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Public Shared Function FilterBody(ByVal Body As String) As String
        Try
            Dim str As String() = Regex.Split(Body, "(\[site:)|(\])|(\[\/site])", RegexOptions.IgnoreCase Or RegexOptions.ECMAScript)
            Return str(0)
        Catch ex As Exception
            Return ""
        End Try
    End Function

End Class

Lovely, and if your .net minded, you'll have noticed the Regex class there.  This is because i use a bit of the body, which looks like: [site:build]url[/site]; to add the extra listings bits to the CS blog. Nifty isn't it.

 

Not much else to say yet, that's all I've done in the last 3 hours, so I can't complain much.  I'm going to slowly get the listings up to working order soon, but it'll take a while.  And with listings 2.0, will be a new design of the listings, something a more IE6 friendly is in order Angel

Anyhow...

/* end of log */ 


Posted Jul 25 2006, 02:35 AM by Nick