Folder2Page Plugin

Posted by beakersoft | Posted in Programming | Posted on 11-02-2010

0

Just a quick post to point you in the direction of my latest (ok second ever!) plugin for wordpress. Its called folder2page, you can check out more info at beakersoft.co.uk/folder2page

Its a simple plugin that will allow you to use a directory of images you have on your web space as a simple gallery on page in your blog. There seemed to be a lot of plugins out there for getting images from flickr and other image hosting services, but not much if you wanted to get at the images your self.

Any comments, suggestions etc please let me know!

WordSlice – My First WordPress plugin

Posted by beakersoft | Posted in Programming | Posted on 15-06-2009

3

I while ago I wrote an artical (here)about the new Web slice feature in IE8. A few people have asked about a plugin for WordPress, and the other night I finally decided to have a go.

Head over to http://www.beakersoft.co.uk/wordslice for all the info, or to http://wordpress.org/extend/plugins/wordslice/ for the download and the install notes.

Hopefully in the not to distant future i will be add some extra features to it (its kind of limited at the moment) so stay tuned!

Creating a Check for update Routine

Posted by beakersoft | Posted in Programming | Posted on 07-10-2008

1

First off, i apologise for not blogging for a while, ive had quite a few other projects on over the summer, plus holidays so I’ve not really had time. Hopefully now I should be able to get back into it with a bit more frequency.

Anyway on to the topic of this post. Most applications nowadays will automaticly go onto the web and check to see if there is a new version, and if there is offer to download/install/visit page etc. I was looking for a simple way to do this using the dotnet framework and Visual Basic.Net, and came across the System.Net class.

This class is extremely powerful, as it contains functions for network communication.  The main one we will use here is the System.net.WebClient. We are going to use this to pull a file down of our web server that will give us information about the latest version of our application.

Information File

So first of all, create a text file, we are going to look on our web server for this file and read information. In the file we will have the following info: App name, version and download location, delimited by a pipe (|) character. You could also add extra things like new features, release date etc to this file. The example file will look something like this.

1.1.0|TestApp|www.beakersoft.co.uk/downloads/

Once you have this file, save it as something like TestApp_Ver_Control.txt, and upload it to your web server.

Downloading the Version information

Now the file containing version information is on your web server, we can write a function in vb that will open the file up, get the information contained in it and use that information to decided if our application is the latest version or not. This is where the System.net.WebClient comes in. First of declare a couple of variables. One is the WebClient, one is the url of the file you have just uploaded and a string array to hold the details of the file.

Dim myWebClient As New Net.WebClient
Dim RemoteUri As String = "www.beakersoft.co.uk/TestApp_Ver_Control.txt"
Dim strFileInfo()As String

Now, we can go and get the file of the web server, using the webclient and read the contents into a string. Then we can split the content of the string up using the pipe char, and there you have all the info you need to check the version.

All the code is wrapped up in a try/catch block to make sure we dont get any unhandled errors such as when there is no net connection, file missing etc.

	Try
	Dim file As New System.IO.StreamReader( _
                    myWebClient.OpenRead(RemoteUri))
        Dim Contents As String = file.ReadToEnd()

	'Split up the sections of the text based on the pipe (|) delimiator
	strFileInfo = Split(Contents, "|")

	'see if we need a new version
	If strFileInfo(0) > Application.ProductVersion Then
		'if we have a new version, make sure the app name matchs from the file
                If strFileInfo(1) = application.ProductName Then

			'we have a new version! So throw up a message, set a flag ect

                End If
	End If

	'close the file stream and web client
	myWebClient = Nothing
	file.Close()

        Catch ex As Exception
	If InStr(ex.Message, "(404)") Then
		'404 means file not found on webserver
                Msgbox("Problem Finding the update information file - " & vbNewLine & ex.Message & _
                        vbNewLine & "Please contact the appliaction vendor")
	Else
                Msgbox("Problem getting update information - " & vbNewLine & ex.Message & _
                        vbNewLine & "Check your internet settings and try again")
	End If
End Try

And thats pritty much it! This is a very bare bones way of doing it, and you probably want to add in support for using a proxy (you can do that using the System.Net.WebRequest.DefaultWebProxy class, and pass login credentials to myWebClient.Credentials using Net.NetworkCredential ) but as a very basic form this should work.

Error Logging ASP.Net with Elmah

Posted by beakersoft | Posted in Programming | Posted on 23-05-2008

1

I’ve been in the situation a few times with ASP.Net applications where someone says to you ‘I got this error on screen when I did x, I don’t know what it said but i couldn’t work.’

Odds are you have got an unhanded exception in your web application, but how are you meant to debug it when the error has long gone? Elmah (error logging and error handling modules for asp.net) may well be your saviour. Download it out now from http://code.google.com/p/elmah/

So, what does it do?

Well, once you have it configured on your application or server, every time something causes an unhanded exception it will log it into a database, send you an email alert and fix the code for you (last part was a joke!). So, now when the user tells you they have had an problem you can look in the system and see exactly what happened.

elmah example

The application is open source, and is based on the article at http://msdn.microsoft.com/en-us/library/aa479332.aspx, check that article out if you want to know more about how it was written

Installing it

You can run it in two ways, on a particular web application or at the server level. As I was a bit confused at first as to how to set it up, here is a quick guide to installing it for an individual application and log the errors onto a SQL 2000 server.

  1. Download the zip file from the website, if you are using dotnet 2.0 you will need the latest beta version.
  2. Extract the files, in the src/Elmah/ folder find the Database.sql script. This is the script that will build the tables it needs. Create a new database and run this script on the database
  3. Next, go into the bin/net-2.0/Release/ folder, and copy the Elmah.dll and Elmah.xml files into you applications /bin folder
  4. Once you have the assembly, you need to configure your application to use it. You do this by adding some sections into your applications web.config file. In the /samples folder there is an example web.config file you can get all the information out of to put in your file. For the most part it is easy to follow, but I had a couple of problems.
  5. The first one was the database connection, make sure you add a new connection to your <connectionStrings> section that points at the database you have created.
  6. You then need to point to this connection in the connectionStringName section of the elmah errorLog.
  7. Once you have added the other sections into your config file you should just be able to browse to your site /elmah.axd to see your errors

You can also configure options such as getting it to send an email when an exception occurs, subscribe to the log as an rss feed etc.

So now you should have a handy reference point for all your exemptions. You can tell the user you are looking into there problem before they even report it to you!