Friday, May 30, 2014

Dashboard Webpart using jQPlot

Recently I had the chance to develop a dashboard Pie chart. The earlier dashboard was too old and don't have effects such as mouse-over and tool tips. I have first chosen Google chart and it has nice effects and looked not effective in old browsers. But later I chose jqPlot as it is a jQuery plugin to generate pure client-side java-script charts in your web pages. 


The below is the HTML code for the above chart. You can download all the js and css files from the jQplot web site and can find a lot of samples with different varieties of charts.
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>jqPlot Examples</title>

    <link rel="stylesheet" type="text/css" href="../style.css" />
    <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]-->
    <script language="javascript" type="text/javascript" src="jquery.min.js"></script>
    <script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery.jqplot.min.css" />
    <script class="include" language="javascript" type="text/javascript" src="jqplot.pieRenderer.min.js"></script>
    <script class="include" language="javascript" type="text/javascript" src="jqplot.highlighter.min.js"></script>
    <script class="include" language="javascript" type="text/javascript" src="jqplot.cursor.min.js"></script>

    <script class="code" type="text/javascript">
        $(document).ready(function () {
            
            var data = [
              ['Chrome - 100,500', 100500], ['Firefox - 80,000', 80000], ['Internet Explorer - 50,000', 50000], ['Safari - 20,000', 20000]
            ];
           
            var plot1 = jQuery.jqplot('chart1', [data],
            {
                gridPadding: { top: 20, bottom: 0, left: 0, right: 0 },
                seriesDefaults: {
                    // Make this a pie chart.
                    renderer: jQuery.jqplot.PieRenderer,
                    rendererOptions: {
                        showDataLabels: true,
                        highlightMouseOver: true,
                        sliceMargin: 0,
                        fill:true,
                        lineWidth: 5,
                        dataLabels: 'percent',
                        dataLabelFormatString: '%d%',
                        padding: 10, sliceMargin: 0
                    }
                },                
                legend: {
                    show: true,
                    location: 'e',
                    rendererOptions: {
                        numberColumns: 1
                    }
                }
            });

            $("#chart1").bind('jqplotDataHighlight', function(ev, seriesIndex, pointIndex, data) {
                var $this = $(this);                
                var value = data[1];
                var num = '$' + value.toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
                $this.attr('title', data[0]);
            }) ;

            $("#chart1").bind('jqplotDataUnhighlight', function(ev, seriesIndex, pointIndex, data) {
                var $this = $(this);  
                $this.attr('title',"");
            });

            $legentIndex = 0;           
        });
       
    </script>

</head>
<body>
    <p class="text">jqPlot - Browser Statistics</p>

    <div id="chart1" style="height:200px; width:350px;"></div>
</body>
</html>
The below code snippets are the implementation of the above code in SharePoint web part and I am not going to explain in detail about web part as it is out of scope of this document. If you are a beginner learn web part development from MSDN.
        protected override void Render(HtmlTextWriter writer)
        {
            EnsureChildControls();
            //Display data
            StringBuilder sb = new StringBuilder();

            LiteralControl litCssJs = new LiteralControl(sb.ToString());
            litCssJs.RenderControl(writer);

            sb = GetValue();
            //Header Items

            LiteralControl litControlTable = new LiteralControl(sb.ToString());
            litControlTable.RenderControl(writer);
        }
   protected StringBuilder GetValue()
        {
            StringBuilder sb = new StringBuilder();
            string sqlConnString = string.Format("Data Source={0};Initial Catalog={1};{2}", server, database, auth);
            //stored procedure
            string L_QueryApps = query;
            object value = new object();
            DataTable appDetail = new DataTable();

            SqlConnection sqlAppConnection = new System.Data.SqlClient.SqlConnection(sqlConnString);
            SqlDataAdapter sqlAppDataAdapter = new System.Data.SqlClient.SqlDataAdapter();
            System.Data.SqlClient.SqlCommand sqlSelectAppCommand = new System.Data.SqlClient.SqlCommand(L_QueryApps, sqlAppConnection);

            sqlAppDataAdapter.SelectCommand = sqlSelectAppCommand;

            sqlAppDataAdapter.Fill(appDetail);

            if (appDetail != null && appDetail.Rows != null && appDetail.Rows.Count >= 3)
            {
                string strType = string.Empty;
                string strDemandDollar = string.Empty;
                string strDemandPercentage = string.Empty;

                string rowData = string.Empty;

                int i = 0;
                //double currValue;
                //string currFormat = "C0";
                string strArrayData = string.Empty;

                foreach (DataRow dr in appDetail.Rows)
                {


                    strType = appDetail.Rows[i][1].ToString();
                    //strDemandDollar = appDetail.Rows[i][2].ToString();

                    string currencyValue = string.Empty;
                    if (appDetail.Rows != null && appDetail.Rows[i] !=null)
                    {
                        currencyValue = appDetail.Rows[i][2].ToString();
                    }

                    DataColumnFormatWithCurrency(appDetail.Rows[i], ref strDemandDollar, ref value, 2, "en-CA", "C0");

                    //strDemandPercentage = string.Format("{0}%", appDetail.Rows[i][3].ToString());
                    DataColumnFormatWithPercentage(appDetail.Rows[i], ref strDemandPercentage, ref value, 3);

                    //Loop Items
                    if (i == appDetail.Rows.Count - 1 && strArrayData.Length>0)
                    {
                        //Remove last char in the string.
                        strArrayData = strArrayData.Remove(strArrayData.Length - 1);
                    }
                    else
                    {
                        strArrayData += string.Format("['{0} ({1}) - {2}', {3}],", strType, strDemandPercentage, strDemandDollar, currencyValue);
                    }

                    //sb.AppendLine(rowData);

                    i++;
                }

                sb.AppendLine("");

                sb.AppendLine("
"); } return sb; }

Monday, May 26, 2014

SharePoint 2013 Migration from MOSS 2007

Recently I had a task to Migrate a SharePoint portal from MOSS 2007 to SharePoint 2013, and It is Interesting and Challenging because there is a huge difference between these two environments such as Hardware requirement, software components requirement. There is no direct upgrade is possible.

Those who are using MOSS 2007 needs to migrate to SharePoint 2013 rather than SharePoint 2010, which is now outdated. The following are the challenges

  1. There is no upgrade tools or features, which ships with SharePoint 2013 to upgrade from MOSS 2007.
  2. However upgrading is possible from SharePoint 2010 to SharePoint 2013 and easy too.
  3. So there are 2 ways to migrate data
Solution 1: 

Setup a SharePoint 2010 Environment to attach the content database of MOSS 2007 website and upgrade the database to SharePoint 2010.
Now backup the SharePoint 2010 website content database and restore/attach to the SharePoint 2013 site.

http://blogs.technet.com/b/nitinsha/archive/2010/07/27/migration-from-sharepoint-2007-to-sharepoint-2010.aspx
http://technet.microsoft.com/en-in/library/cc263299(en-us).aspx
 http://www.sharepointdiary.com/2011/09/migrate-from-moss-2007-to-sharepoint-2010.html
http://www.sharepointdiary.com/2013/09/migrate-from-sharepoint-2010-to-2013-step-by-step.html

Solution 2: 

Export data from List and Libraries site by site using custom code or STS Command and then import it into SharePoint 2013 site and this approach is time consuming and complex. Also require more manual process.


Solution 3: 

The best option is using Third party migration tools such as "Migration Suit for SharePoint" from Dell. Dell, as a Microsoft's migration partner, have a good tool to migrate MOSS 2007 to SharePoint 2013 with more accuracy. The tool have more features such as Pre-migration Analysis and scheduled jobs to manage the migration tasks.

The below is the screenshot of the Tool.





















The below is a small Demo of the migration process.




Also it is worth to try other Third party migration tools, make sure to use trial versions before you buy.

Thursday, May 22, 2014

SharePoint 2013 Three-tier Installation and configuration

We as a SharePoint professional, need to know the Installation and configuration of SharePoint 2013 and its allied components in servers. The typical architecture for development is Three-tier small farm architecture. The following instructions will help you to setup and Install SharePoint 2013 environment.

We need 3 Server for Front end web server, Application server and Database server.

Front End Web Server will be named as "WFE1"
Application Server will be named as "APP1"
Database Server will be named as "SQL1"

Three-tier Small farm architecture

























Installation Sequence

1.       Create AD service and test user accounts and set not to expire the password
2.       Install and Configure a new DB Server named SQL1  
3.       Install SQL Server on SQL1
4.       Install and Configure a new APP Server named APP1
5.       Install Sharepoint 2013 on APP1
6.       Install and Configure a new Web frontend  Server named WFE1
7.       Install Sharepoint 2013 on WFE1

Required Service Accounts

Before SharePoint installation process create the following service accounts in Active directory which is in Domain controller server, you may contact system administrator for creating this.

SQL Installation Accounts
SQL Server Database Engine : DOMSERVER\spsvcSQL
SQL Server Agent : DOMSERVER\spsvcSQLAgent
SQL Server Analysis Service : DOMSERVER\spsvcSQLAnalysis

Sharepoint 2013 Installation Accounts
Farm Administrator : DOMSERVER\spsvcFarm
Sharepoint Installation Administrator : DOMSERVER\spAdmin
Sharepoint Installation Administrator : DOMSERVER\spsvcWbAdmin
Sharepoint Installation Administrator : DOMSERVER\spsvcAppAdmin

SharePoint web application App pool accounts
DOMSERVER\spsvcWebAppPool1
DOMSERVER\ spsvcWebAppPool2
DOMSERVER\ spsvcWebAppPool3

Other Service Application accounts
DOMSERVER\spsvcAccessServices
DOMSERVER\spsvcAccessServices2010
DOMSERVER\spsvcAppManagementService
DOMSERVER\spsvcBusinessDataConnectivityService
DOMSERVER\spsvcExcelServicesApplication
DOMSERVER\spsvcMachineTranslationService
DOMSERVER\spsvcPerformancePointServiceApplication
DOMSERVER\spsvcPowerPointAutomationServices
DOMSERVER\spsvcManagedMetadataServiceApplication
DOMSERVER\spsvcSearchServiceApplication
DOMSERVER\spsvcSecureStoreService
DOMSERVER\spsvcStateService
DOMSERVER\spsvcUserandHealthDataCollectionService
DOMSERVER\spsvcUserProfileServiceApplication (Special permission required : http://technet.microsoft.com/en-us/library/ff182925(v=office.15).aspx#permission )
DOMSERVER\spsvcVisioGraphicsService
DOMSERVER\spsvcWordAutomationServices
DOMSERVER\spsvcWorkManagementServiceApplication
DOMSERVER\spsvcSubscriptionSettingsService

Install Hot Fix

http://www.microsoft.com/en-us/download/details.aspx?id=30653 .NET Framework version 4.5 Release Candidate (RC) (Only on Database server SQL1 )

SQL Server Installation in DB Server (SQL1)


Database Permissions

We need to set the following server roles to the Sharepoint Installation Administrator account (spsvcAdmin)
The below screenshot is the sample for reference.

















Local Administrator Group

Add the Sharepoint Installation Administrator account (spAdmin) to Local Administrator Group on APP1 and WFE1 Servers.
The below screenshot is the sample for reference.
















Prerequisite software (require Internet access)




















Sharepoint 2013 Installation in App server (APP1)

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

Run the setup file and continue the wizard.

When Setup finishes, a dialog box prompts you to run the SharePoint Products Configuration Wizard(SPCW). You can start the wizard immediately or from the Windows command prompt later.

Remember the pass phrase and Configuration database server and database name as these information is required to add the new servers to the Farm later. 

Do not create sites during the SPCW.

Now check the Central admin site

On the Servers in Farm page, click the name of the new server. Use the list of available services on the Services on Server page to start the services that you want to run on the new server.

Configure SharePoint 2013 so that the new server can accommodate the role for which it was intended. For more information, see Configure the new server.

Sharepoint 2013 Installation in Frontend Server(WFE1)


Run the setup file and complete the setup steps.

Start the SharePoint 2013 Products Configuration Wizard.

On the Welcome to SharePoint Products page, click Next.

On the Connect to a server farm page, click Connect to an existing server farm.

Click Next.

On the Specify Configuration Database settings page, type the name of the instance of SQL Server in the Database server box, and then click Retrieve Database Names.

Select the name of the configuration database in the Database name list, and then click Next.

On the Specify Farm Security Settings page, type the name of the farm passphrase in the Passphrase box, and then click Next.

On the Completing the SharePoint Products Configuration Wizard page, click Next.

On the server that hosts Central Administration, click Manage servers in this farm to verify that the new server is part of the farm.

Create your first web app...Great!!!!!!!!!

SharePoint 2013 Site Template for Helpdesk & Trouble tickets

I found a free site template for Helpdesk which supports creating Trouble tickets. We need to download it and Install in SharePoint 2013.

Trouble Ticket system includes the following features:

  1. You can customize the site to show your own company name and logo.
  2. Animated tiles provide links to different sections of the site.
  3. An administration link allows you to view and manage all trouble tickets.
  4. You can move completed tickets to a public archive so users can search and find solutions before creating a new ticket.
  5. You can move completed tickets to billing status so that you know what tickets need to be billed.
  6. Technicians can receive alert messages related to trouble ticket creation, changes and other actions.
  7. Features document library where you can upload technical documents, white papers, cases studies, etc.

Screenshot



Download Links