Monday, October 24, 2011
The Book of Tebow : Chapter 1
Wednesday, March 18, 2009
Web based windows report viewer
1. Print preview is available - this view displays to the user what the form will look like when it is printed. Not available in html or on report server.
2. Often times HTML rendered reports do not appear the same as they do when they are printed. This can be confusing for the user and the developer.
3. More feature rich tool set from which to work from. In my experience, features like multi column reporting seem to work when viewed from the windows report viewer, but not when rendered in html using the web report viewer.
4. HTML/Server reports do not render the same in Firefox and IE. They do when using windows based reports.
With a little bit of configuration, windows report viewers can be embedded in asp/web pages.
This offers the advantages of web availability and windows report viewer functionality.
The next several entries will provide a method to embed a windows report viewer in a web page.
The idea is :
1. Publish a report to SQL report server.
2. Create a windows report viewer project to view the report.
3. Create a wpf project to hold the windows report viewer.
4. Create a web page to hold the wpf project.
5. Set up certificate permissions to view web page
The end result is an xbap (which can be embedded in a web page for presentation) that can dynamically display any report based on its path.
VB .NET Sizable, Draggable, Windows Components in Visual Studio 2008
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Public Class ResizeablePanel
Inherits Panel
#Region "Resize"
Private mDragging As Boolean
Private mMousePos As Point
Private mSize As Size
Public Sub New()
Me.BackColor = Color.FromKnownColor(KnownColor.ButtonShadow)
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
If (mDragging) Then
Me.Width = mSize.Width + e.X - mMousePos.X
Me.Height = mSize.Height + e.Y - mMousePos.Y
Me.Invalidate()
Else
If (e.X >= Me.Width - 8 AndAlso e.Y >= Me.Height - 8) Then
Me.Cursor = Cursors.SizeNWSE
Else
Me.Cursor = Cursors.Default
End If
End If
MyBase.OnMouseMove(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
mDragging = IIf(Me.Cursor = Cursors.SizeNWSE, True, False)
mMousePos = e.Location
mSize = Me.Size
MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
mDragging = False
MyBase.OnMouseUp(e)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim rc As Rectangle = New Rectangle(Me.Width - 16, Me.Height - 16, 16, 16)
ControlPaint.DrawSizeGrip(e.Graphics, Me.BackColor, rc)
MyBase.OnPaint(e)
End Sub
#End Region
#Region "Drag"
' Used to store the current cursor shape when we start
' to move the control
Private m_CurrentCursor As Cursor
' Holds the mouse position relative to the inside of
' our control when the mouse button goes down
Private m_CursorOffset As Point
' Used by the MoveMove event handler to show that the
' setup to move the control has completed
Private m_Moving As Boolean
'Public Sub New()
' ' Call the constructor of the base Label class to properly
' ' initialize our control
' MyBase.New()
' ' Setup the Cursor property so that, by default, when the
' ' mouse passes over our control, the cursor changes to a hand
' Me.Cursor = Cursors.Hand
'End Sub
Private Sub MovableLabel_MouseDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles MyBase.MouseDown
' Check to see if the correct button has been pressed
If Not mDragging Then
If e.Button = Windows.Forms.MouseButtons.Left Then
m_CurrentCursor = MyBase.Cursor
' replace it with our new image that says were in Movable mode
MyBase.Cursor = Cursors.SizeAll
' Save the location of the mouse pointer relative to the top-left
' corner of our control
m_CursorOffset = e.Location
' Set the mode flag to signal the MouseMove event handler that it
' needs to now calculate new positions for our control
m_Moving = True
End If
End If
End Sub
Private Sub MovableLabel_MouseMove( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles MyBase.MouseMove
' Check which mode we're in. If we're supposed to be moving
' our control
If Not mDragging Then
If m_Moving Then
MyBase.Cursor = Cursors.SizeAll
' get the screen position of the mouse pointer and map it
' to the position relative to the top-left corner of our
' parent container
Dim clientPosition As Point = _
MyBase.Parent.PointToClient(System.Windows.Forms.Cursor.Position)
' Calculate the new position of our control, maintaining
' the relative position stored by the MoveDown event
Dim adjustedLocation As New Point( _
clientPosition.X - m_CursorOffset.X, _
clientPosition.Y - m_CursorOffset.Y)
' Set the new position of our control
MyBase.Location = adjustedLocation
End If
End If
End Sub
Private Sub MovableLabel_MouseUp( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles MyBase.MouseUp
' The button was released, so we're going back to Static mode.
If Not mDragging Then
m_Moving = False
MyBase.Cursor = m_CurrentCursor
End If
End Sub
#End Region
End Class
Tuesday, December 2, 2008
Template creation in visual studio 2008
1. -->Tools-->Customize-->Commands-->File and drag the Export Template... button to any menu in the menu bar.
2. -->Export Template... select Project template -->Next. Enter a name and description for the template to be created.
Visual studio will by default export the
3. Add the
4. Create a new project and select the newly created template as the project type.
Creating a template with commonly used base functions is a great way to get a jump start on any project.
Friday, November 14, 2008
Logging to a database with enterprise library 4.0
Because I had a hard time tracking these down online, I thought it would be prudent to blog some simple steps which may be followed to implement database logging using enterprise library.
1. To create a logging database, run the LoggingDatabase.sql script which by default is installed at C:\EntLib4Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts. This script will create a table with logging capabilities.
2. Create a project
3. Add references to:
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll
Microsoft.Practices.EnterpriseLibrary.Logging.dll
4. Add a config file to the project
5. Update the config file using VS or EE config manager including:
Data Access connection string to db
Database trace listener
Reference to database trace listener in general log category
Reference to Data access connection in database trace listener
6. Within the entry point of the project project (using button click below) add:
Imports Microsoft.Practices.EnterpriseLibrary.Logging
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim log As New LogEntry
log.EventId = 1
log.AppDomainName = Me.Name
log.Title = "messageType"
log.Categories.Add("General")
log.Priority = 1
log.Message = "Test Message"
Logger.Write(log)
End Sub
End Class
Following these steps will result in a log to the database.
Filters may be applied to categorize logged messages.
Friday, October 24, 2008
Optimal Scheduling Algorithm
There have recently been discussions regarding the maximum number of docking stations that can be reserved. The maximum number of docking stations that can be reserved is a result of several factors including the scheduling algorithm. The manner in which the recipe is scheduled has a direct impact on the maximum number of docking stations that may be reserved. A clear example of scheduling being used to maximize the number of docking stations that can be run simultaneously can be seen when staggering the start time of a recipe running on multiple docking stations:
Definitions:
Scheduling: is the process by which actions are assigned to a particular docking stations based on the timing defined in a particular recipe.
Total recipe Time (TT), the time from recipe start to completion, is defined in terms of the time when actions are executing (XT) and time when they are not (rest time) (RT). TT = XT + RT. For a recipe to be successfully scheduled there must be a window of execution available for each action in the recipe. At all times, the rest time between actions must be consistent with that defined in the recipe.
Earliest Time available (ET), is the first time within the scheduling window where a recipe may be scheduled. For example, if a docking station is on test for the next 10 hours and after 10 hours there are no scheduled actions, ET = 10 hours.
Future Window (FW), is the maximum amount of time (window) into the future that a recipe may be scheduled. Any recipe may be scheduled against any number of docking stations if the future window is set to a large enough value. To schedule a recipe against a particular docking station, ET + TT must be less than or equal to FW. ET + TT <= FW. For example, if a recipe takes 100 hours to complete and the earliest time a scheduling window is available is at hour 20, then the future window must be at least 120 hours.
Reservation Slot (RS), is the sum of all XT slots within FW that make up a single recipe.
Maximum Docking stations reserved (MaxDS), can be defined as the number of available RSs where a docking station may be reserved within FW. As FW becomes grows, so too does capacity.
The recipe in this example contains a structure similar to the familiar 86 hour recipe that has been run for LiI SAT. It is assumed that the recipe includes two commands, a slow running command and a fast running command. The fast command, BkgMeasurement executes in 30 seconds, while the slow command, ChangeLoad executes in 45 seconds. The time between commands is 1800 seconds (30 minutes).
XT(BkgMeasurement) = 30 seconds
XT(ChangeLoad) = 45 seconds
RT = 1800 seconds (30 minutes).
So, the number of commands that may execute within one block of 1800 minutes is:
n(BkgMeasurement) * XT(BkgMeasurement) + n(ChangeLoad) * XT(ChangeLoad) < 1800
In the worst case, if the recipe is reserved such that all docking stations run the change load command in the same 1800 seconds (setting n(BkgMeasurement) = 0 in the equation above), the maximum number of docking stations that could be reserved (MaxDS) is limited by the execution time (XT) of the slow running command, in this case ChangeLoad.
MaxDS = RT / XT(ChangeLoad)
MaxDS = 1800 / 45
MaxDS = 40.
No more than 40 docking stations could ever be scheduled at once, as all change loads would have to execute in the same block of 1800 minutes.
The best case would be if somehow there were no change loads in the recipe, (setting n(ChangeLoad) = 0 in the equation).
MaxDS = RT / XT(BkgMeasurement)
MaxDS = 1800 / 30
MaxDS = 60.
No matter how the recipe is scheduled, there could never be more than 60 docking stations on test.
From above, the minimum MaxDS = 40 and the maximum MaxDS = 60.
Staggering:
A stagger can be defined as delaying the start of a recipe on a number of docking stations in an effort to maximize the number of docking stations that are placed on test. For example, if a recipe is being run on 40 docking stations, using 0 staggers, then all docking stations would start in the first block of time. If 1 stagger was used, 20 docking stations would start in the first block and 20 docking stations would start in the second block. If 2 staggers were used, 13 docking stations would start in first, second and third block. By staggering the start of recipes, the long running commands are separated from each other and more docking stations may be reserved.
Simple Example with 42 docking stations and recipe with 3 commands (Bkg,Change,Bkg):

So, as groups are staggered, the long running commands become separated from each other (1:40, 2:21, 3:17).
Below is a set of data, based on 86 hour test parameters, which records the number of staggers, total docking stations reserved, and time added on to the tests end.
XT(BkgMeasurement) = 30 seconds
XT(ChangeLoad) = 45 seconds
RT = 1800 seconds (30 minutes).


As the number of staggers increases, the number of maximum number of docking stations (MaxDS) that may be placed on test increases from min(MaxDS) (40) to max(MaxDS) (60).

The benefit of staggering diminishes with each stagger. While the first stagger increases maxDS by 8, the second only increases maxDS by 3, and with each additional stagger the gain becomes less.

At first, a single block of ½ hour may be added to the test to MaxDS. However, as the number of staggers increases, it becomes more expensive to place more docking stations on test.
So there is a direct relationship between recipe length, total test time and capacity. In the case of the 86 hour recipe, if the total test time is increased from 86 to 86 ½ hours, then capacity increases by 20% (40à48).
It may be beneficial to investigate staggering recipe starts at the time of reservation.
