Monday, October 24, 2011

The Book of Tebow : Chapter 1

And so it was that Tebow son of Sebow, grandson of Gebow, came to the Team.  The Team did not know Tebow.  But the Fans rejoiced.  And there was great debate and great animosity between all who would come to know Tebow.

Knowing this, the oddsmakers tried to trick Tebow saying, “For whom do you play : The Fans or the Team?”

And Tebow replied “Let the Fans be the Fans and let the Team be the Team.”

And the oddsmakers were silent.

And to his followers Tebow said” Be still, and know that I am your quarterback.”

And they were.  And it was good.

But Fox scoffed at Tebow and denied his quarterbackability.  And the Team would know naught but losing and suffering for many weeks and many days.  Beaten and bleeding Fox raised his eyes to Tebow, and with a wounded pride cried “Forgive me Tebow.”  And Tebow did.  And it was good.  And the Team knew Tebow.  And Tebow knew the Team.

GAMEDAY

Suddenly there came a great air horn blast and the game began.

The first quarter came and went with little action. 

And Fox said to the fans, “I do not know this man, he is not worthy to be my quarterback and he is no fried of mine.” 

And the oddsmakers laughed saying “This man is a fraud, for no man as unorthodox as he could ever hope to achieve victory”.

Tebow wept. 

Towards the end of the half Tebow fumbled.

And again Fox muttered to himself, “I do not know this man, my other quaterbacks suck and I am despaired.”

At halftime there was great anger throughout the team.  They cursed Tebow.  

Tebow wept.

And Julius Thomas doubted Tebow saying “Until the game is won and I have placed my hands through the holes in your helmet, I will never believe you are the chosen quaterback.”

And Tebow, with love in his eyes, said “Fear not for I am with you, and you with me. I am a virgin and your quarterback, and our victory shall not end.” 


And the team was comforted.  And it was good.

The second half came.  But towards the end of the game all was not well.  With five minutes remaining there was malice in the hearts of the Team.  They clamored for false quarterbacks and made up lies about Tebow.  And Fox doubted Tebow saying “You are an abortion”. 

But Tebow had love in his pads, saying,” Fear not, I will never leave you nor forsake you”.  But the team was not comforted, and it was not good.  And in his heart, Fox forsook Tebow.

The enemies gave a great cheer, and smirked and joked and believed victory was theirs. For nothing, short of a miracle that is, could save the Team.

But at that moment Fox had a vision.  In his vision were four horses.  All were lame.  But the fourth horse rose up from the ground.  Suddenly there was an air horn blast and out of the mouth of the horse flew a dove. 

And Tebow came to Fox in his vision and, with peace in his eyes, said “The horses are quarters.  Look into my eyes and know peace”.

And Fox did.  And Fox knew in his heart that Tebow was his dove.

Now the enemies smirked to themselves.  They teased and they mocked the Team.  They teased and mocked Tebow.  For nothing short of miracle could save the Team.

But then Tebow said to Fox, “Do you know me?” 

And Fox replied, - “Yes”. 

And again Tebow asked Fox, “Do you like me?”

And Fox replied, “I like you, you are the man”.

And finally Tebow said, “Do you love me?”

 And Fox replied, “I love you with all that I am.  You are a virgin and my quarterback, now and forever”.

Tebow scored.

But still the enemies smirked, certain of their victory.  And still, the fans cowered, certain of their defeat.  For the enemies needed only a recovery to win the day.

But Tebow spread wide his arms, and the mud on the field parted, and the return men stumbled, and the Team recovered the ball.  And the team was inspired.  And it was good.

Suddenly there came a great air horn blast and Tebow took the field.  And the Team rallied around him.  And again, Tebow scored.

Now it happened that the kicker was lame.  And slipped upon kicking the ball in overtime, sending the it short and wide.  But as he fell cried out to Tebow. 

And Tebow responded saying “You are saved by your faith.  Tonight you will dine with me in victory.”

And suddenly there was a great gust of wind and the ball flew straight and true.  And it was good.

And Julius Thomas wrenched the helmet from Tebow, placing his hands through the holes in his helmet saying “Let me carry your helmet, my friend, my leader, my quarterback”.

And in the end was the Team.  And the Team was with Tebow, and the Team WAS Tebow.

But the oddsmakers whispered in wonder to themselves saying, “What manner of man is this? that even the mud and the wind obey him”.

2011 Test

Test Message:

Test Message End:

Wednesday, March 18, 2009

Web based windows report viewer

Windows report viewers offer several advantages over their web based counterparts.

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

Adding the following code will add a sizable, draggable, panel to the toolbox. Although in this instance, a panel is used. It just as easily could have been any other windo

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

Visual studio templates are extremely useful tools which can be used to share commonalities across projects. Application functions that are commonly included at the project level include security, configuration, logging, error handling, navigation and reports. To create a template from any project from visual studio:

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 to the visual studio 2008\my exported templates\ directory.

3. Add the to the visual studio template directory. (This directory can be found at -->Tools-->Options-->Projects and Solutions-->General : User project templates location. Also, make sure the "Save new projects when created " checkbox is selected as templates created in temporary projects directories can have unpredictable results.

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.