DCSIMG
Oshry Horn

Oshry Horn

Using Microsoft's UITypeEditors With The OOTB List<T> Editor

This post is a sequel to a previous post - The TFS Build Definition List<T> OOTB UITypeEditor.

In my previous post I showed how easy and cheep it is to use the TFS’s build definition OOTB “List<T>” editor.
We even saw that if we use enum’s or Boolean's the “List<T>” editor’s properties grid gives us drop-down editors for them, but what if we want to use more advanced editors; such as the “ServerFileBrowserEditor” to select a project from the source control or the “PlatformConfigurationListEditor” editor to choose in which configurations and platforms I want to compile the project or any other editor?

Well it seems to be extremely easy as well. All we need to do is take the same object we were using before:

   1: using System.Collections.Generic;
   2: using System.ComponentModel;
   3: using System.Drawing.Design;
   4: using BuildDemosC.Common.Enums;
   5: using Microsoft.TeamFoundation.Build.Workflow.Activities;
   6:  
   7: namespace BuildDemosC.CustomTypes
   8: {
   9:     public class DevEnvCompilationItem
  10:     {
  11:         [Category("Properties")]
  12:         public string Project { get; set; }
  13:  
  14:         [DisplayName("Compiler Name")]
  15:         [Category("Properties")]
  16:         public DevEnvType CompilerName { get; set; }
  17:  
  18:         #region Methods
  19:  
  20:         public override string ToString()
  21:         {
  22:             return string.IsNullOrEmpty(Project) ? "New" : Project + "=>" + CompilerName;
  23:         }
  24:  
  25:         #endregion
  26:  
  27:     }
  28: }

and add the “Editor” attribute with the editor we want to use over the property we want to use it with:

   1: using System.Collections.Generic;
   2: using System.ComponentModel;
   3: using System.Drawing.Design;
   4: using BuildDemosC.Common.Enums;
   5: using Microsoft.TeamFoundation.Build.Workflow.Activities;
   6:  
   7: namespace BuildDemosC.CustomTypes
   8: {
   9:     public class DevEnvCompilationItem
  10:     {
  11:         [Editor("Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor, Microsoft.TeamFoundation.Build.Controls", typeof(UITypeEditor))]
  12:         [Category("Properties")]
  13:         public string Project { get; set; }
  14:  
  15:         [DisplayName("Compiler Name")]
  16:         [Category("Properties")]
  17:         public DevEnvType CompilerName { get; set; }
  18:  
  19:         #region Methods
  20:  
  21:         public override string ToString()
  22:         {
  23:             return string.IsNullOrEmpty(Project) ? "New" : Project + "=>" + CompilerName;
  24:         }
  25:  
  26:         #endregion
  27:  
  28:     }
  29: }

After we check-in our changes, open a new instance of visual studio (So it will load the new dll files) and go to the build definition this is what will see when we came to edit our object list:

image

Easy, elegant, cheep! :)

The TFS Build Definition List<T> OOTB UITypeEditor

A while back I came a problem:

I needed to build for a client an activity  that runs on an unknown number of projects and builds them with DevEnv 2005/2008/2010.

I needed to create an editor that allows the user to select projects to be built in DevEnv and additional properties for each project such as “DevEnv version” and “Configuration to build”.

The problem was that I had very little time to do this.

This is where my good friend Baruch Frei came into the picture; He informed me that when I build a simple dumb object such as:

   1: using System.ComponentModel;
   2:  
   3: namespace BuildDemosB
   4: {
   5:     public class DevEnvCompilationItem
   6:     {
   7:         [Category("Properties")]
   8:         public string Project { get; set; }
   9:  
  10:         [DisplayName("Compiler Name")]
  11:         [Category("Properties")]
  12:         public DevEnvType CompilerName { get; set; }
  13:  
  14:         /// <summary>
  15:         /// Specifies whether Clean and then build the solution or project with the specified configuration. Default is false
  16:         /// </summary>
  17:         [Category("Properties")]
  18:         public bool Rebuild { get; set; }
  19:  
  20:         #region Methods
  21:  
  22:         public override string ToString()
  23:         {
  24:             return string.IsNullOrEmpty(Project) ? "New" : Project + "=>" + CompilerName;
  25:         }
  26:  
  27:         #endregion
  28:     }
  29: }

and add a List<T> of that object to the builds “Process Template” as an argument like this:

image

What we will see in the “Process” tab of the “Edit Build Definition” window is the Microsoft “out of the box” editor of the List<T> object in TFS build definition.

This editor will hand us the functionality of adding and removing objects of type T to and from the list as well as to edit each of the public properties of the object.

image

On the left side you see the object in the list, displayed by their ToString() method, and on the right you see a properties grid of the selected object on the left.

What is also nice is that if you have in your object properties such as Boolean or Enum the properties grid will inflict those restrictions in the form of a drop down. 

 

Easy and fast.

 

In my next post I will show how to use some of Microsoft's internal UITypeEditors with the OOTB List<T> editor.

A List of Out of The Box Usable Microsoft “UITypeEditor”s

As I’ve shown in here, it is easy and productive to use the Microsoft built in “UITypeEditor”s in TFS 2010 build definitions. It is also possible to use them in other WinForms based environments.

This is the list as I’ve extracted it from “Reflector”:

Type Edited Editors
string Microsoft.TeamFoundation.Build.Controls.BuildAgentSelectionEditor
string Microsoft.TeamFoundation.Build.Controls.BuildNumberFormatEditor
StringList OR List<String> Microsoft.TeamFoundation.Build.Controls.BuildProjectListEditor
BuildSettings Microsoft.TeamFoundation.Build.Controls.BuildSettingsEditor
An object of a T Enum Type Microsoft.TeamFoundation.Build.Controls.EnumPropertyEditor
List<PlatformConfiguration> Microsoft.TeamFoundation.Build.Controls.PlatformConfigurationListEditor
string Microsoft.TeamFoundation.Build.Controls.ServerFileBrowserEditor
string Microsoft.TeamFoundation.Build.Controls.ServerFolderBrowserEditor
StringList OR List<String> Microsoft.TeamFoundation.Build.Controls.StringListEditor
List<String> Microsoft.TeamFoundation.Build.Controls.TagsEditor
TestSpec Microsoft.TeamFoundation.Build.Controls.TestSpecEditor
List<TestSpec> Microsoft.TeamFoundation.Build.Controls.TestSpecListEditor
string Microsoft.TeamFoundation.Build.Controls.WorkItemTypeSelectionEditor

These are only the ones directly related to TFS 2010 Build.

 

If you are looking for something more specific, you can open the Reflector find this class “UITypeEditor”, and simply browse through the derived classes (Editors).

How to: Use The Internal Microsoft Custom UI Type Editors In TFS 2010 Build Definition

Let say that I want to enable clients to choose specific projects to publish from within a build definition.

I can obviously add a StringList argument to the build, and have users write the server paths of each project they want to publish as a open strings.

This off course leaves much room for errors on the client side, but farther more it just looks unprofessional!

I don’t want to write A custom UIEditor for this purpose for the following reasons: I’m lazy, no time, and most important I know that such a control exits!! I mean the control that enables us to choose which projects we want to compile as part of the build!

image

image

So now that I see that Microsoft is already using what I need all I have to do is find it and utilize it for my own use:

1) I will go to the arguments tab in the build definition template (possibly DefaultTemplate.xaml) and check what is the type of the variable that is using this UIEditor that I am after. In this case it is “Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings”.

image

2) In our case this is actually not the type that I am looking for because this type contains both project and configurations, and I need only the Projects’ property type. By typing “new Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings().ProjectsToBuild” you can see the type of the property is “StringList”.

3) I will create my own argument and set it to the desired type (since I’m looking for to using the same type of data. In this case a list of strings containing the Server Paths of Projects), and name it “ProjectsToPublish”.

image

4) Now, this part is a bit tricky – I will open “Reflector” and in it open the assembly in which the type I found (BuildSettings) is defined (Microsoft.TeamFoundation.Build.Workflow.Activities).

–If you don’t know where the assembly is, do a general search on your pc--

image

5) Then I will check out the “Editor” attribute of the property “ProjectsToBuild” of the type “BuildSettings”. in this case - "Microsoft.TeamFoundation.Build.Controls.BuildProjectListEditor, Microsoft.TeamFoundation.Build.Controls"

image

image 

6) At this point I will Edit the “Metadata” argument:

image

and get this window:

image

7) In the window I will add my new argument as a Process Parameter, and simply copy the editor’s name (that I found with the reflector) to the Editor textbox.

8) Save and check in the build template file.

9) Go to the “Process” tab of your build definition and press the “Refresh” button to refresh the build definition template.

image

 

That was easy, wasn’t it? :)

image

Works perfectly!

Notice that the editor class we are using is internal, and still it is not a problem!

image 

 

Enjoy! :)

How to Easily Debug a Custom Work Item Control

My friend Assaf Stone have seen my method of debugging Custom Work Item Controls and demanded that I blog about it at once. Thank you! :)

First of all what do we need to debug the WIT custom control:

  1. We need the files that we want to debug to be in this folder: “C:\ProgramData\Microsoft\Team Foundation\Work Item Tracking\Custom Controls\10.0” or an equivalent folder.
  2. We need a second instance of visual studio, and use the “Attach to process” function from the old instance (the one in which I’m writing the control) to attach the new visual studio instance to it.

This can of course be done manually, which means to compile (without debugging), copy the new files to proper folder, start a new instance of visual studio, and attach it to the old one from the old one.

This is extremely annoying and exhausting!! There must be a way atomizes this simple process!!     There is:

The easiest way I know for debugging Custom Work Item Controls is the one I’ve developed using the “Visual Studio Experimental Instance”, and a simple xcopy function.

1) To use “Visual Studio Experimental Instance” for debugging:

    1. Go to the project’s properties window –> “Debug” tab –> check the “Start external program” radio button, and browse to your local visual studio executable (devenv.exe) which is usualy in “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe”.
    2. Write in the “Command line arguments” textbox “/RootSuffix Exp”.

image

This will automate the new visual studio instance creation and its attachment to the old one.

2) In order to not have to copy the dll’s every time I wand to debug the control I added the following “xcopy” function in the control’s post build even:

    1. Go to the project’s properties window –> “Build Events” tab.
    2. Write in the “Post-build event command line” textbox: “xcopy "$(ProjectDir)$(OutDir)*.*" "%ALLUSERSPROFILE%\Microsoft\Team Foundation\Work Item Tracking\Custom Controls\10.0" /i /d /y”.

image

This will automate the copying of the newly compiled files to the proper custom work item control folder according to your operating system.

UPDATE – For this solution to work (the second part: the xcopy) you must run the Visual Studio “As Administrator”!! 

-----------------------------------------------------!!!!!!-----------------------------------------------

All you have to do now in order to debug your custom work item control is to press F5.

-----------------------------------------------------!!!!!!-----------------------------------------------

Experimental Instance of VS 2010 – Safe And Easy Debugging

When you develop a Visual Studio package or add-in you want to be able to run and debug it without having to pollute your environment with untested and\or unfinished applications and components.
This is where the Experimental Instance of Visual Studio 2010 shines. When using this method to debug, what will happen is the following:

  1. A new instance of visual studio will be opened when in the window title bar will written “Start Page – Microsoft Visual Studio (Administrator) - Experimental Instance”.
  2. If the developed app is actually a Visual Studio Package (Visual Studio SDK) the new instance will be loaded as if you have installed your Package already:

image
(New Project window - Visual Studio Package)

If you wish to see how is it done (even though its automatically set) go to the properties of you project and see in the VSIX tab that the checkbox “Deploy VSIX content to experimental instance for debugging” is checked:

image
(Visual Studio Package Project’s properties window)

If the developed app is not a Visual Studio Package it is still possible to use the “Experimental Instance”, but the “face” install will have to be implemented manually (copy dll’s to specific location or whatever).

To use the “Visual Studio Experimental Instance” all you have to do is to do the following:

  1. Go to the project’s properties window.
  2. Go to the “Debug” tab.
  3. In the “Start Action” section, select the “Start external program” radio button. And select your local visual studio executable (devenv.exe), such as: “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe”.
  4. In the “Start Options” section, write in the “Command line arguments” textbox “/RootSuffix Exp”.

image
(Visual Studio Project’s properties window)


Now that we have Visual Studio Experimental Instance and we know how to use it, we should use it when needed to make our lives easier, and help us see what we’re doing!

How to Indicate Unsaved Changes in TFS 2010 Build Definition Custom UI Type Editor

(* – Asterix mark on the parent window)

When I built my own custom UI type editor it was fairly easy, and fully functional.

There was only one bug: when changing (editing) the object in the custom editor, the build definition window did not indicate to me that I had unsaved changes.
Beyond this being extremely annoying, it is also a huge problem because if I close the window I will not know that my changes where not saved (in the case I did not save them).

For this example I will use the Credentials Editor which was posted by Ewald Hofman here.

The Credential object code:

   1: namespace BuildTasks.CustomType
   2: {
   3:     public class Credential
   4:     {
   5:         public string UserName { get; set; }
   6:         public string Password { get; set; }
   7:  
   8:         public override string ToString()
   9:         {
  10:             return UserName;
  11:         }
  12:  
  13:     }
  14: }

This is the code of the UI editor:

   1: using System.Drawing.Design; 
   2: using System.Windows.Forms.Design; 
   3: using System.ComponentModel; 
   4: using System; 
   5: using System.Windows.Forms; 
   6:  
   7: namespace BuildTasks.CustomType 
   8: { 
   9:  
  10:     class CredentialEditor : UITypeEditor 
  11:     { 
  12:  
  13:         public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) 
  14:         { 
  15:             if (provider != null) 
  16:             { 
  17:                 IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); 
  18:  
  19:                 if (editorService != null) 
  20:                 { 
  21:                     Credential credential = value as Credential; 
  22:  
  23:                     using (CredentialDialog dialog = new CredentialDialog()) 
  24:                     { 
  25:                         dialog.UserName = credential.UserName; 
  26:                         dialog.Password = credential.Password; 
  27:  
  28:                         if (editorService.ShowDialog(dialog) == DialogResult.OK) 
  29:                         { 
  30:                             credential.UserName = dialog.UserName; 
  31:                             credential.Password = dialog.Password; 
  32:                         } 
  33:                     } 
  34:                 } 
  35:  
  36:             } 
  37:  
  38:             return value; 
  39:              
  40:         } 
  41:  
  42:         public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) 
  43:         { 
  44:             return UITypeEditorEditStyle.Modal; 
  45:         } 
  46:     } 
  47: } 

The solution was found by my friend Shai Raiten.

The solution is:

The build definition property grid das not recognize changes in the object, therefore we must return a completely different object.

There are 2 possible ways to do this:

1) Use the NEW phrase and to populate the properties accordingly

2) Use a DeepCopy() function. (Recommended for more complex objets)

Now your editor will indicate unsaved changes to the user.

Important: If you use the second option (DeepCopy() function) notice that it could be problematic due to the fact that for the deserialization  process your objects assembly will be loaded at runtime automatically and cause the following exception to be thrown:

{"Unable to find assembly 'BuildTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."}

image

The solution for this issue can be found here!

Problem Deserializing Classes From Assemblies Loaded at Runtime Implicitly – TFS Build Custom UI Type Editor

Lately I’ve created a Custom UI Type Editor for the “Process” Tab in the TFS Build Definition Interface, and came across a problem.
Since my object was a bit complex combined with the reason shown here, I decided to use serialization to “Deep Copy” the object.

For an example I will use the Credential editor, made originally by “Ewald Hofman”. This is the modified code:

Credential objet:

   1: [Serializable]
   2: public class Credential
   3: {
   4:     public string Domain { get; set; }
   5:     public string UserName { get; set; }
   6:     public string Password { get; set; }
   7:  
   8:     public override string ToString()
   9:     {
  10:         if (string.IsNullOrEmpty(UserName))
  11:         {
  12:             return "No Credential";
  13:         }
  14:         else
  15:         {
  16:             return Domain + @"\" + UserName;
  17:         }
  18:     }
  19:  
  20:     public Credential DeepClone()
  21:     {
  22:         using (var ms = new MemoryStream())
  23:         {
  24:             var formatter = new BinaryFormatter();
  25:             formatter.Serialize(ms, this);
  26:             ms.Position = 0;
  27:  
  28:             formatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
  29:  
  30:             return (Credential)formatter.Deserialize(ms);
  31:         }
  32:     }
  33: }

Credential editor:

   1: public class CredentialEditor : UITypeEditor
   2: {
   3:     
   4:     public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
   5:     {
   6:         if (provider != null)
   7:         {
   8:             IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
   9:  
  10:             if (editorService != null)
  11:             {
  12:                 Credential credential = value as Credential;
  13:                 var editableCredential = credential.DeepClone();
  14:                 using (CredentialDialog dialog = new CredentialDialog(editableCredential))
  15:                 {
  16:                     dialog.Domain = credential.Domain;
  17:                     dialog.UserName = credential.UserName;
  18:                     dialog.Password = credential.Password;
  19:  
  20:                     if (editorService.ShowDialog(dialog) == DialogResult.OK)
  21:                     {
  22:                         return editableCredential;
  23:                     }
  24:                 }
  25:             }
  26:  
  27:         }
  28:  
  29:         return value;
  30:         
  31:     }
  32:  
  33:     public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
  34:     {
  35:         return UITypeEditorEditStyle.Modal;
  36:     }
  37: }

Happily I ran it for the first time and it (of course) crashed immediately with the following exception:

{"Unable to find assembly 'BuildTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."}

image

It terns out that due to the fact that for the deserialization  process your objects’ assembly will be loaded at runtime automatically but because it is not strongly typed and in the GAC, it is unable to relate between your objet and your objects’ assembly.

Luckily this is very easy to solve!

1) Add a Serialization Binder class.

   1: public class Binder : SerializationBinder
   2: {
   3:     public override Type BindToType(string assemblyName, string typeName)
   4:     {
   5:         return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName));
   6:     }
   7: }

2) Attach the new Serialization Binder class to the BinaryFormatter instance in the DeepCopy method.

   1: public Credential DeepClone()
   2: {
   3:     using (var ms = new MemoryStream())
   4:     {
   5:         var formatter = new BinaryFormatter();
   6:         formatter.Serialize(ms, this);
   7:         ms.Position = 0;
   8:  
   9:         formatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
  10:         formatter.Binder = new Binder();
  11:         formatter.Binder.BindToType(this.GetType().Assembly.FullName, this.GetType().Name);
  12:  
  13:         return (Credential)formatter.Deserialize(ms);
  14:     }
  15: }

3) Run :)

This will bind your class with it’s misguided runtime loaded assembly!

Stopping Work Item Save From a Custom Work Item Control (in VSTS only, not in MTM)

Sometimes we want to stop a work item from being saved, for security reasons (permissions) or in order to enforce a condition of some sort, This is possible with a work item custom control.

In order to stop a work Item from being saved all you have to do is throw an exception.
Throwing an exception will stop the work item  from being saved and will display the exception in a proper message box.

IMPORTANT: This will not work in MTM!! even though it will stop the WI from being saved it will also cause the Test Manager to crush!

In order to stop a WI save process we need to do the following:

1) Create a work item control with no UI.
2) As part of implementing the IWorkItemControl interface override the FlushToDatasource() method, and insert your coded condition for saving the WI.
3) If you condition for saving the WI is not met throw a new exception with the proper message, such as “You do not have the permissions to change this work item!”.

Any condition can be specified.

We have the old and new values of the fields of the WI:
_workItem.Fields["Field Name"].Value.ToString()
_workItem.Fields["Field Name"].OriginalValue.ToString().
 

If you conditions is about permissions, this is how you get the current user:
_workItem.Project.Store.TeamProjectCollection.AuthorizedIdentity.DisplayName;

 

Good luck

How to fix Tfs_Analysis when it is corrupt.

Problem:

I was approached by my friend Nimrod Stern to help him with a problem he had regarding TFS reports.

When trying to open a TFS report the following error was received:

image

  • An error has occurred during report processing. (rsProcessingAborted)
    • Query execution failed for dataset 'dsIteration'. (rsErrorExecutingCommand)
      • Errors in the metadata manager. An error occurred when loading the Team System cube, from the file, '\\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Team System.25.cub.xml'. Errors in the metadata manager. An error occurred when loading the Test Suite dimension, from the file, '\\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Test Suite.12.dim.xml'. File system error: The following file is corrupted: Physical file: \\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Test Suite.0.dim\12.Hierarchy.Team Project.lstore. Logical file .

 

From the content of the error it seemed to me that the analysis DB was corrupt.

First thing I tried to do was to rebuild the reports databases from the TFS administration console (by going to the “Reports” tab and clicking “Start Rebuild”) and got this error:

image

“Error encountered when creating connection to Analysis Services. Contact your Team Foundation Server administrator.”

Later I tried rebuilding the reports databases from the web service (http://localhost:8080/tfs/TeamFoundation/Administration/v3.0/WarehouseControlService.asmx). Unfortunately also this did not solve the problem.

Finely I resorted to try and rebuilding the Tfs_Analysis DB directly from the SQL management studio as such:

image

but it also did not work and produced this error:

image

“File system error: The following file is corrupted: Physical file: \\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Test Suite.0.dim\12.Hierarchy.Team Project.lstore. Logical file .
Errors in the metadata manager. An error occurred when loading the Test Suite dimension, from the file, '\\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Test Suite.12.dim.xml'.
Errors in the metadata manager. An error occurred when loading the Team System cube, from the file, '\\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Team System.25.cub.xml'.
(Microsoft.AnalysisServices) “

 

(Looks familiar?? :) )

 

Solution:

Even though this problem cannot be solved with the “TFS Administration Consol” or the “SQL Management Studio” the solution is fairly simple:

1) Tern off the “SQL Server Analysis Services” windows service, either by right-clicking the analysis server in the “SQL Management Studio”:

image

or directly from Windows’ “Services” window:

image

2) Browse to this folder: “%ProgramFiles%\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Data” and delete the folder Tfs_Analysis.X.db and the XML file Tfs_Analysis.XX.db.xml.

3) Restart the “SQL Server Analysis Services” windows service.

4) Open the “TFS Administration Consol” and go to the “Reports” tab, then press “Edit” and type in the correct username and password in the “Analysis” tab.

image

5) Rebuild the Report DB’s through the web service: http://localhost:8080/tfs/TeamFoundation/Administration/v3.0/WarehouseControlService.asmx, or through the “TFS Administration Consol” - go to the “Reports” tab, then press “Start Rebuild”.

 

Wait for your DB’s to finish building, and enjoy your reports!

Problem With TFS Reports Parameter Change

When we Change an Existing TFS 2010 Report and  upload it to the ‘TFS report site’ in order to add it to a specific team project (How to Add TFS 2010 Report to a Team Project) we many times want to change the default parameters of that report.

If you try to add default values of a parameter it should work when you’ll upload the new report to the report site and you will see the changes. if you try to delete one of the default values, when you upload the file you will not see the changes.

The reason for that is that the parameters are global (can be used in more then one report) which is why by default you are not let to deduct any default values from the parameters.

Solving this is easy; simply delete the original report before uploading the new one, that way the parameters will be uploaded with the report exactly as you constructed them in report.

Delete before upload

How to Change an Existing TFS 2010 Report

Sometimes the default reports that come with the TFS process templates are not 100% compatible with the clients needs or desires. Luckily for us these reports can be changed customized as we wish.

1) First of all we must open the process template manager, and download the same process template that the team project in which we want to change the report uses.

open the process template manager

Download Process Template 

2) Do steps 1 to 4 from this post How to Add TFS 2010 Report to a Team Project.

3) After these steps instead of creating a new report, go to the location that you downloaded the process template, go into the reports folder and choose the report you wish to change.

Add existing report

4) you can make whatever modifications you want to the report and add it to the team project as it described in steps 6 to 8 of this post How to Add TFS 2010 Report to a Team Project.

5) Change the data source of the report in the report site to the shared data source. Do this by entering the report you changed in the site, go to the “Properties” tab and click ”Data Sources” in the left side menu, then click the “Browse” button. choose a shared data source and click on the “OK” button.

IMPORTANT!!  You must click the “Apply” button! it not your changes will not go into effect.

Browse to the shared data source

 Pic a shared data source

 

Enjoy the modified report .

How to Add TFS 2010 Report to a Team Project

Sometimes the reports that come with TFS 2010 are not enough and we want to create are own custom reports. Beside creating the report itself there is a process of Adding it to a specific Team Project.

This can done easily with a few simple steps:

1) First of all open “SQL Server 2008 Business Intelligence Development Studio”.

SQL Server 2008 Business Intelligence Development Studio

 

2) In the studio open a new report Project.

Create new report project

 

3) Add a data source to the project.

Create a data source

 

4) Set the data source to your local TFS data base.

Set the data source

 

5) Add a report item to the project.

 Add new report Item

 

6) After creating the report we want to add it to a team project. So we open “Team Explorer” and open the team project to which we want to add the report. ‘Right click’ on the ”Reports” of the selected team project and open the reports website.

Show Report Site

 

7) After the report site opens you either create a new folder and upload the report into it, or to only upload the report.

New report folder or report

 

8) An Upload window will open. Choose the new report that you Created!

Upload the file

 

The new report has officially been added to a specific team project, more configurations might be needed depending on the report and the team project.

Hide Columns By Condition in TFS Reports

I was asked to create a TFS report that will show all the changes that where made in “Requirement” work items in the last tow weeks.

The problem was that I didn’t want to see columns that are empty…

What I did is to take from the data base everything, but if one of the columns das not hold any changes(data) it will simply be hidden.

Example:

I have a report that one of the columns returned no values, but it might next time.

Before Hiding

 

I would like to hide this column only when it is empty in all the rows.

So I will go to the properties of that column and choose to change the ‘Hidden’ property from ‘false’ to ‘Expression’.

Hiding Property

Then I insert a condition to hide the column if it contains no values.

Hiding Expresion

This way I can select many columns from the data base and hide the one that will bare no results!

Part 1 - The Need for Client-Side Validations

As I wrote in the previous post  

First of all on the client side the word VALIDATIONS is probably not the best to describe what we call "client-side validations". In my opinion calling it "rich-client interface" or "interactive-client interface" will probably be more fitting.

Client-side validations serve no real security purposes!

Since they are written in JavaScript even the most common users can mark

"Disable Scripts" in their browser and bypass any JavaScript written validation.

So, what do we earn by implementing client-side validations???

1) The first answer is off course performance.

By restricting fields to citrine conditions (required, numeric, number of characters, regex, etc.), Unnecessary PostBacks, Callbacks, and even AJAX calls can be spared from the server.

It is simple; users make many mistakes even in the simplest forms, and there is no reason to waste recourses going to the server unless it is necessary especially when easy to write scripts on the client side will serve the same purpose.

2) The Second answer is also performance but regarding transportation.

Beside the work that you are sparing from your server, using validations on the client-side will also spare the server and client bandwidth.

3) The third answer is User Experience.

Users are not generally patient! They do not like to wait 5 seconds or even 2 seconds to find out they made a tiny mistake somewhere in the 10 fields form, and if it happens to them more than once they might give up all together and simply close the site.

The users are 100% right!!!

Why should they wait when they don't have to???

With client-side validations the fields are being checked on the client side and therefore the action seems to occur almost instantaneously.

Summary

Client-Side validations are a good thing!!!

They Improve server performance and reduce the lode on both servers and clients' bandwidth.

Client-Side validations cannot be replaced by server-side validations!!!

Client-Side validations do not serve any security purposes!!!

More Posts Next page »