Microsoft Team Foundation Server (TFS)


Why do we need version controller or source controller? This post will answer this question and introduce a version controller which is introduced by Microsoft (Team Foundation Server) and compare it with the Microsoft visual sourcesafe.

This is a compact post of all above things, most of the things had refer on internet. Thanks every one who write these things on the web.

Let's try to answer above question. Actually why do we need a Version Control System (VCS)? Let's assume you are working on a large project and each single module developed by single programmer and also they need to share their source or builds among each others when they needed. So simply you can suggest a shared folder to hold all the sources and builds which every one can access it. But what's happen when two programmers open same project and edit it by both of them? Exactly it will complicated for both programmers. And also there are no way to control versions ~ can not roll back to previous version. Now you understood the needs of VCS.

You may find available VCS here

Now let's move to TFS.

What is TFS?

Team Foundation is a client-server source control system that uses a .NET Web service to access items stored in a SQL Server database.
  • Version control, for managing source code and other deliverables that require versioning.
  • Work item tracking, for keeping track of such things as defects, requirements, tasks, and scenarios.
  • Project management functions, which allow the shaping of a team project based on a user-specifiable software process, and which enable planning and tracking using Microsoft Excel and Microsoft Project.
  • Team build, for enabling a common process for building executable products.
  • Data collection and reporting, which aid in the assessment of a team project's state, based on information gleaned from Team Foundation Server tools.
  • The Team Project Portal, which provides a central point of communication for a team project packaged as a Microsoft Windows SharePoint Services site.
  • Team Foundation Shared Services, which provide a number of common infrastructure services that invisible to end users but that, are important to tool smiths and extenders.

Ways to access TFS

  • From Visual Studio – through Team Explorer
  • From the command line
  • From the web browser
  • From Microsoft Office products
  • From other platforms or IDEs
  • From Windows Explorer
There are some other products also to access to TFS.

Following figure shows the web interface of the TFS



Comparison between Visual Source Safe and TFS.

Visual source safe is an old software that Microsoft developed for version control. Most of the visual studio programmers are still use SourceSafe. But there is a way to completely migrate from VSS to TFS. We will see that method later. Now let's move to comparison.







VSS
TFS
Description
Security and Project Rights
Low
High

Reliability

Low
High
VSS does not have a server component, while TFS is client server application. TFS writes operations occur in the database by way of stored procedures that are not subject to network connectivity issues.
Scalability
Low
High
TFS can support teams of up to 2000 users whereas VSS is recommended for teams of 20 or less.
Sharing and Pinning
Yes
No
Share or Pin features not in TFS. When you migrate VSS projects to Team Foundation, Pins in a Visual SourceSafe database are replaced by labels.
Check-Out and Check-In
Yes
Yes
In Visual SourceSafe, you must do an explicit check-out and check-in only if you are editing a file. In Team Foundation, every action requires an explicit check-out and check-in.

Team Foundation Features that Do Not Exist in Visual SourceSafe

Visual SourceSafe Features that Do Not Exist in Team Foundation

  • Share
  • Pin
  • Archive and Restore
  • Destroy
  • Keyword expansion
  • Rollback
 Next post will be a complete guidance to migrate VSS database to TFS.



Continue Reading...

Create Window service project in C# - Part 3 (Using Timers in a service)

So now we know how to create, launch and view event log for a Windows service using C#. If you do not have a clear idea please refer following two posts.

 Now let's create a windows service application which use Timers. Because most of the windows services are running to execute specific task periodically. That's mean execute a code after specific time period without user interaction. 

For that purpose you can use Timer component in C# which enables you to execute a code segment periodically. Let's see how this thing worked...

First you have to create a timer object on your service class. I am not going to further describe these things, because you will be able to understand by looking on following code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace MyWinService
{
    public partial class MyService : ServiceBase
    {
        System.Timers.Timer tmrDelay;
        int count;

        public MyService()
        {
            InitializeComponent();

            if (!System.Diagnostics.EventLog.SourceExists("MyLogSrc"))
            {
                System.Diagnostics.EventLog.CreateEventSource("MyLogSrc", "MyLog");
            }

            //set our event log to system created log
            myEventLog.Source = "MyLogSrc";
            myEventLog.Log = "MyLog";

            tmrDelay = new System.Timers.Timer(5000);
            tmrDelay.Elapsed += new System.Timers.ElapsedEventHandler(tmrDelay_Elapsed);
        }

        void tmrDelay_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            string str = "Timer tick " + count;
            myEventLog.WriteEntry(str);
            count++;
        }

        protected override void OnStart(string[] args)
        {
            myEventLog.WriteEntry("MyService started");
            tmrDelay.Enabled = true;
        }

        protected override void OnStop()
        {
            myEventLog.WriteEntry("MyService stoped");
            tmrDelay.Enabled = false;
        }
    }
}

This code was placed on "Service1.cs" file on my project.

Code explained

 System.Timers.Timer tmrDelay;
 int count;
Declare timer variable for timing purpose and count variable for counting purpose.

 tmrDelay = new System.Timers.Timer(5000);
 tmrDelay.Elapsed += new System.Timers.ElapsedEventHandler(tmrDelay_Elapsed);
Create timerDelay object for 5000ms(5 seconds) delay. Then event handler so that timer will execute the code within the "tmrDelay_Elapsed" method in every five seconds. (Do not worry this event handler code line will automatically generate when you type '+=' and press tab)

 void tmrDelay_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
    string str = "Timer tick " + count;
    myEventLog.WriteEntry(str);
    count++;
 }
This is the event handler for timer elapsed event. When timer elapsed a specific 'interval' time it will execute code within this event handler.

Here adds a new entity on event logger as "Timer tick 1" , 2, 3, 4 ....

Other codes are as it is on previous post. Therefore I am not going to explain those here.


Now build and install your solution as describe in Part 1. Then you will see some thing similar to this in "Event Viewer" or "Visual Studio".


As you can see when each time timer elapsed it will add new entity to logger. So now it's your turn place any code in timer elapsed event to execute it periodically.

Complete project can be downloaded from here.
Continue Reading...

Create Window service project in C# - Part 2 (View event logs)

This article series describes about creation of windows service application using C#.net. My previous post describe about the creation and installing of the windows service using C#. This article will introduce you to the way to check logs on windows system.

Can you can remember, we create an event log for our windows service project. But where should I look for these logs to view those. This article will answer for that question.

You can check whether our new windows service is installed or not from Computer management and also you can start you service from here by clicking on "start". As we write on our program there is a action when starting the service to write "MyService started" on event log. (in OnStart method)

You can check these logs using either Visual studio or event viewer on windows.

Visual studio

Just open Server Explorer from visual studio to view all services. If you unable to find the server explorer, you can select it from view menu. (Or press Ctrl+W then L in VS 2010). You will find your event log under Servers --> [Your PC name] --> Event logs. When you expand your event log you will see all the logs which are loged by your service. (nor Refresh the list)



Event Viewer
Just open "Event viewer" from start menu and you will find your event log and its details. Also you can clear your logs from here.


Continue Reading...

Create Window service project in C# - Part 1 (Create and launch)

Windows service is a running executable on windows which perform a specific functions without user interaction. So you can even create a windows service to do a specific function without your interaction. There is an easy way to create a windows service application in C#. This article describe step by step of creating windows service application in C#.net. and my next parts will describe further more about...

Step 1
Open visual studio and File--> New --> Project. then select "Windows service" and type name and location of your project.


Step 2
Then go to "Service1.cs" file's design view. Then Properties of Service1 and change the 'Name' and 'Service name' as you wish. I changed those as "MyService" as you can see on following screenshot. Then click "Add Installer" to add an installer for this service.

Step 3
Then click on 'serviceInstaller1' component on 'ProjectInstaller.cs' file's design view then get its properties. Now you can change the properties of serviceInstaller1 as shown in following figure.

Make sure the Service name is equal to the service name that you enter for Service1.cs's properties and select StartType as Automatic. Then let's see properties for serviceProcessInstaller1 on ProjectInstaller.cs. You should change the Account as LocalSystem. It will prevent asking username and passward from the user when install this windows service.

Step 4
Now let's see how to get notified whether our service is running or not. For that you can use EventLog component as describe as followings. First go to Service1's design view and the add a eventlog component from tool box.



I changed added event log's name as 'myEventLog'. So then move to the coding... (switch to the code view of Service1.cs file)
Add following code segment to immediately following to the initialize component method calling on the constructor of the MyService class.

 if (!System.Diagnostics.EventLog.SourceExists("MyLogSrc"))
 {
    System.Diagnostics.EventLog.CreateEventSource("MyLogSrc", "MyLog");
 }

 //set our event log to system created log
 myEventLog.Source = "MyLogSrc";
 myEventLog.Log = "MyLog";


This will create a system event log and bind our event log to created log.
Then add following code segment to the override method of OnStart. There are more override methods which are on ServiceBase class as our class extends the ServiceBase class. You can try those methods also for further more actions.

 myEventLog.WriteEntry("MyService started");


OnStart override method can be use to execute actions when our service starts. Because OnStart method executes when a Start command is sent to the service by the Service Control Manager (SCM) or when the operating system starts (for a service that starts automatically).

Let's try OnStop method also. So enter following code segment in OnStop method.

 myEventLog.WriteEntry("MyService stoped");


Now your code should like this,


Now our event logger part finished. You can build this project by pressing F6. (If you try to run this project you will receive an error message which notify you "cannot run or debug... first install this service.." like that) So let's move to install our service on windows.

Step 4
To install the service first create an installation project for our project. Let's create it...
Right click on your solution (not project) from solution explorer window and point to the Add then click on New Project...


Then select Setup Project from the list which can be found under Setup and Deployment category. Then type name for your project then Ok.


Now you can see the new project on solution explorer, right click on it and point to Add then click on Project Output... . Then select your project name and select Primary Output.


Then again right click on setup project and point to View then click on Custom Actions. You will see the custom action window. Then right click on Custom Actions then Add Custom Action . You will see the Select Items from Project window. Select Application folder from the Lock in combo box and select Primary output from (active) then Ok.


No you can see, it will add Primary output for all four actions (Install, Commit, Rollback, and Uninstall).


Now we are ready to install our new windows service on windows. Just right click on setup project and select Install from the drop down menu. Now you will see the installation wizard just like normal installation.

That's all for creating basic Windows and installing windows application in C#.net. You can see your service on windows service list. Just go to Computer management by selecting it from start menu. And navigate to Services which can be find under  Services and application category.


Complete Visual studio C# project can be download from here.

My next post will describe how to check your event log to ensure your program.
Continue Reading...