Tuesday, May 25, 2010

CodePlex & Updated Versions

CodePlex is Microsoft's Open-Source repository, basically, their gift to the Open Source .NET developers out there. As such, it has a number of useful and worthwhile features in its code base for said Open Source developers, things such as issue trackers and discussion functions.

It's good and I like it.

But there is one place where it is lacking, and that's the ability to have the programs "call home" to the project page and make sure that they are the latest version of the software.

Ideally, the way this would work, is that we would provide a key on the release page, and when a RESTFUL API was called, that key would be returned. Then a simple compare would do the job.

Sadly, that doesn't exist.

Even more sadly, I wanted my project to be able to do this. Basically, my goal is that after the application launches (provided the user wishes for updates to be checked), the application would call the eComic home page, and found out the key for the current 'recommended' release. If it was not the "recommended" release, then an icon would be displayed, and when pressed, launch the eComic home page in the browser, ready for downloads.

Luckily, I figured out a way around this.

Since the site provides an RSS feed detailing project releases, I have a viewpoint into the current release. Or at least, the last release that was edited. The other thing that the site provides is the ability to create "Hidden" releases. Basically, these are releases that you've not finished 100% and thus are not released to the public yet. An important thing to note regarding these hidden releases is that they do not show up in the RSS feed.

So, what I did was I created the following settings in my application:

  • Check For Updates (User Setting)
  • Current Version (Application Setting)
  • Check Update Url (Application Setting)
With the Check for Updates setting, I will allow the user to turn on/off the ability to perform these checks. That's just a simple and nice setting that any application that performs these types of checks should implement.

The Check Update Url is basically a read-only setting, that is the RELEASES RSS feed from the eComic site.

Finally, the Current Version is a read-only setting, in which I placed the string identifier for this release.

After those settings were created, I went and generated a "Hidden" release, and got its Release Id from the query string.

I then plugged that Release Id into the Current Version setting.

Finally, I had a function which would perform a web request to the eComic RELEASE RSS feed. After grabbing the first item, I perform a simple compare on the associated link to see if the returned link held the Current Version value, and displayed my UPDATE icon accordingly.

Placing it into a Timer.Elapsed event kept if off my main thread (meaning that the update check would not impact usability) and made it a slight delay from the application launch as well. The final thing is that the whole kit-n-kaboodle is wrapped in a Try/Catch block as I don't want a failure to connect to the web server to bring down the whole application.




   1:   Private Sub _timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles _timer.Elapsed
   2:          Try
   3:              Dim request As HttpWebRequest = WebRequest.Create(My.Settings.UpdateUrl)
   4:              Dim response As HttpWebResponse = request.GetResponse
   5:              If response.StatusCode = HttpStatusCode.OK Then
   6:                  Dim xDoc As XDocument = XDocument.Load(response.GetResponseStream)

   7:   
   8:                  _currentVersionUrl = (From xe In xDoc.Descendants("item") _
   9:                                                   Select xe.Element("link").Value _
  10:                                                   ).Take(1).SingleOrDefault
  11:                  If Not String.IsNullOrEmpty(_currentVersionUrl) Then
  12:                      If Not _currentVersionUrl.Contains(My.Settings.CurrentRelease) Then
  13:                          Me.DisplayUpdate = True
  14:                      End If
  15:                  End If
  16:              End If
  17:   
  18:              ' Check to ensure the link is a VALID url 
  19:              If Me.DisplayUpdate Then
  20:                  Dim re2 As HttpWebRequest = WebRequest.Create(Me._currentVersionUrl)
  21:                  re2.AllowAutoRedirect = False
  22:                  re2.Method = "Head"
  23:                  re2.KeepAlive = False
  24:                  Dim res As HttpWebResponse = request.GetResponse
  25:                  If Not res.StatusCode = HttpStatusCode.OK Then Me.DisplayUpdate = False
  26:              End If ' Me.DisplayUpdate 
  27:   
  28:   
  29:          Catch ex As Exception
  30:              ' Do Nothing.  If this fails, then I'm not concerned, as I'll just continue happily with the current version 
  31:          End Try
  32:      End Sub

Monday, May 24, 2010

eComic 2010

Well, I finally got off my backside and slapped together the .NET 4.0 version of eComic.  In addition to all the enhancements which 4.0 provides to WPF I also streamlined the opening of the archive files, and added a host of additional features.

The most important of these are:

  • Rebuilt form in .NET 4
  • Rebuilt Comic opening engine to improve speed and performance
  • Removed manual zoom control
  • Implemented programmatic PAN/ZOOM functionality on mouse events and ribbon buttons
  • Added progress bar charting opening archive progress to status bar
  • Modified page number/page name to allow selection of pages via that function
  • Added icon to status bar to indicate type of file loaded
  • Added ability to open a directory of images
  • Added functionality to create simple CBZ file from an opened directory of images
  • Added support for a 'full screen' mode
  • Added additional buttons to RIBBON element for ease of access to the functions
  • Allow for DragDrop of a file from Explorer to force open

I'm still in the process of building documentation for the thing though, which is something I dislike, but you know how it is.

Blog Widget by LinkWithin