Microsoft Professional

Tuesday, July 29, 2008

Client TFS Cache

If you changed schemas TFS client, will face many strange errors.

Cause:
Visual Studio and Team Explorer provide a caching mechanism which can get out of sync.

Solution:
For Windows Vista delete contents of this folder
C:\Users\{your account}\AppData\Local\Microsoft\Team Foundation\1.0\Cache

For Windows Xp, 2003 delete contents of this folder
C:\Documents and Settings\{your account}\Local Settings\Application Data\Microsoft\Team Foundation\1.0\Cache

Labels: ,

Sunday, February 05, 2006

Create Resource Gallery Programmatically(MCMS)

Publishing API cannot create Resource Galleries. To solve this problem you can use ASP file called resstub.asp. This file is used bt Site Manager and can do many things which can't be done by CMS APIs (for example create resource gallery). This file depend on transferring requestes using XML. These XMLs has some parameters depend on versions of MCMS (internalClientVersion, clientVersion, clientVersionNumber).

Steps to use this file:

  1. Create c# Project
  2. Add AEServerObject.dll and AEStubObject.dll as references
  3. Use Code Below:
    // {0} = CMSAUTHTOKEN value
    // {1} = GUID of Parent Resource Gallery
    // {2} = Name of new Resource Gallery
    private const string requestCreate = "";
    // {0} = CMSAUTHTOKEN value
    // {1} = GUID of new Resource Gallery
    private const string requestCommit = "";
    ///
    /// The main entry point for the application.
    ///

    [STAThread]
    static void Main(string[] args) {
    // LOG ON AND GET THE AUTHENTICATION STRING AESERVEROBJECTLib.AESessionClass session = new AESessionClass();
    session.Login("WinNT://DOMAIN/username", "password", "localhost", 0);
    // FIND THE ROOT RESOURCE GALLERY
    string rootGuid = null;
    AESERVEROBJECTLib.IAEServer server = session.GetDefaultServer();
    foreach(string s in server.Children)
    {
    AESERVEROBJECTLib.IAENode n = server.GetNodeByGUID(s, false);
    if(n.Name == "Resources") { rootGuid = s; break; } }

    // LOOP THROUGH THE XML RECURSIVELY
    string newGuid = CreateResourceGallery(session, "resource1", parentGuid);
    // COMMIT session.CommitAll();
    }
    static string CreateResourceGallery(AESERVEROBJECTLib.AESessionClass session, string newName, string parentGuid)
    {
    AEStubClass stub = new AEStubClass();
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(stub.ProcessRequest((AESTUBOBJECTLib.IAESession6)session, "127.0.0.1", String.Format(requestCreate, session.LoginCookie, parentGuid, newName)));
    string newGuid = doc.DocumentElement.SelectSingleNode("
    mailto:Node/@GUID;
    stub.ProcessRequest((AESTUBOBJECTLib.IAESession6)session, "127.0.0.1", String.Format(requestCommit, session.LoginCookie, newGuid, newName)); return newGuid;
    }

Notes:
1. To run sample below you need to adjust these parameters (internalClientVersion, clientVersion, clientVersionNumber) depending on you MCMS version.
2. To Use this file to do many action like sample code. you need to trace foramt of passed XML between Site manager and resstub.asp. Easy way to do that change file resstub.asp to save requests from Site Manager.