in

Drowning In Technical Debt

C# | ASP.NET | SharePoint | SQL | Architecture | SOA |

Scott Roycraft

Red meat is NOT bad for you. Now blue-green meat, THAT'S bad for you! ~ Tommy Smothers

April 2007 - Posts

  • A Better Command Prompt Format For Long Path Names

    Have you ever opened up a command prompt and navigated to a deeply nested folder to find you could only type a few letters of the command before it word wrapped?

    With a simple environment setting you can reformat the command prompt to display the full path and automatically move the cursor to next line thus giving you more room to enter your command.

    Right mouse click on your My Computer and then take the Properties menu item and open the Advanced tab. Click the Environment Variables button and add a new variable:

         Variable: PROMPT
         Value: $p$_$+$g

    You can also set colors, display UNC names and many other display settings. I was pleased to find my old DOS prompt settings still worked!

  • Extend Visual Studio with Custom Toolbars

    I determined that the three most common reasons that cause me to have to leave Visual Studio IDE is to open a VS2005 command prompt, open the Entlib Configuration Editor and to open the MMC. I decided that I would address this by creating my own Visual Studio toolbar and adding three icons to launch these external applications.

    Step 1: Register the external tools with Visual Studio
    Launch the Tools\External Tools dialog and add the external tools.

    For the VS2005 Command Prompt I specified the following values:
     Title:  Command &Shell in Project Directory
     Command: C:\WINNT\system32\cmd.exe
     Arguments: /k "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86
     Initial Directory: $(ProjectDir)


    For the EntLib Configuration Editor:
     Title:  EntLib Config Editor
     Command: C:\Program Files\Microsoft Enterprise Library January 2006\bin\EntLibConfig.exe
     Arguments: <left it blank>
     Initial Directory: $(ProjectDir)

    For the Computer Management Console:
     Title:  Computer Management Console
     Command: mmc.exe
     Arguments: c:\winnt\system32\compmgmt.msc
     Initial Directory: <left it blank>

    NOTE: keep track of position these commands are listed in the Menu Contents listbox. In my case my VS2005 command prompt was the second in the list. Therefore it will become my External Command 2. Likewise EntLib Config Editor was External Command 3 and the MMC was External Command 4.

    Step 2: Create a new toolbar
    Right mouse clicking in the toolbar area and select the Customize menu item at the bottom of the context menu. On the Customize dialog click the New button and give it a meaningful name. It will create the new toolbar without any items right next to the dialog. Switch tabs to the Commands tab and then select the Tools category. In the Commands listbox scroll down to the “External Commands” commands. Click and drag the proper external command to your new toolbar (in my case that would be External Commands 2, 3 and 4).

    Step 3: Customize the new toolbar items.
    Your new toolbar is functional but probably doesn’t look very nice. By default the toolbar buttons display the title of the external command. While the Customize dialog is open, right click the first toolbar button to select it and to display a new context menu. Select the Default Style menu item and then you will be able to Copy, Paste, Reset, Edit or pick an toolbar image from a list. I have a hard enough time drawing a stickman let alone a nice looking icon. So I found a few nice 16x16 icons, cut them into my clipboard and then pasted them into my toolbar item. After closing the Customize dialog then position the new toolbar up next to the existing toolbars and you are all set!

    Step 4: Share your external commands
    If you find other helpful external commands to make development easier please share! I recently read how one guy wired in subsonic and another svn commands.

  • SQL Query To Determine User Login Information

    I was asked to put together a query that would allow management to know how many users used one of our internal application per week. Since we deploy our apps via ClickOnce my first stop was to view our WebTrends reports. While it contained lots of useful and interesting data it showed the number of hits and visits but the numbers seemed to be too high and I made a mental note to research their definition of a visit.

    The application has a SQL Server 2005 LoginHistory table that gets populated each time the user launches the application. It records their LoginId char(7) and LoginDate (datetime). There were thousands of rows in this table and with a couple of quick queries I was able to see that the users were launching the application several times a day practically every day.

    I need to determine how many users used the application per week not the number of connections per day. So the first thing to do was to figure how to determine the first day of the week for the given LoginDate:

    LoginDate - (DATEPART(DW, LoginDate) - 1)

    LoginDate is a datetime and all I was interested in was the date part so I converted the date into a string in the "mm/dd/yyyy" format:

    CONVERT( varchar,LoginDate - (DATEPART(DW, LoginDate) - 1 ), 101) as 'FirstOfWeek'

    Next I needed to return one row for each user along with a weekly login count:

    SELECT DISTINCT
    CONVERT(varchar,LoginDate - (DATEPART(DW, LoginDate) - 1),101) as 'FirstOfWeek'

    ,
    LoginId
    ,
    1 as WeeklyLoginAttempt

    FROM LoginHistory

    Lastly, I needed to sum up the attempts so I made my SELECT a sub-query, added a sum, group by and order by statements.

    SELECT
    P1.FirstOfWeek,
    SUM(P1.WeeklyLoginAttempt) as WeeklyLogins
    FROM (
              SELECT DISTINCT
                    CONVERT(varchar,LoginDate - (DATEPART(DW, LoginDate) - 1),101) as 'FirstOfWeek'
                    , LoginId

                    ,
    1 as WeeklyLoginAttempt
               FROM LoginHistory

           ) as P1
    GROUP BY P1.FirstOfWeek
    ORDER BY CONVERT(datetime,FirstOfWeek)

    This resulted in a nice result set that took the raw log of login attempts and converted into a user login by week report that made the boss happy which is always a good thing!

    Posted Apr 19 2007, 10:55 PM by sroycraft with no comments
    Filed under:
  • Quickly Create Folder Tree Structures

    MKDIR [drive:]path
    MD [drive:]path

    If Command Extensions are enabled MKDIR changes as follows:

    MKDIR creates any intermediate directories in the path, if needed.
    For example, assume \a does not exist then:

    mkdir \a\b\c\d

    is the same as doing all of the following:

        mkdir \a
        chdir \a
        mkdir b
        chdir b
        mkdir c
        chdir c
        mkdir d

  • BPEL Activities for WF

    The BPEL for Windows Workflow Foundation March CTP provides developers with support for building applications using Windows Workflow Foundation and BPEL.

    BPEL for Windows Workflow Foundation (WF) is an add on for Windows Workflow Foundation in the .NET Framework 3.0. BPEL is the Business Process Execution Language and this download is an unsupported Community Technology Preview (CTP) for using this technology with WF. The download, which is aimed at software developers, provides import and export tools for BPEL and includes WF activities representing BPEL for the WF designer in Visual Studio 2005.

  • MSDN WF Nuggets

    Mike Taulty has put together several excellent short WF videos (nuggets). I hope he creates a series of WCF and WPF nuggets too!

    Here's the list and the suggested running order:

    01 Workflow Foundation Hello World Watch Download

    02 Dealing with Exceptions Watch Download

    03 Conditional Logic Watch Download

    04 The Conditioned Activity Group Watch Download

    05 Working in Parallel Watch Download

    06 Dealing with Cancellation Watch Download

    07 Listening for Events Watch Download

    08 Passing Parameters to Workflow Watch Download

    09 Working with Transactions Watch Download

    10 Communications from Workflow to Host Watch Download

    11 Communications from Host to Workflow Watch Download

    12 Bidirectional Communications (Host <-> Workflow) Watch Download

    13 State Machine Workflows Watch Download

    14 Building a Simple Workflow Activity Watch Download

    15 Building Declarative Workflows Watch Download

    16 Modifying Workflows whilst Running Watch Download

    17 Using a Persistence Service Watch Download

    18 Building a Persistence Service Watch Download

    19 Using a Tracking Service Watch Download

    20 Building a Tracking Service Watch Download

    21 Using a Scheduling Service Watch Download

    22 Building a Scheduling Service Watch Download

    23 Calling a Web Service from a Workflow Watch Download

    24 Using the Synchronization Activity Watch Download

    Posted Apr 10 2007, 10:17 PM by sroycraft with no comments
    Filed under:
Powered by Community Server (Commercial Edition), by Telligent Systems