June 2006 Entries

Unfortunately, the rants about WGA causing a bluescreen are true. It happened a little while ago on my home PC. Thankfully, F8 booting into safemode still works, and I was able to restore my system to a daily checkpoint. Boy am I glad that was setup. Installing .net 1.1 sp1 worked fine, as did an audio driver I was missing.

After having to rollback to a system restore checkpoint.

Way to go, guys.

My high school principal died on Monday.

This is surreal. It feels like it was just last week that I was skipping class and getting a pep talk from Mr. Holmquist in North House. Worst of all, I went to school with his daughters. Amber was in my graduating class, but she was real into sports (and I wasn't). We had a couple of classes together but I was closer to her sister Kendra, a fellow thespian.

This is so confusing...I've been in the Holmquist house a couple of times, and now...we'll miss you, Mr. Holmquist. Alief is a sad town today.

In the unlikely event that either of my readers finds out any information about the funeral, please let me know. My cell is (281) 684-5688. Alternatively, if I find out anything I will post here.

update: I got this from a friend in the district:

The Holmquist family has made the following arrangements:

Viewing services will be at Forest Park on Westheimer at Dairy Ashford on Thursday evening from 6-8 p.m.  The memorial service will be held Friday morning at 11:00 a.m. at Memoria Drive United Methodist Church on Memorial Drive between Wilcrest and the Beltway.

Respectfully,

Paula Smith

posted @ Wednesday, June 07, 2006 12:40 AM | Feedback (0) | Filed Under [ .NET ]

I'm a little bit behind on my CS releases, as I just got around to installing a fresh copy of Community Server 2.0 to test things out for one of my sites. Since I was going to upgrade an existing CS 1.1 install, I tried that method first, but ended up starting over because the original config I had was single blog and I didn't have the time nor the patience to figure out how to hack 2.0 into a single-blog install with existing content.

However, thanks to Keyvan (che khabbar!), I was able to export the 1.1 content using an HttpHandler I hacked up for exporting CS 1.1 content to BlogML and import into a new, multi-blog install of 2.0. The first thing I did was nuke both the sample weblog and the sample weblog group. Then I created a new group and weblog and used the application key assigned to the new blog to import my posts. Here is the code I used to import a blogML file into a fresh copy of Community Server 2.0

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Collections"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="BlogML"%>
<%@ Import Namespace="BlogML.Xml"%>
<%@ Import Namespace="CommunityServer"%>
<%@ Import Namespace="CommunityServer.Components"%>
<%@ Import Namespace="CommunityServer.Blogs"%>
<script runat="server">
'Community Server 2.0 BlogML converter Beta
'Copyright Keyvan Nayyeri (www.nayyeri.net) - 2006
'BlogML Writer and Reader classes are provided by BlogML project (www.blogml.com)


    Public Class Reader

        Private _ApplicationKey As String
        Private _Blog As CommunityServer.Blogs.Components.Weblog
        Private _SitePath As String
        Private _BlogCommentCount As Integer
        Private _BlogTrackBackCount As Integer

        Sub New(ByVal ApplicationKey As String, ByVal SitePath As String)
            Me._ApplicationKey = ApplicationKey
            Me._SitePath = SitePath


            Dim objCSWeblogs As CommunityServer.Blogs.Components.Weblogs
            Me._Blog = objCSWeblogs.GetWeblog(Me._ApplicationKey)
        End Sub

        Public Sub LoadBlog(ByVal XML As String)
            Dim Blog As New BlogMLBlog
            Try
                Blog = BlogMLSerializer.Deserialize(New StringReader(XML))
            Catch ex As Exception
                Throw New Exception("Couldn't load your BlogML file. Maybe it is wellformedness")
            End Try
            Dim Categories As Hashtable
            Categories = ReadCategories(Blog)

            LoadPosts(Blog, Categories)

            UpdateStats(Blog)
        End Sub

        Private Function ReadCategories(ByVal Blog As BlogMLBlog) As Hashtable
            Dim CategoriesHash As New Hashtable
            For Each Category As BlogMLCategory In Blog.Categories
                Dim NewCategory As New PostCategory
                With NewCategory
                    .DateCreated = Category.DateCreated
                    .Description = Category.Description
                    .IsEnabled = Category.Approved
                    .Name = Category.Title
                    .ParentID = 0
                    .SectionID = Me._Blog.SectionID

                    Dim objCSCats As PostCategories
                    Try
                        objCSCats.CreateCategory(NewCategory)
                    Catch ex As Exception
                        Throw New ArgumentException("Error when tried to add categories to database")
                    End Try
                    CategoriesHash.Add(Category.ID, Category.Title)
                End With
            Next
            Return CategoriesHash
        End Function
        Private Sub LoadPosts(ByVal Blog As BlogMLBlog, ByVal CategoryHash As Hashtable)
            Dim LastPostAuthor As String
            Dim LastPostAuthorID As Integer
            Dim LastPostDate As Date
            Dim LastPostName As String
            Dim LastPostSubject As String




            For Each Post As BlogMLPost In Blog.Posts
                Dim NewPost As New CommunityServer.Blogs.Components.WeblogPost
                Dim objCSPosts As CommunityServer.Blogs.Components.WeblogPosts

                With NewPost
                    .PostID = Post.ID
                    .Body = Post.Content.UncodedText
                    .BlogPostType = CommunityServer.Blogs.Components.BlogPostType.Post
                    .Subject = Post.Title
                    .ThreadDate = Post.DateCreated
                    .UserTime = Post.DateCreated
                    .PostDate = Post.DateCreated
                    .UserTime = Post.DateCreated
                    .SectionID = Me._Blog.SectionID
                    .SetExtendedAttribute("EverPublished", CType(Post.Approved, Boolean))
                    .IndexInThread = True
                    .IsApproved = True
                    .IsAggregated = True
                    .IsLocked = False
                    .PostConfig = CommunityServer.Blogs.Components.BlogPostConfig.IsAggregated

                End With
                'Add categories
                If Post.Categories.Count > 0 Then
                    Dim NewPostCats(Post.Categories.Count) As String
                    For i As Integer = 0 To Post.Categories.Count - 1
                        NewPostCats(i) = CategoryHash(Post.Categories(i).Ref)
                    Next
                    NewPost.Categories = NewPostCats
                End If

                'Add attachments
                'TO DO: Check to add attachments with checking the source code when RTM version has been released.
                'Currently we can't load post attachments

                objCSPosts.Add(NewPost)

                'Temporary saving stats
                LastPostAuthor = NewPost.Username
                LastPostAuthorID = NewPost.AuthorID
                LastPostDate = NewPost.PostDate
                LastPostName = NewPost.Name
                LastPostSubject = NewPost.Subject

                LoadComments(NewPost, Post)
                LoadTrackBacks(NewPost, Post)
            Next

            'Update blog stats
            Me._Blog.MostRecentPostAuthor = LastPostAuthor
            Me._Blog.MostRecentPostAuthorID = LastPostAuthorID
            Me._Blog.MostRecentPostDate = LastPostDate
            Me._Blog.MostRecentPostName = LastPostName
            Me._Blog.MostRecentPostSubject = LastPostSubject
        End Sub
        Private Sub LoadComments(ByVal NewPost As Post, ByVal Post As BlogMLPost)
            If Post.Comments.Count > 0 Then
                For Each Comment As BlogMLComment In Post.Comments
                    Dim NewComment As New CommunityServer.Blogs.Components.WeblogPost
                    Dim objCSComments As CommunityServer.Blogs.Components.WeblogPosts

                    With NewComment
                        .Body = Comment.Content.UncodedText
                        .BlogPostType = Blogs.Components.BlogPostType.Comment
                        .Subject = Comment.Title
                        .ThreadDate = Comment.DateCreated
                        .UserTime = Comment.DateCreated
                        .PostDate = Comment.DateCreated
                        .UserTime = Comment.DateCreated
                        .SectionID = Me._Blog.SectionID
                        .SetExtendedAttribute("EverPublished", True)
                        .SetExtendedAttribute("TitleUrl", Comment.UserUrl)
                        .SetExtendedAttribute("SubmittedUserName", Comment.UserName)
                        .IsApproved = CType(Comment.Approved, Boolean)
                        .ParentID = NewPost.PostID
                        .ThreadID = NewPost.ThreadID

                    End With

                    objCSComments.Add(NewComment)

                    'Update blog counter
                    Me._BlogCommentCount += 1
                Next
            End If
        End Sub
        Private Sub LoadTrackBacks(ByVal NewPost As Post, ByVal Post As BlogMLPost)
            If Post.Trackbacks.Count > 0 Then
                For Each TrackBack As BlogMLTrackback In Post.Trackbacks
                    Dim NewTrackBack As New Blogs.Components.WeblogPost
                    Dim objCSTrackBacks As Blogs.Components.WeblogPosts

                    With NewTrackBack
                        .Body = TrackBack.Title
                        .BlogPostType = Blogs.Components.BlogPostType.Trackback
                        .Subject = TrackBack.Title
                        .ThreadDate = TrackBack.DateCreated
                        .UserTime = TrackBack.DateCreated
                        .PostDate = TrackBack.DateCreated
                        .UserTime = TrackBack.DateCreated
                        .SectionID = Me._Blog.SectionID
                        .SetExtendedAttribute("EverPublished", True)
                        .SetExtendedAttribute("TitleUrl", TrackBack.Url)
                        .SetExtendedAttribute("trackbackName", "TrackBack")
                        .IsApproved = CType(TrackBack.Approved, Boolean)
                        .ParentID = NewPost.PostID
                        .ThreadID = NewPost.ThreadID

                    End With

                    objCSTrackBacks.Add(NewTrackBack)

                    'Update blog counter
                    Me._BlogTrackBackCount += 1
                Next
            End If
        End Sub
        Private Sub UpdateStats(ByVal Blog As BlogMLBlog)
            Me._Blog.PostCount += Blog.Posts.Count
            Me._Blog.CommentCount = Me._BlogCommentCount
            Me._Blog.TrackbackCount = Me._BlogTrackBackCount
        End Sub

    End Class

    Sub Page_Load(sender as Object, e as EventArgs)
    	Dim Path as String = "d:\tmp\BlogML\BlogML.xml"
    	Dim reader as New Reader("chris", Request.PhysicalApplicationPath)

    	If File.Exists(Path) Then
    		Dim sr as New StreamReader(File.Open(Path, FileMode.Open))
    		Dim xml as string = sr.ReadToEnd

    		reader.LoadBlog(xml)

    		Response.Write("Content moved successfully!")
    	Else
    		Response.Write("Uh-oh. Something crapped.")
    	End If

    End Sub

</script>
<html>
    <head>
    </head>
    <body>
        <form runat="server">
            <!-- Insert content here -->
        </form>
    </body>
</html>

I hacked up this file in WebMatrix and slapped it into the webroot of my new CommunityServer install. This way I was able to copy the content to a local install before pushing the final product out into the wild, and I didn't have to recompile any of CS to get it working. Merci, Keyvan!