Paul Vick at PDC

Monday, October 27 2008         No Comments

I can't make it to PDC this year due to a project commmittment, but if you are there be sure to drop by and say "hi" to Paul Vick.  He is doing a talk on the future of VB this year, and it is sure to be something I should be at ... oh well.  Anyway, I guess I'll just have to live with the video.  This is the description from microsoftpdc.com

Hear language architect Paul Vick and specification lead Lucian Wischik discuss the future direction of the Visual Basic language. Learn about the new capabilities of the next version of the language, including additional LINQ features, syntax simplifications, and a host of other improvements. Also gain insight into possible future features, including meta-programming and scripting.

If you are at PDC, be sure to check him out, cheer loudly, and report back here with the scoop!  Here is the channel 9 link:

http://channel9.msdn.com/pdc2008/TL12/

I'm sure it will be a great presentation!

 

Dates and Nothingness

Monday, August 11 2008         No Comments

Sounds like a metaphysical post, but it isn't. In working with an object for which I needed a last change date, I set the DateTime variable value to Nothing in the constructor.

Dim lastReset as DateTime = Nothing

But when I check for IsNothing() later in the code the check always fails due to the fact that the Nothing value for the DateTime (a value type in .NET) is actually MinValue. To make sure that it wasn't Nothing I would avtually have to compare to MinValue

If lastReset <> Date.Minvalue Then DoSomething()

Well, I was sure that .NET 2.0 fixed this with Generics and I was right. This is what happens when you do to much designing and not enough coding, I guess. The new Nullable object type can be Of DateTime, so that this now works:

Dim lastReset as Nullable(Of DateTime) = Nothing
'…
If IsNothing(LastReset) Then DoSomething()

From a pragmatic programming perspective, this isn't a big deal. From a solid code perspective it is a rather large deal. If I say Nothing, I want NOTHING in there. I don't want the MinValue in there. I want Nothing in there. Then I want to see if the value is still nothing later.

Generate a managed class for WMI instrumentation

Monday, July 14 2008         No Comments

So,I need a list of services from a remote machine for an application I am building for Wendys.  I wrote a boatload of System.Management code to do it, liike something like this:

Public Function ListServices() As Dictionary(Of String, String)
  co = New ConnectionOptions()
  co.Username = My.Settings.Username
  co.Password = My.Settings.Password
  co.Impersonation = ImpersonationLevel.Impersonate
  scope = New ManagementScope("\\" + IPNumber + "\root\cimv2", co)
  Dim result As New Dictionary(Of String, String)
  Dim mc As New ManagementClass("Win32_Service")
  Dim oc As ManagementObjectCollection
  Dim query As New ObjectQuery
  query.QueryString =
"SELECT * FROM Win32_Service"
  Dim mos As New ManagementObjectSearcher(scope, query)
  oc = mos.Get
  For Each item As ManagementObject In oc
    result.Add(item.Item("DisplayName"), item.Item("State"))
  Next
  Return result
End Function

Then what did I learn?  Lo and behold, there is a Tool To Do This.  I hate it when that happens!  Just pass in the WMI namespace and it will generate all the class code you can eat.  (Win32_Battery made me 2800 lines of code).  Check it out here on MSDN.

Downloading a file from a remote server with network credentials

Monday, June 09 2008         No Comments

Man, was this a pain in the butt.  Seems like downloading a file from a remote PC would be easy, but 'taint.  This worked great for me,  your milage may vary.

'First we set up all of the filesnames and locations, making heavy use of app.config.
Dim filename As String = String.Format("{0}-{1}-{2}.txt", CDate(checkDate).Year.ToString, CDate(checkDate).Month.ToString, CDate(checkDate).Day.ToString + 1)
Dim RemoteFile As String = String.Format("\\{0}\{1}\{2}", My.Settings.IpNumber, My.Settings.LogDirectory, filename)
Dim LocalDirectory As String = String.Format("{0}logs\", My.Settings.ReportLocation)
Dim LocalFile As String = String.Format("{0}{1}", LocalDirectory, filename)
'Hey, check for the localdirectory
If Not Directory.Exists(LocalDirectory)
Then
  Directory.CreateDirectory(LocalDirectory)
End
If
'Then we set up a little security

Dim
myClient As New System.Net.WebClient
Dim myCreds As New System.Net.NetworkCredential(My.Settings.Username, My.Settings.Password)
'Log the fact that we are starting.
My
.Application.Log.WriteEntry(String.Format("Starting download of file {0}", fileName))
'Set up the securit
myClient.Credentials = myCreds
'Now we actually try and get the file.
Try
  myClient.DownloadFile(RemoteFile, LocalFile)
Catch uae As System.UnauthorizedAccessException
  My.Computer.FileSystem.WriteAllText(LocalFile, String.Format("The file path to file {0} was not available at the time of this posting.", file), True)
Catch ex As Exception
  My.Application.Log.WriteException(ex)
End
Try
My.Application.Log.WriteEntry(String.Format("Finished download of file {0}", fileName))

Did this as part of a project at Wendy's.  Part of the Classic Posts collection.  (heh)

Going to the decision maker matters for IT pros and developers too

Tuesday, April 22 2008         No Comments

When I was in sales, one of the tenants of making a close was driving to the decision maker.  Anyone who stands in the way is a "gatekeeper" and is just there to protect the decision maker, like the offensive line in football.  Jeke past the tackle!  Watch out for the tight end!

The reason for focusing on the decision maker is to reduce the number of times that you have to hear the organizational customer say "no".  You have to wait througn 7 nos to get a sale as it is, you don't want to hear "But now you have to talk with Mr. Manager."  You want a check written after you hear yes.  Therefore, get to the decision maker.  There are a bevy of methods to use to get past gatekeepers, and young sales trainees - such as myself years ago - learn them by heart.

What I am learning, as I delve deeper into the Software Architecture role, is that getting to the decision maker is just as important for the professional IT consultant.  There are just as many gatekeepers in the IT department of midsized companies as there are in the purchasing department.  These are even more subtle, too, if that is possible; they might even think (incorrectly) that they are the decision maker, but they are not.  Whe you are consulting for a company, and have the opportunity to garner additional project hours by solving a new problem, you are often the only person in the building who can bring the new sale to a close.

The problem is one of feifdoms.  Someone in IT designs a network, or manages a server, or writes a key piece of software, or configures some middleware, and they think that they own it.  They do all the work, they make all of the key decisions, so they must own it, right?  Well, no.  Especially when a decision impacts something else in the company.  Now, if they do something on company time and get overruled, it's not a big problem.  They grumble, turn it off or whatever, and all is forgotten.

But if you, as a consultant, do it on their OK and it gets overruled, you might not get paid.

Suddenly, getting to the decision maker seems like a really good idea, especially when pitching a new piece of work.  Here are a few tips from my experience to help you get past the IT Manager of the Fiefdom, and to the person who writes the checks.

  1. First, know who writes those checks.  It is tough to find the real decision maker in some firms.  Often, the functional decision maker is the IT manager, but they have a higher power in the CIO or CEO or owner who might know little about technology.  It is essential to get this person's buy in.
  2. Remember that gatekeepers are your friend.  Don't tick off the 'owner' of the target system just because they don't write the check.  Your case is so much better off if both you and the system manager go to the decision maker.
  3. Have an elevator message ready.  Often, you will find yourself at the coffee shop or wherever with the decision maker, and might be able to catch him or her for a minute before or after.  Have a compelling 30 second pitch ready that describes what you are trying to do.
  4. Remember to listen.  Don't just talk.  Sometimes no is no.  Sometimes you have a bad idea, and that is why you are being blown off.  Sometimes you are explaining it poorly, and that's why you can't make the close.  Listen to the feedback.

Finding continuing work as a consultant often requires sales measures.  You can depend on a recruiter to get you into a client, but you often have to keep yourself there.  Having a plan to get tot he decision maker will make that process smoother.