Wednesday, 28 April 2010

Creating a Virtual Hard Drive from an Existing Macine

This shows how to create a VHD from an existing non-virtual PC.

For windows XP or greater it is very easy.

Disk2VHD is a free microsoft utility that runs under windows and created a VHD on the same computer, that is a model of the machine. This can be attached to a virtual machine in Virtual PC and started. All that is required is sufficient disk space on the machine to create this VHD. On the first machine I tried this on it took a few hours to build.


For Windows 2000 and older this approach will not work.
I am testing a shareware utility called WinImage (winima85.exe)
This did not work either.

Final course, I am going to pull the HD out of the laptop running windows 2000, plug it into a Windows 7 machine, and use Disk2VDH to clone it from there.





Thursday, 1 April 2010

Unknown server tag telerik:grid

When trying to open aspx forms that contained Telerik controls I received the error message, "Unknown server tab telerik:grid". My colleague was able to open thse

We tried cleaning and rebuilding, opening and closing the project, which made no difference.

Then we noticed that in the solution explorer there were warning symbols against the telerik references.

My colleague had referenced the Telerik controls from the bin folder in the solution, but this folder had not been checked into source safe.

When my colleague added the bin folder to source safe, and I rechecked the code out, all worked fine.

So the answer we have found is to make sure that the Telerik dlls are in the project binary folder, and to reference them from there.

A similar problem occurred when the project refused to build. This was solved by adding a blank form, and dragging one of the telerik controls onto it.

Thursday, 25 March 2010

Generic Charting Concept

ASP Flexible Charting Solution

The challenge is to add a chart output option to a system containing many existing reports. This legacy system is written in classic asp, but it would be desirable to create the charts in asp.net so that the latest controls could be used.

Ideally, the solution should be reusable, so that many reports can have this facility added. If we can do this in a elegant way that allows the use of asp.net controls in a system running classic asp then we have achieved our goals.

New asp Function fnctSaveValuesForCharts

On classic asp system create a function with 3 arguments:
1) Recordset
2) Name of measure column
3) Name of description column

When the report is run for the first time, this new function should be called at the same time.

New asp.net aspx page.
The second part of the system will be a new asp.net page.
This will take three arguments:
  1. Segments (number of segments (n)),
  2. Style (Pie, Bar)
  3. Title (The title for the aspx page)

This will pick up the values and captions from the cookie saved by the classic asp page.
The top n-1 values will be displayed in bars or slices
The rest or the values that are not in the top n-1 will be summarised and displayed in a single bar/slice with the caption "Others"

For example, if the user chooses 5 slices, the pie chart will show the top 4 categories as individual slices, then all the other values will be summarised in the "Others" slice.
Having an "others" column/slice avoids cluttering up the chart with insignificant data.

The advantages of this overall approach are:
  • It avoids the need to run the same query a second time
  • Avoids need to transfer a complex object, such as a recordset, between asp version
  • The data required for the charting is saved in a simple form ready for use
  • The charting can easily be added to many pages. Changes to the look of the charts only need to be done in one place.
See this article on how to share session state information between asp versions:




Monday, 22 February 2010

How to add a total to an SSRS Report

To put totals into a SSRS report:
1) click on the detail of the report
2) Right click on the side bar that appears
3) Select footer from the menu
4) Note the extra row that appears in the report



In each cell of the footer where you want a total to be, right click and choose Expression.
Paste in something like this: =SUM(Fields!WORK_HOURS.Value)
The bit in the braces will normally be identical to the value in the field of of the detail report.

To format right click the cell again, choose Properties
In the format tab enter N2 to format to 2 decimal places.




Wednesday, 27 January 2010

ASP.Net


I had a strange problem with a asp.net form created by another developer. It had some totals labels that were updated on the fly depending on the values of text boxes on the form.

However, one of the total labels did not update.

The solution was to add this line in the source of the page as shown in the image below.



Friday, 6 November 2009

ASP.Net Keeping Session Alive

ASP.Net Time-out

We have a problem with a client with a slow network that does a file upload. This takes only a minute or some on our development network. The client IIS server has a timeout of 60 minutes. However, the file upload may take longer than 60 minutes, and the page times out before the operation is complete.

Looking into the mechanics of what is going on I have found the following:

IIS Time-out is controlled by 3 settings

Note: none of these can be set to zero, or indefinite. The value for the first two is in seconds.
  • ConnectionTimeout - How long since the link between the client and server is idle.
  • HeaderWaitTimeout - I don't understand this one, but it is to do with client requests
  • MinFileBytesPerSec - This measures the amount of data received at the client.

It seems the best approach is to find a way to tell the server that our page is actually still alive.
Here are two code examples of an approach to doing this:

The common logic to each of these methods is to have a small part of the page, such as a frame, automatically refresh before the page is due to expire. So if it should expire every hour, have it refresh every 50 minutes. The question in our scenario will be - will this work when part of the page is still waiting for SQL Server.

To handle this we need to do something like threading. In other words - send the page off to do some database work, and in the meantime, continue to be responsive.

This link shows how to do that Threading in ASP.Net

To achieve this in ASP.net, as well as understanding threading and automatic page refreshing we need to know how to use frames too. This is elementary to most web developers, but I am not a web developer!!.

To create a page with two frames I actually created 3 aspx pages. This is the key part of the code that appears on the parent page.

Refreshing Frames Individually

To refresh a frame manually, you can put code like this in the click event of a button, or some other event. This is client side javascript.

parent.frames[1].location.href=parent.frames[1].location;

To refresh a frame automatically, put this line in the head section:

<meta http-equiv="REFRESH" content="15" />

(This is the on-line application I used to convert html code into something that will display properly in a blog: www.felgall.com/htmlt47.htm)

To solve the problem with the client application that we have:
1) Rename the data load form
2) Create a new form with the name of the old dataform
3) Add a frameset to the new form, the old form will be the first frame in the frameset
4) Create a new form
5) Add the new form to the frameset
6) Add the automatic refresh feature to the new form.

NOTE:
The proof of concept still needs to show that this works in conjunction with a dataload taking place in another frame, and that it is sufficient to keep the session open.
Carry on from here on Thursday.


Wednesday, 7 October 2009

Pie Chart Control

I found a nice pie chart control here: www.codeproject.com/KB/graphics/julijanpiechart.aspx.

To include this in one of my own projects this is the quick start method.

Copy the PieChart.dll into the solutions folder.
Go to toolbox and browse for the dll to add it.

Drag the piechart control to a form.

There are two sets of values that must be setup, otherwise an exception occurs.
Here is a sample of the most basic code:
Dim Vals(4) As Decimal
Dim Texts(4) As String
Texts(0) = "apples"
Texts(1) = "plums"
Texts(2) = "grapes"
Texts(3) = "cherries"
Try
Vals(0) = 45
Vals(1) = 20
Vals(2) = 75
Vals(3) = 45
Me.PieChartControl1.Values = Vals
Me.PieChartControl1.Texts = Texts
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try


This produces a odd looking pie chart. For nice charts some other settings should be changed too.

Setting up displacements give a chart that looks like this:


Displacements should have values like 0.05 and o.20


SliceRelativeHeight gives depth to the chart



These are the minimum settings to create a nice 3-D pie chart.