Dont’ install StyleCope 4.3, StyleCope 4.4 avaliable now



StyleCope  4.4 available now on for visual studio 2010 on  Codeplex, you can download it from here download

for pepole that don’t know styleCope

StyleCop is a wonderful analyzer tool that analyze C# source code to enforce a set of style, and consistency coding  rules. It can be run from inside of Visual Studio or integrated into an MSBuild project

for more infomration visit the follwoing link

StyleCop blog

For tutorial about StyleCop see the follwing link

StyleCop Tutorial

Why and how to clear TFS client cache?


**** Update on February, 9, 2013 *****

Sometimes there are errors like “Cannot find team project” or you can’t create a project because duplicate name  despite of you don’t have one or you are not connected to that one that have this project, so all you have to do just clear the cache example of the error that could occur the following error

Cache Error

For example I clear my cache from the following path

C:\Users\MRadwan\Local Settings\Application Data\Microsoft\Team Foundation\3.0\Cache

This will cause your client Tool  to download a fresh copy of the cache the next time it deals with the server.

And everything  will  going well.

 

**** Begin of update ****

When we need to delete the server cache, we will navigate to “C:\ProgramData\Microsoft\Team Foundation\Web Access\….

delete the cache files and reset the IIS.

**** End of update ****

Can’t create new build definition in TFS 2010



When I start create my first build definition for Team project I face the following error,

BuildError

TF225001: Creating a build definition requires a build controller be defined for this team project collection. There may not be any controller configured or you may not have permission to view them

So after little search I figure it out it will be as the following

TFS Admin consol

Configure build

Configure build

success build configuration

So now if you create a new build definition you should see the following screen

New build defnation

but the problem that I didn’t choose network service so I have the following error “Cannot start service TFSBuildServiceHost on computer”

and after good search on event log I found that this because failure of the login so I change it to be a network service as the previous configuration.

Error TF218017 when you Creating New Team Project TFS2010



Today I start create a new Team project on my new TFS 2010 and I face the following error.

TF218017: A SharePoint site could not be created for use as the team project portal. The following error ocurred: TF250044: A SharePoint site cannot be created at the following location: “yourLocation” The following user account does not have the required permissions in SharePoint Products to create a site at that location: “yourLocation” The user account must have sufficient permissions to create a sub-site on the following site: “yourLocation”

Error tf218017

I worked with TFS since 2005 and I used to follow the installation guide, and that’s what I did, but I don’t know why I got this error despite of blind following  the installation guide, anyway this error mean that the account that try to create the sharepoint portal for your project doesn’t have permission to create it, so I solve it as the following

I login to my machine using local account  called mradwan and of curse this account existing on the TFS2010 server because I used workgroup approach for various reasons not important now, so All I have to do is to go to the TFS2010 server and start add mradwan account to the site administrator of the sites of the TFS2010 as the following

Application Management in sharepoint

Assign local account

Of curse sometimes this is not the only reasons for error TF218017 as we used too :) so if this the case you can keep search of the error and maybe this link could help you

MSDN Forum
The error with beta version

Free Microsoft Licenses programs



Microsoft announced two free license programs , for individual or companies with less 10 employees  you can get this program, to help companies and individuals to use Microsoft technology, of curse there is another program for student that called DreamSpark

Microsoft offers a variety of programs to help companies who develop and market solutions based on Microsoft technologies, provide consulting or technical services for Microsoft systems.

BizSpark WebsiteSpark DreamSpark

And each program has a registration requirement for example for the DreamSpark program you will need to get e-mail of youname@yourUniveristy.com and start register to the program using this email and then you can start download the software.

For overview of the 3 programs see the following link

Licenses overview

Thanks Microsoft for your real support.

Multiple web.config with ASP.NET and Visual Studio 2010



No need to change your code multiple times to configure your code for different staging, now you can add multiple web.config files.

umbraco database structure



To understand the DB we will assume a scenario that we create CMS project for Training Center that provide training in ASP.NET, C#, etc.We will see what happen in DB when we start create most action in Admin site how this effect on the DB, we will see the following Actions

  • Add Document Type (ex.”Course Categories”)
  • Add Template (ex.”Master”)
  • Add Content (ex.”Programming (of type course Categories)”)
  • Publish content
  • Add Data Type
  • Add Macro that use XSLT
  • Add user
  • Add User Type like administrator, writer, and translator
  • Add Member Type
  • Add Member
  • Add Group

First let’s see the main object node ID that exist

Object Node ID “GUID” Type and Description
1 30A2A501-1978-4DDB-A57B-F7EFED43BA3C Data Type ex. Label, DatePicker, RichText, (Sys & user define)
2 01BB7FF2-24DC-4C0C-95A2-C24EF72BBAC8 Recycle Bin <? >
3 EA7D8624-4CFE-4578-A871-24AA946BF34D Umbraco master root<?>
4 4EA4382B-2F5A-4C2B-9587-AE9B3CF3602E Media ex.Image, file, folder
5 A2CB7800-F571-4787-9638-BC48539A0EFB Document Type ex. Trainer, Course Management
6 6FBDE604-4178-42CE-A10B-8A2600A2F07D Template ex. Course Management, Category, New Course
7 B796F64C-1F99-4FFB-B886-4BF4BC011A9C Media ex. image1, image2
8 C66BA18E-EAF3-4CFF-8A22-41B16D66A972 Content ex. Business, C #, ASP.NET
9 9B5416FB-E72F-45A9-A07B-5A9A2709CE43 Member Type ex. Member
10 366E63B9-880F-4E13-A61C-98069B029728 Group ex.Group
11 39EB0F98-B348-42A1-8662-E7EB18487560 Member ex.Mohamed Radwan, Maged Farag,
12 9F68DA4F-A3A8-44C2-8226-DCBD125E4840 Style sheet ex.rating, styleCourseHome (Custom CSS)


 

Add Document Type (ex.”Course Categories”)

1-add 1 record “node” to [umbracoNode] Table “with objectNodeID ending with 0EFB

2-add 1 record to [cmsContentType] Table

3-add n records to [cmsTab] Table “if you add tabs”

4-add n records to [cmsContentTypeAllowedContentType] Table “if you add structure”"with all nodes under this node id”

5-add n records to [cmsPropertyType] Table”for each property”"if you add properties”

ERD


umbracoNode Table


cmsContentType Table

cmsTab Table

cmsContentTypeAllowedContentType Table



Add Template (ex.”Master”)


1-add 1 record “node” to [umbracoNode] Table “with objectNodeID ending with F07D

2-add 1 record to [cmsTemplate] Table

3-add 1 record to [cmsDocumentType] Table “to associate content type with template”

ERD



umbracoNode Table


cmsTemplate Table


cmsDocumentType Table



Add Content (ex.”Programming (of type course Categories)”)

1-add 1 record “node” to [umbracoNode] Table “with objectNodeID ending with A972

2-add 1 record to [cmsContent] Table “to associate new content with document type”

3-add 1 record [cmsDocument] Table “That generate GUID of this version”

4-add 1 record [cmsContentVersion] Table” with the generated GUID and the date

5-add 1 record to [cmsContentXml] Table “with all node information as “XML” if you publish it”

6-add n records to [cmsPropertyData] Table “one record for each data which point to property type id from [cmsPropertyType] Table”"If you add data to its properties”

ERD

umbracoNode Table


cmsContent Table


cmsDocument Table


cmsContentVersionTable



cmsContentXml Table



cmsPropertyData Table



cmsPropertyType Table



Publish content

1-add 1 record to [cmsDocument] Table “That generate GUID of this version” and make newest column = True

2-update 1 record of the previous version and make published =True “1″ and update date very near of the last one, update newest=false

3-add 1 record to [cmsContentVersion] Table” with the generated GUID and the date

4-add 1 record to [cmsContentXml] Table “with all node information as “XML” if you publish it”

5-add n records to [cmsPropertyData] Table “one record for each data “if you change any value otherwise it will not add any “ex. content has 4 properties you change 1 property so it will add 4 records considering none changed value as a new values


ERD



cmsDocument Table

See the previous

cmsContentVersion Table

See the previous

cmsContentXml Table

See the previous

cmsPropertyData Table

See the previous


Add Data Type



1-add 1 record “node” to [umbracoNode] Table “with objectNodeID ending with BA3C

2-add 1 record to [cmsDataType] Table “with the type of the data “int, date, txt” and the type of the control “dropdown, list

3-add n records to [cmsDataTypePreValues] Table “which has all entered values like “Egypt, UAE, KSA

ERD


umbracoNode Table


cmsDataType Table



cmsDataTypePreValues Table



Add Macro that use XSLT



1-add 1 record to [cmsMacro] Table “that associate this macro with the XSLT file name if it use XSLT

ERD



cmsMacro Table



Add user

1-add record to [umbracoUser] Table

2-add 7 records to [umbracoUser2app] Table “if you select all modules “Content-Developer-Media-Members-Settings-Translation-Users

ERD



umbracoUser Table



umbracoUser2app Table

Add User Type like administrator, writer, and translator



1-add 1 record to [umbracoUserType] Table “With all permission needed” “one character for each permission” “F:C54ZDMOSRPKAUHI

ERD



umbracoUserType



Add Specific permission for specific node

 



1-add n records to [umbracoUser2NodePermission] Table for each node for each permission “ex. Node: 1055 premission: 5 for each node, it will add one record for each character of the following “F:C54ZDMOSRPKAUHI” if needed

ERD

umbracoUser2NodePermission


Add Member Type



1-add 1 record “node” to [umbracoNode] Table “with objectNodeID ending with CE43

2-add 1 record to [cmsContentType] Table “like adding document type” to be associated with members like content to be associated with document

ERD



umbracoNode Table



cmsContentType Table




Add Member



1-add 1 record “node” to [umbracoNode] Table “with objectNodeID ending with 7560

2-add 1 record to [cmsContent] Table “to associate new content (member) with member type (like document type)”

3-add 1 record to [cmsContentVersion] Table” with the generated GUID and the date

4-add 1 record to [cmsContentXml] Table “with all node information as xml”

5-add n record [cmsMember2MemberGroup] Table “if we add it to group” “1 record for each group to this member with member nodeid and group nodeid”

ERD



umbracoNode



cmsContent

See the previous

cmsContentVersion

See the previous

cmsContentXml

See the previous

cmsMember2MemberGroup




Add Group



1-add 1 record “node” to [umbracoNode] Table “with objectNodeID ending with 9728

umbracoNode Table


Adapter Pattern



Summary.


Adapter pattern Convert the interface of a class into another interface clients expect.
Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.
Also known as Wrapper

Example and reasons.
Dot Net library, we cannot change the library interface, since we may not have its source code
Even if we did have the source code, we probably should not change the library for each domain-specific application

Solution
We will create our adapter for our domain that adapts the interface to match our needed interface.
Participants
•         Target
•         Adapter
•         Adaptee
•         Client
•         Factory
Class adapters
•     Simple and invisible to the client.
•     A class adapter has instance of an interface and inherits a class.
•     Overriding behavior can be done more easily with a Class adapter
Use the Adapter pattern when you want to:
•     Create a reusable class to cooperate with yet-to-be-built classes.
•     Change the names of methods as called and as implemented.
•     Use an existing class, and its interface does not match the one you need.

Classes

public class Client1
{
public void AnyMethod()
{
//Target t = Factory.CreateTarget();
Target t = new Target();
//Client1 use the the target interface “Request”
t.Request();
}
}

public class Target
{
public virtual void Request()
{
Console.WriteLine(“Called Target Request()”);
}
}

public class Adapter : Target
{
private Adaptee _adaptee = new Adaptee();
public override void Request()
{
// Possibly do some other work
//  and then call SpecificRequest
_adaptee.SpecificRequest();
}
}

public class Adaptee
{
public void SpecificRequest()
{
Console.WriteLine(“Called SpecificRequest()”);
}
}
public class Factory
{
public static Target CreateTarget()
{
return new Adapter();
//or
//return new Target();
}
}

Thanks
M.Radwan

Why using Interface


Using interface add flexibility and power to your design it solves the hard equation how to make the classes cohesion and lose coupling? , because by making interface, class doesn’t need each other anymore, by using interface you define the services that will provided by the class.
This will apply the Dependency inversion principle
You can see the video for more information.
For more information about Dependency inversion principle visit the following links

http://www.objectmentor.com/resources/articles/dip.pdf
Thanks
M.Radwan