: : Tom Fury
Den enda dokumentationen över Tommies liv

Visar inlägg med etikett Exjobb. Visa alla inlägg
Visar inlägg med etikett Exjobb. Visa alla inlägg

Framläggningen av examensarbetet

Category: By Tom Fury
Äntligen så var det gjort! Framläggningen klar, och med ett gott resultat! Vi skulle egentligen ha varit i konferensrummet John von Neumann, men i och med att det kom så himla mycket folk (vad kan det ha varit... 60-70 personer totalt?), och Visionen var ledig, så flyttade vi framläggningen dit. Otroligt kul att få lägga fram sitt examensarbete i den stora high-tech salen! Kände mig faktiskt aningen ärad att få göra det.


Presentationen gick väl, bättre än väntat även om jag tappade tråden ett par gånger. Jag lyckades dock plocka upp den ganska snabbt igen (tror jag åtminstone). Opponenterna gjorde även de ett strålande jobb med en riktigt bra presentation och intressanta frågor för diskussion. Trodde ärligt talat att de skulle såga rapporten mer, men de gav mer creds än väntat. Det tackar vi för! Publiken hade även de ett par frågor som var intressanta och skapade debatt.

Jag vill tacka alla som tog sig mödan att komma dit för att lyssna på oss. Även om det kanske inte är världens roligaste ämne för alla, och att alla kanske inte förstod riktigt vad det var vi babblade om där framme, så betyder det ändå väldigt mycket att ni fanns där på plats. Tack ska ni ha!

Åhörarna lyssnar uppmärksamt.... eller sover :-p.

Efter framläggningen diskuterade vi lite vad vi behöver korrigera i rapporten innan den kan skickas in för tryck. Det var inte så mycket, och idag har vi suttit och fixat till det mesta. Hursomhelst, efter framläggningen så bar det av hemåt till mormor i Norrpan för att skåla i Champagne och äta diverse exotisk mat - riktigt gott och ett stort tack till allihopa i familjen/släkten som lagt ned så mycket tid och ork på att ordna det här.

Improvisation! :D

Därefter bar det av ut till Mange på vischan för att fortsätta festandet. Grabben fyllde ju år samma dag, så hans föräldrar hade ordnat med en härlig tillställning med smörgåstårta, alla möjliga sorters dricka och trevligt sällskap. Stort tack för att man fick komma och vara delaktig! Kvällen blev ganska sen - vi i järngänget stannade kvar allra sist och vi åkte hem i taxin runt 03 någonting. Blev kvar i Linköping till lördagen och åkte sedan hem på eftermiddagen.

Bla bla bla bla....

Jag kommer slänga upp lite fler bilder varefter jag orkar ladda upp dem, men håll till godo med dessa så länge. Sammanfattningsvis kan man säga att det var en toppendag, och det var länge sedan jag blev så uppvaktad som jag blev. Återigen är jag grymt glad över att det kom så pass många! Visserligen saknade man en del personer som har betytt och fortfarande betyder väldigt mycket för mig, men det kan ju inte alltid klaffa.

"Ni ser den här symbolen här? Den har inte jag ritat."

Nu lämnar man studentlivet och har redan smakat på en veckas arbete. Jag tror jag kommer trivas! Imorgon bär det av upp till Stockholm för Nova Forum. Tror det kommer bli skitkul!

Dags att göra lite nytta idag nu, får återkomma med fler uppdateringar senare. Över och ut!


Förresten; Rapporten kommer publiceras inom två veckor på nätet, och sedan kommer den även skickas till tryck och blir tillgänglig på bibliotek. Jag återkommer när den slutgiltiga versionen finns att tillgå, för de som är intresserade.


Finally an update

Category: By Tom Fury
I know I haven't updated the blog in a while. That's because nothing interesting really has been happening. The last couple of days have been dedicated to write the master thesis report - and we're almost done with the theoretical part.

Regarding the implementation, I've got the Adapter + the XML schema left to do. I'm not sure how far Magnus has proceeded at the client part and the Excel reports, but I think it's going well. I know he's been able to produce an add-in package to Visual Studio which adds a meny item, from where you can communicate with our webservice to send the code metrics.

I'll get back to the blog as soon I've got some interesting news. Just wanted to assure you that I wasn't dead or slacking off ;-).


Database connection is working on the TFS now

Category: By Tom Fury

FINALLY! After too many hours of work I've finally got it working. Let me just summarize what I've done.

First of all I downloaded and installed the SQL Server Management Studio Express so I won't need to use a command line tool on my local computer. A very good tool for configuring your SQL server. What I did was to detach the database from my Solution in Visual Studio and saved it somewhere else (D:\CodeMetricsDB.mdf & D:\CodeMetricsDB_log.ldf) - this was because I couldn't add files located in my user account directory into the Management studio (I wonder why?).

Anyway. After opening the application and connecting to your SQL serve, right-clikc Databases --> Attach... --> Add... --> Select the D:\CodeMetricsDB.mdf file and then press OK. Congrats, you have your CodeMetricsDB in your SQL Server now. (I renamed it to CMDB in this case afterwards).

In Visual Studio, open the Server Explorer and right-click on the Data Connections symbol --> Add new connection... --> choose your server name and then choose the DB from "Select or enter a database name:" (in this case CMDB). Press OK.

Now you're set to develop against a database in your SQL server instead of a separate file located in the App_Data subfolder (which is troublesome when moving it to the VPC).

You can from inside SQL Server Management Studio Express generate a script which creates the database with all constraints, stored procedure etc. Do this and run the script on the VPC, or copy over the files (.mdf and .ldf) and then run this from a command line (found the tip here):

sqlcmd -E -Q "exec sp_attach_db @dbname=N'CMDB',
@filename1=N'C:\path\CodeMetricsDB.mdf',
@filename2
=N'C:\path\CodeMetricsDB_log.ldf'"

Now you should have the database in you VPC SQL Server (check it by either download and install SQL Server Management Studio Express on the VPC (yes, it works fine for "regular" SQL Server too), or use sqlcmd like this):

C:\> sqlcmd
1> use CMDB
2> go
Changed database context to
'CMDB'
1>

If it works, you have the database. Or, you could use a stored procedure to list the databases:

C:\>sqlcmd
1> sp_databases
2> go
DATABASE_NAME
---------------------------------------
---------------------------------------
CMDB

master

model

msdb

ReportServer

ReportServerTempDB

tempdb

TfsActivityLogging

TfsBuild

TfsIntegration

TfsWarehouse

TfsVersionControl

TfsWorkItemTracking

TfsWorkItemTrackingAttachments

WSS_AdminContent

WSS_Config

WSS_Content

1>

As you can see the CMDB database is on top.

But it isn't all set and done by just adding the table. Secondly you'll have to alter the connection string to:

1 string connstring = "Data Source=ORCASBETA2_TFSV;" +
2 "Database=CMDB;" +
3 "Integrated Security=true;";

As you can see we've changed the "Data source" from .\\SQLEXPRESS --> ORCASBETA2_TFSV (line 1) and the database name must match (line 2). Another thing to think about is if it is preferred to use SQL Server Authentication or Windows NT Authentication. We don't know yet, but probably Mr. König can give us some guidance of what method to prefer (as of now, I've just used Windows NT Authentication).

So everything should work fine now, right? No. When trying to access the database via the webservice by running the client on the VPC, we get an exception:

---------------------------

---------------------------
System.Data.SqlClient.SqlException: A connection was successfully established with the server, but then an error occurred during the login process.
(provider: Shared Memory Provider, error:
0 - No process is on the other end of the pipe.)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadPacket(Int32 bytesExpected)
at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
at System.Data.SqlClient.TdsParserStateObject.ReadByte()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at CodeMetricsService.registerMetrics(Int32[] theMetrics, String projName)
in c:\WCFService1\App_Code\CodeMetricsService.cs:line 32
---------------------------
OK
---------------------------

After some googling and research, I finally found a solution to the problem. Here's how to get around:

  1. Start SQL Server Management Studio Express (in the VPC)
  2. Go to [your server] --> Security --> Logins in the left pane
  3. find NT AUTHORITY\NETWORK SERVICE and double click it to open the properties dialog
  4. Go to User Mappings in the left pane of the properties pane
  5. Identify your database in the table to the right (in this case: CMDB) and make sure the checkbox is marked under the column "Map" for you database
  6. Under "Database role memebership for: CMDB [you databasename] check "db_owner".
  7. Now it should work fine!

I don't know if this is a smart thing to do when havin security in mind, and there are possibly other combinations of role memberships that you could use to make it work (instead of db_owner). But it worked and I'm satisfied with that as for now. Improving things will be a later problem - now we can continue our work - and that would be to create an adapter for the TFS warehouse (finally!).

Oh yeah, and another thing. It isn't really working well to develop in the VPC using VS 2008. Everytim I try to build my solution for the website, it never finishes the build - just keeps on chewing on forever (even though it says "Validation Complete"). I don't know what's wrong and I don't have time to find out - so I will continue to develop on my XP machine and transfer files as necessary to the VPC via FTP.

Phew! That's a long post. Hope it could be helpful for someone out there.



Stored Procedure done!

Category: By Tom Fury

I decided we're better off making a stored procedure instead of managing the SQL queries in C#. First of all it's more efficient since stored procedures are are pre-compiled such that they execute optimally. Second, the abstraction is good. Now you just have to call "InsertCodeMetrics" from the webservice instead of creating complex SQL queries at that level. The positive parts are many, the negative parts are non-existing. So, how did I do the stored procedure? See here:

1 ALTER PROCEDURE dbo.InsertCodeMetrics
2 (
3 @Metric1 int,
4 @Metric2 int,
5 @Metric3 int,
6 @Metric4 int,
7 @Metric5 int,
8 @ProjectName varchar(50)
9 )
10
11 AS
12 DECLARE @LatestEntry int
13
14
15 INSERT INTO SavedEntries (ProjectName) VALUES (@ProjectName)
16 SET @LatestEntry = (SELECT @@IDENTITY)
17
18 INSERT INTO MetricsData (EntryID, Metrics1, Metrics2, Metrics3, Metrics4, Metrics5)
19 VALUES (@LatestEntry, @Metric1, @Metric2, @Metric3, @Metric4, @Metric5)

Simple and easy and it works. This is how you would use it in the webservice (C#):

1 SqlConnection conn = new SqlConnection(connstring);
2
3 try
4 {
5 SqlCommand command = new SqlCommand("InsertCodeMetrics", conn);
6 command.CommandType = CommandType.StoredProcedure;
7 command.Parameters.Add("@Metric1", SqlDbType.Int).Value = theMetrics[0];
8 command.Parameters.Add("@Metric2", SqlDbType.Int).Value = theMetrics[1];
9 command.Parameters.Add("@Metric3", SqlDbType.Int).Value = theMetrics[2];
10 command.Parameters.Add("@Metric4", SqlDbType.Int).Value = theMetrics[3];
11 command.Parameters.Add("@Metric5", SqlDbType.Int).Value = theMetrics[4];
12 command.Parameters.Add("@ProjectName", SqlDbType.VarChar).Value = projName;
13
14 command.ExecuteNonQuery();
15 return "OK! Metrics added.";
16 } catch (Exception e)
17 return e.ToString();
18 }

Easy to both use and understand. (You can see how connstring is constructed in a previous post on my blog, if you're interested).



Getting it right with multiple dependent tables in SQL

Category: By Tom Fury

I've spent some time figuring out how to keep data integrity intact when working with several tables in my SQL Database. Several solutions are possible, and one of them are to create a stored procedure which takes care of updating several tables at once. I think that would be the wisest thing to do. However, I've postponed that solution for a while and made it work directly in my web service.

I discovered the @@IDENTITY attribute you can use in SQL. The @@IDENTITY attribute (or directive or whatever it is called) gives you the latest identifier for the table. So I've added it to my query when I insert an entry into the SavedEntries table:

myCommand.CommandText = "INSERT INTO SavedEntries (ProjectName) " +
"VALUES ('" + projName +"'); SELECT @@IDENTITY;";

Then I save the identity just selected:

string latestIdentity = myCommand.ExecuteScalar().ToString();

Finally, I alter the MetricsData table using the identity as a foreign key to the column EntryID:

myCommand.CommandText = "INSERT INTO MetricsData (EntryID, Metrics1, Metrics2, Metrics3, Metrics4, Metrics5) " +
"VALUES (" + Convert.ToInt32(latestIdentity) + "," +
theMetrics[
0] + "," +
theMetrics[
1] + "," +
theMetrics[
2] + "," +
theMetrics[
3] + "," +
theMetrics[
4] + ");";

I don't know if the conversion to Int32 is necessary (second row above), but it feels safer because latestIdentity is declared as a string.

Anyway, it works. Now I just have to make it work on the VPC. Furthermore, I'll give it a thought about implementing this in a stored procedure instead. We'll see what happens :-). Feedback and thoughts on this matter are much appreciated!



Inserting automatic timestamps into the database

Category: By Tom Fury

After some search I've found the way to do it:

  1. Open the table in Server Explorer and select the column in which you want to store the automatic timestamp.
  2. Under Column Properties, modify "Default Value or Binding" to hold: (getdate()).
  3. Save, and you're done!

Now everytime you insert a record into the database, the timestamp will be generated for you.



To get the SQL-thingy going....

Category: By Tom Fury

Now, I've managed to create my own database in my Solution in VS, created some (preliminary) tables, and I got it all working on my XP machine. But then we have that thing about transferring it to the VPC to get it to work in Windows Server 2003. Not so easy as I thought.

First of all, let's talk about my tables. This is just a preliminary design, but I think we will keep it somehow intact:

ID ProjectName TimeStamp (more identifying properties)

This table is called "SavedEntries". Everytime someone evaluates code metrics and sends the result to TFS, a new row will be added to this table in the database. ID is the primary key, ProjectName (or whatever ww in the future will choose as an artifact) will hold artifact-information. TimeStamp stores time and date for when the metrics were performed. We will perhaps need to store more attributes, so it is possible to extend the table with more columns.

ID EntryID Metric1 Metric2 Metric3 Metric4 Metric5

This table is called "MetricsData". It speaks for itself. ID is the primary key for the table, EntryID is a foregin key mapped to SavedEntries.ID (see SavedEntries table above). The meric reults are stored in his table.

That was the tables. Now to my problems. I've created a new SQL Database called CodeMetricsDB.mdf and it is stored in the App_Data folder (together with its CodeMetricsDB_log.LDF file). It works fine on XP with the following connection string:

string connstring = "Data Source=.\\SQLEXPRESS;" +
"AttachDbFilename=|DataDirectory|CodeMetricsDB.mdf;" +
"Integrated Security=True;" +
"User Instance=True;";

However, when I transfer the webservice files to the VPC for TFS, I get a severe exception. After some search on the net I found that it is probably the attaching of the CodeMetricsDB.mdf file that makes it all go to hell.

Mr. König helped me out a bit by telling me that I shouldn't use SQLEXPRESS but instead a "real" SQL server, and attaching the database by using some database tool. The problem is that I can't find any tool (or other way to do it) on the VPC. And even if I use the Server Explorer inside Visual Studio 2008, when I try to add a new connection, all I can choose as server is ORCASBETA2_TFSV\SQLEXPRESS. Why? Shouldn't I be able to choose some "non-Express-SQL-server"? I'm really confused.

So I'm stuck again, with something working on XP but not on the VPC. And I don't know if the Integrated Security + User Instance in the connection string is a wise thing to do. Perhaps I should use SQL authentication instead. But then again, I need to find some way to add users to the SQL server databases (which I don't know how to do in the VPC).

One positive thing is that I at least know how I should read information from the database usin C# (same connection string [conn] as above - it works on my local computer but not on the VPC):


1 SqlConnection conn = new SqlConnection(connstring);
2
3 try
4 {
5 conn.Open();
6 }
7 catch (Exception e)
8 {
9 return e.ToString();
10 }
11
12 // try to read data from the DB
13 try
14 {
15 SqlDataReader myReader = null;
16 SqlCommand myCommand = new SqlCommand("select * from SavedEntries", conn);
17 myReader = myCommand.ExecuteReader();
18 string result = "Result: ";
19 while (myReader.Read())
20 {
21 result = result + myReader["ProjectName"].ToString() + "....";
22 }
23 return result;
24 }
25 catch (Exception e)
26 {
27 return e.ToString();
28 }
29
30 conn.Close();

Lines 15-17 performs the reading operation. Everytime myReader.Read() is called, it consumes one row of the results returned from the SQL database. (In the above examples, it returns a string containing all ProjectNames stord in the SavedEntries table, separated by four dots).

I'll have to figure out how to solve this XP <--> VPC problem. As I've tried so far, developing on the VPC instead doesn't seem to help me at all. I'm pretty sure that it all will work fine if I could figure out a way to (1) attach the database to the SQL Server in the VPC and (2) create a correct connection string for the scenarioa in (1).



Finally it works...!

Category: By Tom Fury

Finally I've managed to get the webservice work on the TFS VPC. What did I do? There are some further things you have to have in mind when deploying on the VPC (when developed on another machine):

  • Make sure that the right version of ASP.NET is used (should be 2.0.50727). This is easily changed through the IIS Manager by right-clicking on your website --> properties --> ASP.NET tab.
  • You have to change some parts of the XML schema for your client. This is because it uses Windows authentication, and the <identity> entry must be adjusted to the user logged in on the VPC (in this case TFSSETUP). So make sure your <client> ... </client> part in [clientfilename].exe.config looks like this:

1 <client>
2 <endpoint address="http://localhost:38970/Service.svc"
3 binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
4 contract="ServiceReference.IService" name="WSHttpBinding_IService">
5 <identity>
6 <userPrincipalName value="ORCASBETA2_TFSV\TFSSETUP" />
7 </identity>
8 </endpoint>
9 </client>

The thing you need to change is on line 6 (userPrincipalName). Also make sure that the endpoint (line 2) is linked correctly (see previous post).

Phew! Now I just have to do some fine-tuning to adjust it to our code metric model. And figure out how to make TFS recognize this webservice exists...(anyone?)



Another one with the same problem

Category: By Tom Fury

This guy had exactly the same problem as me. Too bad no solution is posted. As of now I have to choose between a 405 error message or an "endpoint not found" error message.

Congratulations Tommie. It's your lucky day....



Things to concider when deploying the web service

Category: By Tom Fury

The purpose of this post is mostly as a reminder for myself.

The Webservice

  • Copy the whole directory to the TFS installation (anywhere on drive)
  • Open IIS Manager
    • Right click on Web Sites --> New Web Site
    • In the Wizard specify:
      • Description: (whatever)
      • IP Adress and Port Settings, set IP = 38970. Leave the other fields as default. (next -->)
      • Path: Browse to the directory you copied over to TFS (next -->)
      • Permissions: Read, Run scripts, execute, browse (?)

The Client

  • Copy the .exe and the .exe.config to anywhere on TFS
  • Open the .exe.config file and scroll down. Find the tag and remove the subdirectory
  • Do something else so it works with permissions and authorization...


Some good news now...

Category: By Tom Fury

I didn't wreck my computer and I'm glad I didn't. I managed to create a working web service and host it on my own computer on IIS (running windows XP Professional). However, there are some complications when transfering my service to the TFS VPC (I'm developing on my own computer, usin Visual Studio 2008).

The problems encountered has to do with the configuration of IIS, and how they differ from XP <--> Windows Server 2003. First of all, it took some time before I even managed to create a (correct) virtual directory to store my web service in. Although managed (by editing the client .config-file and deleting the subfolder entry to make it point directly at http://localhost:38970/Service.svc, even though I've created a virtual subdirectory for my webservice), I still have som problems regarding authorization. Because the credentials differ from my XP installation and the TFS VPC, I'll have to go around that somehow. When I try to call the webservice it just shouts back at me:

System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---

I really don't know how to work around this part as of now. Suggestions would be greatly appreciated. (It works extremely well on my own XP computer! I just can't get it to work on the TFS VPC...).



Freaking out on IIS

Category: By Tom Fury

As I said in a previous post, I got the webservice working okay. But then it was hosted in a simple console application. Now I've been trying all day to host it on IIS, but I can't seem to get it to work. It's frustrating and I'll soon apply my sledgehammer ultra extreme super mega dropkick on my computer.

There's a bunch of articles on the web saying how you should do to host your WCF service on IIS. But the more I read, the more confused I get. Some bloggers mention one thing, others mention another. I get all things mixed up and to add to it all it doesn't look like I'm making any progress.

Jesus christ, I hope I'll solve this soon before I go nuts...



Freaking out on IIS

Category: By Tom Fury

As I said in a previous post, I got the webservice working okay. But then it was hosted in a simple console application. Now I've been trying all day to host it on IIS, but I can't seem to get it to work. It's frustrating and I'll soon apply my sledgehammer ultra extreme super mega dropkick on my computer.

There's a bunch of articles on the web saying how you should do to host your WCF service on IIS. But the more I read, the more confused I get. Some bloggers mention one thing, others mention another. I get all things mixed up and to add to it all it doesn't look like I'm making any progress.

Jesus christ, I hope I'll solve this soon before I go nuts...



Connecting to TFS

Category: By Tom Fury

I managed to make a short program which connects to the TFS Server and extracts information from it. The program is written in C#, and is not really hard to make. I'm not sure though if that's the right way to go. I know that I can implement some C# code in my webservice, but it's still not clear to me if I should connect to TFS this way or another.

Anyway, I do it like this, in a simple C# console application (yes, it is from an article at MSDN - I just don't remember the source right now):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace MyFirstApplicationForTFS
{
class Program
{
static void Main(string[] args)
{
// Let the user choose a TFS Server
Console.Write("Please enter a valid TFS Server or URI: ");
String tfsServer
= Console.ReadLine();
tfsServer
= tfsServer.Trim();

// Connect to the TeamFoundation Server
Console.WriteLine();
Console.Write(
"Connecting to Team Foundation Server {0}...", tfsServer);
TeamFoundationServer tfs
= TeamFoundationServerFactory.GetServer(tfsServer);

// Example: Connect to the WorkItemStore
Console.WriteLine();
Console.Write(
"Reading from the Work Item Store...");
WorkItemStore workItemStore
= (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

// Example: Display the details about the teamFoundationServer
Console.WriteLine("\n");
Console.WriteLine(
"Team Foundation Server Details");
Console.WriteLine(
"Server name: " + tfs.Name);
Console.WriteLine(
"Uri: " + tfs.Uri);
Console.WriteLine(
"AuthenticatedDisplayName: " + tfs.AuthenticatedUserDisplayName);
Console.WriteLine(
"AuthenticatedUserName: " + tfs.AuthenticatedUserName);
Console.WriteLine(
"workItemStore:");

// Example: List the projects in the WorkItemStore.
Console.WriteLine(" Projects.Count: " + workItemStore.Projects.Count);
foreach (Project pr in workItemStore.Projects)
{
Console.WriteLine(
" " + pr.Name);
}
Console.WriteLine(
"\n\nDONE!");
}
}
}

It works fine, I've tried it on the TFS VPC. But as I said, I'm not sure that I'm on the right track here. Perhaps webservices that are to be a part of TFS should communicate in some other way with the server. I'll have to study some more. Please do give me some feedback on my thoughts!



I did it! WCF Conquered

Category: By Tom Fury
Found this excellent example on how to implement a simple web service (explained step by step on this blog). It helped me a lot to understand how I am supposed to do. And, amazingly, I got it working! I’m so overfilled with joy right now I don’t know what to do. I’ve spent almost all day figuring out how to use WCF and configuring IIS to get around all possible types of error messages – and finally, it worked.

Now, there are obviously more things to do. First of all I need a client which sends the code metrics data to the web service (I did implement a simple client, but Magnus is taking a deeper look into making a client via a package for VS 2008). Secondly, the web service needs a method that receives these code metric data and finally forwards them into the Data Tier on TFS. I know how to construct a method that receives the data. Now I need to concentrate on two primary things regarding the web service:

  • How does TFS register that my web service exists? (I think I’ve read about that somewhere but forgot it by now… typical!)
  • How does the web service push the data into our operational store?
  • Furthermore, after these two things have been dealt with, I need to find out:
  • Where and how do we implement the operational store? (Yeah I know, in the SQL server in TFS – but I need more details! Preferably a guide or walkthrough)
  • …and then all the things concerning the adapter, the XML schema and those things in that area.
TODO-list:
  • Learn WCF
  • Build a web service
  • Make XML schema for the adapter
  • Create Adapter
  • Create operational store
  • Write some parts of the master thesis (theoretical)


Extending TFS continued (and more...)

Category: By Tom Fury

It's been a while since I wrote something here, so I think it's time I'll give you all an update on what's going on in the project.

On monday this week we had a Live Meeting with Mr. König, where we showed
this presentation with our findings and questions. The black hole as we saw it then was how to implement the operational store where we should store our data in the TFS server.

The answer to that question were pretty straightforward. We have to create a new database in the same SQL-Server. Then we have to build our own Web service layer on TFS. Finally, we have to implement a client which communicates with the web service. This client should send the code metrics down to our operational store (database). The webservice we implement should then be added to the IIS on the TFS server. As an endpoint to which the client can communicate, we need to provide an URL for the service.

The Team Foundation Object Model that I've been wondering about will apparently be created when you supply the URL to the client. I didn't really understand how that works, but I think It'll be clear as soon I start experimenting with it.

We should have our emphasis on the Adapter + operational store + the report, and not spend too much time constructing the web service.

One thing to think about is how to map our dimensions we'll create to those that already exist in the data warehouse in TFS.

We still need to put our emphasis on the server part of the project, not the client. Next week we will meet with an American gentleman who has been responsible for the (now existing) Code Metrics in Visual Studio 2008. Depending on the outcome of that meeting, we'll see what twist & turns the project will take on the client side. Some suggestions were uttered during the meeting; you could for example see if it is possible to extend the Code Analysis engine to get our code metrics. Or, we could use some kind of external open source tools that performs the code analysis in Visual Studio.

Regarding the reports, we should use MDX and the Report Designer to create them.

So Magnus and I have splitted up the work between us.
I will take care of:

  • Figuring out how to create the Operational Store
  • Create a Web Service
  • Create an Adapter
  • Create a XML schema for the Adapter


Magnus will take care of:

  • Creating the report (MDX + Report Designer)
  • Take a look at the Dashboard-part; how to implement that in the project portal
  • Figuring out how to use the TFC API to create our client


As for the master thesis part, work is not going so well. We still haven't got a project context to work with (delimitations on project type, role, size of project etc) so we can't do any empirical research. We're at a complete halt here, and it is very concerning! Time is running out and I'm really worried if we'll make it on time. To add up to all this we still haven't got the books we need to do a good job. None of these things are at our table, so I really really do hope that it gets sorted out soon, preferrably already yesterday.

Anyway, my TODO-list:

  • Learn WCF
  • Build a web service
  • Make XML schema for the adapter
  • Create Adapter
  • Create operational store
  • Write some parts of the master thesis (theoretical)
I will start with a try to create the web service and a client (just a simple one) to see if it works. Then I will create a really simple operational store and an adapter associated with it. Start simple, and then extend it further.

Well, time to get some work done.

Over and out!


Extendning the TFS data warehouse

Category: By Tom Fury
I've been reading some material on how you could extend the TFS data warehouse, and it definitely not a trivial task. As far as I've understood we will have to implement our own operational store (Microsoft SQL Server 2005?), whereafter we implement an adapter. This adapter serves as the interface to the TFS data warehouse and transforms our data so that reports could be generated from these data in the future.

Although, I am wondering if it isn't possible to use existing operational stores to use a new adapter on? It isn't really clear, and with the lack of books which collect all this important information in one single place, it's really hard to get an overview. There are 5 existing operationl stores as of now:

  • Common Structures
  • Work Item Tracking
  • Source Control
  • Team Foundation Build
  • Team Test
But how do you implement an Adapter? According to some articles on MSDN, you'll have to implement the IWarehouseAdapter interface, which in turn must implement at least 4 methods:

  • void Initialize(IDataStore ds)
    Initializes the adapter, and holds a reference to the IDataStore object (keeps the adress of the TFS server and the tools the adapter will work with).
  • SchemaChangeResult MakeSchemaChanges()
    Provides means by which an adapter can indicate whether it will change a schema on this run.
  • DataChangesResult MakeDataChanges()
    Does the primary work of the adapter. Pulls data from the operational store and writes to the warehouse using the object model.
  • void RequestStop()
    Stops the adapter in an orderly fashion in the event the service is taken down.
The practical part of building the adapter involves building it as an DLL and copying it to a plugin folder of the TFS installation.

But you do really only need to create an adapter if you're adding new data types to the warehouse. I can see no other option than doing so if we are to save code metrics in the warehouse. Code metrics is (or rather I think it probably will be) a new data type for the data warehouse. Do correct me if I'm wrong.

So if I am correct in my assumptions (further studies have to be made, I'm not 100 % sure on these things) the tasks that lie ahead of us are to define and implement an operational store and an adapter for that store. The last step will be to utilize these new data in the data warehouse by designing a report which uses these code metrics.

Of course we first have to implement a tool in the client (VSTS) to have something to save into our operational store (also a part of our original assignment).

I will have to read some more about extending the data warehouse in TFS before I am totally sure on how we should proceed.

Some useful links:
IWarehouseAdapter Interface
Implementing an Adapter
How to: Create an Adapter
Understanding the Data Warehouse Architechture (good diagram of the architecture on this page)
Data Warehouse Extensibility
How to Extend the Data Warehouse Database

Reading tips are greatly appreciated! I will continue tomorrow with my investigation. Feels like I'm on the track of something here at least. Hopefully it will not show to be a dead-end.


Status Update

Category: By Tom Fury
Yesterday we had a Live Meeting with Dag König and Nils Stadling. I thought I'd just summarize what we concluded from the meeting:

Software metrics were defined together with the conecpt of code metrics. It is code metrics that are of a particular interest (in contrast to software metrics, which includes measurements on documentation, requirement specifications, use cases, etc). Mr. Stadling is going to investigate which types of projects are most common when developing with Visual Studio Team System and Team Foundation Server, together with some kind of contact list from where we will be able to do some empirical research.

This means that it is possible that we will deviate from our original description of our project. The task will be the same, but the prerequisites and delimitations will probably differ (no longer from a project managers perspective - probably rather from a Developer Managers perspective, or some similar role). We will, although, still implement some code metrics in VSTS and then implement these metrics in TFS.

The books were on the way, and I hope we will get them soon. Until we get them though, I and Magnus will dig deep into the Visual Studio SDK for the 2008 Beta to learn exactly how you can extend the Data Warehouse to our needs. Also, we will probably have some looks at VisualStudio Extensions home at CodePlex and the Visual Studio Extensibility Forum on MSDN.

On monday (October 8th) we will have another Live Meeting with our supervisors. Until then we hope that Mr. König has some news about the code metrics utility in the VS 2008 client. As for our task, we should've come up with a solution on how to extend the Data Warehouse in TFS. If you do have suggestions on how to do it, or have some suggestions where to search for information - please do let me know.

If you want to se our PowerPoint slides, please do have a look at it here. Feel free to use it as you wish, as long as you don't change it.

I won't waste any more time here now, it's time to check out the VS 2008 SDK and start searching for solutions.


I'm going west, the project is going well.

Category: By Tom Fury
These days I've been reading three previous master theses on the subject of Software Metrics: "Mätetal för mjukvaruutveckling - Framtagande av ett mätprogram på Ericsson Business Networks AB" (Translates to "Software Metrics for Software Development - Developing a Measurement program at Ericsson Business Networks AB"), "Tillämpning av Software Metrics på objektorienterade system - En studie och ett praktikfall" (Translates to "Application of Software Metrics on Object-Oriented Systems - a study and practical case"), and finally "A Study of Software Metrics: Choosing a Relevant Set of Attributes for the Measurement of Software Quality at Tandberg Data A/S".

I must say that I really didn't learn much new - mostly I just got my previous knowledge confirmed. Nevertheless, there were some useful tips on how to choose relevant quality factors. Maybe not so much with a specific role in mind as I had hoped, but it was hopefully useful knowledge anyway.

I've also been watching some of the few on-demand webcasts that I had left. Can't say that I really learned something useful (for our project) there either - most of them were just repetition of what've been said before in previous web-casts.

Got some other good news though - probably we have two project managers at IFS that can assist us in our empirical research. Magnus has more information about that part.

We've also put together a powerpoint presentation and installed the Live Meeting client, so all deliverables are prepared for the meeting on monday with our supervisors on October 1st, at 1600 hours.

I'll be in Norway during the weekend to visit some relatives, and I'll get back sometime Sunday evening. So I won't be able to answer emails or calls.

Over and out!


Quality factors

Category: By Tom Fury
As I stated in a previous post, our first "mission" will be to find what quality factors that are relevant to a project manager, managing a software engineering project using the MSF Agile process model.

But what is a quality factor? A quality factor is a key attribute of the software, normally high-level external attributes. It is these attributes that constitue the quality of the software product from the users perspective in the end. The quality factors are determined by dividing them into some criterias which are relevant for that quality factor. Each criteria is measured and quantified by some kind of metric(s) (there is a possibility that several metrics contribute to one criteria).

An example is in place. Let's look at the quality factor Maintainability. Maintainability can be described by three criterias; Correctability, Testability and Expandability, where:

  • Correctability is quantified by using the metrics Fault counts and Effort
  • Testability is quantified by using the metrics Degree of testing and Effort
  • Expandability is quantified by using the metrics Change counts and Effort
Fault count could be measured by either Closure time, Isolate/fix time or Fault rate. Degree of testing could be measured by either Statement coverage, Branch coverage or Test plan completeness. Effort could be measured by Resource prediction or Effort expenditure. Change counts could be measured by Change effort, Change size or Change rate.

Other quality factors than Maintainability that could be mentioned are e.g. Usability, Integrity, Efficiency, Correctness, Reliability, Testability, Flexibility, Reusability, Portability and Interoperability. Each of these are then defined by some criteria, which in turn are measured (or quantified, if you prefer that term) by using some metrics.

The ISO 9126 standard suggests there should be only 6 quality factors depicting the quality of a software product. These quality factors are:

  • functionality
  • reliability
  • efficiency
  • usability
  • maintainability
  • portability

As you can see the quality factors are high-level descriptors of software quality. With the constraint on the context for our investigation, we will have to find both theoretical and empirical guidelines of which quality factors that are relevant.

As of today we have one software project manager confirmed who (hopefully) will be able to help us out with some real-life experience on these topics. But other than that, we mostly rely on Microsoft to provide us with willing customers who are using the MSF Agile process model.

And another thing Magnus and I discussed today is how much the process model really affects the results. Do a project manager leading a project under the MSF Agile process model prioritize different quality factors than those leading a project under the, say, RUP och waterfall model? We're not confident that this variable will have such a great impact on the conclusions to be drawn.

More to come later on...