Mobile Version Save 'Beakersoft Blogg' to Facebook post 'Beakersoft Blogg' to del.icio.us post 'Beakersoft Blogg' to digg subscribe to 'Beakersoft Blogg' posts via feed

Latest Digg Tech Headlines


'60 Minutes': How online gamblers unmasked c... (126 diggs)
How to Recover Data From a Dead Hard Drive (462 diggs)
Power.com: For Social Networking Power Users (269 diggs)
SanDisk plans hat trick of SSD performance i... (312 diggs)
ISP's secret opt-in advertising test draws t... (306 diggs)
24 Free Christmas Photoshop Tutorials (395 diggs)
Sons of Macintosh: Shaking the Apple Family ... (373 diggs)

Programming


Programming07 Oct 2008 07:07 pm
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4 out of 5)
Loading ... Loading ...

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.

Programming23 May 2008 10:02 am
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4 out of 5)
Loading ... Loading ...

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!

Programming24 Mar 2008 06:42 pm
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4 out of 5)
Loading ... Loading ...

Wordpress and Webslices header

One of the new features in the beta of Internet Explorer 8 is something called Webslices. These work in a similar way to RSS feeds, but allow you to subscribe to a section of a web page, as opposed to just a feed. The section of the page you subscribe to is a div with a class name of hsclice.

If a page contains webslice’s that can be subscribed to, a little purple icon shows in the IE tool bar, along with any rss feed options for the page. If you click on the webslice option a new link appears in the favorites bar, when you click on this you get the contents of the div. If the content of the div is updated, the item in the favorites bar shimmers and goes bold to inform you of the update.

Webslice

So, I have written a small php script that can be used on a Wordpress blog to subscribe to the 7 last posts as a webslice. At the moment all I have is a script, but if people are interested I can turn it into a Wordpress plugin. You can download all the parts as a .zip file at the end of the post, but here is what it contains

  • readme.txt - This file contains the bit of HTML code you need to insert in your index.php file (or where ever you want the webslice subscription option to show) and more detailed install information.
  • webslice.php - The actual file that contains a div with the last 7 posts
  • webslice.css - Style sheet for the php file

When you have downloaded the files, change the css to suite you, insert the div code into your page, upload to the server and away you go.

More Info on the script

When I first looked at adding a webslice to my Wordpress blog, I thought i would just place the hslice div around the existing previous posts section in my side bar. I went away from that idea though as I wanted the ability to format it differently, maybe add a graphic to the bottom etc so i went with an external file.

To make the page flag as having a webslice, but re-direct it to another page for the actual div, I used the class=”feedurl” option in the div. This just tells IE to look in a different place for the actual content. You can tell it to look at a page or an rss feed. The div containing all this info is hidden so it doesn’t interfere with any of the existing front page content.

The script it’s self is very straight forward. It just looks in your Wordpress DB for the last 7 (you can easily change this) posts , and puts them into n unordered list on the page, the formating is controlled by an external style sheet.

Please note this might not be 100% reliable. IE 8 is still in beta so its possible (but unlikely) the way it handles Webslices could change. I have also only tested this on one machine running the new IE, so it might not always work right. If you have problems get in contact and ill try and iron them out.

As I mentioned before if there is enough interest I might turn it into a plugin

Download The Zip Archive

Download the script: wordpress_webslice.zip

Programming03 Jan 2008 10:13 pm
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4 out of 5)
Loading ... Loading ...

Header

I went on Holiday to the German Beer festival, Oktoberfest and wanted to be able to upload photos from my camera phone onto Flickr, so I can put them onto a website I run. I also wanted to put the pictures onto a Google map. There were quite a few things that would allow me to do this, but none met my criteria:

  • Most of the scrips i found were PHP or .net, I needed an classic asp one
  • I needed to be able to tag the GPS co-ords into a tag on the photo. My camera phone did not have GPS built in, so I wanted to add two tags to them containing the info, called geo:lat=[xxx] and geo:lon=[xxx]

So, I came up with this script, you can see it in action at http://www.oldmanales.co.uk/feat_OktoberFest07.asp

In order to use the script, you will need a couple of things:

Once you have these, change the API key values to yours in the script, then upload it to your server. Now, call the script something like this:

FlickrTags2Google.asp?lat=11.511955&long=48.129893&tags=Oktoberfest_07&flickrID=7389734@N03

The lat and long parts of the string are where in the world the map will be placed when the pages loads, the tags are a comma separate list of tags to show on the map, in this case everything I have tagged as Oktoberfest_07. The last parameter is your flickrID.

Hopefully, when your call the page now you should get something like the screen shots below, the photos are indicated by the little camera icon, when you click on them you should get a popup preview of the image along with some info on the photo:

Preview1

Download The ASP Script

Download the file :FlickrTags2Google.asp
(and dont forget to rename it to a .asp extension otherwise it wont run.)

Hopefully when I get time I will document the code a bit better. If you find problems with it, or have any good ideas for enhancements let me know.

Next Page »

Page 1 of 512345»