Team System widgets
Accentient has a really nice list of Widgets for team System. Here you will find links to useful tools like the TFS Administration Tool, the TFS Power Pack and useful plugins like the Must Have Comments Check-in Policy. The list is growing, which is a good thing, because TFS has some missing functionalities, but you will probably find the missing parts on the list.
The LCD-TV integration is also listed, which is really cool
Check it out on: http://accentient.com/widgets.aspx
Presentasjonen fra NNUG [in Norwegian]
Takk for et fantastisk bra oppmøte i går. Mulig det var pga. Halloween og at folk følte seg truet til å komme
. Beklageligvis ble det fullt, og forståelig nok ville ikke brannansvarlig la folk sitte i midtgangen, så desverre måtte noen av de påmeldte deltakerne snu i døra. Totalt sett var det 140 påmeldte og det var plass til ca. 100 i auditoriet.
Uansett, her er presentasjonen jeg holdt i går. Hvis du skal kjøre Continuous Integration, så er det bare å laste ned eksemplet som jeg har lagt ut i denne artikkelen. Gjerne legg inn kommentarer hvis noe er uklart, så skal jeg forsøke å svare på det så godt jeg kan.
Working with WebTests
I have found very few articles on how to make customized WebTest with Visual Studio 2005 Team Edition for Testers or Visual Studio 2005 Team Suite. However, I bumped into this great article that show some of the more advanced techniques for authoring advanced and custom WebTests.
The article had excatly what I needed. My goal is to make a crawler that fetches most of the URL's on a website. This is useful for testing resources on the server when content is cached. Hitting the same page over and over again is not useful for testing memory resources. The test must fill the cache to it's limits and then we can see what performance the users will experience.
If the article is removed (or the server is down), here is the example code I used. I have of course modified it (removed links to external pages, javascripts, CSS/Images, etc.) to match the site I am running the test against, but the core code is the same.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.WebTesting;
public class LoopingCoded : WebTest
{
public LoopingCoded()
{
}
public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
// Issue a search for the term "Microsoft"
WebTestRequest request7 = new WebTestRequest("http://testserver/website/Search.aspx");
request7.ThinkTime = 20;
request7.Method = "POST";
FormPostHttpBody request7Body = new FormPostHttpBody();
request7Body.FormPostParameters.Add("txtSearch", "Microsoft");
request7.Body = request7Body;
yield return request7;
// Loop through each anchor tag in the search result and issue a request to each tag's target url (href)
foreach (HtmlTag tag in this.LastResponse.HtmlDocument.GetFilteredHtmlTags("a"))
{
WebTestRequest loopRequest = new WebTestRequest(tag.GetAttributeValueAsString("href"));
yield return loopRequest;
}
}
}
Resharper Team Blog
Can't live without it. Developing without resharper is like drinking a beer with a straw. It's possible, but slow. And to be honest refactoring in Visual Studio 2005 sucks. It's a lightweight implementation of refactoring, and it's slow. Compare "Find usages" in VS 2005 with resharper and I think you get the point.
Ok, resharper has a lot of bugs, but it will become more stable in the near future. Anyway, check out the new Team Blog for resharper.
A great article on understanding ViewState
This is as important to ASP.NET developers as it is to developers creating server controls (both user controls and custom controls). ViewState is difficult to understand, but when used correctly, it's very powerful.
Read and learn: http://infinitiesloop.blogspot.com/2006/03/truly-understanding-viewstate.html
Wrong timestamp in the Enterprise Application Logging block
If you have tried the standard implementation of the SimpleFormatter in Enterprise Library Logging block, you will notice that timestamps are not what they should have been (depending on where you live in the world, of course;) ) . In Norway, for instance, the timestamp is 2 hours wrong. This is actually by design, since logging should be time independent and use UTC time. Anyway, in my opinion this should be configurable by default, but it seems the only way around is to write your own, or extend the SimpleFormatter.
Tom Hollander writes about the solution in his blog.
BTW, make sure you use the rolling file trace listener by Erwyn van der Meer. It's excellent for not having one HUGE log file.
Passing an object to ObjectDataSource
I like the ObjectDataSources in some occasions, even if liked the .NET 1.1 way of working with data better. I have played around with ObejctdataSources for a while, and it hit me that it's not intuitive to pass an object as the parameter. The Visual Studio designer has functionality for passing parameters to the business objects, but only as strings. This is actually a limitation to the Parameter class as the DefaultValue is of type string.
Coding standards suggest that a method should have 7 parameters or less (some say even 5), and databinding methods can have a lot of parameters based on what data to fetch. A good way is to pass a struct or object instead of several parameters.
So it's not possible to initially pass an object as a parameter. You have to do it in an event instead. The following solution illustrates how it could be done:
- Select the ObjectDataSource in the designer and select the Events for the ObjectdataSource.
- Double click the Selecting event. This generates a callback method for the event in your code behind file.
- The method should look something like this:
protected void ObjectDataSourceNewsList_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
NewsArchive newsArchive = new NewsArchive();
newsArchive.Language = "no";
newsArchive.Country = "NO";
e.InputParameters["newsArchive"] = newsArchive;
}
The newsArchive parameter is defined in the ObjectDataSource as of type Object. This works fine, but it's rather strange that you have to define the parameter in an event and not by the parameters in the ObjectDataSource.
Override the rendering of the ASP.NET 2.0 controls.
In April, the ASP.NET team will ship examples on how to use ControlAdapters for the ASP.NET 2.0 controls. This is a really good idea, because very few people knows how to override the rendering of the standard ASP.NET 2.0 controls. The ControlAdapters allows the developers to render the controls in a really nice way instead of using tables, which seems to be the Microsoft way. For instance, the menu control can be rendered with <ul><li> tags and be customized with CSS classes. This is a really nice feature that few people know about.
Working with Visual Studio 2005 and ADO.NET
Seems like there are some changes in how to work with related tables in Visual Studio 2005 compared to VS 2003. I really like working with the designer tool as it does a lot of timeconsuming stuff for you. It's really easy to work with typed datasets by dragging and dropping the tables from theServer Explorer into the designer. But there are some hick ups that are really diffucult to find the answers to. In my opinion, Microsoft are really good in making Mickey Mouse examples and not real life examples. What happens when you for instance are trying to update two tables that are related at the same time ? Well, you get an SqlException, typical like:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Customers_Employees". The conflict occurred in database "EnterpriseCRM", table "dbo.Employees", column 'EmployeeId'.
The statement has been terminated.
yuck! Ths was really not the intention.
Here is the solution:

Figure 1: An Enterprise CRM system
My database schema looks something like figure 1 (added to the Visual Studio designer by dragging and dropping). I have added a couple of queries to the Customers table, but have nothing to do with the example.
Now, here is the code that generates this error:
Here is the code that does the logic. It's adding some new rows to the Customers and Employees tables, and setting the relations between the rows. The relation is the newCustomer.EmployeesRow = newEmployee:
ds = new DataSetEnterpriseCRM();
ds.GetRegions();
for (int i = 0; i < 3; i++)
{
DataSetEnterpriseCRM.EmployeesRow newEmployee = ds.Employees.NewEmployeesRow();
newEmployee.Name = "SomeOne";
DataSetEnterpriseCRM.CustomersRow newcustomer = ds.Customers.NewCustomersRow();
newcustomer.Region = 1;
newcustomer.Name = "New TestRelatedRow";
newcustomer.EmployeesRow = newEmployee;
newcustomer.KAM = newEmployee.EmployeeId;
ds.Employees.AddEmployeesRow(newEmployee);
ds.Customers.AddCustomersRow(newcustomer);
}
ds.SaveEmployeeAndCustomer(ds);
The code in the partial class of my DataSet. This code updates the tables in the database by calling the update method on the TableAdapters:
public void SaveEmployeeAndCustomer(DataSetEnterpriseCRM dataSet)
{
CustomersTableAdapter adapter = new CustomersTableAdapter();
EmployeesTableAdapter employeeAdapter = new EmployeesTableAdapter();
employeeAdapter.Update(dataSet.Employees);
adapter.Update(dataSet.Customers);
}
This code is perfectly legal and should teoritically work fine, but instead you will get the error message described above. Seems like there are some problems with cascading updates. There is, and here is the solution to the problem.
Configuring the relation
You need to configure the Typed DataSet. By default it does not support cascading updates. It is easy to do, but not well documented anywhere! One should maybe think that this was automatically supported when dragging and dropping the tables from the designer, but that's not the case.
Double-click the relation between the tables and you will get the following properties box:
Notice the dropdownlists
Set the update and delete dropdowns to "cascade" and the radiobutton to "Both Relation and Foreign Key Constraint".
Updating the AutoIncrementSeed and AutoIncrmentStep
This is only necessary if you are using AutoIncrement for the primary key. You need to specify that the increment seed should start with -1 and that the step should be -1. Click the table containing the primary key and select properties for the primary key column.

Set the AutoIncrementSeed and the AutoIncrementStep to -1 if you are using AutoIncrement for the primary keys.
This will cause the keys to be -1, -2, -3 and so on. This prevents the keys from interferring with the keys in the database. When the update methods of the adapters are executed, the keys will change and fetched again from the database. You can double check that by looking at the insert statement in the adapter. There is an select right after the insert which is returning the Identity_scope of the inserted row. That will always the latest incremented key inserted. The best of all is that the foreign key relation will be correct when the primary key is inserted before the row containing the foreign key.
Now, everything should be up to shape and the relations should work. Happy coding!
[Updated] Continuous Integration using an LCD-TV
You have probably seen examples of doing CI (Continuous Integration) using lamps. Shortly explained, the idea is that when the build breaks, the red lamp is turned on and when the build is OK, the green lamp is turned on. It's a pretty cool feature, so I thought of moving this idea a step further! Lamps are for dinosaurs
I have already implemented CI using the excellent example in Khushboo's blog. It's implemented with Team Foundation Server RC. The setup with the LCD-TV can be used in any CI environment, the idea is the same. Every time a developer checks in code, the build process is triggered. The display on the LCD-TV is just a custom website displaying the status of the build-server. The website has an auto-refresh (every 5th second or so) to get the latest status. When building, the screen turns yellow, and when the build fails, the screen turns red. The screen is green when everything is OK.
Here are some screens from our setup:
The OK screen:
The Build screen:
The Failed build screen:
The setup:
The setup is quite simple actually, you need the following items:
- A huge LCD-TV (at least 37" to make the people in the back happy)
- A laptop/PC/server to connect the LCD-TV. This will serve as a client.
- The FireFox browser (it supports blinking text
, IE don't) - A website that displays the result of the process. Should probably be installed on the build server.
and of course, you need a Project Leader that sees the point in investing a couple of bucks in a good development environment. It's not a simple task, but at least it's worth it. The quality of the code will definitively be better and the status of the build is very visible for the project team. My experience is that the red screen is not red for long, especially when your face is on it
Server setup:
- Install TFS Build Service on server
- Install VS 2005 Team Suite or VS 2005 Team Edition for Software Developers (code analysis/fxCop) + VS 2005 Team Edition for Testers (Code Coverage)on server
- Install VS 2005 Web Deployment Projects on server for deployment possibilities. Only needed for web projects, though.
- Create WebSite for CI (for instance http://[tfsserver]:8090). Use code in ci.zip (download further down on this page). Use the same AppPool as TFS (TFS AppPool)
- Configure web.config for CI
- Run the following command on server: “%programfiles%\Microsoft Visual Studio 2005 Team Foundation Server\TF Setup\BisSubscribe.exe /eventType CheckinEvent /address http://[tfsserver]:8090/service/WebService.asmx /deliveryType Soap /domain http://[tfsserver]:8080”
- Check in the following table in SQL server that the subscription is registered: tfsintegration.dbo.tbl_subscription
Possibilities
Ok, you really don't need a LCD-TV to show a red or green screen. But, it's the information that is important. You could for instance display burn down charts, code quality, test result etc. when the screen is green. And how about a blue screen (no, not a BSoD) when the standup meeting is supposed to start (to get the team members attention). There are a lot of possibilities with this setup.
(update) Install and setup
Well, people, here is the source code.
The Webapplicaiton includes the status screen as well as the CI example in Khushboo's blog (a little modified, but mostly the same). Install the webapplication as a new Web Site in IIS (with a different port) on the build server (in my environment, I am running the build and tfs services on the same server). The status screen is using the TFS API instead of the webservices, so all DLL's need to be installed on the server running the status screen application. It should be possible to use the webservcies as well, if this setup doesn't suite you.
A couple of things:
- Remember to trigger the checkin event described in Khushboo's blog. The WebServcie is included in the web application in the CI code package. it's located in the Service folder.
- Remember to set the correct Application pool for the web application. It should be the same pool as for the TFS web application (TFS AppPool or similar)
- Use FireFox as the browser on the client machine connected to the TV. If you remove the standard toolbars and hit F11 the status page will fill the whole screen, which is really nice. It also supports blinking text.
- Do anything you wan't with the code and use it as you like, I don't care, but I'm interested in any cool changes you do to it, maybe it could be an Open Source project in the future.
- Don't spam me with support issues. Please post them in this blog, maybe we can figure it out together.
Good luck!
Feel free to come with ideas and feedback of the setup.
Search
Knut Hamang
Recent Posts
Recent Comments
- Tim M on Passing an object to ObjectDataSource
- harin yadav.C on Html to Pdf in .NET
- harin yadav.C on Html to Pdf in .NET
- gautham on Html to Pdf in .NET
- How To Convert HTML To PDF With Image Tags Using iTextSharp | Top Online Trading on Html to Pdf in .NET




