SharePoint Server 2007 Training for End Users

Recently, In one of the mailing list I came across a question that is very commonly asked by many enterprise customers:

Now that we have SharePoint deployed, How do I train my users?

These users can be Business end users, Helpdesk staff, IT teams etc.

Here are the three links that I think would act as a Starting Point for any good training. They are an excellent resource for Beginners and Novice users alike:

  1. Introduction to Microsoft Office SharePoint Server 2007
  2. Microsoft Office SharePoint Server 2007
  3. Roadmap of using SharePoint Server 2007

Group by Multiple Columns using Anonymous Types in LINQ to SQL

I believe LINQ is a very nice advancement in creating database oriented applications as it allows us to separate application logic from the database. I have been using LINQ to SQL in my recent reporting application and have used various queries with ease.

With the power of Anonymous Types, I was able to create a number of reports with different grouping senarios. Anonymous Types as defined in the C# programming guide:

Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to first explicitly define a type. The type name is generated by the compiler and is not available at the source code level. The type of the properties is inferred by the compiler.

Let’s look at a few ways of Grouping using Anonymous Types. Before we start, displayed below is the sample data used in the queries below:

Sample Data

Simple Group by Anonymous Type – Grouping by Month and Year in a Date

The purpose of this query is to group transactions in the table and retrieve a list of unique months and years in a simple list.

var months = from t in db.TransactionData

    group t by new { month = t.Date.Month, year = t.Date.Year } into d

    select new { t.Key.month, t.Key.year };

 

Transactions Grouped By Month and Year

Group by Database Column and then by Anonymous Type – Grouping by Expense Category and Monthly Total

The purpose of this query is to group all database records by Category first and then display a Total Expense based on the month in a simple list.

var categoryExpense = from t in db.TransactionData

    group t by t.Category into g

    select new

    {

        Category = g.Key,

        Items = from i in g

            group i by new { month = i.Date.Month, year = i.Date.Year } into d

            select new { Date = String.Format("{0}/{1}", d.Key.month, d.Key.year ), Amt = d.Sum(s => s.Amount) }         

    };

 

Multiple Groups

Group by Anonymous Type and then by Database Column – Grouping by Month and then by Expense Category and Category Total

The purpose of this query is the opposite of the group query 2. We will first group by the Month and then group by the Category Total:

var monthlyExpenses = from t in db.TransactionData

    group t by new { month = y.Date.Month, year = y.Date.Year } into g

    select new

    {

        Month = String.Format("{0}/{1}", g.Key.month, g.Key.year),

        Items = from i in g

        group i by new { i.Category } into d

        select new

        {

            Amt = d.Sum(s => s.Amount) 

        }

    };

 

Multiple Groups

With SQL you can seamlessly do all of the above on XML, CSV files or .NET Objects as well.

Recommend Resources to Learn more about LINQ to SQL

Using jQuery Google Charts (JGCharts) with ASP.NET application

I had been looking for a light weight charting library that I could use with my ASP.NET application for a while now. There are a number of charting libraries with jQuery but I found the jQuery wrapper for Google Charts by Massimiliano Balestrieri to be efficient and simple to use.

In this tutorial I will show you how to integrate jQuery Google Charts 1.0 with your ASP.NET application.

Income and Expense Chart

Let us start by downloading the libraries required for this to work. We need two JavaScript files to be downloaded:

  1. jQuery 1.3.2 Minified Version
  2. jgcharts Library

Next is to create or open an existing ASP.NET web page that will display the chart, and include these libraries in the HEAD section of the page.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Chart.aspx.cs" Inherits="Chart" %>

<head runat="server">

    <title>jQuery Google Chart Demo</title>

    <script src="jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="jgcharts.pack.js" type="text/javascript"></script>

</head>

<body>

    <form id="dform" runat="server">

    <div></div>

    </form>

</body>

</html>

 

Within the BODY tags of this page, Let us create two DIV’s, one to display the chart (bar_chart) and another one to display the data (bar_chart_data). A Hidden field is also defined that will hold the JavaScript Array of the GridView data. This will be used by the Charting Library on the client side to display the Bar Chart.

<body>

    <form id="dform" runat="server">

        <h4>Income and Expense Overview</h4>

        <div id="bar_chart"></div>

        <div id="bar_chart_data">

            <asp:HiddenField ID="hidChartData" runat="server" />

            <asp:GridView ID="grvIncomeExp" runat="server">

                <Columns>

                    <asp:BoundField DataField="Month" HeaderText="Month" DataFormatString="{0:c}" />

                    <asp:BoundField DataField="Income" HeaderText="Income" DataFormatString="{0:c}" />

                    <asp:BoundField DataField="Expense" HeaderText="Expense" DataFormatString="{0:c}" />

                </Columns>

            </asp:GridView>

        </div>

    </form>

</body>

 

Within the HEAD tag of this page, you will need to create a jQuery call to initiate the Charting api’s and create graph based on data available in “hidChartData” hidden field.

<head runat="server">

    <title>jQuery Google Chart Demo</title>

    <script src="JQuery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="JQuery/jgcharts.pack.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function()

        {

            var api = new jGCharts.Api();

            var opt = 

            { 

                data : eval($("[id$='hidChartData']").val()),   

                axis_labels : ['01','02','03','04','05','06','07','08','09','10','11','12'],

                legend : ['Income', 'Expense'],

                size : '600x335',

                bar_width : 15

            };

            jQuery('<img>').attr('src', api.make(opt)).appendTo("#bar_chart"); 

        });

    </script>

</head>

f you now look at the page in the browser – you should see a blank bar chart without any data in it. This is because we have not bound the data to the Hidden Field (hidChartData) and the GridView.

Bar Chart without Data

Lets now look add a Page_Load function in the code behind. This event handler will bind data to the GridView and assign the value to the HiddenField with a JavaScript array of data.

protected void Page_Load(object sender, EventArgs e)

{

        DataTable dTable = GetSampleData();

        grvIncomeExp.DataSource = dTable;

        grvIncomeExp.DataBind();

 

        ArrayList chartData = new ArrayList();

        foreach (DataRow dr in dTable.Rows)

        {

            chartData.Add(String.Format("[{0}, {1}]", dr[1], dr[2].ToString().Replace("-", "")));

        }

 

        //Convert .NET Array to JS Array

        string ReturnValue = String.Empty;

        for (int i = 0; i < chartData.Count; i++)

        {

            ReturnValue += chartData[i];

            if (i != chartData.Count - 1)

                ReturnValue += ",";

        }

 

        //Data is returned in the following format: 

        //[[1000, 3003.55],[1000, 72.65],[1000, 760.89],[1000, 354.55],[1000, 180.52],[1000, 408.54],[0, 0],[0, 0],[0, 0],[0, 0],[0, 0],[0, 0]]

 

        hidChartData.Value = String.Format("[{0}]", ReturnValue);

}

This will create the chart displayed in the first Image. NOTE: I have removed all CSS styles to make the code more readable.

 

 

Finding Min or Max Date using LINQ to SQL

In one of my recent project, I had to retrieve Minimum and Maximum date from the result set using LINQ to SQL. I was really surprised how easy it was:

//Retrieve Minimum Date

var MinDate = (from d in dataRows select d.Date).Min();

 

//Retrieve Maximum Date

var MaxDate = (from d in dataRows select d.Date).Max(); 

In its simplest form, all you have to do is have .Min() or .Max() at the end of your LINQ query. That’s it.

BlackNewspaper – free BlogEngine.NET theme

Introducing BlackNewspaper a free BlogEngine.NET theme. This theme is a modified version of an existing theme called Newspaper v1.1 by jankoatwrapspeed.com.

BlackNewspaper theme is a simple White on Black theme with cleaner boundaries and gray sidebar text to give more emphasis to the contents in the post.

Home Preview

With minimal blog graphic, the post view is very clean with a lot of emphasis on blog text and the comments section.

Post Preview

Windows Live Writer Source Code Plugin is used for the Code blocks. This plugin uses SyntaxHighligter for BlogEngine.NET

Also included with the theme is a modified version of the MonthsList control. I have modified the existing control to display a flat list of Months instead of a tree structure. Replace the MonthsList.cs file in the AppCodeControls directory of your blog installation.

Install Windows 7 from USB Flash Drive

Update: Microsoft has released a very useful open source tool to create USB flash drive for installation. Have a look at Windows 7 USB/DVD Download Tool at CodePlex. – 01/01/2010.

I recently bought an Acer One Netbook which comes with Windows XP preloaded. Since these Netbooks come without built in DVD drives, upgrading to another OS is a challenge. With the high storage capacity USB drives becoming cheaper by the day it is a perfect medium to installing Windows.  Although this tutorial is for Windows 7, you can use these steps to install Windows Vista as well.

Pre-Requisites

  • A Computer or Netbook that can boot from USB Drive. Check your BIOS for boot options, It should have an option to boot from USB disk or Removable drive.
  • A computer with an OS and/or software that can mount an ISO file.
    On Windows, I prefer using Slysoft Virtual Clone Drive to mount ISO. It supports both x86 and x64 bit platforms and is free.
  • USB Flash Drive with 3 GB or more space.
  • Windows 7 ISO (or Windows Vista ISO)
    Microsoft has published Windows 7 RC for everyone to download and test. This version can be used for 1 year. You can download Windows 7 from Microsoft Technet Website.

Prepare your USB Flash Drive

In order to boot from USB Flash Drive – you will need to mark the USB flash drive partition as Primary and format it in FAT 32 mode. Please be careful as while performing these steps. An incorrect step can render your current installation useless.

Step 1 – Open Command Prompt

Open command prompt in Administrator mode. (Click on) Start Button –> (Click on) All Programs –> (Click on) Accessories –> (Right Click on) Command Prompt –> (Click on) Select Run as Administrator –> (Click) Continue. You should a command prompt start “Administrator: “ in the title like below.

New Command Prompt

Step 2 – Setup USB Drive as Bootable

These following steps are very straight forward, but be careful with these steps, make sure you select the right drive. Read these steps and look at the screenshot before you start entering these commands.

  1. Enter command diskpart
  2. Enter command list disk – this will list drives on your computer. Check the size column and note the Disk ### for your USB drive
  3. Enter command select disk #, here replace # with the number of your USB drive.
  4. Enter command clean
  5. Enter command create partition primary
  6. Enter command select partition 1
  7. Enter command format fs=fat32 quick
  8. Enter command exit

command window

Copy Windows 7 Installation files

Mount the ISO that you have downloaded from Microsoft Website and copy all the files to the root of your USB Flash Drive

file explorer

Reboot your computer & set the option in BIOS to boot from USB or Removable Drive

Nice and Easy. Now wait and see how fast Windows 7 installs.

The Big Bang Theory

The Big Bang Theory is a US comedy TV series that circles around the geekiness of two physicist Leonard and Sheldon.

About the Show

Leonard and Sheldon are brilliant physicists, the kind of "beautiful minds" that understand how the universe works. But none of that genius helps them interact with people, especially women. All this begins to change when a free-spirited beauty named Penny moves in next door. Sheldon, Leonard’s roommate, is quite content spending his nights playing Klingon Boggle with their socially dysfunctional friends, fellow CalTech scientists Wolowitz and Koothrappali. However, Leonard sees in Penny a whole new universe of possibilities… including love.

This is a must see TV show for all the geeks out there. Here is a quick preview of the Pilot:

And the cast is on twitter as well:

How to selectively update your Facebook status with Twitter

It has been possible to update your Facebook Status from Twitter using the official twitter application on Facebook. But if you don’t want your friends to go crazy and comment on every tweet you publish, there is another Facebook application – Selective Twitter.

Here is what you do in 4 easy steps:

Step 1: (Optional) If you have Twitter application already installed on your Facebook profile – remove or disable it

Remove Twitter from FacebookStep 2: Search and install Selective Twitter Application

Selective Twitter Application

Step 3: Authorize this application and provide your twitter username

Step 4: Go to Twitter and post a tweet. If you want to update your Facebook Status with a tweet – end it with #fb

And YES – the application removes “#fb” before updating Facebook status.

Add domain user to local vista administrator group

Recently I had to re-format my work laptop and I decided to fix one of the most annoying thing that I dealt with everyday but I was too lazy to research.

My company has a group policy setup for UAC. We need to have it enabled at all times but the pain of entering the username (domainusername) and password every time I wanted to start visual studio or IIS console was very unproductive and tedious.

Turns out a simple command at CMD prompt can do the trick:

net localgroup Administrators /add domainusername

Behold – no more password – one click and we are elevated. Oh the joys of Windows Vista.

Update: This works for Windows 7 as well. – 8th June 2009

Retrieving SharePoint Blog Post HTML

image Following my series of retrieving HTML from SharePoint – I had to recently retrieve the HTML from the Blog post in SharePoint.

One again – it is pretty straight forward but as the Blogs are a different site compared to SharePoint MySite – you will need to develop a feature at a Site Collection level.

 

 

public bool Convert(string ItemId, string SiteUrl)

{

    //Get Site, Web, List and Retrieve ListItem

    using (SPSite Site = new SPSite(SiteUrl))

    {

        using (SPWeb Web = Site.OpenWeb())

        {

            SPList List = Web.Lists["Posts"];

            SPListItem ListItem = List.GetItemById((Int32.Parse(ItemId)));

            HTML = String.Format("<html><body>{0}</body></html>", 

                   ListItem["Body"].ToString());

        }

    }

}

The list you are retrieving data from here is “Posts”.