Tuesday 25 February 2014

Calendar Overlay in SharePoint 2013

  • Using Calendar overlay, we can see other calendar events or project tasks overlaid onto the first calendar view with a different color.
  •  Using this option we can see sub site’s calendar or Task List events on the main Calendar and the main Calendar or Task List events on the sub site’s calendar with a different color.
  • Using this option we can also see external site’s calendar events and Exchange web services of calendar events.

Refer below Screen Shots









Wednesday 19 February 2014

12 reasons to maintain folders in SharePoint are a bad idea

1. Usability. Nested folder structure is only known to the person who created it. Also, too many sub-folders tend to “hide” things.
2. URL length limitation. SharePoint adds all folder and sub-folder names to URL. Overall URL length is limited to around 260 characters. You are out of luck if you create too many sub-folders.
3. File URL. Moving file from one folder to another means change of file URL.
4. Security. Maintaining Security by folders in SharePoint is an administrative nightmare. Don’t even think about doing it!
5. User experience. User Experience (navigation, finding the documents) just stinks with folders (it is so 1990’s!)
6. File duplication. With folders you can deposit multiple copies of same file into different locations – not a good thing when you try to organize documents and data in the first place!
7. 1 Lonely View. There is another reason NOT to user folders. With folders, you get one view: the folder view. Using metadata, you can create unlimited number of views by whatever properties you have setup (i.e. organize documents by date, by customer, by project, etc.) So the document browsing experience is much better-off.
8. Can’t Sort & Filter. Since your files are buried in the folders, you can’t really benefit from sorting and filtering capabilities of document library headers (unless of course you are just sorting and filtering in the particular folder).
9. Change is hard.  It’s hard to change folder structure, while changing metadata is easy.
10. Lost documents. You can “lose” documents when placed in the wrong folder. Additionally, Also, too many sub-folders tend to hide things, making it impossible or too time-consuming for users to find a particular document.
11. Navigation. When you are in a particular sub-folder, there is no way to tell in which folder you are at any given time, and no easy way to navigate to the parent folder (there is no breadcrumb on folder navigation menu available)
12. Cost. If you are essentially recreating nested folders you had on file share, by using SharePoint, you have got yourself one expensive file share. Why not stay with folders on shared drive? Or go with the DropBox account?
So that is my list. Do you have any other ones that you think should be added? Will be happy to discuss this topic further via email or on Social Media. Email me at dvsivakrishna@gmail.com

The Top 5 Best Practices for Document Management in SharePoint

I get lots of questions on social media regarding best practices for SharePoint document management for the users. The truth of the matter is, there definitely are best practices I can share, however, they are not applicable for end users per se. In reality, users have little control over the document library – usually most have “Contribute” access, which means they can’t do much other than upload/edit docs and use whatever solution has been delivered to them by SharePoint Administrators or Site Owners.
With that being said, I would like to share what I think are the top five best practices for SharePoint document management. I expect my audience to be those who setup sites and have admin control over the site/document library. If you do not have it – it might be useful to discuss below ideas with your administrator as some might really help you improve usability and satisfaction of your document repository. So here it goes:

1. Use Meta tags/Data Columns to tag documents, rather than recreating network drive folders

Stuffing documents in folders is such an old school. Meta tags are the way to go. Not convinced? 
 I led and participated in several SharePoint implementations over the recent years and the number one organizational need I see is document management (file storage, sharing). I believe SharePoint is a superior tool for document management. Yet, it strikes me every time I see people replicating folder structures they used to have on their computers or shared drives.
I will be blunt about it and I know some will disagree with my opinion, but using folders in SharePoint is a really poor practice. The first question I want to ask pro-folder users is why users switched to SharePoint in the first place. If you are using folders in SharePoint, you have one very expensive network drive to administer, maintain and pay licensing fees for!
Here are some of the reasons not to use folders in SharePoint (the list is extensive, I just chose some of the critical ones):
  • Impact to search capability when files are hidden in nested folders. You are essentially recreating nested folders you had on network drives
  • URL length limitation. Folders increase URL length, which is limited to 255 characters. You are out of luck at that point
  • Security at folder level is a nightmare. Don’t even think about doing it
  • User experience (navigation, finding documents) just stinks with folders
  • File duplication – with folders you can deposit multiple copies of same file – not a good thing when you try to organize documents and data in the first place
So what’s the best practice to store documents in SharePoint? The answer is simple – by tagging them with document properties (columns of Meta Data in SharePoint terms) you can create ahead of migration.
In the next blog post I will expand on this topic and share tips and tricks on how to setup your structure and meta tagging for your next folder-less library.

2. Use Content types for dynamic meta tagging

Go one step further and take advantage of Content Type functionality. It allows you to set dynamic properties/meta tags depending on the document you upload (i.e. if you are uploading Meeting Minutes from last project meeting – you might want to tag them differently comparing to, say, PowerPoint presentation you received from last week’s vendor presentation.

3. Setup an alert for a document library

Do you have hard time falling asleep at night because you think someone will delete the file you uploaded to SharePoint? Or may be you are just a control freak? Then an alert will put your worries aside. Alerts can be configured at a library and document level and will notify the user if files in the library have been deleted or changed by someone else. Alert can be setup by any user, even those without admin rights.

4. Use Version Control/Check-out features only if users require it

Versioning and document check-in is cool, but do you really need it? Yes, versioning allows you to restore previous versions of the document and check-out feature prevents from accidentally modifying same doc by 2 people at same time, but does Business actually need it? The features demand strict adherence and discipline (i.e. same file names) within organization. Unless you are using document repository as records management tool, you might want to think twice about this. If all your users need is some place to store files, you can easily get away from additional frustration.

5. Create Views, many views!

Once you setup your Meta tags, you can do wonders with views! Create all sorts of views (make sure to make them public) and use filter/sort/group function to display what you want. Views can also help manage space on a page. If you have lots of lists and libraries on a page and want to fit it all, make sure to use “simplified’ view with just few columns to capture “important” data. Users can then use rest of views to display other pieces of information.
Do you have other best practices you would like to share? Will be glad to hear from you!

Tuesday 11 February 2014

Configure SharePoint Server 2013 in a Three-Tier Farm

overview

In SharePoint Server 2013 functionality in a three-tier farm is deployed by using the following:

  • One computer running Windows® Server® 2008 R2 Enterprise Edition with Service Pack 1 named DC1 that is configured as an intranet domain controller, Domain Name System (DNS) server, DHCP server, and enterprise root certification authority (CA).
  • One intranet member server running Windows Server 2008 R2 Enterprise Edition with Service Pack 1 named SQL1 that is configured as a SQL database server.
  • One intranet member server running Windows Server 2008 R2 Enterprise Edition with Service Pack 1 named APP1 that is configured as the SharePoint Server 2013 application server.
  • One intranet member server running Windows Server 2008 R2 Enterprise Edition with Service Pack 1 named WFE1 that is configured as the SharePoint front-end web server.
  • One member client computer running Windows 7 Enterprise or Ultimate named CLIENT1.

The SharePoint Server 2013 consists of a single subnet named Corpnet (10.0.0.0/24) that simulates a private intranet. Computers on the Corpnet subnet connect by using a hub or switch. See the following figure.

Hardware and software requirements

The following are required components:

If the computers are being hosted in a Hyper-V-based virtualized environment, see the following topics for more information:

Steps for Configuring the SharePoint Server 2013 Three-Tier Test Lab
There are seven steps to follow when setting up the SharePoint Server 2013 three-tier test lab.

  1. Set up the Base Configuration test lab.
  2. Install and configure a new server named SQL1.
  3. Install SQL Server 2012 on SQL1.
  4. Install SharePoint Server 2013 on APP1.
  5. Install and configure a new server named WFE1.
  6. Install SharePoint Server 2013 on WFE1.
  7. Demonstrate the facilities of the default Contoso team site.

Note

You must be logged on as a member of the Domain Admins group or a member of the Administrators group on each computer to complete the tasks described in this guide. If you cannot complete a task while you are logged on with an account that is a member of the Administrators group, try performing the task while you are logged on with an account that is a member of the Domain Admins group.

The following sections provide details about how to perform these steps.

Step 1: Set up the Base Configuration

Set up the Base Configuration test lab for the Corpnet subnet using the procedures in the “Steps for Configuring the Corpnet Subnet” section of the Base Configuration.
When you install and configure the servers in the base configuration test lab, Windows Server 2008 R2 Service Pack 1 is installed.

Step 2: Install and configure a new server named SQL1

In this procedure, you install the Windows Server 2008 R2 operating system and the latest updates on a new server named SQL1.

To install Windows Server 2008 R2 on SQL1

  1. Start the installation of Windows Server 2008 R2.
  2. Follow the instructions to complete the installation, specifying Windows Server 2008 R2 Enterprise Edition (full installation), the computer name SQL1, and a strong password for the local Administrator account.
  3. Once the installation completes, log on using the local Administrator account.
  4. Connect SQL1 to a network that has Internet access and run Windows Update to install the latest updates for Windows Server 2008 R2, including Windows Server 2008 R2 Service Pack 1.
  5. Once the updates are complete, restart SQL1 and log on as the local Administrator.
  6. Connect SQL1 to the Corpnet subnet.

In this procedure, you configure the TCP/IP properties on SQL1 so that it can join the corp.contoso.com domain.

To configure the TCP/IP properties on SQL1


  1. In Initial Configuration Tasks, click Configure networking.
  2. In the Network Connections window, right-click Local Area Connection, and then click Properties.
  3. Click Internet Protocol Version 4 (TCP/IPv4), and then click Properties.
  4. Select Use the following IP address. In IP address, type 10.0.0.4. In Subnet mask, type 255.255.255.0. In Default Gateway, type 10.0.0.1. In Preferred DNS server, type 10.0.0.1.
  5. Click Advanced, and then click the DNS tab. In DNS suffix for this connection, type corp.contoso.com, click OK twice, and then click Close.
  6. Close the Network Connections window and leave the Initial Configuration Tasks window open.
  7. To check name resolution and network communication between SQL1 and DC1, click Start, click All Programs, click Accessories, and then click Command Prompt.
  8. In the Command Prompt window, type ping dc1.corp.contoso.com.
  9. Verify that there are four replies from 10.0.0.1.
  10. Close the Command Prompt window.

In this procedure, you join SQL1 to the corp.contoso.com domain.

To join SQL1 to the corp.contoso.com domain


  1. In Initial Configuration Tasks, click Provide Computer Name and Domain.
  2. In the System Properties dialog box, on the Computer Name tab, click Change.
  3. In Member of, click Domain, type corp.contoso.com, and then click OK.
  4. When you are prompted for a user name and password, type User1 and its password, and then click OK.
  5. When you see a dialog box welcoming you to the corp.contoso.com domain, click OK.
  6. When you are prompted that you must restart the computer, click OK.
  7. On the System Properties dialog box, click Close.
  8. When you are prompted to restart the computer, click Restart Now.
  9. After the computer restarts, click Switch User, and then click Other User and log on to the CORP domain with the User1 account.
  10. In Initial Configuration Tasks, click Do not show this window at logon, and then click Close.

Step 3: Install SQL Server 2012 on SLQ1

Install and configure SQL Server 2012 on SQL1 as described in Steps 2, 3, and 4 of the SQL Server 2012, substituting SQL1 for APP1 in the instructions.

Alternately, you can use SQL Server 2008 R2. In this case, install and configure SQL Server 2008 R2 on SQL1, as described in Steps 2, 3, and 4 of the SQL Server 2008 R2, substituting SQL1 for APP1 in the instructions.

Note

If you are building out the Business Intelligence, you must install SQL Server 2012 on SQL1. You cannot use SQL Server 2008 R2 on SQL1.
In this procedure, you configure the inbound rule in Windows Firewall with Advanced Security to allow incoming traffic to the SQL Server service.

To configure the Windows Firewall for an inbound rule

  1. On SQL1, log on using the User1 user account.
  2. From the desktop, click Start, point to Administrative Tools, and then click Windows Firewall with Advanced Security.
  3. In the tree pane, click Inbound Rules, right-click Inbound Rules, and then click New Rule.
  4. On the Rule Type page, click Port, and then click Next.
  5. On the Protocols and Ports page, type 1433-1434 in Specific local ports, and then click Next.
  6. On the Action page, click Next.
  7. On the Profile page, click Next.
  8. On the Name page, type SQL Server TCP ports in Name, and then click Finish.

Step 4: Install SharePoint Server 2013 on APP1

In this procedure, you install the prerequisite software components for SharePoint Server 2013 on APP1.

  1. On APP1, log on using the User1 user account.
  2. Connect APP1 to a network that has Internet access and configure the TCP/IP protocol on the Local Area Connection as needed. The SharePoint Server 2013 prerequisite installer must download and install components from the Microsoft Download Center. For example, if the network that has access to the Internet uses DHCP, configure the Internet Protocol version 4 (TCP/IPv4) component from the properties of the Local Area Connection in the Network Connections folder to use automatic addressing and to automatically configure a DNS server.
  3. On APP1, navigate to the location that contains the SharePoint Server 2013 installation files and double-click default.hta.
  4. On the SharePoint 2013 page, click Install software prerequisites.
  5. On the Welcome to the Microsoft SharePoint Products Preparation Tool page, click Next.
  6. On the License Terms for software product page, review the terms, select the I accept the terms of the License Agreement(s) check box, and then click Next.
  7. On the Installation Complete page, click Finish.
    • The computer might restart to install some of the prerequisites. After it does the Products Preparation Tool will run again and install the remaining prerequisites. The computer must be restarted again to install these prerequisites.
  8. On the Installation Complete page, click Finish.
  9. In this procedure, you prepare DC1 and SQL1 for the installation of SharePoint Server 2013 on APP1.

To prepare DC1 and SQL1

  1. On DC1, click Start, point to Administrative Tools, and then click Active Directory Users and Computers.
  2. In the console tree, open corp.contoso.com, right-click Users, point to New, and then click User.
  3. In the New Object - User dialog box, in Full name, type SPFarmAdmin, and in User logon name, type SPFarmAdmin.
  4. Click Next.
  5. In Password and in Confirm password, type P@ssword1.
  6. Clear User must change password at next logon.
  7. Click Next, and then click Finish.
  8. On SQL1, log on with the User1 account.
  9. Click Start, click All Programs, click Microsoft SQL Server 2012, and then click SQL Server Management Studio.
  10. In Connect to Server, click Connect.
  11. In SQL Server Management Studio, in the tree pane, open Security.
  12. Right-click Logins, and click New Login.
  13. In Login – New, type CORP\SPFarmAdmin in Login name.
  14. In the Select a page pane, click Server Roles.
  15. In the Server Roles pane, select dbcreator, and then click OK.
  16. Close SQL Server Management Studio.
In this procedure, you install SharePoint Server 2013 on APP1.

To install SharePoint Server 2013

  1. Connect APP1 to the Corpnet subnet and configure the TCP/IP protocol on the Local Area Connection as needed. For example, configure the Internet Protocol version 4 (TCP/IPv4) component from the properties of the Local Area Connection in the Network Connections folder to use the address 10.0.0.3 with a subnet mask of 255.255.255.0 and the preferred DNS server of 10.0.0.1.
  2. Click the Server Manager icon. In Security Information, click Configure IE ESC.
  3. In the Internet Explorer Enhanced Security Configuration dialog box, click Off in Administrators, click Off in Users, and then click OK.
  4. Close Server Manager.
  5. Navigate to the location that contains the SharePoint Server 2013 installation files and double-click default.hta.
  6. On the SharePoint 2013 page, click Install SharePoint Server.
  7. On the Enter Your Product Key page, enter your product key as needed, and then click Continue. For the 180-day trial version of SharePoint Server 2013, use the product key NQTMW-K63MQ-39G6H-B2CH9-FRDWJ.
  8. On the Read the Microsoft Software License Terms page, review the terms, select the I accept the terms of this agreement check box, and then click Continue.
  9. On the Server Type tab, click Complete, and then click Install Now.
  10. When Setup finishes, a dialog box prompts you to complete the configuration of your server. Ensure that the Run the SharePoint Products and Technologies Configuration Wizard now check box is selected, and then click Close to start the configuration wizard.
  11. On the Welcome to SharePoint Products page, click Next.
  12. In the dialog box that notifies you that some services might need to be restarted during configuration, click Yes.
  13. On the Connect to a server farm page, click Create a new server farm, and then click Next.
  14. On the Specify Configuration Database Settings page, type sql1.corp.contoso.com in Database server, type CORP\SPFarmAdmin in User name, type P@ssword1 in Password, and then click Next.
  15. On the Specify Farm Security Settings page, type P@ssphrase in both Passphrase and Confirm passphrase, and then click Next.
  16. On the Configure SharePoint Central Administration Web Application page, click Next.
  17. On the Completing the SharePoint Products Configuration Wizard page, click Next.
  18. On the Configuration Successful page, click Finish. Internet Explorer launches with a tab named Initial Farm Configuration Wizard.
  19. In the Help Make SharePoint Better dialog box, click No, I don’t wish to participate, and then click OK.
  20. For How do you want to configure your SharePoint farm?, click Start the Wizard.
  21. On the Configure your SharePoint farm page, in Service account, click Use existing managed account.
  22. In Services, clear all the check boxes except the box next to State Service, and then click Next. The Working on it page might display for a while before it completes.
  23. On the Create Site Collection page, click Skip.
  24. On the This completes the Farm Configuration Wizard page, click Finish. The Internet Explorer tab shows the SharePoint 2013 Central Administration site.
  25. From Central Administration, click Configure alternate access mappings under System Settings.
  26. Click the http://app1 internal URL.
  27. In URL, protocol, host and port, type http://wfe1/, click OK, and then click Central Administration.

Step 5: Install and configure a new server named WFE1

In this procedure, you install the Windows Server 2008 R2 operating system and the latest updates on a new server named WFE1.

To install Windows Server 2008 R2 on WFE1

  1. Start the installation of Windows Server 2008 R2.
  2. Follow the instructions to complete the installation, specifying Windows Server 2008 R2 Enterprise Edition (full installation), the computer name WFE1, and a strong password for the local Administrator account.
  3. Once the installation completes, log on using the local Administrator account.
  4. Connect WFE1 to a network that has Internet access and run Windows Update to install the latest updates for Windows Server 2008 R2, including Windows Server 2008 R2 Service Pack 1.
  5. Once the updates are complete, restart WFE1 and log on as the local Administrator.
  6. Connect WFE1 to the Corpnet subnet.
In this procedure, you configure the TCP/IP properties on WFE1 so that it can join the corp.contoso.com domain.

To configure the TCP/IP properties on WFE1

  1. In Initial Configuration Tasks, click Configure networking.
  2. In the Network Connections window, right-click Local Area Connection, and then click Properties.
  3. Click Internet Protocol Version 4 (TCP/IPv4), and then click Properties.
  4. Select Use the following IP address. In IP address, type 10.0.0.5. In Subnet mask, type 255.255.255.0. In Default Gateway, type 10.0.0.1. In Preferred DNS server, type 10.0.0.1.
  5. Click Advanced, and then click the DNS tab. In DNS suffix for this connection, type corp.contoso.com, click OK twice, and then click Close.
  6. Close the Network Connections window and leave the Initial Configuration Tasks window open.
  7. To check name resolution and network communication between WFE1 and DC1, click Start, click All Programs, click Accessories, and then click Command Prompt.
  8. In the Command Prompt window, type ping dc1.corp.contoso.com.
  9. Verify that there are four replies from 10.0.0.1.
  10. Close the Command Prompt window.
In this procedure, you join WFE1 to the corp.contoso.com domain.

To join WFE1 to the corp.contoso.com domain

  1. In Initial Configuration Tasks, click Provide Computer Name and Domain.
  2. In the System Properties dialog box, on the Computer Name tab, click Change.
  3. In Member of, click Domain, type corp.contoso.com, and then click OK.
  4. When you are prompted for a user name and password, type User1 and its password, and then click OK.
  5. When you see a dialog box welcoming you to the corp.contoso.com domain, click OK.
  6. When you are prompted that you must restart the computer, click OK.
  7. On the System Properties dialog box, click Close.
  8. When you are prompted to restart the computer, click Restart Now.
  9. After the computer restarts, click Switch User, and then click Other User and log on to the CORP domain with the User1 account.
  10. In Initial Configuration Tasks, click Do not show this window at logon, and then click Close.
In this procedure, you install the Web Server (IIS) server role on WFE1.

To install the Web Server (IIS) server role on WFE1

  1. In the console tree of Server Manager, click Roles. In the details pane, click Add Roles, and then click Next.
  2. On the Select Server Roles page, select Web Server (IIS), and then click Next three times.
  3. Click Install.
  4. Verify that the installation was successful, and then click Close.

Step 6: Install SharePoint Server 2013 on WFE1

In this procedure, you install the prerequisite software components for SharePoint Server 2013 on WFE1.

To install the SharePoint Server 2013 prerequisite software

  1. On WFE1, log on using the User1 user account.
  2. Click the Server Manager icon. In Security Information, click Configure IE ESC.
  3. In the Internet Explorer Enhanced Security Configuration dialog box, click Off in Administrators, click Off in Users, and then click OK.
  4. Close Server Manager.
  5. Connect WFE1 to a network that has Internet access and configure the TCP/IP protocol on the Local Area Connection as needed. The SharePoint Server 2013 prerequisite installer must download and install components from the Microsoft Download Center. For example, if the network that has access to the Internet uses DHCP, configure the Internet Protocol version 4 (TCP/IPv4) component from the properties of the Local Area Connection in the Network Connections folder to use automatic addressing and to automatically configure a DNS server.
  6. On WFE1, navigate to the drive or folder that contains the SharePoint Server 2013 installation files and double-click default.hta.
  7. On the SharePoint Server 2013 Start page, click Install software prerequisites.
  8. On the Welcome to the Microsoft SharePoint 2013 Products Preparation Tool page, click Next.
  9. On the License Terms for software product page, review the terms, select the I accept the terms of the License Agreement(s) check box, and then click Next.
  10. On the Installation Complete page, click Finish.
  11. The computer might restart to install some of the prerequisites. After it does the Products Preparation Tool will run again and install the remaining prerequisites. The computer must be restarted again to install these prerequisites.
  12. On the Installation Complete page, click Finish.
In this procedure, you install SharePoint Server 2013 on WFE1 and join the existing SharePoint farm.

To install SharePoint Server 2013

  1. Connect WFE1 to the Corpnet subnet and configure the TCP/IP protocol on the Local Area Connection as needed. For example, configure the Internet Protocol version 4 (TCP/IPv4) component from the properties of the Local Area Connection in the Network Connections folder to use the address 10.0.0.5 with a subnet mask of 255.255.255.0 and the preferred DNS server of 10.0.0.1.
  2. On the SharePoint Server 2013 Start page, click Install SharePoint Server.
  3. On the Enter Your Product Key page, enter your product key as needed, and then click Continue. For the 180-day trial version of SharePoint Server 2013, use the product key NQTMW-K63MQ-39G6H-B2CH9-FRDWJ.
  4. On the Read the Microsoft Software License Terms page, review the terms, select the I accept the terms of this agreement check box, and then click Continue.
  5. On the Server Type tab, click Complete, and then click Install Now.
  6. When Setup finishes, a dialog box prompts you to complete the configuration of your server. Ensure that the Run the SharePoint Products and Technologies Configuration Wizard now check box is selected.
  7. Click Close to start the configuration wizard.
  8. On the Welcome to SharePoint Products page, click Next.
  9. In the dialog box that notifies you that some services might need to be restarted during configuration, click Yes.
  10. On the Connect to a server farm page, click Connect to an existing server farm, and then click Next.
  11. On the Specify Configuration Database Settings page, type sql1.corp.contoso.com in Database server, and then click Retrieve Database Names.
  12. Click SharePoint_Config in the Database name list, and then click Next.
  13. On the Specify Farm Security Settings page, type P@ssphrase in Passphrase, and then click Next.
  14. On the Completing the SharePoint Products Configuration Wizard page, click Next.
  15. On the Configuration Successful page, click Finish. The Internet Explorer tab shows the SharePoint 2013 Central Administration site. Leave Internet Explorer open.
  16. On APP1, in the Internet Explorer window for SharePoint Central Administration, in System Settings, click Manage servers in this farm and verify that WFE1 is part of the farm.
  17. On WFE1, from Internet Explorer and the Central Administration tab, for How do you want to configure your SharePoint farm?, click Start the Wizard. The Working on it page might display for a while before it completes and you might have to start the wizard again.
  18. On the Configure your SharePoint farm page, click Next.
  19. On the Create Site Collection page, in Title and description, type Contoso Corporation in Title, from the URL list select “/”, and then click OK.
    1. This step creates a team site at the URL http://wfe1.
  20. On the This completes the Farm Configuration Wizard page, click Finish.
The Internet Explorer tab shows the SharePoint 2013 Central Administration site, from which you can configure and manage the SharePoint server.

Step 7: Demonstrate the Facilities of the Default Contoso Team Site

In this procedure, you click through the default SharePoint facilities and resources for the Contoso Corporation team site at http://wfe1/.

To see the facilities of the default Contoso Corporation team site

  1. Attach CLIENT1 to the Corpnet subnet, and then log on with the User1 account.
  2. Start Internet Explorer on CLIENT1.
  3. In the Address bar, type http://wfe1/ and then press ENTER.
    • You should see a SharePoint team site for the Contoso Corporation. The site might take a while to render.
  4. To add a new page to the site, click Site Contents on the Quick Launch, click the Site Pages icon, and then click New wiki page.
  5. In New page item box, type the name of the page, and click Create.
  6. Type the new page contents, and then click Save.
  7. Click Home on the Quick Launch to return to the home page of the Contoso Corporation team site.
  8. To add a site to the site collection, click Site Contents on the Quick Launch, and then click New subsite.
  9. In New SharePoint Site, configure the title, description, web site address, template, permissions and navigation settings, and then click Create.
  10. On the Home page of the Contoso Corporation site, click Documents on the Quick Launch or Documents below the Get started with your site section.
    • This is a list of shared documents that you can work on together. Multiple users can work on each document in a central location, which makes document collaboration much easier that sending files around in email. You can click New document to add a new document to the list of shared documents.
  11. Click Home on the Quick Launch.
  12. In the Get started with your site section, click Working on a deadline?.
  13. In the Working on a deadline dialog box, click Add Them to add the Calendar and Tasks apps to your site.
  14. To access the calendar, click Calendar on the Quick Launch.
    • This is a shared team calendar that can be used to manage and share events across your team. You can point to a day and then click Add to add a calendar event.
  15. Click Home on the Quick Launch.
  16. To access the task list, click Tasks on the Quick Launch.
This is a shared team task list that can be used to manage and share tasks across your team. You can click New task to add a task.

Snapshot the Configuration

This completes the SharePoint Server 2013 three-tier . To save this configuration so that you can quickly return to a working configuration from which you can test other SharePoint TLGs or test lab extensions or for your own experimentation and learning, do the following:
  1. On all physical computers or virtual machines in the test lab, close all windows and then perform a graceful shutdown.
  2. If your lab is based on virtual machines, save a snapshot of each virtual machine and name the snapshots SP2013ThreeTier. If your lab uses physical computers, create disk images to save the SharePoint Server 2013 three-tier test lab configuration.

Passing Data Table and Parameter to RDLC Report

In Designer page add RDLC Report viewer

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>


<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
  Visible="false" Width="100%" OnPreRender="ReportViewer1_PreRender" InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Style="border: #c2c1be solid 1px;"></rsweb:ReportViewer> 


Based on your requirement design Report

In button click place below code


ReportViewer1.Visible = true;

string reportPath = ConfigurationManager.AppSettings["ReportsPath"] + "ReportName.rdlc";


//Pass "Report name" and "Data Set" to Report Data source
ReportDataSource datasource = new ReportDataSource("ReportataSet", CommisionOverView);

//Clear existing Report Data Source
ReportViewer1.LocalReport.DataSources.Clear();

//Add new Data Source
ReportViewer1.LocalReport.DataSources.Add(datasource); 

ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence);

//Pass Report file to Report Viewer
ReportViewer1.LocalReport.ReportPath = Server.MapPath(reportPath);

//Display Report File Name
ReportViewer1.LocalReport.DisplayName = "ReportName" + Convert.ToDateTime(DateTime.Now).ToString("ddMMMyyyyhhmmss");

------------------------------Passing Parameters to RDLC--------------------------
ReportParameter rp = new ReportParameter("prmMonth", this.ddlMonth.SelectedItem.Text, false);
ReportParameter rp2 = new ReportParameter("prmYear", this.ddlYear.SelectedItem.Text, false);

this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp, rp2 });

ReportViewer1.LocalReport.Refresh();





#region Hiding XML,MHTML,CSV Document in a Report Viewer
protected void ReportViewer1_PreRender(object sender, EventArgs e)
{
    DisableUnwantedExportFormats(ReportViewer1.LocalReport);
}
public static void DisableUnwantedExportFormats(LocalReport rvServer)
{
    foreach (RenderingExtension extension in rvServer.ListRenderingExtensions())
    {
                //|| extension.Name == "WORD"
     if (extension.Name == "XML" || extension.Name == "MHTML" || extension.Name == "CSV")
     {
           ReflectivelySetVisibilityFalse(extension);
     }
    }
}
public static void ReflectivelySetVisibilityFalse(RenderingExtension extension)
{
   FieldInfo info = extension.GetType().GetField("m_isVisible", BindingFlags.NonPublic | BindingFlags.Instance);
if (info != null)
       {
            info.SetValue(extension, false);
       }
}
#end region



Monday 10 February 2014

Update Word Template Dynamically using Open XML

using System.Data;

using System.Text;
using System.IO;
using System.Xml;
using DocumentFormat.OpenXml.Packaging;

using DocumentFormat.OpenXml;

// use this method in you Page
DataTable dtDoc = new DataTable();
dtDoc =CreateDocDataTable();
SearchAndReplace(Sourctfilepath, DestinationfilePath, dtDoc);


//Creating Data table
public DataTable CreateDocDataTable()
    {
        DataTable dtDoc = new DataTable();
        DataColumn dcKey_Name = new DataColumn("Key_Name");
        DataColumn dcOutputValue = new DataColumn("OutputValue");
        dtDoc.Columns.Add(dcKey_Name);
        dtDoc.Columns.Add(dcOutputValue);

        DataRow drContractRef = dtDoc.NewRow();
        drContractRef["Key_Name"] = "<<ContractRef#>>";

       drContractRef["OutputValue"] = "value" ;

       dtDoc.Rows.Add(drContractRef);
     
        return dtDoc;

}



    public static byte[] StreamFile(string filename)
    {
        FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

        // Create a byte array of file stream length
        byte[] FileData = new byte[fs.Length];

        //Read block of bytes from stream into the byte array
        fs.Read(FileData, 0, System.Convert.ToInt32(fs.Length));

        //Close the File Stream
        fs.Close();
        return FileData; //return the byte data
    }

//Save Output file with Memory Stream
    public static void SaveMemoryStream(MemoryStream ms, string FileName)
    {
        FileStream outStream = File.OpenWrite(FileName);
        ms.WriteTo(outStream);
        outStream.Flush();
        outStream.Close();
    }


//Search and Replace data in Word document
 public static void SearchAndReplace(string strSourcePath, string outPutFilepath, DataTable dtKey_Vlaues)
    {

        //SPFile objSpFile = myWeb.GetFile(strSourcePath);
        //byte[] fileByteDoc = objSpFile.OpenBinary();


        byte[] fileByteDoc = StreamFile(strSourcePath);
        MemoryStream streamSource = new MemoryStream();
        streamSource.Write(fileByteDoc, 0, (int)fileByteDoc.Length);

        using (var mainDoc = WordprocessingDocument.Open(streamSource, false))


        using (MemoryStream outPutMemStream = new MemoryStream())
        {
            using (var resultDoc = WordprocessingDocument.Create(outPutMemStream,
              WordprocessingDocumentType.Document))
            {
                // copy parts from source document to new document
                foreach (var part in mainDoc.Parts)
                    resultDoc.AddPart(part.OpenXmlPart, part.RelationshipId);
                // perform replacements in resultDoc.MainDocumentPart
                // ...
            }
            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(outPutMemStream, true))
            {
                string docText = null;
                using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream()))
                {
                    docText = sr.ReadToEnd();
                }
                XmlDocument xmlDoc;
                xmlDoc = GetXmlDocument(wordDoc.MainDocumentPart.DocumentSettingsPart);
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
                nsmgr.AddNamespace("w",
                    "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
                XmlNodeList trackedRevisions =
                    xmlDoc.SelectNodes("descendant::w:trackRevisions", nsmgr);
                if (trackedRevisions.Count > 0)
                    throw new SearchAndReplaceException(
                        "Revision tracking is turned on for document.");

                xmlDoc = GetXmlDocument(wordDoc.MainDocumentPart);
                foreach (DataRow theRow in dtKey_Vlaues.Rows)
                {
                    SearchAndReplaceInXmlDocument(xmlDoc, theRow["Key_Name"].ToString(), strReturnDate(theRow["OutputValue"].ToString()), true);
                }
                PutXmlDocument(wordDoc.MainDocumentPart, xmlDoc);

                int headerpartscount = wordDoc.MainDocumentPart.HeaderParts.Count();
                foreach (var headerpart in wordDoc.MainDocumentPart.HeaderParts)
                {

                    xmlDoc = GetXmlDocument(headerpart);

                    foreach (DataRow theRow in dtKey_Vlaues.Rows)
                    {
                        SearchAndReplaceInXmlDocument(xmlDoc, theRow["Key_Name"].ToString(), strReturnDate(theRow["OutputValue"].ToString()), true);
                    }
                    PutXmlDocument(headerpart, xmlDoc);
                }


                //myWeb.Files.Add(outPutFilepath, outPutMemStream, true);

                SaveMemoryStream(outPutMemStream, outPutFilepath);

                //outPutMemStream.Close();  //closed in the above function                      
                wordDoc.Close();
                wordDoc.Dispose();
            }
        }


    }


    private static string strReturnDate(string strDate)
    {
        string strReturn = string.Empty;
        try
        {

            return strReturn = string.Format("{0:dd-MMM-yyyy}", Convert.ToDateTime(strDate));
        }
        catch (Exception ex)
        {
            return strDate;
        }
    }

//Creating base class method for exceptions
    public class SearchAndReplaceException : Exception
    {
        public SearchAndReplaceException(string message) : base(message) { }
    }

//Fetching data in XML Format on Word document
    public static XmlDocument GetXmlDocument(OpenXmlPart part)
    {
        XmlDocument xmlDoc = new XmlDocument();
        using (Stream partStream = part.GetStream())
        using (XmlReader partXmlReader = XmlReader.Create(partStream))
            xmlDoc.Load(partXmlReader);
        return xmlDoc;
    }

//Search and Replace Data in XML Format
private static void SearchAndReplaceInXmlDocument(XmlDocument xmlDocument, string search, string replace, bool matchCase)
    {

        XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable);
        nsmgr.AddNamespace("w",
            "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
        var paragraphs = xmlDocument.SelectNodes("descendant::w:p", nsmgr);
        foreach (var paragraph in paragraphs)
            SearchAndReplaceInParagraph((XmlElement)paragraph, search, replace, matchCase);
    }

//Open file and Write data in XML Format
    public static void PutXmlDocument(OpenXmlPart part, XmlDocument xmlDoc)
    {
        using (Stream partStream = part.GetStream(FileMode.Create, FileAccess.Write))
        using (XmlWriter partXmlWriter = XmlWriter.Create(partStream))
            xmlDoc.Save(partXmlWriter);
    }

// Search and Replace data in XML Format
static void SearchAndReplaceInParagraph(XmlElement paragraph, string search, string replace, bool matchCase)
    {
        try
        {
            XmlDocument xmlDoc = paragraph.OwnerDocument;
            string wordNamespace =
                "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
            XmlNamespaceManager nsmgr =
                new XmlNamespaceManager(xmlDoc.NameTable);
            nsmgr.AddNamespace("w", wordNamespace);
            XmlNodeList paragraphText = paragraph.SelectNodes("descendant::w:t", nsmgr);
            StringBuilder sb = new StringBuilder();
            foreach (XmlNode text in paragraphText)
                sb.Append(((XmlElement)text).InnerText);
            if (sb.ToString().Contains(search) ||
                (!matchCase && sb.ToString().ToUpper().Contains(search.ToUpper())))
            {
                XmlNodeList runs = paragraph.SelectNodes("child::w:r", nsmgr);
                foreach (XmlElement run in runs)
                {
                    XmlNodeList childElements = run.SelectNodes("child::*", nsmgr);
                    if (childElements.Count > 0)
                    {
                        XmlElement last = (XmlElement)childElements[childElements.Count - 1];
                        for (int c = childElements.Count - 1; c >= 0; --c)
                        {
                            if (childElements[c].Name == "w:rPr")
                                continue;
                            if (childElements[c].Name == "w:t")
                            {
                                string textElementString = childElements[c].InnerText;
                                for (int i = textElementString.Length - 1; i >= 0; --i)
                                {
                                    XmlElement newRun =
                                        xmlDoc.CreateElement("w:r", wordNamespace);
                                    XmlElement runProps =
                                        (XmlElement)run.SelectSingleNode("child::w:rPr", nsmgr);
                                    if (runProps != null)
                                    {
                                        XmlElement newRunProps =
                                            (XmlElement)runProps.CloneNode(true);
                                        newRun.AppendChild(newRunProps);
                                    }
                                    XmlElement newTextElement =
                                        xmlDoc.CreateElement("w:t", wordNamespace);
                                    XmlText newText =
                                        xmlDoc.CreateTextNode(textElementString[i].ToString());
                                    newTextElement.AppendChild(newText);
                                    if (textElementString[i] == ' ')
                                    {
                                        XmlAttribute xmlSpace = xmlDoc.CreateAttribute(
                                            "xml", "space",
                                            "http://www.w3.org/XML/1998/namespace");
                                        xmlSpace.Value = "preserve";
                                        newTextElement.Attributes.Append(xmlSpace);
                                    }
                                    newRun.AppendChild(newTextElement);
                                    paragraph.InsertAfter(newRun, run);
                                }
                            }
                            else
                            {
                                XmlElement newRun = xmlDoc.CreateElement("w:r", wordNamespace);
                                XmlElement runProps =
                                    (XmlElement)run.SelectSingleNode("child::w:rPr", nsmgr);
                                if (runProps != null)
                                {
                                    XmlElement newRunProps =
                                        (XmlElement)runProps.CloneNode(true);
                                    newRun.AppendChild(newRunProps);
                                }
                                XmlElement newChildElement =
                                    (XmlElement)childElements[c].CloneNode(true);
                                newRun.AppendChild(newChildElement);
                                paragraph.InsertAfter(newRun, run);
                            }
                        }
                        paragraph.RemoveChild(run);
                    }
                }

                while (true)
                {
                    bool cont = false;
                    runs = paragraph.SelectNodes("child::w:r", nsmgr);
                    for (int i = 0; i <= runs.Count - search.Length; ++i)
                    {
                        bool match = true;
                        for (int c = 0; c < search.Length; ++c)
                        {
                            XmlElement textElement =
                                (XmlElement)runs[i + c].SelectSingleNode("child::w:t", nsmgr);
                            if (textElement == null)
                            {
                                match = false;
                                break;
                            }
                            if (textElement.InnerText == search[c].ToString())
                                continue;
                            if (!matchCase &&
                                textElement.InnerText.ToUpper() == search[c].ToString().ToUpper())
                                continue;
                            match = false;
                            break;
                        }
                        if (match)
                        {
                            XmlElement runProps =
                                (XmlElement)runs[i].SelectSingleNode("descendant::w:rPr", nsmgr);
                            XmlElement newRun = xmlDoc.CreateElement("w:r", wordNamespace);
                            if (runProps != null)
                            {
                                XmlElement newRunProps = (XmlElement)runProps.CloneNode(true);
                                newRun.AppendChild(newRunProps);
                            }
                            XmlElement newTextElement =
                                xmlDoc.CreateElement("w:t", wordNamespace);
                            XmlText newText = xmlDoc.CreateTextNode(replace);
                            newTextElement.AppendChild(newText);
                            if (replace[0] == ' ' || replace[replace.Length - 1] == ' ')
                            {
                                XmlAttribute xmlSpace = xmlDoc.CreateAttribute("xml", "space",
                                    "http://www.w3.org/XML/1998/namespace");
                                xmlSpace.Value = "preserve";
                                newTextElement.Attributes.Append(xmlSpace);
                            }
                            newRun.AppendChild(newTextElement);
                            paragraph.InsertAfter(newRun, (XmlNode)runs[i]);
                            for (int c = 0; c < search.Length; ++c)
                                paragraph.RemoveChild(runs[i + c]);
                            cont = true;
                            break;
                        }
                    }
                    if (!cont)
                        break;
                }

                // Consolidate adjacent runs that have only text elements, and have the
                // same run properties. This isn't necessary to create a valid document,
                // however, having the split runs is a bit messy.
                XmlNodeList children = paragraph.SelectNodes("child::*", nsmgr);
                List<int> matchId = new List<int>();
                int id = 0;
                for (int c = 0; c < children.Count; ++c)
                {
                    if (c == 0)
                    {
                        matchId.Add(id);
                        continue;
                    }
                    if (children[c].Name == "w:r" &&
                        children[c - 1].Name == "w:r" &&
                        children[c].SelectSingleNode("w:t", nsmgr) != null &&
                        children[c - 1].SelectSingleNode("w:t", nsmgr) != null)
                    {
                        XmlElement runProps =
                            (XmlElement)children[c].SelectSingleNode("w:rPr", nsmgr);
                        XmlElement lastRunProps =
                            (XmlElement)children[c - 1].SelectSingleNode("w:rPr", nsmgr);
                        if ((runProps == null && lastRunProps != null) ||
                            (runProps != null && lastRunProps == null))
                        {
                            matchId.Add(++id);
                            continue;
                        }
                        if (runProps != null && runProps.InnerXml != lastRunProps.InnerXml)
                        {
                            matchId.Add(++id);
                            continue;
                        }
                        matchId.Add(id);
                        continue;
                    }
                    matchId.Add(++id);
                }

                for (int i = 0; i <= id; ++i)
                {
                    var x1 = matchId.IndexOf(i);
                    var x2 = matchId.LastIndexOf(i);
                    if (x1 == x2)
                        continue;
                    StringBuilder sb2 = new StringBuilder();
                    for (int z = x1; z <= x2; ++z)
                        sb2.Append(((XmlElement)children[z]
                            .SelectSingleNode("w:t", nsmgr)).InnerText);
                    XmlElement newRun = xmlDoc.CreateElement("w:r", wordNamespace);
                    XmlElement runProps =
                        (XmlElement)children[x1].SelectSingleNode("child::w:rPr", nsmgr);
                    if (runProps != null)
                    {
                        XmlElement newRunProps = (XmlElement)runProps.CloneNode(true);
                        newRun.AppendChild(newRunProps);
                    }
                    XmlElement newTextElement = xmlDoc.CreateElement("w:t", wordNamespace);
                    XmlText newText = xmlDoc.CreateTextNode(sb2.ToString());
                    newTextElement.AppendChild(newText);
                    if (sb2[0] == ' ' || sb2[sb2.Length - 1] == ' ')
                    {
                        XmlAttribute xmlSpace = xmlDoc.CreateAttribute(
                            "xml", "space", "http://www.w3.org/XML/1998/namespace");
                        xmlSpace.Value = "preserve";
                        newTextElement.Attributes.Append(xmlSpace);
                    }
                    newRun.AppendChild(newTextElement);
                    paragraph.InsertAfter(newRun, children[x2]);
                    for (int z = x1; z <= x2; ++z)
                        paragraph.RemoveChild(children[z]);
                }

                var txbxParagraphs = paragraph.SelectNodes("descendant::w:p", nsmgr);
                foreach (XmlElement p in txbxParagraphs)
                    SearchAndReplaceInParagraph((XmlElement)p, search, replace, matchCase);
            }
        }
        catch (Exception ex)
        {

        }
    }