Tuesday 23 December 2014

SharePoint 2010

Plan managed metadata (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ee530389.aspx



Managed metadata overview (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ee424402.aspx



SharePoint 2010 – Provisioning User Profile Synchronization

http://blogs.msdn.com/b/russmax/archive/2010/03/20/sharepoint-2010-provisioning-user-profile-synchronization.aspx



Configure profile synchronization (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ee721049.aspx



User Profile service overview (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ee662538.aspx



User Profile Replication Engine overview (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/cc663011.aspx



Create, edit, or delete a User Profile service application (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ee721052.aspx



Maintain profile synchronization (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ff681014.aspx



User Profile Synchronization Service unexpected failure - Events 6300-6309 (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ff519523.aspx



User Profile Synchronization service not started (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ff519522.aspx









Windows PowerShell for SharePoint Server 2010

http://technet.microsoft.com/en-us/library/ee662539.aspx



SharePoint 2010 Products administration by using Windows PowerShell

http://technet.microsoft.com/en-us/library/ee806878.aspx



SharePoint Foundation 2010

http://technet.microsoft.com/hi-in/library/cc288070(en-us).aspx  



Initial configuration (SharePoint Foundation 2010)

http://technet.microsoft.com/en-us/library/ee837435.aspx  



Prepare to host sites (SharePoint Foundation 2010)

http://technet.microsoft.com/en-us/library/cc303306.aspx  



SharePoint Server 2010

http://technet.microsoft.com/hi-in/library/cc303422(en-us).aspx



Upgrading to SharePoint Server 2010

http://technet.microsoft.com/en-us/library/cc303420.aspx  



Perform an in-place upgrade (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/cc303423.aspx  



Upgrade in place to SharePoint Server 2010

http://technet.microsoft.com/en-us/library/cc263212.aspx  



Troubleshoot upgrade issues (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/cc262967.aspx  



Resume upgrade (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/ff382638.aspx  



Configure automatic password change (SharePoint Foundation 2010)

http://technet.microsoft.com/en-us/library/ff607826.aspx  



Configuring Kerberos authentication for SharePoint 2010 Products (white paper)

http://technet.microsoft.com/hi-in/library/ff829837(en-us).aspx  



Video demos and training for SharePoint Server 2010

http://technet.microsoft.com/hi-in/library/cc262880(en-us).aspx

SharePoint Administration Interview

What timer job is responsible for propogating changes to SharePoint configuration objects across the farm?

HiddenListFullSyncTimerJob

Which of the following logs is not intended to be read directly in SharePoint 2010?

Which of the following is not a scope for SharePoint features?

How should the User Profile Synchronization Service be configured via PowerShell?

By default, what TCP ports are used for PowerShell v2 remoting (non-SSL/SSL)?

The AssignmentCollection parameter is available on all SharePoint cmdlets. Which of the following cmdlets actually utilize assignment collections?


True or False: If a cmdlet parameter specifies that it takes a *PipeBind object, it will always be set by output from previous cmdlets in the pipeline.

What downloadable package contains PowerShell and other Windows Management components?

Which one of the following shows a call of a static method?

True or False: SharePoint Service Application Proxies only connect to SharePoint Service Applications (in SharePoint 2010 or 2013).

Which method must you call to persist changes to a SPPersistedObject to the configuration database?

Which of these machine-local groups are added by SharePoint?

True or False: Switch parameters and Boolean parameters are specified the same way in PowerShell cmdlets.

What method must be called to push web.config modifications added to a SPWebConfigModificationCollection to web applications?

What SPN prefix is used to identify service accounts for PowerShell CredSSP authentication?

Which of the following objects are not derived from SPPersistedObject?

Objects from which of the following object frameworks are not treated as first-class objects in PowerShell? First class objects can have their members (properties and methods) invoked directly via dot notation.

What is the root object of the SharePoint object model?

Which of the following are children of SPFarm?

Which version of PowerShell is the minimum required for SharePoint 2013?

Additional details about webs, lists, and list items are stored in a hashtable member of these objects named:

Move/Migrate SharePoint list items/documents and preserve metadata properties


In moving the mass documents to other folder or libraries there is a pretty common way by using Windows Explorer view. But there's a drawback to that method as the metadata properties like document properties get updated in the process - manily the modified Date/Time as well as the user would take on the role of the person that 'Last modfied '. This also applies to copying list data in the data sheet view from one list/library to another.

I have figured out a new way to doing this where you can save the current list properties after moving the documents as a template with content included and redeploying that to other location. 

So if you want to move the contents of a SharePoint Document Library or List and be able to preserve the item’s metadata/property values at the same time you should use this method:

The process to move the content of a SharePoint Document library or List and be able to preserve the item's metadata/property values at the same time you should use this method:

1. Create a Blank Document library where you want to move, don't worry about the custom field it will automatically created once document moved.

2. Go to to "Content and Structure" page. You can access this item within the site with Site Actions  >Site Settings then under Site Administration tab there is a option called Content and Structure.


3. Navigate to you Source Library and select the view that you would like to have moved. Then click on  View > Select the view . Then Click on Action > Move...

   Note: You can create you own custom view. Example You want to move 30 days old file. So  create your view which show files for only 30 Days.


 4. You'll then be prompted witha pop-up that will let you navigate to your destination library or Document library .After you find that, just press the OK button

Monday 22 December 2014

SharePoint 2013 Best Practices

http://social.technet.microsoft.com/wiki/contents/articles/12438.sharepoint-2013-best-practices.aspx

Migration from SharePoint 2010 to SharePoint 2013

1. Go to sql management studio and your databse right click db-->Tasks-->detach go to C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA(2files ".mdf and .ldf" files take)
2. go to 2013 server sql management studio -->attach both .mdf and ldf files
3. Create ur webapplication in 2013 site collection-->if any custom solutions,webparts etc add your site
4.using Powershell: Mount-SPContentDatabase -Name WSS_Contenet_2010 -WebApplication "http://webapp:2013"

How to get SharePoint Server Version

SharePoint Server Version
Open PowerShell:
PS C:\Users\My Name>(get-spfarm).buildversion
You will get Version

Or
PS C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN>(get-spfarm).buildversion
Major Minor Build Revision
----- ----- ----- --------
14 0 6100 5002
Or
To see which build your products are, go to Central Administration > Upgrade and Migration > Check Product and patch installation status.
Or
http://SERVER/_admin/PatchStatus.aspx
Data Base Version:
Central Administration --> System Settings -->Manage servers in this farm
You can see:
Configuration database version: 14.0.6100.5002
Configuration database server: SREVER
Configuration database name: SharePoint_Config
Or
To see which build your databases are, go to Central Administration > Upgrade and Migration > Review database status.
Or
http://SERVER/_admin/DatabaseStatus.aspx

How to open Windows PowerShell

The use should have permission on SharePoint_Shell_Access, if not Adds a user to the SharePoint_Shell_Access role for the specified database.
How to add user to SharePoint_Shell_Access?
Go to Security–>logins–>[Domain\MyName]
Right click–>properties.
Click on User Mapping.
Select “SharePoint_Config” database in the —–Users Mapped to this login section:
Select “SharePoint_Shell_Access” in the —Database role membership for :SharePoint_Config

On the Start menu, click All Programs.
Click Microsoft SharePoint 2010 Products.
Click SharePoint 2010 Management Shell.
At the Windows PowerShell command prompt (that is, PS C:\>), type the following command, and then press ENTER:
Restore-SPFarm -Directory -RestoreMethod Overwrite -Item [-BackupId ] [-Verbose]
Note:
If you are not logged on as the Farm account, you are prompted for the Farm account’s credentials.

Microsoft.SharePoint.PowerShell

Get-Command –PSSnapin “Microsoft.SharePoint.PowerShell” | format-table name > C:\SP2010_PowerShell_Commands.txt
And
Get-Command –PSSnapin “Microsoft.SharePoint.PowerShell” | select name, definition | format-list > C:\SP2010_PowerShell_Commands_new.txt

How to Move content Databases using PowerShell

How to Move content Databases using PowerShell?
—————————–
Step1: Create an additional content database either using PowerShell (PS) or the UI namely:
Go to CA > Application Management > Manage Content Databases > Add a Content Database (I called my content database “WSS-Content-NewUserDB”).
Now we will Use PS
Syntax:
———-
PS C:\Users\Admin> Move-SPSite [-Identity] -DestinationDatabase [-
AssignmentCollection ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAction ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer ] [-WhatIf] [-Confirm]
Eample:
——–
PS C:\Users\Admin> Move-SPSite -Identity http://sp2010 -Destinationdatabase WSS-Content-NewUserDB
Confirm
Are you sure you want to perform this action?
Performing operation “Move-SPSite” on Target “http://sp2010?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “Y”): y
WARNING: IIS must be restarted before this change will take effect.
Now you have to restart IIS.
open a command prompt window and type iisreset.

Web Config Modifications using PowerShell in SharePoint 2010

Web Config Modifications using PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell
$oWebApp = Get-SPWebApplication http://SP2010
$oWebApp.WebConfigModifications
$oWebConfig = New-Object -TypeName Microsoft.SharePoint.Administration.SPWebConfigModification
$oWebConfig.name = "add[@key='TEST']"
$oWebConfig.path = "/configuration/appSettings"
$oWebConfig.value = "<add key='TEST' value='My Test' />"
$oWebConfig.owner = "oTest"
$oWebConfig.sequence = 0
$oWebConfig.type = [Microsoft.SharePoint.Administration.SPWebConfigModification+SPWebConfigModificationType]::EnsureChildNode
$oWebApp.WebConfigModifications.Add($oWebConfig)
$oWebApp.Update()
$oWebApp.Parent.ApplyWebConfigModifications()
GO to C:\inetpub\wwwroot\wss\VirtualDirectories\80
Open Web.config file, Search with "TEST", you will able to see <add key='TEST' value='My Test' />

Windows PowerShell for SharePoint Command Builder

SharePoint PowerShell Commands to get Feature List

Get All Feature List
Get-SPFeature >D:\a.txt
SharePoint Version
(get-spfarm).buildversion
To Check SharePoint is installed and working or not
get-spfarm
if you get below output then it's installed and working fine...
Name                                                                                                         Status
---- ------
SharePoint_Config_6983cd15-2834-4645-a3f3-b7c63500545f               Online

If status is Online, it's correct installation

Monday 15 December 2014

msoidcliL.dll file is missing


I was trying to authenticate sharepoint using SharePointOnlineCredentials. I am getting msoidcliL.dll file is missing error.

Same code is working from my development system.

Root Cause: The system where i was executing my code, it is not having msoidcliL.dll.

Solution:
The client system should have office 15 software or SharePoint Server 2013 Client Components SDK. So that it will give msoidcliL.dll

You can download from:
http://www.microsoft.com/en-us/download/details.aspx?id=35585

Saturday 6 December 2014

RAISERROR 50000 error

In SQL i was using below syntax, it was working fine. But after migrating to SQL 2012, i was getting error.
RAISERROR 50000 'Error.'

Error: RAISERROR 50000 error

Solution:
DECLARE @ErrorMsg varchar(500)

SET @ErrorMsg = 'Error'
RAISERROR (@ErrorMsg,16,1)

I have changed my code and updated my stored procedures. Problem solved.

this.context.session null

You are missing below line in web.config

<configuration>
  ...
  <system.webServer>
    ...
    <modules>
      <remove name="Session" />
      <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
      ...
    </modules>
  </system.webServer>
</configuration>

Friday 5 December 2014

SQL Server 2012 connection string

 <add name="myProjectConn" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ProjectDbName;Data Source=ProjectSQLSeverName"
providerName="System.Data.SqlClient" />

Could not load file or assembly 'AjaxControlToolkit, Version=3.0.30930.28736, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I am working SP 2010 custom webpart, where I am using AjaxControlToolKit dll, I have added reference. When I build I am not getting any errors, after deploying while adding web part I am getting below error.

Could not load file or assembly 'AjaxControlToolkit, Version=3.0.30930.28736, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) 

Solution:

Download 'AjaxControlToolkit
You will get dll
Now add that dll to sharepoint server gac
To use gacutil on a development machine go to:
Start -> programs -> Microsoft Visual studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt (2010)

Then use these commands to uninstall and Reinstall respectively. Note I did NOT include .dll in the uninstall command.
gacutil /u myDLL

gacutil /i "C:\Program Files\Custom\AjaxControlToolkit.dll"

SharePoint WebPart SQL Connection string

<add name="AdventureWorksConnectionString"
connectionString="Data Source=SQLServerName;Initial Catalog=DbName;Persist Security Info=True;User ID=sa;Password=Microsoft"
        providerName="System.Data.SqlClient" />

<add name="AdventureWorksConnectionString" connectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBName;Data Source=SQLServerName"
        providerName="System.Data.SqlClient" />

The following module was built either with optimization enabled or without debug information

I was trying to attach the process to my web part code, i was getting above error.
Solution:

In the Visual Studio

Click on Tools
Options
Debugging
Options

Unchecked: "Enable Just My Code"


How to find sql connection string

Create a .txt file in SQL server.Ex: a.txt
Change .txt to .udl. Ex: a.udl
Double click on a.udl
It will open a window.
Enter SQL server name
Select authontication type.
Select Database
Click Test connection

Now right click on a.udl
Click on Open With
Select notepad
Now you will get sql connection string

A web part or web form control on this page cannot be displayed or imported. the type could not


Solution:
This is common error if you eg. changed WebPart name after creation and/or changed its namespace.

Since you are working on SharePoint 2010 and most likely with Visual Studio 2010 in VS project:

Option 1
Select your custom webpart
Use right click > Properties
In properties windows under SharePoint find Safe Control Entries
Click ... button
Verify your settings (namespace)

Retract your solution and delete your web part from Web Part Gallery (this can be your first step). Rebuild, package and deploy your project.

You don't need to edit your web.config manually!
Option 2
Since i imported old web part in VS 2010, and i tried to deploy in the same Site collection...I got this error..
I renamed my new project and instead of importing old file, i copied the code and deployed...

It work like a charm..

System.InvalidOperationException: Operation is not valid due to the current state of the object


Root Cause:
Typically this happens when AJAX controls are involved (Microsoft’s UpdatePanel or others that utilize AJAX POST requests.)

Solution:

Go to this path in SharePoint server.
C:\inetpub\wwwroot\wss\VirtualDirectories\80

Open web.config
Add below tags inside <appSettings>

<add key="aspnet:MaxHttpCollectionKeys" value="2000" /">
<add key="aspnet:MaxJsonDeserializerMembers" value="2000" /">

Another important change, which i did...

I was migrating MOSS 2007 to SP 2010.
I was using old custom webpart, which is having a class file.
It is referring
public class MyCustomClassWebPart : WebPart 

I changed above line to:
public class EditFormWebPart : Microsoft.SharePoint.WebPartPages.WebPart

Still if you get same error, then don't  press F5 or Ctrl+F5 from your Visual Studio.
Right click on project -->Select Retract, 
Then right  click on project-->Select Deploy.
If you press F5 or Ctrl +F5, you will get error...

It solved my problem.


Wednesday 19 November 2014

SideLoadinf feature is not enabled on the site in SharePoint online


Error: Error occurred in deployment step 'Install app for SharePoint': Sideloading of apps is not enabled on this site.

I was trying to deploy a app in to SharePoint Online, then i got above error.

Solution: I have enabled Sideloading, then it resolved my problem.

Open: sharepoint online Management Shell

Copy below script and paste it sharepoint online Management Shell.

It will ask SPO Site url. Enter SPO url.
It will ask SPO Administrator User name and password. Enter user name and password.

You will see:
SideLoadinf feature enabled on the site.....

That's it. Now deploy your app in to SharePoint Online.

Sign in as Different User option missing in SharePoint 2013

Today i was trying to login to my SharePoint site using different user, but i couldn't find that option.
Then i came to know OOB SharePoint 2013 don't provide it.

Solution:
Follow below steps to get "Sign in as Different User" option

Go to SharePoint Server, open this path
C:\Program Files\Common Files\microsoft shared\Web ServerExtensions\15\TEMPLATE\CONTROLTEMPLATES\
Open Welcome.ascx

Search for ID = ID_RequestAcess




Paste above code above the tag ID = ID_RequestAcess

Tuesday 18 November 2014

Not connected - No connections are available Windows 8


I am not able to see wifi icon
Solution:
Open C drive
You will find Network in the left side pane
Right click on Network, select properties
You will get new window
Click on "Change adapter settings"
You will get another window.
If You are able to see Wi-Fi and if it is Disabled.
Right click on Wi-Fi Click Enable
Now you will see wi fi icon in your task bar
Click on wi fi icon, it will show Wi Fi is On or Off
If Wi FI is Off, change to On
Now you will see abailable Wi Fi connections
Select any connection Click on Connect
If it is having pass word, enter password.
Check Connect automatically
Now you ready to access wi fi

SharePoint result source with OR condition

Using GUID
path:"https://spo" SPContentType=MyList owstaxIdColumnTerm:{03b7b387-506e-4620-99ff-2d1ee315581d} owstaxIdColumnType:{e5035750-1c98-4a72-8e12-0f1ccdb4244f} owstaxIdListPageElement:{720a2f5c-52f3-482e-a359-5861a48aac5c} isActiveOWSBOOL=1 -owstaxIdColumnRegion:{USA} OR owstaxIdColumnRegion:{QueryString.region}

Using Column text
path:https://spo SPContentType=MyList owstaxIdColumnTerm:MyTerm owstaxIdColumnType:MyType owstaxIdListPageElement:MyElement isActiveOWSBOOL=1 -owstaxIdColumnRegion:{USA} OR owstaxIdColumnRegion:{QueryString.region}

SharePoint Client Object Model JavaScript

Advantage of SharePoint Client Object Model for JavaScript
Web page can interact with SharePoint without requiring a page refresh. In the background, the page uses JavaScript to communicate with SharePoint via the COM to retrieve or update data in SharePoint.
Accessing SharePoint
The first thing to note about the COM with JavaScript is that it is disconnected from SharePoint in the sense that in order to retrieve or update data in SharePoint, asynchronous calls to the server must be made. Because of its asynchronous nature, the page can continue to be responsive to the user while the data is being retrieved or updated in the background. This can be both an asset and a liability if not handled properly.
In order to access the COM in a webpage, a reference to the JavaScript file containing the COM code must be included. There are 3 JavaScript files which contain the code for the COM: SP.js, SP.Core.js, and SP.Runtime.js. SharePoint provides the SharePoint:ScriptLink server control tag for referencing JavaScript files. Using the ScriptLink control will:
assure that the JavaScript file is loaded only once
assure that dependency files are also loaded
In a SharePoint Application page, the ScriptLink tag should be declared within the PlaceHolderAdditionalPageHead Content Placeholder.

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server" />
<SharePoint:ScriptLink Name="SP.js" LoadAfterUI="true" runat="server" />
</asp:Content>

Monday 17 November 2014

Infosys PL/SQL Interview Questions

Tell me about your project
Can we load the data from table to table through utl_file package
Difference b/w sql *loader and utl_file package
Which is the faster way to load the data
Description about project?
What r the packages, functions, procedures you Developed in your project what are their Functionality?
Where u stored the files in db?
How u execute the code in sql prompt?
Tell me some names of functions and Procedures that u created in u r project?
What is the name of requirement Specification?

JSON JavaScript Object Notation

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.
It is an open standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. It is used primarily to transmit data between a server and web application, as an alternative to XML.
Ex: Create JSON Object
var objJason = {
"EmpNo" : "1001",
"Name" : "JSON",
"Dept" : "IT"
};
Ex: Read JSON Object
document.write('EmpNo ' objJason.EmpNo); // Output: EmpNo 1001
document.write('Name ' objJason.Name); // Output: Name JSON

REST is Stateless service

Advantages of Stateless service
  • Better scaling
    1. No session storage on server
    2. Any server in a cluster can handle any request
    3. All the result pages can safely be cached
  • More reliable
    1.  client can safely re-send a request
  • Better resource reuse
    1. All the result pages can safely be linked to
  • By using REST over HTTP instead of SOAP, we can drastically reduce the overhead of message processing
  • An HTTP server implementation is feasible for a mobile device

Saturday 15 November 2014

SharePoint 2013 New Features


1. My Documents — My "SkyDrive for Work"
The idea of storing personal documents in My Sites, rather than local drives, has always made sense to me: I can access my files from multiple devices as well as easily share files with teammates using links, rather than sending copies via email. Using a My Site for storing my documents also ensures that files are in a managed environment, rather than residing on intrinsically fallible local hard drives.
Despite these potential advantages, the My Site documents experience in SharePoint 2010 is clunky, overly reliant on constant availability and, more often that not, is not used.
The good news is that in SharePoint 2013 saving documents into My Sites is going to get a lot easier. In fact, it is the default location for saving documents from Office 2013. There is a single document library, not two as in SharePoint 2010, and the permissions have been simplified, making it a cinch to share documents with colleagues.
Better still, the My Site document library can be synced with a local drive to enable offline access so you can access your documents even when the server is unavailable. With this capability SharePoint 2013 My Documents can mount a strong case to be your "SkyDrive for Work."

2. App Store
In an interesting move that will at one stroke empower end users, reduce load on overworked IT operations departments and add fuel to the already active after-market for SharePoint add-ons, Microsoft is introducing an Apps Store model with SharePoint 2013.

3. Social Enterprise
Perhaps the most exciting changes in SharePoint 2013 relate to social capabilities. The list of new features is extensive: micro blogs, activity feeds, community sites, Following, Likes and Reputations are the standouts.
Of these I really like Following, which adds the ability to "follow" people, sites, documents and topics, with subsequent actions of the followed entity appearing in the user's activity stream. Keeping up to date with the activities of colleagues in SharePoint has never been easier.
As an aside, it is worth noting that the social tools market is white hot and feature advances are coming fast and furious. In this environment, Microsoft's three year product release cycle seems like an anachronism, leaving it constantly lagging behind its competitors.
The social features announced in this SharePoint 2013 preview — though representing the arrival of SharePoint a s a legitimate social platform contender — are nevertheless behind the state of the market today and this gap will only get wider by the time SharePoint 2013 is released to the market. This gap won’t matter to organizations that are committed to the SharePoint platform who will tolerate feature shortcomings in exchange for tight integration of "good enough" social capabilities into SharePoint.

4. Mobility
Clearly recognizing the massive rise in use of mobile smart devices, Microsoft has done some nice work to make it easier to access SharePoint content from a mobile device. Adding to the existing classic view, SharePoint 2013 offers two new views for mobile devices, including a contemporary view for optimized mobile browser experience and a full-screen view which enables the user to have a full desktop view of a SharePoint site on a smartphone device. These new views will be well received by smartphone users, as the existing experience, using mobile apps or the browser, is a little ordinary.

5. Site Permissions
A key selling point of SharePoint is the ability to have a distributed governance model, pushing the management of sites out to the business units. In practice though, the processes of granting or requesting access to a site in SharePoint 2010 are overly complex and a major source of confusion for site owners.
With SharePoint 2013 site owners are going to love the new, simplified sharing-based model for site permissions management. For IT help desk staff, used to spending a disproportionate amount of their time sorting out permission issues, this should come as a welcome relief.

6. Themes
The ability to have some control over the visual styling of a site is important to site owners. Everybody would like to have a site that looks great! SharePoint 2010 standard styling options are a little on the dull side. SharePoint 2013 will bring richer themes and even the ability to add a background image to the page.

7. Metro
Last, in this super 7 list is Metro, the Microsoft’s big user interface bet that’s easier to use, snazzy and well, different (in a good way)
its new, radical UI design, there is no doubt that the concept itself will be around for a while — Microsoft are planning to use Metro as the default UI for SharePoint as well as user tools like Office, Windows, Xbox and mobile devices.

Create custom view in sharepoint list

SharePoint stsadm backup restore export import

SharePoint site collection backup
--------------------------
1.On your SharePoint server hit WINDOWS + R.Type “cmd” and click OK.
2.In the cmd window navigate to the “C:\Program files\common files\microsoft shared\web server extensions\12\bin” directory.
stsadm -o backup -url -filename [-nositelock] [-overwrite]
Ex:stsadm -o backup -url http://companyweb -filename d:\companyweb.bak -overwrite
3.Press Enter
4. file is there in d drive
How restore back site
1. Create a blank site in target sharepoint
2.On your SharePoint server hit WINDOWS + R.Type “cmd” and click OK.
3.In the cmd window navigate to the “C:\Program files\common files\microsoft shared\web server extensions\12\bin” directory.
4 Type stsadm -o restore -url “http://companyweb” -filename “d:\companyweb.bak” -overwrite
5 Press Enter
Export
Stsadm –o export –url -filename .cmp
To back up an individual database, Web application, or the entire farm, you can use the following Stsadm command.
stsadm –o backup –directory -backupmethod
Restore
To import sites to your SharePoint Products and Technologies deployment, you use the following Stsadm command.
Stsadm –o import –url -filename .cmp
To restore a site collection, you must use the following Stsadm command.
stsadm –o restore –url -filename
To restore an entire farm you can use the following Stsadm command.
stsadm –o restore –directory -restoremethod

Not able to open MS Office files on SharePoint


Go to tools->
Internet options-->
Advanced -->
select "Always Send URLs as UTF-8"

Wipro PL/SQL Interview Questions

Tell me about your project
|What are the path names u provided to Execute u r coded data?
Steps to get the data from oracle to unix Environment?
Difference between having and group by
Difference between case and decode
Difference between delete and truncate
How many types of indexes
What is trigger and types
Diff b/w view and materialized view
Can we update the view
I have one table i created view and materialized view on a table if i delete a table
Can i see the view and materialized view?
Can u call function in same function
Can we use tcl commands in trigger
What is the cursor and ref cursor

Thursday 13 November 2014

C# Remove duplicates

Error occurred while configuring Search Foundation

How to open Environment variables
Open Control Panel
Search for: Environment variables
Click Edit the system Environment variables
Click on Advanced Tab
Click Environment Variables..
Click on PSModulePath
Variable Name: PSModulePath
PSModulePath should not have leading and ending white space
Variable value: valye should not have leading and ending white space

SharePoint error the context has expired and cannot be used


Solution:
Set the application pool to recycle once in 24 hours
Configure an Application Pool to Recycle at a Scheduled Time 
Steps:
Open IIS Manager
In the Connections pane, expand the server node and click Application Pools
On the Application Pools page, select an application pool, and then click Recycling in the Actions pane.
Select Specific time(s), and in the corresponding box type a time at which you want the application pool to recycle daily.For example, type 11:30 AM or 11:30 PM.
Note: The value that you enter is saved in configuration based on a 24-hour clock.
Click Next, select the events that should be logged when an application pool recycles and then click Finish.

How to find FAST server names


Ans:
Open  deployment.xml file.
C:\FASTSearch\deployment.xml 
<FASTSearchFolder>\etc\, where <FASTSearchFolder> is the path of the folder where you have installed FAST Search Server 2010 for SharePoint, for example C:\FASTSearch.
Example of deployment.xml
You can find server names from above file

Could not load the current My Site Settings SharePoint error

Solution:
I have provided the farm account full permissions on the Search Service Application, then it has resolved.

Contact your administrator for more information error SharePoint Server 2013 site

I was trying to log in my SharePoint site, i was getting above error.
Solution:
I have cleared the cookies from my Internet Explorer. Then problem solved.
How to delete cookies from Internet Explorer
Open Internet explorer.
Click on Internet Options.
You get a window.
Under General.
Click on Delete.
Select the Cookies and website data check box, and then click Delete .

Update SharePoint List Item using CSOM

Wednesday 12 November 2014

VSTF How to find build number

Open Visual Studio
Connect VSTF
Click on Builds
Actions
View My Builds
Un check: Only show builds requested by me
Now find which build number you want.
Click on that item.
Check for: SourceBuildNumber

Microsoft Test Manager integration with tfs

Assuming you have written all automation test cases using C# or Vb.Net and successfully build the code.
Provided your MTM is configured environment.

Open MTM.
Click Plan.
Create New Suite.
Click on Your Suite.
Add existing test cases to your suite.
Click Add @right side.
Write your Query to get all your test cases.
Select all TCs.
Click Add test cases.
Open each test case and click on Associated Automation (last tab).
If you are seeing blank at: Automated test name, the do bellow steps.
Open test case from VSTF:You will find "associated automation". Click on ...Search for your automation test case method and select it. Save
Save
Go to TEST mode in MTM
Set build:
Click on Build in the top right side of MTM.
Click on Modify @  Filter for builds. Change build name...
Click on Modify @ Build in use.
Select right build... Save
Click on your test suite.
Select all your test cases.
Rigt click select run with option.
Select your build, where your test case code is there
Build Config: select release
Test settings: Select browser
Environment:
Click Run

SharePoint Content Search Web Part (CSWP)


Content Search Web Part (CSWP):  This is new web part in SharePoint 2013 and SPO. It will take a query and get the results based on query.
We can create a result source (Result source: where we can write query) and select that in CSWP.

We can apply custom Item and Control template to render the data.

Normally all search output pages will expect some input, but in CSWP we can get the result with out input. Mean if you want to show List Items in a page, we can use CSWP with query as select My list items.
So CSWP will get all list items, with out writing any code..we can all filtering for query.

We can use custom display templates (Item/ control template) to show custom rendering.

How to add a Content Search Web Part to a page:

Go to SharePoint site, open any page. Click Edit page.
In the Web Part Zone where you want to add the Web Part, click Add a Web Part.
In the Categories list, click Content Rollup.
In the Parts list, click Content Search, and then click Add.
The CSWP contains a default query, so it already displays some content.
Note: To get our content, we'll need to configure the query in the Web Part.

How to configure a query in a Content Search Web Part on a category page

In the Web Part, click the Web Part Menu , and then click Edit Web Part.
In the Web Part tool pane, click Change query. This will open a dialog box.
Now you can play and try with different query to get your data.

If you want to change the display templates.
Under "Display Templates"
Change "Control" and "Item" dropdowns..You will see some out of box templates...
You can add custom templates also..

Carousel image and Message using jQuery and bootstrap

Download bootstrap css and js files and jquery file.

How to find Solution files in SharePoint

Open Wen Site.
Site Actions
Site Settings
Galleries
Click on "Solutions"
You can find Deployed solution in that Web site.

Infopath date time - today() vs now()

Difference between today() vs now()
today() and now() can both be used to set the default value of a date picker. However, the type of form you have can affect which one you use.
- Use today() when you have a date-only field.
- Use now() when your field requires a date and time.
In general, when using a SharePoint list form, use now(). When using a form library or filler-only form, use today(), unless you have changed the data format of the date field to date and time.

K2 BlackPearl Read Process Data From XML

Polaris Sharepoint Interview

• What is Office 365 , SharePoint online?
• How does  SharePoint online actually work?
• What is the use of SQL server in SharePoint & use of Virtual path provider?
• What is Ghosting and UnGhosting in SharePoint?
• How can we create a site in SharePoint online?
• How can we Customize a SharePoint Site?
• What kind of ready made functional modules exists collaboration?
• Can you display a simple Custom Page in SharePoint?
• How can we implement behind code ASPX pages in SharePoint?
• What is the concept of features in SharePoint?
• I want a feature to be only displayed to admin?
• How do we debug SharePoint error’s?
• Why customized pages are parsed using no-compile mode?
• Can you explain SPO model?
• How can we use custom controls in SharePoint?
• How can we display ASCX control in SharePoint pages?
• What is WebPart and App Part?
• How can we achieve customization and personalization using App Part?

Tuesday 11 November 2014

What is the difference between method activity and event activity in Workflow

A method activity is one that performs an action, such as creating or updating a task. An event activity is one that runs in response to an action occurring.

TCS informatica Interview

What are the scheduling options to run a session
Can you start a batches with in a batch?
Can you start a session inside a batch individually?
what is inline view?
checkout and check in in informatica 8.6
how did u understand business requirement?
How do you configure mapping in informatica?
How to Join Tables my Source is having 15 table target is one?
How many types of dimensions are available in Informatica?
What is the difference between stop and abort?
How can you recognize whether or not the newly added rows in the source are gets insert in the target?
What is the difference between Informatica 7.0 and 8.0 ?
Performance tuning in Informatica?

"New" ribbon icon disabled in SharePoint central admin

Solution:
Start-->All Programs-->Select IE--> Right Click on IE-->Select Run as Administrator

How to show infoptah form new item request in the home page.

Open SP2013 home page
Click Edit the page
Add webpart
Select Infopath form webpart from form category
Add
Configure the webpart
Select the Source list
Ok.
Now you will see infopath form in the home page.

SharePoint Site Backup and Restore

Backup the site using the following STSADM Command:
Stsadm –o backup –url http://: -filename

Example:
Stsadm –o backup –url http://vanillargk:5555 –filename "e:\backup5555.bak"
Create a new Web Application for restoring the site:
Go to Central Administration -> Application Management -> under SharePoint Web Application Management -> click Create or Extend Web Application. Fill in the required information, click Ok and wait until the progress continues.
Once the new web application is created, run the following STSADM command and restore the site using the backup file created above.
Stsadm –o restore –url http://: -filename
Stsadm –o restore –url http://vanillargk:6666 –filename "e:\backup5555.bak"
Restored site should be up and running.
If it is not (and you are receiving weird errors in your browser), keep reading:
Now it could be the case that you have customized your site. So, we must deploy those customizations properly for the site to work as expected. This is typically a scenario while moving your site from Testing to Production environment. First you have to add the solutions (if any created) to the farm.
Add a Solution to the SharePoint Farm:
Add the solution package to the farm by running the following commands. Make sure full path of WSP file is supplied.
stsadm –o addsolution –filename
Deploy the Solution to the restored site:
stsadm -o deploysolution -name mysolution.internet.test.wsp -url -immediate -allowgacdeployment –allowcaspolicies
Make sure all your assemblies (DLLs) are available in Global Assembly Cache (GAC) usually placed at c:\windows\assembly.
Activate features installed by mysolution.internet.test.wsp solution package:


Backup and restore will not work for sub sites.
Import and export will not work for workflows. It will work for sub sites and site collection also.

Get User Email from Active Directory

SharePoint Client Object Model Javascript : JSOM to retrieve an item based on its ID

var item;
Function getItemById(itemId)
{
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var list = web.get_lists().getByTitle('mycustomList');
This.item = list.getItemById(itemId);
clientContext.load(item);
clientContext.executeQueryASync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFailure);
}
Function onSuccess()
{
Alert('Success');
}
Function onFailure()
{
Alert('Failure!');
}

Can i make my web front end server as a Crawl server in Sharepoint

Can i make my web front end server as Crawl server.
Ans) It's not suggestable.
Reason:
The reason for a crawl target is to limit the user impact of the Search Crawl on your Production farm. Crawling will hammer your Front End servers due to massive amount of requests for content. If you set up a crawl target (dedicate a box directly for search crawls) then users will be not impacted by your heavy performance crawl in-progress
How to stop Crawl in WFE.
Disable HTTP throttling on the crawl target so no crawl requests will be queued or delayed on the Front End machine. Open up a SharePoint Management Console (PowerShell) and run this script
$svc=[Microsoft.SharePoint.Administration.SPWebServiceInstance]::LocalContent
$svc.DisableLocalHttpThrottling
$svc.DisableLocalHttpThrottling=$true
$svc.Update()
How to setup a dedicated Crawl Server.
To set the farm to distribute crawl traffic to only the Front End that is specified as your crawl target, in this example : Server1 is my crawl target and http://sharepoint is my farm name. Run this in the same or seperate instance of PowerShell.
$env:farmurl = "http://sharepoint"
$env:crawltarget = "server1"
$listOfUri = new-object System.Collections.Generic.List[System.Uri](1)
$zoneUrl = [Microsoft.SharePoint.Administration.SPUrlZone]'Default'
$webappUrl = $env:farmurl
$webapp = Get-SPWebApplication -Identity $webappUrl
$webApp.SiteDataServers.Remove($zoneUrl)
$listOfUri.Add("http://$env:crawltarget");
$webApp.SiteDataServers.Add($zoneUrl, $listOfUri);
$WebApp.Update()
You have successfully setup your crawl target, now your Search crawls can perform with high performance without impacting users on your farm.

SharePoint Add Query Rules for promoted results

Create a result source. Ex: MySearchResult
Add Query Rules for promoted results
Open SPO site. The site where your search page is configured.
Click on Site Settings
Click on Query Rules

Click on “Select Result Source…”

Select: MySearchResult
Click on “New Query Rule “


In the new window, Enter Rule name.
Click on “Add Promoted Result

You will see new window. Add some data.

Repeat Click on “Add Promoted Result” and add some data.

After adding promoted results, page will looks like this.


Why we need to create Named Query in SSAS instead of using Normal View


In Actual Development, You will not have any permission in Database (Client Database), so you can not create View in Database.
So we can do only using Named query from Data Source Views and named query will not be available in Actual Database. It will be available in Data Source Views level

How to restart IIS


Click Start.
Click Run
Type IISReset
ok
Or
Open IIS.
How to open IIS
Click Start.
Click Run
Type inetmgr
In IIS Manager, right click the local computer, point to All Tasks, then click Restart IIS.
Or
1. From the Start menu, click Run.
2. In the Open box, type cmd, and click OK.
3. At the command prompt, type iisreset /stop. IIS will attempt to stop all services and will return confirmation once all services have been stopped.
4. At the command prompt, type iisreset /start.

How to hide Web Part Headers in SharePoint

1. Add a content editor web part to your page.
2. Edit the Web Part
3. Click in the content area of the web part, click HTML and select “Edit HTML Source”
4. Put the following code in the web part:
Add below code in the style tag
TR.ms-viewheadertr > TH.ms-vh2 {
DISPLAY: none
}

5. Click “OK”
6. Expand “Appearance” (on the right side of the page)
7. Set the chrome type to “None”
8. Click “OK” and then save and check in your page.
The headers of your web part should now be hidden. This can be extremely helpful when your page contains a web part using “boxed” for your style when creating a list view. The only downside to this approach is if you have multiple web parts on a single page, it will hide the headers for all the web parts on your site.
Hide Web Part Headers with SharePointHide Web Part Headers with SharePointHide Web Part Headers with SharePointHide Web Part Headers with SharePointHide Web Part Headers with SharePointHide Web Part Headers with SharePoint

Monday 10 November 2014

What is Site and Site Collection in SharePoint

What is Site
Site is a collection of web pages which is used to store information in organized way.
Site stores list of documents, discussion, events, task and many other types of information.
Site provides controlled access to share information among user. i.e. Only Authorize users are allowed to access shared information.
What is Site Collection
Site Collection is collection of SharePoint site. i.e. SharePoint site collection is logical grouping of multiple SharePoint site.

Microsoft Windows

\\SystemName\ c$ To access C drive
\\SystemName\ d$ To access D drive
\\SystemName\ e$ To access E drive
==========================================
Services
--------
MOSS 2007
Windows SharePoint Services Administration
Windows SharePoint Services Search
Windows SharePoint Services VSS Writer
SQL
SQL Server Browser
SQL Server (MSSQLSERVER)
==========================================
ildasm.exe
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin
machine.config
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG
aspnet_regsql.exe
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
==========================================
Sharepoint Log
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS
====================================================================================
MSTSC
Login as Admin and Kill other user accounts
mstsc -v:SERVER /f -admin
====================================================================================
Managing event logs from the command line
Run-->eventvwr.exe
or
Start-->control panel-->Administrative Tools-->Event Viewer
====================================================================================
Service
Run-->services.msc
Or
Start-->control panel-->Administrative Tools-->Services

Add user custom action to Site Actions menu using Client Object Model


C# Get Set Properties

Sharepoint Custom Workflow

// Method used to get the SharePoint List that the workflow is attached to and the list item that we are working on
private void getTaskListInformation()
{
// Get the Task List that we are attached to, by converting the Guid Parameter into a Guid
this._TaskListAttachedTo = this._myTeamSite.Lists[new Guid(this._paramSPListGuid)];
// Get the Task Item Object that the workflow has created
this._TaskListItem = this._TaskListAttachedTo.GetItemById(System.Convert.ToInt16(this._paramTaskListItemID));
string[] passedLink = _TaskListItem["Link"].ToString().Split(',');
listID = Convert.ToInt32(passedLink[0].Split('=')[1]); // Get the application request ID.
// Get the ID of the Workflow Instance that we are running with in
this._workflowInstanceGuid = new Guid(Convert.ToString(this._TaskListItem["WorkflowInstanceID"]));
// Instantiate the workflow
this._activeWorkflow = new SPWorkflow(this._TaskListItem, this._workflowInstanceGuid);
}
=============================
private void getTaskListInformationByListItem()
{
listID = Convert.ToInt32(Request.Params["ID"]);
SPSite site = SPContext.Current.Site;
using (SPWeb web = site.OpenWeb())
{
SPList JobRequest = this._myTeamSite.Lists["Request"];
SPListItem JobRequestItem = null;
if (listID > 0)
{
JobRequestItem = JobRequest.GetItemById(listID);
}
if (JobRequestItem != null)
{
SPListItemCollection taskListItems = JobRequestItem.Workflows[0].TaskList.Items;
foreach (SPListItem item in taskListItems)
{
string[] passedLink = item["Link"].ToString().Split(',');
if (Convert.ToString(item["Status"]) == "Not Started") // Get the Application request ID.
{
// Get the Task List that we are attached to, by converting the Guid Parameter into a Guid
this._TaskListAttachedTo = this._myTeamSite.Lists["Tasks"];
// Get the Task Item Object that the workflow has created
this._TaskListItem = this._TaskListAttachedTo.GetItemById(item.ID);
// Get the ID of the Workflow Instance that we are running with in
this._workflowInstanceGuid = new Guid(Convert.ToString(this._TaskListItem["WorkflowInstanceID"]));
// Instantiate the workflow
this._activeWorkflow = new SPWorkflow(this._TaskListItem, this._workflowInstanceGuid);
}
}
}
}
}
==================================================================
// Code that responds to the Reject Button Click event.
protected void btnReject_Click(object sender, EventArgs e)
{
if (isValid())
{
Hashtable taskHash = new Hashtable(); // Task data is sent via a Hash Table
taskHash["_ApporvalStatus"] = false;
taskHash["Status"] = "Complete";
taskHash["PercentComplete"] = "0";
taskHash["Action"] = "Rejected";
SPSite site = SPContext.Current.Site;
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWorkflowTask.AlterTask(this._TaskListItem, taskHash, true); // Send the data to the task list, by altering the tasks value
});
web.AllowUnsafeUpdates = false;
}
string strRequestorRole = this._TaskListItem.Title;
UpdateAuditTrail("Rejected", strRequestorRole.Replace(" Task", ""));
SPUtility.Redirect(this._TaskListAttachedTo.DefaultViewUrl, // Redirect the UI back to the Task List. You could chose
SPRedirectFlags.UseSource,
HttpContext.Current);
}
}
==============================================================================
// Code that responds to the Cancel Button Click event.
protected void btnCancel_Click(object sender, EventArgs e)
{
// If the user cancels out on the Workflow Task Edit Form, we'll take them back to the Document Library
if (this._TaskListAttachedTo == null)
{
SPUtility.Redirect(this._myTeamSite.Url,
SPRedirectFlags.UseSource,
HttpContext.Current);
}
else
{
SPUtility.Redirect(this._TaskListAttachedTo.DefaultViewUrl,
SPRedirectFlags.UseSource,
HttpContext.Current);
}
}
=========================================================================
// Code that responds to the Accept Button Click event.
protected void btnAccept_Click(object sender, EventArgs e)
{
SPSite site = SPContext.Current.Site;
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
int statusID = GetLookupId("Accepted", "Title", "JobRequestStatus");
SPList JobRequestListItems = web.Lists["Request"];
SPListItem requestItem = JobRequestListItems.GetItemById(listID);
requestItem["Status"] = new SPFieldLookupValue(statusID, "Accepted");
requestItem["Scheduler"] = Request.ServerVariables["LOGON_USER"].ToString();
requestItem.Update();
web.AllowUnsafeUpdates = false;
}
// If the user cancels out on the Workflow Task Edit Form, we'll take them back to the Document Library
SPUtility.Redirect(this._TaskListAttachedTo.DefaultViewUrl,
SPRedirectFlags.UseSource,
HttpContext.Current);
}

issue while installation K2 Blackpearl

If you are getting any issue while installation if you get any issue please check whether below things are installed or not.
SharePoint Server 2007 SP2 64bit (one server - Windows Server 2003 R2 SP2 64bit)
SQL Server 2005 SP2 32bit (one server - Windows Server 2003 SP2 32bit)
1.All necessary additional software and windows components are installed
Ex: com+, MSMQ, MS Redist, DTC installed and configured
2.Kerberos is activated for the SharePoint Portal Web Application
3.DNS entries, host header and SPNs are set correctly (no duplicate entries)
4.Permissions for k2 service accounts are set correctly (farm admin, site collection admin, sql admin)

Coding Standards

Namespaces:
Remove the unused namespaces and separate the Asp.Net framework namespaces with third party or other frame work spaces as below.
This makes the identification of namespaces at first look itself.
Always use Response. Redirect with false as its second parameter value
Response.Redirect("Response.aspx?ErrorID=1000",false);
Conditions Format
if (!(Session["FullName"] == null))
Use the below format for better readability
if (Session["FullName"] != null)
String Conversion not required on control’s text values
if (!string.IsNullOrEmpty(txtComment.Text.ToString().Trim()))
{
}
txtComment.Text itslef will return the string value and again don’t need to convert that value using ToString() method this looks odd, pleease remove this.
Use Page.IsValid property under submit/resubmit event handlers
if (Page.IsValid)
{
//Show some message to the user saying the validations are not met on page/ show validation summary control
return;
}
This helps avoiding the unexpected behavior of pages when validations are not firing because of JavaScript errors.
Add sub functions for main functions
If possible try to reduce the no’ of lines of code for each function by diving the functionality into sub functions (common logic).
Exception rising
catch (Exception ex)
{
//objCommonMethods.GenericExceptionMethod(ex);
spnErrorMsg.Visible = true;
objCommonMethods.DisplayMessage(this.spnErrorMsg, "Error", "Error Occured While Page Loading.");
}
Here we are not sowing the actual exception; this will not help in trouble shooting the issues in production. So please add the inner exception message to the display message.
catch (Exception ex)
{
//objCommonMethods.GenericExceptionMethod(ex);
spnErrorMsg.Visible = true;
objCommonMethods.DisplayMessage(this.spnErrorMsg, "Error", "Error Occured While Page Loading." + ”
” ex.Message +”
” + ex.StackTrace);
}
ex.StackTrace will give us the line number of code which is throwing the exception.
When throwing exception use the below format:
catch (Exception ex)
{
// throw ex;
throw new Exception("Exception in GetApprovers method", ex);
}
Use StringBuilder over strings when string concatenation is required more than 2 levels:
Use length condition before using string remove methods ***
Remove web related and unused namespaces in class files.
For string comparison use string.Compare()
With comparison method:
if (string.Compare(CompairFile.Trim(),InFile.Trim(),false) == 0)
{
file.Delete();
break;
}
Remove the commented code in all the files
Use count condition check before using a list enumeration in foreach loop
Ex:
foreach (DataRow drRole in dsApprovers.Tables[0].Rows)
{}
If the dsApprovers.Tables[0] doesn’t have any rows, it throws an exception.
Please check the for the same in other places.
Use DataTables over Datasets
For functions we are using Dataset in many places, but I think it will make sense when we use Data Table directly. Usually we use Dataset when we fill multi table’s data with relation. In our case we are nowhere storing multiple tables into Dataset. So using Data Tables is suggestible.
Move all the connection strings and constant values those are coming form web.config file can be moved to CommonConstantVariables class and can be made them static properties
Make Page level viewstate and session false for static pages like Response.aspx, confirmation.aspx and Unauthorized.aspx. This helps the pages load faster.
Example:

SharePoint Apply Branding using Feature


Apply Branding using Feature

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
Add a class
public class ApplyBranding : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = (SPWeb)properties.Feature.Parent;
using (SPSite site = new SPSite(web.Url))
{
using (SPWeb rootWeb = site.RootWeb)
{
string serverRelativeUrl = rootWeb.ServerRelativeUrl;
string masterUrl = getPropertyFrom(properties, "MasterUrl");
string customMasterUrl = getPropertyFrom(properties, "CustomMasterUrl");
string alternateCssUrl = getPropertyFrom(properties, "AlternateCssUrl");
string siteLogoUrl = getPropertyFrom(properties, "SiteLogoUrl");
string theme = getPropertyFrom(properties, "Theme");
bool isMySite = getPropertyFrom(properties, "IsMySite").Equals("TRUE", StringComparison.InvariantCultureIgnoreCase);
if (serverRelativeUrl != "/" && !isMySite)
{
masterUrl = mergeUrls(serverRelativeUrl, masterUrl);
customMasterUrl = mergeUrls(serverRelativeUrl, customMasterUrl);
alternateCssUrl = mergeUrls(serverRelativeUrl, alternateCssUrl);
}
saveOldBranding(web);
applyBranding(web, masterUrl, customMasterUrl, alternateCssUrl, siteLogoUrl, theme, isMySite);
}
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWeb web = (SPWeb)properties.Feature.Parent;
bool isMySite = getPropertyFrom(properties, "IsMySite").Equals("TRUE", StringComparison.InvariantCultureIgnoreCase);
if (!isMySite)
{
resetBranding(web);
}
else
{
string masterUrl = "default.master";
string customMasterUrl = "default.master";
string alternateCssUrl = "";
string siteLogoUrl = "";
string theme = "";
web.Properties.Update();
applyBranding(web, masterUrl, customMasterUrl, alternateCssUrl, siteLogoUrl, theme, isMySite);
}
}
public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{ }
public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{
SPWeb web = (SPWeb)properties.Feature.Parent;
string masterUrl = removeFromwebProperties(web, "BrightstarrBrandingMasterPageUrl");
string customMasterUrl = removeFromwebProperties(web, "BrightstarrBrandingCustomMasterUrl");
string alternateCssUrl = removeFromwebProperties(web, "BrightstarrBrandingAlternateCssUrl");
string siteLogoUrl = removeFromwebProperties(web, "BrightstarrBrandingSiteLogoUrl");
string theme = removeFromwebProperties(web, "BrightstarrBrandingTheme");
web.Properties.Update();
web.Update();
}
private string getPropertyFrom(SPFeatureReceiverProperties properties, string key)
{
string propertyValue = string.Empty;
try
{
propertyValue = properties.Feature.Definition.Properties[key].Value;
}
catch
{ }
return propertyValue;
}
private void saveOldBranding(SPWeb web)
{
saveToWebProperties(web, "BrightstarrBrandingMasterPageUrl", web.MasterUrl);
saveToWebProperties(web, "BrightstarrBrandingCustomMasterUrl", web.CustomMasterUrl);
saveToWebProperties(web, "BrightstarrBrandingAlternateCssUrl", web.AlternateCssUrl);
saveToWebProperties(web, "BrightstarrBrandingSiteLogoUrl", web.SiteLogoUrl);
saveToWebProperties(web, "BrightstarrBrandingTheme", web.Theme);
web.Properties.Update();
}
private void saveToWebProperties(SPWeb web, string key, string value)
{
saveToWebProperties(web, key, value, false);
}
private void saveToWebProperties(SPWeb web, string key, string value, bool update)
{
if (!web.Properties.ContainsKey(key))
web.Properties.Add(key, value);
if (update)
web.Properties.Update();
}
private void applyBranding(SPWeb web, string masterPageUrl, string customMasterUrl, string alternateCssUrl, string siteLogoUrl, string theme)
{
applyBranding(web, masterPageUrl, customMasterUrl, alternateCssUrl, siteLogoUrl, theme, false);
}
private void
applyBranding(SPWeb web, string masterPageUrl, string customMasterUrl, string alternateCssUrl, string siteLogoUrl, string theme, bool isMySite)
{
if (!string.IsNullOrEmpty(masterPageUrl))
{
if (isMySite)
{
if (web.MasterUrl.Contains("default.master"))
{
web.MasterUrl = web.MasterUrl.Replace("default.master", masterPageUrl);
}
else
{
web.MasterUrl = web.MasterUrl.Replace(masterPageUrl, "default.master");
}
}
else
web.MasterUrl = masterPageUrl;
}
if (!string.IsNullOrEmpty(customMasterUrl))
{
if (isMySite)
{
if (web.CustomMasterUrl.Contains("default.master"))
{
web.CustomMasterUrl = web.CustomMasterUrl.Replace("default.master", customMasterUrl);
}
else
{
web.CustomMasterUrl = web.CustomMasterUrl.Replace(customMasterUrl, "default.master");
}
}
else
web.CustomMasterUrl = customMasterUrl;
}
web.AlternateCssUrl = alternateCssUrl;
web.SiteLogoUrl = siteLogoUrl;
web.ApplyTheme(theme);
web.Update();
}
private void resetBranding(SPWeb web)
{
string masterUrl = fetchFromwebProperties(web, "BrightstarrBrandingMasterPageUrl");
string customMasterUrl = fetchFromwebProperties(web, "BrightstarrBrandingCustomMasterUrl");
string alternateCssUrl = fetchFromwebProperties(web, "BrightstarrBrandingAlternateCssUrl");
string siteLogoUrl = fetchFromwebProperties(web, "BrightstarrBrandingSiteLogoUrl");
string theme = fetchFromwebProperties(web, "BrightstarrBrandingTheme");
applyBranding(web, masterUrl, customMasterUrl, alternateCssUrl, siteLogoUrl, theme);
}
private string removeFromwebProperties(SPWeb web, string key)
{
return removeFromwebProperties(web, key, false);
}
private string removeFromwebProperties(SPWeb web, string key, bool update)
{
string returnValue = string.Empty;
if (web.Properties.ContainsKey(key))
{
returnValue = web.Properties[key];
web.Properties.Remove(key);
}
if (update)
web.Update();
return returnValue;
}
private string fetchFromwebProperties(SPWeb web, string key)
{
string returnValue = string.Empty;
if (web.Properties.ContainsKey(key))
{
returnValue = web.Properties[key];
}
return returnValue;
}
private string mergeUrls(string serverUrl, string relativeUrl)
{
string returnUrl = serverUrl;
if (!serverUrl.EndsWith("/"))
returnUrl = serverUrl + "/";
if (relativeUrl.Length > 1)
{
if (relativeUrl.StartsWith("/"))
relativeUrl = relativeUrl.Substring(1);
returnUrl = returnUrl + relativeUrl;
}
return returnUrl;
}
}