Subscribe:

Labels

Friday, July 26, 2013

Content DataBase Migration from SharePoint 2010 to SharePoint 2013

  
DB Migration from sharepoint 2010 to sharepoint 2013

1.       Use Farm Admin Account For the Installation
2.        Check the Windows 2008 R2 SP1 (using Winver in the RunPrompt) or windows2012 server
3.       Run PreUpgradechecker.(Present in the SharePoint 2013 Installation Wizard)









Click on Finish on Prerequisites and it will Restart your computer.

4.       Get the  4 KB’s from the following link and Install one-by-one

Install the KB 2554876 
           Install KB 2708075

          Install KB 2759112
         Install the KB 2765317

5.      5.  Install SharePoint

         Run SharePoint set up


Right Click on Prerequisites and click on Run as administrator 
Right Click Run As Administrator





6.Configure SharePoint Farm Using PowerShell

############################################################
# Configure-SPFarm.ps1
# Configures a SharePoint 2013 farm with:
# Configuration Database
# Central Administration web application and site
#
#
############################################################
# Service accounts
$DOMAIN = "Domain"
$accounts = @{}
$accounts.Add("SPFarm", @{"username" = "user account"; "password" = "pwd"})
$accounts.Add("SPWebApp", @{"username" = "user account"; "password" = "pwd"})
$accounts.Add("SPSvcApp", @{"username" = "user account"; "password" = "pwd"})
Foreach ($account in $accounts.keys) {
$accounts.$account.Add(`
"credential", `
(New-Object System.Management.Automation.PSCredential ($DOMAIN + "\" + $accounts.$account.username), `
(ConvertTo-SecureString -String $accounts.$account.password -AsPlainText -Force)))
}
# SQL Server client alias
#This is the name of SQL Alias
$AliasName = "SPFarmAlias"
#This is the name of your SQL server (the actual name!)
# In this case we're using the current computer name as we are assuming #SharePoint and SQL are on the same server
# Change this if this isn't the case in your environment!
$ServerName = $env:devshpt31
#These are the two Registry locations for the SQL Alias locations
$x86 = "HKLM:\Software\Microsoft\MSSQLServer\Client\ConnectTo"
$x64 = "HKLM:\Software\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo"
#We're going to see if the ConnectTo key already exists, and create it if it doesn't.
if ((test-path -path $x86) -ne $True)
{
write-host "$x86 doesn't exist"
New-Item $x86
}
if ((test-path -path $x64) -ne $True)
{
write-host "$x64 doesn't exist"
New-Item $x64
}
#Adding the extra "fluff" to tell the machine what type of alias it is
$TCPAlias = ("DBMSSOCN," + $ServerName)
#Creating our TCP/IP Aliases
New-ItemProperty -Path $x86 -Name $AliasName -PropertyType String -Value $TCPAlias
New-ItemProperty -Path $x64 -Name $AliasName -PropertyType String -Value $TCPAlias
# Open cliconfig to verify the aliases
Start-Process C:\Windows\System32\cliconfg.exe
Start-Process C:\Windows\SysWOW64\cliconfg.exe
# Farm configuration
$configPassphrase = "SharePoint 2013 Intranet!"
$s_configPassphrase = (ConvertTo-SecureString -String $configPassphrase -AsPlainText -force)
$serverDB = $AliasName
$dbConfig = "SP2013_Configuration"
$dbCentralAdmin = "SP2013_Content_CentralAdministration"
$caPort = 55555
$caAuthProvider = "NTLM"
########################################
# Create the farm
Add-PSSnapin Microsoft.SharePoint.PowerShell
Write-Output "Creating the configuration database $dbConfig"
New-SPConfigurationDatabase `
-DatabaseName $dbConfig `
-DatabaseServer $serverDB `
-AdministrationContentDatabaseName $dbCentralAdmin `
-Passphrase $s_configPassphrase `
-FarmCredentials $accounts.SPFarm.credential
# Check to make sure the farm exists and is running. if not, end the script
$farm = Get-SPFarm
if (!$farm -or $farm.Status -ne "Online") {
Write-Output "Farm was not created or is not running"
exit
}
Write-Output "Create the Central Administration site on port $caPort"
New-SPCentralAdministration `
-Port $caPort `
-WindowsAuthProvider $caAuthProvider
# Perform the config wizard tasks
Write-Output "Install Help Collections"
Install-SPHelpCollection -All
Write-Output "Initialize security"
Initialize-SPResourceSecurity
Write-Output "Install services"
Install-SPService
Write-Output "Register features"
Install-SPFeature -AllExistingFeatures
Write-Output "Install Application Content"
Install-SPApplicationContent
# Add managed accounts
Write-Output "Creating managed accounts ..."
New-SPManagedAccount -credential $accounts.SPWebApp.credential
New-SPManagedAccount -credential $accounts.SPSvcApp.credential
New-SPManagedAccount -credential $accounts.SPCrawl.credential
#Start Central Administration
Write-Output "Starting Central Administration"
& 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN\psconfigui.exe' -cmd showcentraladmin
Write-Output "Farm build complete."


7.Service Applications Configuration using the Powershell


Start the service instances

The following procedures start the service instances.

To start service application instances from Central Administration

       I.            Start SharePoint 2013 Central Administration.
o    For Windows Server 2008 R2:
§  Click Start, click Microsoft SharePoint 2013 Products, and then click SharePoint 2013 Central Administration.
o    For Windows Server 2012:
§  On the Start screen, click SharePoint 2013 Central Administration.
If SharePoint 2013 Central Administration is not on the Start screen:
§  Right-click Computer, click All apps, and then click SharePoint 2013 Central Administration.
For more information about how to interact with Windows Server 2012, see Common Management Tasks and Navigation in Windows Server 2012.
    II.            In SharePoint 2013 Central Administration, on the Application Management page, in the Service Applications section, click Manage Services on Server.
 III.            Next to the Business Data Connectivity service, click Start.
 IV.            Next to the Managed Metadata Web Service, click Start.
    V.            Next to the PerformancePoint Services service, click Start.
 VI.            Next to the Secure Store Service, click Start.
VII.            Next to the User Profile Service, click Start.
8. The Search service instance must be started by using Windows PowerShell because you cannot start it from Central Administration unless a Search Service application already exists.
To start the Search service instance by using Windows PowerShell

Add-PSSnapin Microsoft.SharePoint.Powershell
$SearchInst = Get-SPEnterpriseSearchServiceInstance
# Stores the identity for the Search service instance on this server as a variable
Start-SPServiceInstance $SearchInst

 9. start the service instances using power shell commands follow the below commands


# Starts the service instance
Add-PSSnapin Microsoft.SharePoint.Powershell
#Upgrade Secure Store Service
$applicationPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services System"
$sss = New-SPSecureStoreServiceApplication -Name 'Secure Store Service' -ApplicationPool $applicationPool -DatabaseName 'Secure_Store_Service_DB' –AuditingEnabled
$sssp = New-SPSecureStoreServiceApplicationProxy -Name SPSecureStoreProxy -ServiceApplication $sss –DefaultProxyGroup
Update-SPSecureStoreMasterKey -Passphrase "Republ1c1" -ServiceApplicationProxy $sssp
Start-Sleep 5
Update-SPSecureStoreApplicationServerKey -Passphrase "Republ1c1" -ServiceApplicationProxy $sssp
Start-Sleep 5

#Upgrade BDS Service
$applicationPool = Get-SPServiceApplicationPool -Identity 'SharePoint Web Services System'
New-SPBusinessDataCatalogServiceApplication -Name 'BDC Service' -ApplicationPool $applicationPool -DatabaseName 'Bdc_Service_DB_df53d6bd850b46f7b58130f35ac23f28'

#Upgrade the Managed Metadata service application
$applicationPool = Get-SPServiceApplicationPool -Identity 'SharePoint Web Services System'
$mms = New-SPMetadataServiceApplication -Name 'Managed Metadata Service Application' -ApplicationPool $applicationPool -DatabaseName 'ManagedMetadata'
New-SPMetadataServiceApplicationProxy -Name 'ManagedMetadataProxy' -ServiceApplication $mms -DefaultProxyGroup


#Upgrade the User Profile service application
$applicationPool = Get-SPServiceApplicationPool -Identity 'SharePoint Web Services System'
$upa = New-SPProfileServiceApplication -Name 'User Profile Service Application' -ApplicationPool $applicationPool -ProfileDBName 'Profile_DB' -SocialDBName 'Social_DB' -ProfileSyncDBName 'Sync_DB'
New-SPProfileServiceApplicationProxy -Name 'UserProfileServiceProxy' -ServiceApplication $upa -DefaultProxyGroup

#Upgrade the PerformancePoint Services service application
$applicationPool = Get-SPServiceApplicationPool -Identity 'SharePoint Web Services System'
$pps = New-SPPerformancePointServiceApplication -Name 'PerformancePoint Service' -ApplicationPool $applicationPool -DatabaseName 'PerformancePoint Service Application_42130b2b01484fe79461506442afb46e'
New-SPPerformancePointServiceApplicationProxy -Name 'PerformancePointProxy' -ServiceApplication $pps -Default

#Upgrade the Search service application

$applicationPool = Get-SPServiceApplicationPool -Identity 'SharePoint Web Services System'

$searchInst = Get-SPEnterpriseSearchServiceInstance -local
# Gets the Search service instance and sets a variable to use in the next command

Restore-SPEnterpriseSearchServiceApplication -Name 'SP2013_SearchServiceApplication' -applicationpool $applicationPool -databasename 'FASTContent_DB_0d544f286d044d4a83cf9ba001a2e405' -databaseserver 'devshpt31' -AdminSearchServiceInstance $searchInst
$ssa = Get-SPEnterpriseSearchServiceApplication
New-SPEnterpriseSearchServiceApplicationProxy -Name 'SearchServiceAppProxy' -SearchApplication $ssa
$ssap = Get-SPEnterpriseSearchServiceApplicationProxy
Add-SPServiceApplicationProxyGroupMember –member $ssap -identity " "
#Verify that all of the new proxies are in the default proxy group
$pg = Get-SPServiceApplicationProxyGroup -Identity " "
$pg.Proxies


10. Claims authentication and Classic Authentication: SharePoint 2013 uses Classic authentication

Database Upgrade:
WARNING: The Windows Classic authentication method is deprecated in this release and the default behavior of this cmdlet, which creates Windows Classic based web application, is obsolete. It i
s recommended to use Claims authentication methods. You can create a web application that uses Claims authentication method by specifying the AuthenticationProvider parameter set in this cmdle
t. Refer to the http://go.microsoft.com/fwlink/?LinkId=234549 site for more information. Please note that the default behavior of this cmdlet is expected to change in the future release to cre
ate a Claims authentication based web application instead of a Windows Classic based web application.

Resolve the Issue using the following.

Data Base Upgrade

1.     Copy all the dbs from the SP2010 Farm SQL DB Server to SP2013 Farm SQL DB Server

2.     Create all the Web Applications in SP 2013 using the following Powershell
Create all the web applications (with the same url, same port and same name with the dummy db name – something like D
eletethis1, Deletethis2)

Below one is to create web application using classic based authentication.
#test webapp
Add-PSSnapin Microsoft.SharePoint.Powershell
$WebAppName = "test - 26173"
$WebAppHostHeader = "testDevInside2013.com"
$WebAppPort = 80
$WebAppAppPool = "test - 26173"
$URL = "http://testDevInside2013.com"
# This User has to be a Sharepoint Manager Account
$WebAppAppPoolAccount = "microsoft\_dev"
$WebAppDatabaseName = "DeleteThis1"
$WebAppDatabaseServer = "sevsht31"
# Create a new Sharepoint WebApplication
New-SPWebApplication -Name $WebAppName -Port $WebAppPort -HostHeader $WebAppHostHeader -URL $URL -ApplicationPool $WebAppAppPool  -AuthenticationMethod "NTLM" -ApplicationPoolAccount (Get-SPManagedAccount $WebAppAppPoolAccount) -DatabaseName $WebAppDatabaseName -DatabaseServer $WebAppDatabaseServer

For claims based authentication


#test webapp
Add-PSSnapin Microsoft.SharePoint.Powershell
$WebAppName = "test - 5555"
$WebAppHostHeader = "testDevInside2013.com"
$WebAppPort = 80
$WebAppAppPool = "test - 5555"
$URL = "http://testDevInside2013.com"
# This User has to be a Sharepoint Manager Account
$WebAppAppPoolAccount = "microsoft\_dev"
$WebAppDatabaseName = "DeleteThis1"
$WebAppDatabaseServer = "sevsht31"
$ap = New-SPAuthenticationProvider
# Create a new Sharepoint WebApplication
New-SPWebApplication -Name $WebAppName -Port $WebAppPort -HostHeader $WebAppHostHeader -URL $URL -ApplicationPool $WebAppAppPool -AuthenticationMethod "NTLM" -ApplicationPoolAccount (Get-SPManagedAccount $WebAppAppPoolAccount) -DatabaseName $WebAppDatabaseName -DatabaseServer $WebAppDatabaseServer –AuthenticationProvider $ap



11. Get all the .wsp from SharePoint 2010 to SharePoint 2013 using the following Powershell

  Export the wsps from the old farm to the new Form using the powershell script

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

## setup our output directory
$dirName = "c:\sp2010_wsps"

Write-Host Exporting solutions to $dirName
foreach ($solution in Get-SPSolution)
{
  $id = $Solution.SolutionID
    $title = $Solution.Name
    $filename = $Solution.SolutionFile.Name

    Write-Host "Exporting ‘$title’ to …\$filename" -nonewline
    try {
        $solution.SolutionFile.SaveAs("$dirName\$filename")
        Write-Host " – done" -foreground green
    }
    catch
    {
        Write-Host " – error : $_" -foreground red
    }
}

12 .Install all the .wsps in SP 2013 using the following powershell
Add-PSSnapin Microsoft.SharePoint.Powershell
# areasecuredwp.wsp
Add-SPSolution "C:\Deployments\SharePoint2013\sp2010_wsps\testwp.wsp"
Install-SPSolution –Identity testwp.wsp –WebApplication http://testdevinside2013.com/ -GACDeployment


13.Test the DB Upgrade Customizations errors using the following powershell
Test-SPContentDatabase –Name ‘your db name’ -WebApplication http://www.testdevinside2013.com/
Test-SPContentDatabase –Name ‘your db name’ -WebApplication http://www.xxprojectsdevinside2013.com/
Test-SPContentDatabase –Name ‘your db name’ -WebApplication http://www.yyysdevinside2013.com/

14.Delete the dummy Databases which you created with SP 2013 web apps
Dismount-SPContentDatabase "DeleteThis1"
Dismount-SPContentDatabase "DeleteThis2"
Dismount-SPContentDatabase "DeleteThis3"
Dismount-SPContentDatabase "DeleteThis4"
Dismount-SPContentDatabase "DeleteThis5"
15.Upgrade the web application using the following PowerShell
Mount-SPContentDatabase –Name ‘your db name’  -DatabaseServer ‘your db server name’ -WebApplication http://www.testdevinside2013.com/
Mount-SPContentDatabase –Name ‘your db name’  -DatabaseServer ‘your db server name’ -WebApplication http://www.xxprojectsdevinside2013.com/
Mount-SPContentDatabase –Name ‘your db name’  -DatabaseServer ‘your db server name’ -WebApplication http://www.yyydevinside2013.com/


16.Now access the web applications, you will see all your sites in SP2013 with SP 2010 UI

17. Now Upgrade the Customizations
Custom Master Pages
Custom Page Layouts

Custom Web parts or Custom Controls 

Friday, July 12, 2013

Implement the Custom "Like" and "Rating" functionality in Share Point 2013

If u want implement custom Like and Rating functionality in Sharepoint 2013,find the below code.
Add Microsoft.Office.Server.UserProfiles.dll as a reference in your project
Class: Following are the classes which are available with the namespace
Reputation,ElevatedPrivilegesHelper

Set Custom Like for ur Sharepoint List or Library

SPList resourceList = SPContext.Current.Web.Lists["Resources"];
SPListItem likeItem = resourceList.Items[0];
Reputation.SetLike(resourceList.ID.ToString(), likeItem.ID, true);

Set custom Rating for ur List or Library

SPList resourceList = SPContext.Current.Web.Lists["Resources"];
SPListItem likeItem = resourceList.Items[0];
Reputation.SetRating(resourceList.ID.ToString(), likeItem.ID, 4);

Before this code you have to enable the Rating and Like functionality on ur sharepoint list...
Goto List settings u will find Rating settings.
once u enable this automatically some fields are created to ur list
Those are
LikedBy
LikesCount
etc

Same thing u can implement using client side object model code

var likepage = {
//Likes the current page.
LikePage: function () {
likepage.getUserLikedPage(function(likedPage, likeCount) {
var aContextObject = new SP.ClientContext();
EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function() {
Microsoft.Office.Server.ReputationModel.
Reputation.setLike(aContextObject,
_spPageContextInfo.pageListId.substring(1, 37),
_spPageContextInfo.pageItemId, !likedPage);
aContextObject.executeQueryAsync(
function() {
var elements = document.getElementsByClassName('likecount');
if (likedPage) {
likeCount--;
} else {
likeCount++;
}
for (var i = 0; i < elements.length;i++) {
elements[i].innerHTML = likeCount;
}
}, function(sender, args) {
// Custom error handling if needed
});
});
});
},
// Checks if the user already liked the page, and returns the number of likes.
getUserLikedPage: function (cb) {
var context = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
var list = context.get_web().get_lists().getById(_spPageContextInfo.pageListId);
var item = list.getItemById(_spPageContextInfo.pageItemId);
context.load(item, "LikedBy", "ID", "LikesCount");
context.executeQueryAsync(Function.createDelegate(this, function (success) {
// Check if the user id of the current users is in the collection LikedBy.
var $v_0 = item.get_item('LikedBy');
if (!SP.ScriptHelpers.isNullOrUndefined($v_0)) {
for (var $v_1 = 0, $v_2 = $v_0.length; $v_1 < $v_2; $v_1++) {
var $v_3 = $v_0[$v_1];
if ($v_3.$1E_1 === _spPageContextInfo.userId) {
cb(true, item.get_item('LikesCount'));
}
}
}
cb(false, item.get_item('LikesCount'));
}),
Function.createDelegate(this, function (sender, args) { //Custom error handling if needed }));
},
initialize: function () {
var elements = document.getElementsByClassName('likecount');
likepage.getUserLikedPage(function(likedPage, likesCount) {
for (var i = 0; i < elements.length; i++) {
elements[i].innerHTML = likesCount;
}
});
}
};
_spBodyOnLoadFunctionNames.push("likepage.initialize");

Thursday, June 20, 2013

Export to excel from Data table in C#

 public void ExporttoExcel()
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=Reports.xls");

            HttpContext.Current.Response.Charset = "utf-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
            //sets font
            HttpContext.Current.Response.Write("<font style='font-size:10.0pt; font-family:Calibri;'>");
            HttpContext.Current.Response.Write("<BR><BR><BR>");
            //sets the table border, cell spacing, border color, font of the text, background, foreground, font height
            HttpContext.Current.Response.Write("<Table border='1' bgColor='#ffffff' " +
              "borderColor='#000000' cellSpacing='0' cellPadding='0' " +
              "style='font-size:10.0pt; font-family:Calibri; background:white;'> <TR>");
            //am getting my grid's column headers
           // int columnscount = GridView_Result.Columns.Count;
            for (int i = 0; i < grdViewYMP.Columns.Count ; i++)
            {
                HttpContext.Current.Response.Write("<Td>");
                //Get column headers  and make it as bold in excel columns
                HttpContext.Current.Response.Write("<B>");
                HttpContext.Current.Response.Write(grdViewYMP.HeaderRow.Cells[i].Text.Trim());
                HttpContext.Current.Response.Write("</B>");
                HttpContext.Current.Response.Write("</Td>");
            }
            HttpContext.Current.Response.Write("</TR>");
            DataTable dtYMP = ViewState["dtYMP"] as DataTable;
                                           
            foreach (DataRow row in dtYMP.Rows)
            {//write in new row
                HttpContext.Current.Response.Write("<TR>");
                for (int i = 0; i < dtYMP.Columns.Count; i++)
                {
                    HttpContext.Current.Response.Write("<Td>");
                    HttpContext.Current.Response.Write(row[i].ToString());
                    HttpContext.Current.Response.Write("</Td>");
                }

                HttpContext.Current.Response.Write("</TR>");
            }
            HttpContext.Current.Response.Write("</Table>");
            HttpContext.Current.Response.Write("</font>");
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }        

Export to Excel functionality Using Office.Interop.excel referenc

public void ExporExcelusingOffice()
        {
            // creating Excel Application

            Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();

            // creating new WorkBook within Excel application

            Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);

            // creating new Excelsheet in workbook

            Microsoft.Office.Interop.Excel._Worksheet worksheet = null;

            // see the excel sheet behind the program
            app.Visible = true;

            // get the reference of first sheet. By default its name is Sheet1.

            // store its reference to worksheet

            worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["Sheet1"];

            worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;

            // changing the name of active sheet

            worksheet.Name = "Exported from gridview";


            // storing header part in Excel

            for (int i = 1; i < grdViewYMP.Columns.Count + 1; i++)
            {
                worksheet.Cells[1, i] = grdViewYMP.HeaderRow.Cells[i - 1].Text.Trim();
            }

            DataTable dtYMP = ViewState["dtYMP"] as DataTable;


            // storing Each row and column value to excel sheet

            for (int i = 0; i < grdViewYMP.Rows.Count - 1; i++)
            {
                for (int j = 0; j < grdViewYMP.Columns.Count; j++)
                {
                    worksheet.Cells[i + 2, j + 1] = dtYMP.Rows[i][j].ToString();
                    //worksheet.Cells[i + 2, j + 1] = grdViewYMP.Rows[i].Cells[j].Text;
                }
            }

            // save the application
            object misValue = System.Reflection.Missing.Value;
            // workbook.SaveAs("c:\\output.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            workbook.SaveAs("c:\\YMPoutput.xlsx", Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel9795, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, misValue, misValue, misValue, misValue, misValue);
            // Exit from the application

            app.Quit();

        }

Monday, June 3, 2013

Create a mysite(personal site) Using the Object Model


Below code is using object model creating the my sites dynamically.


            SPSite site = new SPSite("http://win-rgqt3bch3nk:22929/sites/Test");

            SPWeb web = site.OpenWeb();
            // SPWeb web = SPContext.Current.Web;


            web.AllowUnsafeUpdates = true;

         
            if (ApproveitemId > 0)
            {
                SPList thislist = web.Lists["Requests"];
                SPListItem item = thislist.Items.GetItemById(ApproveitemId);
                string AStatus = item["Approval_Status"].ToString();
                string strYes = "Yes";
                if (AStatus == strYes)
                {
                    string mysiteusername = item["Username"].ToString();
                     //SPUser mysiteuname = web.AllUsers[mysiteusername];

                    SPSecurity.RunWithElevatedPrivileges(delegate()
                         {
                             using (SPSite spSite = new SPSite("http://win-rgqt3bch3nk:38562"))
                             {
                                 spSite.AllowUnsafeUpdates = true;
                                 SPContext.Current.Web.AllowUnsafeUpdates = true;
                                 SPServiceContext siteContext = SPServiceContext.GetContext(spSite);
                                 //UserProfileManager up = new UserProfileManager(siteContext,true);
                                 UserProfileManager up = new UserProfileManager(siteContext);
                                 //string sAccount = "WIN-RGQT3BCH3NK\\test1";
                                 //UserProfile uprof = up.GetUserProfile(sAccount.Trim());
                                 UserProfile uprof = up.GetUserProfile(mysiteusername);
                                 uprof.CreatePersonalSite();
                             }
                         });
                }
            }
         
        }

DB Upgrade for migrating from SharePoint 2007 to SharePoint 2010

Find the following Steps which we used for the Intranet Migration

We used DB Upgrade for migrating the Intranet environment from SharePoint 2007 to SharePoint 2010.
  
  1.    Run the PreUpgrade check in SharePoint 2007
  2.    Resolve the errors
  3.    Installed the SharePoint 2010 in the new SharePoint Farm environment
  4.    Configured the SharePoint farm
  5.     Copied the DBs from SP 2007 DB to SP 2010 DB
  6.   Configured the Service Applications
  7.   Installed the customizations(wsps)
  8.  Created all the Web Applications in SP 2010 with test DB
  9.  Checked the DB upgrade errors using test-mount
  10.  Upgraded the Web App DBs using PowerShell
  11.   Upgraded the Customizations
  12.  Changed the Web Sites(Site Collections and Sub Sites) UI from SP 2007 to SP2010
  13.    Configured the Search Service app
  14.    Configured the User profile app and Synchronized the users from AD