Saturday, 11 July 2015

Hide tabs on site

under CSS file
set display property to NONE instead of instead of INLINE.

Tuesday, 7 July 2015

REF Cursor vs cursor

A cursor is really any SQL statement that runs DML (select, insert, update, delete) on your database.
A ref cursor is a pointer to a result set. This is normally used to open a query on the database server, then leave it up to the client to fetch the result it needs. A ref cursor is also a cursor, though normally the term cursor is used when discussing static SQL.




create or replace
function f (input in varchar2)
return sys_refcursor as cur sys_refcursor;
begin
if input = 'EMP' then
open cur for select * from emp;
elsif input = 'DEPT' then
    open cur for select * from dept;
  end if;
return cur;
end;



Powershell Get Size SharePoint Sites or Webs

param(
[Parameter(Mandatory = $true, ValurFromPipelineByPropertyName=$true) ][System.String] $env,
[Parameter(Mandatory= $true, ValueFromPipelineByPropertyName = $true)][System.String] $outputFile
)

$snapin = Get_PSSnapin | Where-Object{$_.Name -eq "Microsoft.SharePoint.PowerShell"}
if($snapin -eq $null)
{
Write-Host "Adding SharePoint Snapin..."
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$table = New-Object System.Data.DataTable "WebSite Size Table"
$title = New-Object System.Data.DataTable Title,([system.string])
$url = New-Object System.Data.DataTable URL, ([system.string])
$size = New-Object System.Data.DataTable size, ([system.string])
$table.Columns.Add($title)
$table.Columns.Add($url)
$table.Columns.Add($size)

function GetSpWebSize($Web)
{
 [long]$subtotal = 0
    foreach ($folder in $Web.Folders)
    {
        $subtotal += GetFolderSize -Folder $folder
    }
  
    return $subtota
}

function GetSubWebSizes ($Web)
{
    [long]$subtotal = 0
    foreach ($subweb in $Web)
    {
        [long]$webtotal = 0
        foreach ($folder in $subweb.Folders)
        {
            $webtotal += GetFolderSize -Folder $folder
        }
       
        $subtotal += $webtotal
       
    }
    return $subtotal
}

function GetFolderSize ($Folder)
{
    [long]$folderSize = 0 
    foreach ($file in $Folder.Files)
    {
        $folderSize += $file.Length;
    }
    foreach ($fd in $Folder.SubFolders)
    {
        $folderSize += GetFolderSize -Folder $fd
    }
    return $folderSize
}


if($env  -eq "QA")
{
 $File = "AllQASites.csv"
}
elseif($env -eq "Live")
{
 $File = "AllLiveSites.csv"
}
else
{
Write-Host "Please  choose the environment either QA or Live!"
return
}

$getContent = Import-Csv -path $File

Foreach($rowin in $getContent)
{
  Write-Host "Fetching details of " $rowin.Site -ForegroundColor Green
if($rowin.Type -eq "Site")
{
 $WebSite = Get-SPSite -Identity $rowin.URL -ErrorAction SilentlyContinue
}
elseif($rowin.Type -eq "Web")
{
$WebSite = Get-SPWeb -Identity $rowin.URL -ErrorAction SilentlyContinue
}
else
{
Write-Host "Please choose type either Site or web!"
return
}
try{
if($WebSite -ne $null)
{
 $row = $table.NewRow()
if($rowin.Type -eq "Site")
{
 $row.Title = $WebSite.RootWeb.Title
$row.URL = $WebSite.URL
$row.size = $WebSite.usage.storage/1MB
}
else if($rowin.Type -eq "Web")
{
 $row.Title = $WebSite.Title
$row.URL = $WebSite.URL

[long]$total = 0

$total += GetSPWebSize -Web $WebSite.URL
$total += GetSubWebSizes -Web $site.Url

            $Folder = $site.Folders
            foreach ($file in $Folder.Files)
            {
                $total += $file.Length;
            }
            foreach ($fd in $Folder.SubFolders)
            {
        $total += GetFolderSize -Folder $fd
                }

$row.size = ($total/1024)/1024
}
$table.Rows.Add($row)
$table.AcceptChanges()
$WebSite.Dispose()
}
}
Catch{
 Write-Host $_.Exception.Message -ForegroundColor Red
}
}

$table | Export-Csv -Path $outputFilePath -NoTypeInformation

$endDate = Get-Date
Write-Host "script completed at" $endDate -ForegroundColor Yellow


#Please write your queries on "Arpit_Mohan@outlook.com"

Monday, 6 July 2015

Response File CSC.rsp

Response file is text file which consists of a set of command line switches.


And the switches were user by CSC.exe compiler.



# Reference the common Framework libraries
/r:Accessibility.dll
/r:Microsoft.CSharp.dll
/r:System.Configuration.dll
/r:System.Configuration.Install.dll
/r:System.Core.dll
/r:System.Data.dll
/r:System.Data.DataSetExtensions.dll
/r:System.Data.Linq.dll
/r:System.Data.OracleClient.dll
/r:System.Deployment.dll
/r:System.Design.dll
/r:System.DirectoryServices.dll
/r:System.dll
/r:System.Drawing.Design.dll
/r:System.Drawing.dll
/r:System.EnterpriseServices.dll
/r:System.Management.dll
/r:System.Messaging.dll
/r:System.Runtime.Remoting.dll
/r:System.Runtime.Serialization.dll
/r:System.Runtime.Serialization.Formatters.Soap.dll
/r:System.Security.dll
/r:System.ServiceModel.dll
/r:System.ServiceModel.Web.dll
/r:System.ServiceProcess.dll
/r:System.Transactions.dll
/r:System.Web.dll
/r:System.Web.Extensions.Design.dll
/r:System.Web.Extensions.dll
/r:System.Web.Mobile.dll
/r:System.Web.RegularExpressions.dll
/r:System.Web.Services.dll
/r:System.Windows.Forms.Dll
/r:System.Workflow.Activities.dll
/r:System.Workflow.ComponentModel.dll
/r:System.Workflow.Runtime.dll
/r:System.Xml.dll
/r:System.Xml.Linq.dll

This Web Site Cannot be Started. Another Web Site May Be Using the Same Port

Open the IIS.
Check all the websites port.
Surely you will get same for two websites.
Resolution:
1) Stop any of the website, which you don't want to use.
2) Change the port number for any of the website. Go to Advance Settings and change the port number

Saturday, 4 July 2015

useLegacyV2RuntimeActivationPolicy + CorBindToRuntimeEx function

Definition


This attribute is useful if your application uses legacy activation paths, such as the CorBindToRuntimeEx function, and you want those paths to activate version 4 of the CLR instead of an earlier version, or if your application is built with the .NET Framework 4 but has a dependency on a mixed-mode assembly built with an earlier version of the .NET Framework. In those scenarios, set the attribute to true.


<?xml version = 1.0?>
   <Configuration>
      <Startup useLegacyV2RuntimeActivationPolicy = "true">
        <SupportedRuntime Version = "V4.0.30319"/>
      </Startup>
   </Configuration>


CorBindToRuntimeEx function:
Enables unmanaged hosts to load the common language runtime (CLR) into a process.

Powershell Get SharePoint Site Collections Size

Please run the below mentioned script but before that create input file of the environment:


File Name:
QAAllSites.csv


Content:
Site   URL
ABC http:\\Webapp1\sites\SC1
DEF  http:\\WebApp1\sites\SC2


Script:




#First steps to pass parameter values


param(
[Parameter(Mandatory = $true, valueFromPipelineByPropertyName = $true )][system.string] $env,
[Parameter(Mandatory = $true, valueFromPipelineByPropertyName = $true)][system.string] $outputFilePath
)


#Check SharePoint snapin is added or not?


$snapin = Get-PSSnapin | Where-Object {$_.Name = ""Microsoft.SharePoint.PowerShell"}
if($snapin -eq $null)
{
     Write-Host "Adding 'Microsoft.SharePoint.PowerShell' snapin..."
      Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}


#create variable to get current date time


$startDate = Get-Date
Write-Host "Script start running.." $startDate -ForegroundColor Yellow




#Create table for binding result


$table = New-Object System.Data.DataTable ["Site Collection Size Table"]
$Title = New-Object System.Data.DataColumn Title,[(system.string)]
$URL = New-Object System.Data.DataColumn URL,[(system.string)]
$Size_In_MB = New-Object System.Data.DataColumn Size_In_MB,[(system.string)]


#Check the environment for which script is going to run(eg: QA, Pre-QA)


if($env -eq "QA")
{
    $FileName = "QAAllSites.csv"
}
elseif($env -eq "Pre-QA")
{
   $FileName = "Pre-QAAllSites.csv"
}
else
{
    Write-Host "Choose the correct environment name!"
    return
}


$getFileContent = Import-csv -path $FileName
$getSites  = $getFileContent.URL


Foreach($getSite in $getSites)
{
           Write-Host "Fetching size details of site..." $getSite -Foreground Green
  try{
           $Site = Get-SPSite -Identity $getSite
            $row = $table.NewRow()
            $row.Title = $Site.RootWeb.Title
            $row.URL = $Site.URL
            $row.Size_In_MB = $Site.usage.storage/1MB
            $table.Rows.Add($row)
            $table.AcceptChanges()
            $Site.Dispose()
}
Catch{
             $_.Exception.Message -ForegroundColor Red
}
}


#Export result


$table | Export-csv -path $outputPath -NoTypeInformation


#Get the end date & time of the script


$endDate = Get-Date
Write-Host "Script Completed successfully, Please verify the output file"






##To run the above script pass the command:


.\GetSiteCollectionSizes -env "QA" -outputPath "QAReport.CSV"








###Incase of query, please write to me on Arpit_Mohan@outlook.com