Brian's Blog

  • Free Deployment help for Windows Server 2008

    Windows Sever 2008 is out the door, Hyper-V has shipped and SQL 2008 is not far behind. Customers are still upgrading to Vista and Office 2008 so all is good. While not if you are the folks in charge of deploying all of this. If so you may be working your tail off to understand what boxes you currently have that will support the new operating systems. You may also be asking questions like: Which servers can be virtualized? If I upgrade will I have compatibility issues?  Questions like these need to be answered before organizations deploy Windows Server 2008, Hyper-V, and SQL 2008. Client questions while very similar still need to be answered before you can deploy Vista and Office 2007. To help you or your customers answer many of these questions let me introduce the Microsoft Assessment and Planning Toolkit (MAP). MAP is an inventory, assessment, and reporting tool that can be used in small or large IT shops. One very nice feature is that it does not require the installation of an agent.  Here are a few thing that it can be used for:

    Secure and Agentless Inventory
    The Microsoft Assessment and Planning Toolkit (MAP) provides secure, agent-less and network-wide inventory that scales from small business to large enterprises.

    Comprehensive Data Analysis
    The Microsoft Assessment and Planning Toolkit (MAP) performs a detailed analysis of hardware and device compatibility for migration to Windows Server 2008, Microsoft Office 2007, Microsoft Application Virtualization, and Windows Vista.

    In-Depth Readiness Reporting
    The Microsoft Assessment and Planning Toolkit (MAP) generates reports containing both summary and detailed assessment results for each migration scenario. The results are provided in both Microsoft Excel and Microsoft Word documents.

    System Center Virtual Machine Manager (SCVMM) is a great tool for helping you manage your virtual environment and I highly recommend it. However many times and organization would like to get some information about doing server consolidation with Hyper-V or Virtual Server in their environment without first deploying SCVMM. Well MAP can help with this too.  It has a Server Consolidation and Virtualization Wizard that can be used to provide a server consolidation and virtualization assessment. This wizard performs the following functions to complete the assessment:

    • Performs an inventory of the computers considered for consolidation and virtualization.
    • Consumes the performance monitoring data collected by the Performance Metrics Wizard.
    • Allows the user to provide a “model” virtual server that will host virtual machines (guests).
    • Determines the number and placement of guests on the virtual server.

     

    • Provides detailed reports and proposals describing which servers can be virtualized and on which virtual server host computers the consolidation process can be carried out.

    As you can see this tool can be a very useful addition to your toolbox and the price is right, free! For more information on MAP please see the following link:

    http://technet.microsoft.com/en-us/library/bb977556(TechNet.10).aspx

    Ok so you are still having trouble sleeping because you are in charge of helping plan and design some of your  organization’s or your customer’s infrastructure and if it fails heads will roll. Well don’t worry take a look at our Infrastructure Planning and Design Series on TechNet.

    http://technet.microsoft.com/en-us/library/cc196387(TechNet.10).aspx

    This will either help answer your questions or put you to sleep as you read another NAP paper.  Either way it is a good resource to help both you and your customers with infrastructure planning and providing some best practices. 

    Until next time, enjoy!

  • Read-Only Domain Controller

    For this post I would like to talk about one of the new features to Active Directory (AD) that ships as part of Windows Server 2008. While AD may be used for many things the main job that most organizations use it for is authentication. Because AD holds user account information including passwords security is a major concern for the boxes that are AD controllers. To help address security concerns for when an AD controller needs to be deployed to a locations outside of the main data center Windows Server 2008 now has a Read-Only Domain Controller role (RODC). So why is this important? In the old days you would either have to place a Domain Controller (DC) in remote location or have the users authenticate across a WAN to the DC. Both of these may cause some issues. Network bandwidth and performance if the DC is remote and you use a WAN to authenticate to the DC. Security and admin concerns if the DC is located at a remote site.

    So welcome the RODC. It allows you to have a DC at a remote site so users can authenticate at the local site for better performance and less WAN traffic. So why is this so cool? Because except for account passwords, an RODC holds all the Active Directory objects and attributes that a writable domain controller holds. However, changes cannot be made to the database that is stored on the RODC. Changes must be made on a writable domain controller and then replicated back to the RODC. You can also delegate local administrative permissions for an RODC to any domain user without granting that user any user rights for the domain or other domain controllers. Ok if you are paying attention you saw that passwords are not stored on the RODC. So you are asking how it can authenticate a user. The answer is that the RODC will need to make a call to the writable DC to authenticate the user. After that the credentials are cached on the RODC, the RODC can then directly service that user's logon requests until the credentials change. This limits credential caching to only users who have authenticated to the RODC. So if someone were able to hack the RODC only those credentials that are cached can potentially be cracked.

    So what does this mean for folks that devleops software? While maybe nothing. However if you do use authentication or any AD calls in your code you should make sure to test against an RODC. If you have local applications that request Read access to the directory they will obtain access because Lightweight Directory Application Protocol (LDAP) applications that request Write access receive an LDAP referral response. This response directs them to a writable domain controller. A key point to remember with this is that if you attempt to read this new information you just wrote to the DC from the RODC you may fail if it has not received the update through replication.

    For more information on RODC see the following links:
    http://technet2.microsoft.com/windowsserver2008/en/library/ea8d253e-0646-490c-93d3-b78c5e1d9db71033.mspx

    http://technet2.microsoft.com/windowsserver2008/en/library/ce82863f-9303-444f-9bb3-ecaf649bd3dd1033.mspx

    Until next time, enjoy!

  • Make your apps highly available with Hyper-V and Server 2008 failover Cluster

    Many applications are now required to run 24X7 with little or no downtime. They are also expected to quickly recover in case of a natural disaster or internal outage.  So how can you use Server 2008 to easily have highly available, scalable and manageable system even if an application is not designed to be cluster aware?  One answer is to use a Server 2008 failover cluster along with Hyper-V Quick Migration.

    With quick migration, you run server workloads and applications on virtual machines that are hosted and moved between clustered physical (host) servers. This enables you to provide a wide variety of services through a small number of physical servers and, at the same time, maintain the availability of the services you provide.

    Quick migration combines Windows Server 2008 Hyper-V hypervisor-based virtualization with failover clustering in Windows Server 2008 Enterprise and Windows Server 2008 Datacenter. In quick migration, you run server workloads on virtual machines—guest operating systems running in turn on physical hosts. Each host server is then configured as a node in a failover cluster. If the server initially hosting the virtualized workload fails or requires scheduled maintenance, another server in the cluster hosts the virtualized workload.

    If you think about this it is pretty cool. Each of the guest operating systems behaves like a cluster-aware application, with the cluster service providing health monitoring and automatic recovery for the guest operating system.

    Now Hyper-V Quick Migration is not live migration. For planed downtime a quick migration saves the state of the running guest virtual machine to storage and then moves the storage connectivity from one physical server to another. It then restores the guest virtual machine onto the second server. So how long does this take? The answer is it depends on the speed and sophistication of the storage and network hardware in the cluster. The other factor is the amount of information in RAM (state of guest OS) that must be stored before the move can be completed. For unplanned downtime the guest OS is not able to commit memory (state) to storage. So in this case the guest virtual machine is started from previously stored images. If you are using a backup program that takes snapshots of the running virtual machine you can recover to the most recent snapshot of  the virtual machine. Here are some scenarios where Hyper-V Quick Migration may be useful:

    ·         Scheduled maintenance for host (either hardware of software updates)

    ·         For operating systems or applications that could not previously have been run in a cluster

    ·         Maintaining the availability of servers consolidated on to virtual machines.

    For more information on this topic please see the following links:

    http://download.microsoft.com/download/3/B/5/3B51A025-7522-4686-AA16-8AE2E536034D/Quick%20Migration%20with%20Hyper-V.doc

    http://blogs.technet.com/roblarson/archive/2007/12/17/building-a-host-cluster-with-hyper-v-beta-1.aspx

    http://download.microsoft.com/download/3/B/5/3B51A025-7522-4686-AA16-8AE2E536034D/Microsoft%20High%20Availability%20Strategy%20White%20Paper.doc

    Until next time, enjoy!

  • Hyper-V Beta is in Windows Server 2008

    The launch of Windows Server 2008 has come and gone and you can now download RTM version of Server 2008 from the MSDN subscription area. Included in RTM of Server 2008 is beta of Hyper-V (formerly codenamed “Viridian”) which is a good reason to download and play with RTM version. Ok why should you care about Hyper-V. Well I could give you some cool marketing talk, but I think it would be easier for you to go read the Hyper-V overview whitepaper.

    http://download.microsoft.com/download/e/7/0/e703ca6e-8d81-4d6d-b0a4-8752fadd3ef7/Hyper-V%20Product%20Overview_v1.0.doc

     

    Alright, you are ready to make the move to Server 2008. But what about the folks in your organization are they ready? Well don’t worry we have some free e-books and training to help get your folks and team members ready for Server 2008. Just take a look at the following:

    http://www.microsoft.com/learning/windowsserver2008/default.mspx#EBOOK

    http://www.microsoft.com/learning/windowsserver2008/default.mspx#ELEARNING

     

    Until next time

    Enjoy!

     

  • WS 2008 App Compat

    Windows Server 2008 is almost out the door. So one big question is will your applications run on Server 2008. If you are an ISV this could be a very important question that your customers are asking. This should also not come as a surprise to you as by now you should have started testing to see if your applications are compatible with Server 2008. Ok so you have started testing, however your development teams are asking for information like: “What are the major changes I need to be aware of?”, “How can I be sure I am testing the correct areas to make sure I don’t have any compatibility issues?” Well the good news is that you can easily download white papers and tools that can help you answer the above questions and many others that you may have around certification on Server 2008. Your one stop shopping place is http://microsoft.mrmpslc.com/InnovateOnWindowsServer/

    From here you have access to tools, and white papers, along with many other resources. For example:
    The Windows Server 2008 Application Compatibility Cookbook
    http://microsoft.mrmpslc.com/InnovateOnWindowsServer/Download/WindowsServer2008andVistaCookbook.pdf

    And the Server 2008 works with tool.
    http://microsoft.mrmpslc.com/InnovateOnWindowsServer/redirect.aspx?d=Download/Works_with_tool.msi
    This is also a good tool to use as part of your applications Q&A process.

    So take a look at these and other resources that are available on the resource page.
    http://microsoft.mrmpslc.com/InnovateOnWindowsServer/Resources.aspx

    For flagship and other critical applications you should also look at Certified for Windows Server 2008 certification.
    http://microsoft.mrmpslc.com/InnovateOnWindowsServer/CertifiedForLogoProgram.aspx

    For non-flagship applications you may want to get Works with Windows Server certification.
    http://microsoft.mrmpslc.com/InnovateOnWindowsServer/WorksWithLogoProgram.aspx

    Until next time enjoy!

  • A Look at Server Core in Windows Server 2008

    RC0 for Windows Server 2008 is out. If you don’t already have it you can download it from the following link:

    http://www.microsoft.com/downloads/details.aspx?FamilyId=0818D425-CD47-4279-BE8D-24ABA14530A3&displaylang=en

    You can get more information on RC0 from here: http://www.microsoft.com/windowsserver2008/default.mspx

    One of the great new features of Server 2008 is Server Core. Ok you installed Server Core to take a look and all you saw was the command prompt (C:\>) so you say how exciting is that. Not very, but let’s take a look at what is behind the curtain. Many IT organizations have older hardware that they would like to continue using. Sever Core allows me to do that and to dedicate that box to just doing one or two tasks. They may also be looking at keeping their servers more secure by just installing the specific roles that I need on the box. Ok if I have your interest read on, if not feel free to change the channel.

    So let’s look at what roles a Server Core Installation supports. Out of the box you can do the following:

    ·        Active Directory Domain Services

    ·        Active Directory Lightweight Directory Services (AD LDS)

    ·        Dynamic Host Configuration Protocol (DHCP) Server

    ·        DNS Server

    ·        File Services

    ·        Print Server

    ·        Streaming Media Services

    ·        Web Server (IIS)

    The following optional features are also supported:

    ·        Microsoft Failover Cluster

    ·        Network Load Balancing

    ·        Subsystem for UNIX-based Applications

    ·        Windows Backup

    ·        Multipath I/O

    ·        Removable Storage Management

    ·        Windows Bitlocker Drive Encryption

    ·        Simple Network Management Protocol (SNMP)

    ·        Windows Internet Naming Service (WINS)

    ·        Telnet client

    ·        Quality of Service (QoS)

    Now all this looks good so there must be a catch. Well there is. Here are some of the limitations.

    ·        No graphical user interface is available

    ·        Dot Net(managed code) Framework (CLR) is not installed

    This means that you are very limited in what you can run on a Core installation and how you can manage it.  For example because CLR is not installed you will not be able to use IIS to run ASP.Net applications. For management you will either have to use command prompt or remote manage the server. For remote management of a Server Core installation you can use the following:

    ·        Remotely using the MMC

    ·        Terminal Services Remote Desktop

    ·        WS-Management and Windows Remote Shell

    ·        WMI – This includes using PowerShell to call WMI features to remotely manage

    I would like to end on a few of the benefits that Sever Core can provide IT departments.

    ·        Reduced maintenance

    ·        Reduced attack surface

    ·        Reduced management

    ·        Less disk space required

     

    If you want to learn more about Server Core take a look at the following links:

    http://www.microsoft.com/windowsserver2008/servercore.mspx

    http://technet2.microsoft.com/windowsserver2008/en/library/bab0f1a1-54aa-4cef-9164-139e8bcc44751033.mspx?mfr=true

    http://download.microsoft.com/download/b/1/0/b106fc39-936c-4857-a6ea-3fb9d1f37063/Server%20Core%20Installation%20Option%20of%20Windows%20Server%20Longhorn%20Step-By-Step%20Guide.doc

     

    Until next time, Enjoy!

  • Using ServerManagerCmd

    Longhorn is now officially Windows Server 2008. Beta 3 is now out and you can download the beta from the following URL: http://www.microsoft.com/windowsserver2008/default.mspx

     If you want to do the try before you buy take a look at the TechNet Virtual Labs for Windows Server 2008
    http://www.microsoft.com/technet/traincert/virtuallab/longhorn.mspx

    It does not matter how you plan to use Server 2008, you will need to manage it. This includes tasks such as adding or removing server roles or features. One way to do this is through Server Manager which is an expanded Microsoft Management Console (MMC). This is great if you want to us a UI to add and remove roles and features along with seeing what is available and what has already been installed.

    If you don't want to use a UI you can take a look at the new ServerManagerCmd.exe. This is a new command-line tool that allows you to perform most of the Server Manager tasks outside of the Server Manager Console. This makes it a great tool to support scripting and automatic deployment of server roles or features.

    Many times you want to find out what roles and features are installed. With ServerManagerCmd.exe you and issue the following command and get an xml file that lists all the different roles and features and if they are installed or not.

    ServerManagerCmd.exe –query c:\myQuery.xml

    If you look at the xml you will see something like the following:

    <Role DisplayName="DHCP Server" Installed="false" Id="DHCP" />
    <Role DisplayName="DNS Server" Installed="false" Id="DNS" />
    <Feature DisplayName="BitLocker Drive Encryption" Installed="false" Id="BitLocker" />
    <Feature DisplayName="Windows PowerShell" Installed="true" Id="PowerShell" />

    If a Role or Feature has sub items they will also show, like the following:
    <Role DisplayName="Active Directory Federation Services" Installed="false">
     <RoleService DisplayName="Federation Service" Installed="false" Id="ADFS-Federation" />   <RoleService DisplayName="Federation Service Proxy" Installed="false" Id="ADFS-Proxy" />
     <RoleService DisplayName="AD FS Web Agents" Installed="false" Id="ADFS-Web-Agents">  <RoleService DisplayName="Claims-aware Agent" Installed="false" Id="ADFS-Claims" />  
    <RoleService DisplayName="Windows Token-based Agent" Installed="false" Id="ADFS-Windows-Token" />  
     </RoleService>
      </Role>

    As you can see we list if the role or feature is installed and also give the Id which can be used to install or remove a role or feature. The results from the query allow you to quickly document what roles or features are currently installed on a specific server or compare two different servers. 

     

    Now let’s look at installing and removing a role or feature. By default PowerShell is not installed in the default server installation. So if you want to run PowerShell scripts you will need to install it. Here is the command that will install PowerShell:
    ServerManagerCmd.exe –install PowerShell

    This is fine if you don’t want to track what this does or see if installing PowerShell installs anything else.  One nice feature of ServerManagerCmd.exe is the “whatIf” parameter. For example I want to check to see what installing PowerShell will do. So I run the following command.
    ServerManagerCmd.exe –install PowerShell –whatIf –logPath c:\PSLog.txt

    This creates a log file that shows what would have been done if the “whatIf” parameter was not there.

    The “whatIf” parameter is a great way to check and see what a remove or install of a role or feature will do before you actually do it.

    Ok now you are ready to install or remove a role or feature and you would like to document what actually happened. Don’t worry this can easily be done. Let’s look at the above command to install PowerShell again.
    ServerManagerCmd.exe –install PowerShell –resultPath c:\PSInstall.xml –logPath –c:\PSInstallLog.txt

    Now I get both and XML file that shows the results of my command and a log file to check if something went wrong. Here is what the XML for the –resultPath looks like:


    <ServerManagerConfigurationResult Action="Install" Time="2007-07-03T16:32:31" Language="en-US" RequiresReboot="false" Success="true" xmlns="http://schemas.microsoft.com/sdm/Windows/ServerManager/Configuration/2007/1">

      <Message Level="Information">Start Installation...</Message>

    - <Feature DisplayName="Windows PowerShell" Id="PowerShell" RequestedBy="UserSpecified" Success="true" RequiresReboot="false">

      <Message Level="Information">[Installation] Succeeded: [Windows PowerShell].</Message>

      </Feature>

      <Message Level="Information">Success: Installation succeeded.</Message>

      </ServerManagerConfigurationResult> 

    We can see that this shows that the installation succeeded and that we don’t need to reboot the box (RequiresReboot="false") I now have documentation that provides information about what I changed along with date and time of the change. This is great if you need and audit trail.

     

    The one area I am not covering in this article is how to use an XML answer file. This is a very powerful feature of ServerManagerCmd.exe. It allows you to create and XML file that contains information on how the install or remove of roles and features is done.

     

    As we can see the ServerManagerCmd.exe provides a very powerful tool that allows for automation of installation and removal of roles and features in Windows Server 2008. For more information on Server Manager and ServerManagerCmd.exe see the following links:
    http://technet2.microsoft.com/windowsserver2008/en/library/e7edce1d-442c-4ec3-b324-c748e4f937551033.mspx?mfr=true

     

    http://technet2.microsoft.com/windowsserver2008/en/library/e7edce1d-442c-4ec3-b324-c748e4f937551033.mspx?mfr=true

     

    http://technet2.microsoft.com/windowsserver2008/en/library/e7edce1d-442c-4ec3-b324-c748e4f937551033.mspx?mfr=true

     

    Enjoy!

    Brian

  • New Job New Post

    Just looked and saw that my last post was Oct. 2006. Time sure flys by. Let's see what has changed. Moved from developer support to our global ISV team. My new job is to work with ISV's around adopting MSFT technology into their product lines. So what are some of the new technologies that ISV's are looking at.

    PowerShell
    http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx

    IIS 7.0 in Windows Server 2008
    http://www.microsoft.com/windowsserver2008/iis/default.mspx

    System Center Virtual Machine Manager 2007
    http://www.microsoft.com/systemcenter/scvmm/default.mspx

    Office Business Applications (OBA)
    http://msdn2.microsoft.com/en-us/office/aa905528.aspx

    Software as a Service (SaaS)
    http://msdn2.microsoft.com/en-us/architecture/aa699384.aspx

    Visual Studio 2008 (formerly known as Visual Studio code name "Orcas")
    http://msdn2.microsoft.com/en-us/vstudio/default.aspx

    These are just a few of the many. If you are a developer I would suggest that you take a look at Visual Studio 2008. I think you will find that it is a big improvement from the 2005 version.

    If you are an IT-Pro take a look at PowerShell. It can make your life much easier.

    Have fun.

    Brian

     

  • Custom Validation Rule for Web Test

    The other day someone on the Team System Testing forum posted a question about Web Test validation rules when using master pages in their ASP.Net application. The problem is that if you use a master page it will change the names of your form fields at runtime. For example if you have a form field named “LName” it will be change to something like “ctl00$ContentPlaceHolder1$LName”. So if you have created a validation rule for “LName” it will now fail as there a field with “LName” is no longer returned.

     

    So how do you handle validation or extraction rules for a web test if the names of your form fields are changed at runtime by the master page.  Well you can use one of the two following methods.

     

    1. Hard code the names that the master page generates. If you do this you just need to be careful that you don’t change your ASPX page in such a way that the generated name is changed.
    2. Use a custom validation rule. This allows you to write code so that you can look and make sure that “LName” is part of a field name. This way we don’t care about the generated name.  A custom rule also gives you much more control over what you are validating. You can add the code for a custom validation or extraction rule to your test project or you can create them in a class library project if you want others to be able to use the rules you create.

     

    Here is an example of a custom validation rule that allows you to enter a form field name and a value to check for. It then checks to see if the name you entered is in any of the field names. So if you enter “LName” as the field name to look for and you use a master pages that changes the name to “ctl00$ContentPlaceHolder1$LName” it will find this field as the code uses the String.Contains Method to check and see if “LName” is contained within the HtmlTag.

     

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.ComponentModel;

    using Microsoft.VisualStudio.TestTools.WebTesting;

    using System.Diagnostics;

     

    namespace myRules

    {

        public class rule2:ValidationRule

        {

            private string _name;

            private string _value;

     

            public string Name

            {

                get {return _name;}

                set {_name = value;}

            }

     

            public string Value

            {

                get { return _value; }

                set { _value = value; }

            }

            public override string RuleName

            {

                get { return "rule2"; }

            }

            public override string RuleDescription

            {

                get

                {

                    return "validate rule";

                }

            }

            public override void Validate(object sender, ValidationEventArgs e)

            {

                if (e.Response.HtmlDocument != null)

                {

                    //look for input tags

                    foreach (HtmlTag tag in e.Response.HtmlDocument.GetFilteredHtmlTags(new string[] { "input" }))

                    {

                        for (int i = 0; i < tag.Attributes.Count; i++)

                        {

                            string temp = tag.Attributes[i].Value.ToString();

                            //Debug.WriteLine("Name  " + tag.Attributes[i].Name);

                            //Debug.WriteLine("Value " + temp);

                            //check to see if the tag contains the name we are looking for

                            if (temp.Contains(_name))

                            {

                                //Debug.WriteLine("check " + tag.GetAttributeValueAsString("value"));

                                //check to see if the value of the tag name we were looking for is what we are expecting

                                if (tag.GetAttributeValueAsString("value") == _value)

                                {

                                    e.IsValid = true;

                                    return;

                                }

                            }

                        }

     

                    }

                    e.Message = "No input tag contained " + _name + " in it";

                    e.IsValid = false;

                }

            }

        }

    }

     

    For more information on custom validation rules check out the following links

    http://msdn2.microsoft.com/en-us/library/ms182556.aspx

    http://blogs.msdn.com/joshch/archive/2005/11/17/494164.aspx

     

     

    Enjoy and have fun.

    Brian

  • Programmatically get Work Items from TFS

    My manager needed a report on bugs (work items) in TFS (Team Foundation Server). The bugs were in different areas of the project and I had been using different queries in Team Explorer to get and view the data. So now I wanted to automate this so I did not have to run the different queries and then create a report by hand from him. My design goal was to use the queries that are designed in VS Team Explorer and saved to .WIG files. The code should then pull the query from all .WIG files. This will allow queries to be updated and new ones to be added with out the need to change any of the code.  With this in mind I downloaded the VS 2005 SDK which has some classes that allow you to programmatically work with TFS. You can download the SDK from the following link:

    http://www.microsoft.com/downloads/details.aspx?FamilyID=7e0fdd66-698a-4e6a-b373-bd0642847ab7&DisplayLang=en

     

    While looking through this I found an excellent sample showed how to run TFS queries. The sample is “Work Item Query Sample.Zip” in the version of the SDK I am using it is located in the following folder:

    “Visual Studio 2005 SDK\2006.04\VisualStudioTeamSystemIntegration\Work Item Tracking”

     

    Using this as a starting point I created a small app that would use the .wiq files to get the queries to run. After it ran the query I would place the results into a Table which is then stored into a DataSet. This way I can just walk the different tables or bind them to a control to create my report. Here is the code for anyone who is interested. Standard disclaimer: “I don’t have much error checking in this code so use at your own risk”

     

    My using statements:

    using System;

    using System.Collections.Generic;

    using System.Text;

    using Microsoft.TeamFoundation.Client;

    using Microsoft.TeamFoundation.WorkItemTracking.Client;

    using System.Diagnostics;

    using System.Data;

    using System.Xml;

    using System.IO;

    using System.Collections;

    using System.Configuration;

     

    C# Code:

    class Program

        {

            static DataSet BugDataSet;

            static void Main(string[] args)

            {

               // get the path to the querys.

                DirectoryInfo myDir;

                if (ConfigurationManager.AppSettings["QueryDirPath"].ToString().Length > 0)

                {

                    myDir = new DirectoryInfo(ConfigurationManager.AppSettings["QueryDirPath"].ToString());

                }

                else

                {

                    //if it is not in the config file we assume they are in the following folder.

                    myDir = new DirectoryInfo(Environment.CurrentDirectory + "\\TFSquerys");

                }

                FileInfo[] myfiles = myDir.GetFiles("*.wiq");

                int FileCount = myfiles.Length;

                BugDataSet = new DataSet();

                for (int i = 0; i < FileCount; i++)

                {

                    Console.WriteLine(myfiles[i].FullName);

                    XmlReader reader = XmlReader.Create(myfiles[i].FullName);

                    reader.ReadToFollowing("TeamFoundationServer");

                    string connection = reader.ReadString();

                    reader.ReadToFollowing("TeamProject");

                    string project = reader.ReadString();

                    reader.ReadToFollowing("Wiql");

                    string DTSQuery = reader.ReadString();

                    int finddot = myfiles[i].Name.IndexOf(".");

                    ProcessDTSQuery(connection, project, DTSQuery, myfiles[i].Name.Substring(0,finddot));

                }

                CreateReport(); // this code is not included!

               

            }

     

            static void ProcessDTSQuery(string connection, string project, string DTSQuery, string BugType)

            {

                //run the query and save the results into a table

                bool idField = false;

                TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(connection);

                WorkItemStore store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

                Hashtable context = new Hashtable();

                context.Add("project", project);

                WorkItemCollection result = store.Query(DTSQuery, context);

                Console.WriteLine(BugType);

                DisplayFieldList fieldList = result.Query.DisplayFieldList;

                //give the table the same name as the wiq file.

                DataTable table = new DataTable(BugType);

                DataColumn column;

                DataRow row;

                int i;

                for (i = 0; i < fieldList.Count; i++)

                {

                    column = new DataColumn();

                    column.DataType = System.Type.GetType("System.String");

                    column.ColumnName = fieldList[i].Name;

                    table.Columns.Add(column);

                    if (fieldList[i].Name == "ID")

                        idField = true;

                }

                column = new DataColumn();

                column.DataType = System.Type.GetType("System.String");

                column.ColumnName = "WorkItemUri";

                table.Columns.Add(column);

              

                for (int ii = 0; ii < result.Count; ii++)

                {

                    row = table.NewRow();

                    for(i= 0; i< fieldList.Count; i++)

                    {

                        object o = result[ii].Fields[fieldList[i].Name].Value;

                        string s;

                        if (o is DateTime)

                        {

                            s = ((DateTime)o).ToLocalTime().ToString();

                        }

                        else if (o != null)

                        {

                            s = o.ToString();

                        }

                        else

                        {

                            s = "";

                        }

                        row[fieldList[i].Name] = s;

                    }

                    if(idField) //only add this if we have the workitem ID

                // Workitem.aspx allows you to get a web page to view the bug using the workitem ID

                        row["WorkItemUri"] = connection + "/WorkItemTracking/Workitem.aspx?artifactMoniker=" + result[ii].Fields["ID"].Value;

                    table.Rows.Add(row);

                }

                BugDataSet.Tables.Add(table);

               

            }

    }

     

    Please note I have not posted the code that walks through the DataSet Tables to create my custom report.

     

    Hope this helps if you have a need to pull work item data from TFS.

     

    Enjoy and have fun.

     

    Brian  

     

     

  • Unit Testing on Vista's IIS

    Ok you are now unit testing your web service and everything is going fine. So now you decide that you want to try out RC1 of Vista so you set it up and make sure IIS is installed. So now you try and create an ASP.Net app in the localhost only to find that it does not work. Don’t worry check out the following blog that explains what you need to do so you can create ASP.Net websites on IIS in Vista with VS 2005

    http://blogs.msdn.com/jorman/archive/2006/06/06/619246.aspx

     

    Cool so now you are coding away and you go to test your unit test only to get the following error: “The web site could not be configured correctly; getting ASP.NET process information failed. The server may not be running a version of Asp.Net version 2.0 or greater.  Requesting 'http://localhost/website/VSEnterpriseHelper.axd' returned an error: The remote server returned an error: (500) Internal Server Error.”

     

    What is this I have Asp.Net 2.0 install! Ok don’t worry. You can easily fix this by doing the following.

     

    1.       Start/Run “InetMgr”

    2.       Navigate to the website.

    3.       Choose “Advanced settings…”

    4.       Set the application pool to "Classic .NET AppPool".

    5.       Restart IIS.

    6.       Run you unit tests again.

     

    Enjoy and have fun!

  • Save Time by Unit testing your webservices

    Ok folks here we go, the first post on my new blog. My current job at Microsoft is a Developer Tools Support Engineer supporting the new tools that ship in Visual Studio 2005 Team Edition. Ok enough about me.

     

    There has been a big push for SOA (Service Orientated Architecture) and the new tools in VS 2005 Team Edition reflect that. Ok so now that you have created your web service how do you quickly test it on both your development box and then in production. One easy way to do this is to create a unit test for your web service. With the team edition for developers you can just right click in the class code for you web service and select “Create Unit Tests” from the popup menu.  You can then select the different methods that you want to test.

     

    Ok so you have done that but you need to test with different values being passed for calls to each method. You could go into each unit test and change the code values you want, run the test and then do it all over again. However that gets old very fast. Not to worry you can place all of you data into a database table and then bind your unit tests to a table. When the test runs it will loop through all of the data in the table and call the webservice method once for each row in the table. Binding your unit test methods to a table can be done with a few clicks of the mouse of by adding the connection string as an attribute to your test method.

     

    So now everything is working and you deploy your code out to production or pre-production. How do you quickly test to see if everything works in your production environment? While the answer is that you can just change the URL in the App.config file for your test project or the “URLToTest” attribute of your test methods. Which one of these your unit test uses will depend on if you used the new asp.net development server or IIS when you created your webservice. For example the section in your app.config file that you need to change the URL will look like the following:

     

    <TestProject1.Properties.Settings>

                <setting name="TestProject1_localhost_MathServiceDemo" serializeAs="String">

                    <value>http://localhost:21940/MathService/MathServiceDemo.asmx</value>

                </setting>

            </TestProject1.Properties.Settings>

     

    So now everything is working but you would like to stress your webservice. Don’t worry if you have Team Edition for testers you can create a load test using your unit tests. This will allow you to quickly load test you web server using the unit tests you have already created.

     

    Now you say, Brian I am sold how do I find out more. Well if you don’t have VS 2005 team editions you can get a trial version from the following site:

    http://msdn.microsoft.com/vstudio/teamsystem/products/suite/

     

    For more information on Unit testing and databinding a unit test see the following links:

    http://msdn2.microsoft.com/en-us/library/ms182515.aspx

     

    http://msdn2.microsoft.com/en-us/library/ms404708.aspx

     

    So go enjoy and have fun.

     

    Brian


© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker