Thursday, July 18, 2013

VSS to TFS Migration

Prerequisites
To complete this walkthrough, you need the following software installed on the computer where you plan to run VSSConverter.exe:
·         Team Explorer (By default, Team Explorer is installed during installation of Visual Studio 2010)
·         Log on to the computer by using administrative credentials
·         SQL Server Express (By default, SQL Server Express is installed during installation of Visual Studio)
·         Visual SourceSafe 2005 or later versions
·         The Visual SourceSafe database that you want to analyze. The database format must be version 6.0 or a later version. You must run the converter on the same computer as your Visual SourceSafe database to complete this walkthrough.
·         The administrator’s password for the Visual SourceSafe database that contains the projects that you want to analyze.
·         To perform this walkthrough, you must have administrative permissions for the Visual SourceSafe database that you will migrate. For more information, see How to: Assign Project Rights.
Analyzing the Projects
VSSConverter.exe is a command-line tool that requires the following input:
·         A path of the folder that contains the srcsafe.ini file for the Visual SourceSafe database under migration.
·         An XML-based file that contains settings.
·         VSSConverter.exe is stored in <root>:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE, but it can be invoked from the Visual Studio command prompt.
This walkthrough assumes that your Visual SourceSafe database is in c:\VSSDatabase.


In our case, we copied the vss database files to the machine where the prerequisites are installed. Although you can migrate a Visual SourceSafe database in a shared folder on a remote computer, the migration takes much longer to finish.
After you have decided which projects you want to analyze, create a file to contain the settings. This file lists the projects that you want the converter to analyze.

To create the settings file for analysis

1.       Open Command Prompt.
2.       At the command prompt, type mkdir c:\VSS2TeamFoundation, Press ENTER.
3.       At the command prompt, type cd c:\VSS2TeamFoundation. Press ENTER.
4.       Type notepad settings.xml, and then press ENTER.
5.       Select Yes to create the file.
6.       Copy the following XML.
<?xml version="1.0" encoding="utf-8"?>
<SourceControlConverter>
      <ConverterSpecificSetting>
            <Source name="VSS">
                  <VSSDatabase name="c:\VSSDatabase"></VSSDatabase>
            </Source>
            <ProjectMap>
                  <Project Source="$/ "></Project>
            </ProjectMap>
      </ConverterSpecificSetting>
      <Settings>
       <Output file="Analysis.xml"></Output>
     </Settings>
</SourceControlConverter>
7.       Save your changes and close Notepad.
Next, run the converter tool from the command prompt to analyze the project, as shown in the following steps.
The user who is performing the analysis must be a system administrator for SQLExpress. By default, the user who installs Visual Studio will receive the required permissions for SQLExpress.
After you have the migration settings file and granted system administrator rights, you can run the converter tool to analyze the project.

To analyze the project with the converter

1.       At the command prompt, type the following.
<root>:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE \VSSConverter Analyze settings.xml
2.       When you are prompted, provide the Visual SourceSafe administrator password.
The converter tool displays the status of the preconversion analysis. When it is completed, it generates a report (VSSAnalysisReport.xml) and a user mapping file (usermap.xml), and saves them in the current directory. You can use the user mapping file to map Visual SourceSafe users to Team Foundation users. For more information, see How to: Edit the Source Control Migration User Mapping File.

Migrating from Visual SourceSafe to Team Foundation:

Prerequisites
Before you try to complete this walkthrough:
·         Perform all steps as outlined in “Preparing to Migrate from Visual SourceSafe to Team Foundation.
·         Identify empty folders in Team Foundation version control where you want to migrate your Visual SourceSafe folders. If the destination folder does not exist, the converter will create it for you. The only exception is if the destination folder is a team project. The destination folder should be either a valid team project or a subfolder of a valid team project. For more information, see How to: Create a Team Project.
Additionally, you need:
·         A Team Foundation Server name.
In our case: server name: HOMECMP, Team Collection: PRJ-VSS, Team project: PRJ-VSS
·         You must have administrative permissions to connect to a SQLExpress database to use the converter tool.
Required Permissions
To perform this walkthrough, you must have administrative permissions for the Visual SourceSafe database that you will migrate. For more information, see "How to: Assign Project Rights" at the Microsoft Web site (http://go.microsoft.com/fwlink/?LinkId=99103). You must also be a member of the sysadmin server role for SQL Express. By default, you are a member of the sysadmin server role if you are a member of the  Administratorssecurity group on the computer where SQL Express is installed. For more information, see "sysadmin" from the Microsoft Web site (http://go.microsoft.com/fwlink/?LinkId=60405) in the SQL Server 2005 documentation.
Migrating SourceSafe Project Folders
Before you continue with the actual conversion, customize your settings file to include the destination folders for the SourceSafe projects that you specified when you prepare for conversion

To modify the settings file to create a migration file

1.       Open Command Prompt.
2.       At the command prompt, type cd c:\VSS2TeamFoundation. This folder was created when you analyzed the Visual SourceSafe database for migration.
3.       Save the settings file that you created for the analysis, settings.xml, with a new name, for example, migration_settings.xml.
4.       At the command prompt, type notepad migration_settings.xml, and then press Enter.
The settings.xml file you created when you analyzed your database for migration is displayed in Notepad.
5.       Change the settings file as follows.
·         In the <ProjectMap> section, for each Visual SourceSafe folder that you are migrating, add the destination folders in Team Foundation version control. Use the following format, adding the Destination section as shown in the following example.
·         <Project Source="$/FolderA" Destination="$/Team_Project"></Project>
To migrate everything in your Visual SourceSafe database, insert the following XML instead.
<Project Source="$/" Destination="$/Team_Project/"></Project> 
·         Under the <Settings> section, add a <TeamFoundationServer> section, and specify the name, port, and protocol for the Team Foundation Server to which you are migrating. Use the following format.
·         <TeamFoundationServer name="TFS_server_name" port="port_number" protocol="http" collection="collection_name" ></TeamFoundationServer>
For example,
<TeamFoundationServer name="AdventureWorks" port="8080" protocol="http" collection="tfs/DefaultCollection"></TeamFoundationServer>
6.       Remove <Output file="Analysis.xml"></Output> from the <Settings> section, or rename the output file to "migration_Analysis.xml".
Your migration_settings.xml file should resemble the following:
<?xml version="1.0" encoding="utf-8"?>
<SourceControlConverter>
      <ConverterSpecificSetting>
            <Source name="VSS">
                  <VSSDatabase name="c:\VSSDatabase"></VSSDatabase>
            </Source>
            <ProjectMap>
            <Project Source="$/" Destination="$/PRJ-VSS/"></Project>           
            </ProjectMap>
      </ConverterSpecificSetting>
      <Settings>
       <TeamFoundationServer name="HOMECMP" port="8080" protocol="http" collection="tfs/PRJ-VSS" ></TeamFoundationServer>
     </Settings>
</SourceControlConverter>
Be sure to substitute your server name for server name and an actual port number for port number.
7.       Save your changes and close Notepad.

To run the converter

1.       Open Command Prompt.
2.       At the command prompt, type the following.
<root>:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE \VSSConverter Migrate migration_settings.xml
3.       Type Y to confirm the migration.
When you are prompted, provide the password for the Visual SourceSafe admin user.
The converter tool displays the migration status. When the conversion process is finished, the tool saves a migration report in the current directory.

 

Incrementally Migrate to Team Foundation:

This topic describes how to do an incremental migration if you want to migrate your Visual SourceSafe database in phases.
Limitations on Incremental Migration
Be aware of the following limitations that apply when you start incremental migration and continue until all phases of incremental migration are finished.
·         You must not change the existing mapping of Visual SourceSafe folders to Team Foundation version control folders. Also you must not add or remove mappings.
·         Do not perform destroy, purge, archive, or restore activities on the Visual SourceSafe database.
·         Do not use the migrated Team Foundation version control folders.

To migrate in phases

Restart migration on the copied Visual SourceSafe database. The VSS converter will automatically determine that this is an incremental migration and start migrating changes that occurred after the first migration.
  1. Open Command Prompt.
  2. At the command prompt, type the following command, using the same settings file that you used during the previous migration:
<root>:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE \VSSConverter Migrate migration_settings.xml
  1. The converter automatically detects that this is an incremental migration, and it prompts you to confirm you want to do an incremental migration. Press Y to confirm that you want to do an incremental migration.

  1. When you are prompted, provide the password for the Visual SourceSafe admin user.
  2. The converter tool displays the migration status. When the conversion process finishes, the tool saves a post-migration report in the current directory.

VSSConverter automation
To automate the migration process we can create a batch file and add it to the windows task scheduler.
The batch file should resemble the following:
set SourceSCMPasswd=VssPassword
set HATCONTESTING=yes


"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\vssconverter.exe" migrate migration_settings.xml

Thursday, April 19, 2012

Launch many exes from windows service

In a real time scenario, sometimes we have to launch many exes from windows service to do a task and/or utilizing all the cores in a machine.

If the total number of exes are more, there are chances that few exes will not run. It will exit at the initial stage itself without doing task. The event log also will not have any error.

This may happen due to low desktop heap memory. In general interactive applications can use more desktop heap memory and non-interactive applications can use less desktop heap memory. This is defined in system registry.

If we launch more exes (non-interactive) from windows service, few exes may not be able to access desktop heap memory because it is low. We can increase the desktop heap memory by changing the value in registry. So that we can launch many exes without any issue.

Below is the Microsoft link where increasing the desktop heap memory is explained:
http://support.microsoft.com/kb/184802

steps to increase the heap memory in registry:
Go to Start -> Run -> type “regedit”

Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
(It’s better to take Backup of registry value by right-clicking 'Subsystems' and Export.)

Double click on Windows, the “Edit String” window shows up:

The string on the Value data will look like below:
%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows
SharedSection=1024,20480,768 Windows=On SubSystemType=Windows
ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3
ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4
ProfileControl=Off MaxRequestThreads=16

Increase the value in bold (from 768 to 2048), and click OK.
System reboot is required.

Tuesday, November 30, 2010

Read xml file content or node value of xml file from sql server

Using "xp_cmdshell" command we can read the contents of xml file like below. Finally the variable @FileContents will have the contents of xml file.

DECLARE @FilePath varchar(255)
DECLARE @xCmd VARCHAR(255)
DECLARE @FileContents VARCHAR(MAX)

CREATE TABLE #temp(PK INT NOT NULL IDENTITY(1,1), ThisLine VARCHAR(8000))

SET @FilePath = '\\ServerAddress.com\xmlFiles\xmlFile1.xml'
SET @xCmd = 'type ' + @FilePath
SET @FileContents = ''

INSERT INTO #temp EXEC master.dbo.xp_cmdshell @xCmd
DECLARE @x INT
DECLARE @y INT

SET @x = 0
SELECT @y = count(*) from #temp

WHILE @x <> @y
    BEGIN
        SET @x = @x + 1
        SELECT @FileContents = @FileContents + ThisLine from #temp WHERE PK = @x
    END

SELECT @FileContents as FileContents



There are different options available to read particular node value of xml file. I will explain them one by one. My default xml file will be in below format:

<?xml version="1.0" standalone="yes" ?>
<Price xmlns="http://tempuri.org/Price.xsd">
  <Rate>
     <ITEMNMBR>100</ITEMNMBR>
     <ITEMDESC>Audio Cassette</ITEMDESC>
     <QTY>1</QTY>
     <TPRICE>50</TPRICE>
  </Rate>
  <Rate>
     <ITEMNMBR>101</ITEMNMBR>
     <ITEMDESC>Video Cassette</ITEMDESC>
     <QTY>1</QTY>
     <TPRICE>100</TPRICE>
  </Rate>
</Price>

Method 1:

DECLARE @MyXML XML
SET @MyXML = @FileContents
SELECT  fileds.value('ITEMNMBR[1]', 'varchar(30)') AS ITEMNMBR,
        fileds.value('ITEMDESC[1]', 'varchar(30)') AS ITEMDESC,
        fileds.value('QTY[1]', 'varchar(30)') AS QTY,
        fileds.value('TPRICE[1]', 'varchar(30)') AS TPRICE
FROM    @MyXML.nodes('//Rate') as  xmldata(fileds)
WHERE fileds.value('ITEMNMBR[1]', 'varchar(30)') = '101'



Method 2:

CREATE TABLE #docs (pk INT PRIMARY KEY, xCol XML)
INSERT INTO #docs VALUES (1, @FileContents)

SELECT nref.value('ITEMNMBR[1]', 'nvarchar(50)') ITEMNMBR,
       nref.value('ITEMDESC[1]', 'nvarchar(50)') ITEMDESC,
       nref.value('QTY[1]', 'nvarchar(50)') QTY,
       nref.value('TPRICE[1]', 'nvarchar(50)') TPRICE      
FROM   #docs CROSS APPLY xCol.nodes('/Price/Rate') AS R(nref)
WHERE  nref.exist('.[ITEMNMBR = "100"]') = 1



Method 3:

DECLARE @idoc INT
EXEC sp_xml_preparedocument @idoc OUTPUT, @FileContents

   SELECT   *
   FROM   OPENXML (@idoc, 'Price/Rate', 2)
          WITH (ITEMNMBR  varchar(50) 'ITEMNMBR',
                ITEMDESC   varchar(50) 'ITEMDESC',
                QTY varchar(50) 'QTY',
                TPRICE varchar(50) 'TPRICE'                               
               ) R
   WHERE  R.ITEMNMBR = '101'

EXEC sp_xml_removedocument @idoc

SSRS - Clear multi-value cascading dropdown selected value

Most of us are facing problems that multi-value cascading dropdown selected value is not clearing when changing the value in parent dropdown.


For example I am having two dropdowns State and City in SSRS report. Based on State dropdown selected value, City dropdown values will be populated.

In my sample, State dropdown will have two values "Tamilnadu" and "Karnataka".
Cities for Tamilnadu will be "Trichy" and "C.City".
City for Karnataka will be "C.City".

Initially in State dropdown I will select Tamilnadu and in City dropdown I will select C.City.








Then if I select Karnataka in state dropdown city dropdown will be populated with C.City. But the problem is by default it will be selected as shown below.








But we may need that when it is populating newly, no values should be selected by default.


The solution is very simple.


In Report Parameters, city parameter has value field and label field as City. This is the root cause for this problem.
















If I change the value field to state like below, the problem will be solved.
















Because the state value is always changing. So the report will assume it as a different item. We can get the desired output.

Monday, March 1, 2010

Send Reminder mail based on Date field in SharePoint List

Below is the C# console application program to send reminder mail to user, seven days prior to due date.
It is used check WSS 3.0 list item and send mail.

Add Microsoft.SharePoint.dll in your project.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Net.Mail;

namespace MailSending
{
    class Program
    {
        static string strMailFrom = "MailId";
        static string[] strMailTo = new string[] { "MailId", "MailId" };

        static void Main(string[] args)
        {
            SPSite oSite = new SPSite("SiteURLHere");
            SPWeb oWeb = oSite.OpenWeb();
            SPList oList = oWeb.Lists["ListNameHere"];

            for (int i = 0; i < oList.Items.Count; i++)
            {
                SPListItem oListItem = oList.Items[i];
                DateTime dtDate = Convert.ToDateTime(oListItem["Due Date"]);
                DateTime dtToday = DateTime.Today;
                TimeSpan TS = dtDate.Subtract(dtToday);
                if (TS.Days == 7)
                    SendMail(oList.Items[i].ID.ToString(), Convert.ToDateTime(oListItem["Due Date"]).ToShortDateString());
            }           
        }

        static void SendMail(string strListItemID, string strDueDate)
        {
            MailMessage message = new MailMessage();
            message.Subject = "This is Subject";
            message.From = new MailAddress(strMailFrom);

            for (int j = 0; j < strMailTo.Length; j++)
                message.To.Add(strMailTo[j]);

            string strMsgBody = "Please note that Due Date is " + strDueDate + ". Please check the below list for more information.
";
            strMsgBody += "" + strDueDate + ";

            message.Body = strMsgBody;
            message.IsBodyHtml = true;

            SmtpClient smtp = new SmtpClient("SMTP_Address_Here");
            smtp.Send(message);
        }
    }
}

After compiling we can take the exe file of this application and add in windows Task Scheduler. So that it will send mail to user.

Friday, February 26, 2010

Move Files between SharePoint document library

There are different options to move files between SharePoint document libraries. We can see them one by one.

Option 1 :

We can go to Explorer view, then copy paste the files to different location.


Here we can move multiple files. But Meta data like created by and created time will be changed.


Option 2 :

We can click the file --> Send To --> Other Location

Here Meta data will be retained. But we have to move one by one.

Option 3 :

We can write a C# application.
Add Microsoft.SharePoint.dll in your project.

    using Microsoft.SharePoint;

    private void button1_Click(object sender, EventArgs e)
    {
        SPSite sourceSite = new SPSite(SourceSiteURL);
        SPWeb sourceWeb = sourceSite.OpenWeb();
        SPSite destSite = new SPSite(DestinationSiteURL);
        SPWeb destWeb = destSite.OpenWeb();

        SPFolder oFolder = sourceWeb.GetFolder(SourceFolderName).SubFolders.Folder;
        SPFolder oDestFolder = destWeb.GetFolder(DestinationFolderName).SubFolders.Folder;

        foreach (SPFile oFile in oFolder.Files)
        {
            string strDestURL = oDestFolder.Url + "/";
            SPFile f = oFile;
            f.MoveTo(strDestURL + f.Name);
        }

        sourceWeb.Dispose();
        sourceSite.Dispose();
        destWeb.Dispose();
        destSite.Dispose();
    }


You can customize the code as you need files inside folder or subfolder.
Here we can move multiple files with meta data.

Monday, February 8, 2010

Expand Infragistics Grid using javascript

 Call the expandGrid function in onclientclick event of button.
  
    function expandGrid()
    {          
        var grid = igtbl_getGridById('<%=UltraWebGrid1.ClientID%>');      
        expand(grid);
    }

    function expand(grid)
    {           
      var rowsLength = grid.Rows.length;
        for (var i = 0; i < rowsLength; i++)
        {
            var rowObj = grid.Rows.getRow(i);
     
            if(rowObj.ChildRowsCount != 0)
            {           
                rowObj.setExpanded(true);
                expand(rowObj);
            }
            else
            {
                break;
            }
        }     
    }