Pages

Tuesday, December 28, 2010

Google Analytics on SharePoint

Seeing the title we might feel that what is the big deal in using Google Analytics on SharePoint content management sites, yes we can get the page views by just embedding few lines of code provided by Google Analytics site.

In the Current implementation we went with a different approach for providing flexibility to Content Authors to manage the Custom Variables, Events and so on...

At a high level following image shows you the flow:



At a high level we used following components in SharePoint which are the inputs to Google Analytics APIs

1. Custom Site Columns

There a set of site columns created for the publishing pages. Few of them are grouped with the group name called "MetaTagGroup". All the columns which are part of this group will be converted to Metatags.

We used a delegate control in SharePoint for generating these meta tags. For more info you can refer to the article on Meta tag generator

Following image shows the set of custom Site Columns mapped to MetaTagGroup



Now the content author has a flexibility to define the values for these Site Columns or Publishing page attribute which inturn converted Meta Tags and then passed to Google Analytics variables as explained in the next step.

2. Additional javascript layer on Google Analytics APIs

An additional javascript functions are created to call respective Google Analytics APIs. And also this javascript contains an array to map Meta tag name with the GA variables, Scope and their slots as shown below:

var arrGAVariables = [
{'GAVariable':'Segment-Type', 'MetaTagName':'Segment-Type', 'Scope':3, 'Slot':3},
{'GAVariable':'Target-Audience', 'MetaTagName':'Target-Audience', 'Scope':1, 'Slot':1},
{'GAVariable':'Business-Technology', 'MetaTagName':'Business-Technology', 'Scope':3, 'Slot':4}
];

Please feel free to contact me to get more insights on this implementation.

Work around for Disable offline folder in Outlook Client

Recently when I upgraded from outlook 2003 to outlook 2007 at work place (as part of Windows 7 upgradation - I know its too late to go with Win7, we cant help it as we have to adhere to corporate standards but not yet personal laptop :)), I am not able to make the existing pst file as the default for downloading the emails to local pst.

Following are the steps to change the default data file

1. Open Outlook Client -> File Menu -> Data File Management...

Before this step I added the existing outlook 2003 pst file using File Menu -> Open -> Outlook Data File (browse to the existing pst file).

2. Select the respective file in the data files popup window and click on "Set as Default" button.

When we select this option, it promts us to create a new outlook data file or disable the offline folder before setting as default data file.

Now to disable the offline use we can with the steps provided at the msdn article @

http://office.microsoft.com/en-us/outlook-help/disable-an-offline-folder-file-ost-HP005242264.aspx

Now in the last step you will come to know that the "Disable Offline Use" button is always disable with out allowing us to change.

Basicalling this complete issue happens when your pst file is in the "Outlook 97-2002 Personal Folders File" format. The easiest work arond for this problem is by creating a new pst file in Outlook Client 2007 and import the content from the existing pst file. It took around 10 mins for 1.5 GB pst file.

After importing you can make it as a default data file for downloading the emails to local pst file.

Thursday, April 29, 2010

Sql Server 2008 Standard Edition Installation on Win 2008 R2 Issue

In the process of setting up Project Server 2010 and SharePoint 2010 on Windows Server 2008 R2 faced a strange issue as shown in the following image.

This instillation error occurred even though after verifying the Software and Hardware requirements as well as prerequisites for SQL Server 2008 installation with the initial steps of the installation.



Error indicates that there is a network error while reading the file Sql21D7.tmp.msi. When I checked, this file is not available in the specified path. I even tried to install the Database engine with Full Text Search and Replication and also even tried installing only the Database engine, but still installation failed with the same error.

I verified all the installation documents as well googled for this error with no luck.

Finally, copied and pasted one of the msi file in the installation location (indicated in the error message) and renamed the file to Sql21D7.tmp.msi. After this change we are able to install the SQL Server 2008 successfully.

Right now I am not sure where it will impact, i will post my findings after working on the server for next few days...

Friday, March 12, 2010

New Features in SQL Server 2008 R2

Last two day I was in Microsoft SQL Server 2008 R2 HOL Session in Microsoft, India where we came to know the features and enhancements in SQL Server 2008 R2. Following are the feature set at a high level:

1. Data Tier Application Project - Nice way of managing database projects and deployment approach...

2. Master Data Services (Master Data Management) - Initial introduction of MDM within SQL server from MS

3. StreamInsight

4. PowerPivot - Self Analysis Service with in Excel 2010

5. Complex Event Processing (CEP)

6. Visual Studio 2010 feature for T-SQL

7. Reporting Services Enhancements

Hope I will get some time to evaluate these features and to use in our Design and architecture...

Tuesday, December 8, 2009

SharePoint 2010 Beta Installation Issue cum Resolution

Recently when I am installing SharePoint 2010 Beta on one of our sandbox we faced following issue:

Microsoft.Office.Server.UserProfiles.UserProfileException: The request channel timed out while waiting for a reply after 00:00:19.9340000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: The request channel timed out while waiting for a reply after 00:00:19.9340000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: The HTTP request to 'https://myserver:32844/d31735f8a1b34f3a8263707181c7e298/ProfilePropertyService.svc' has exceeded the allotted timeout of 00:00:19.9990000. The time allotted to this operation may have been a portion of a longer timeout. ---> System.Net.WebException: The operation has timed out

After trying all possible approaches, following steps resolved the issue:

Step:1
Open the Channel.Config file available @
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebClients\Profile

Step:2
Replace the "sendTimeout="00:00:20" to "sendTimeout="00:01:20"

Step:3
Reset the IIS (Option as the wizard will restart the service)

Step:4
Rerun the wizard, you can successfully complete the SharePoint 2010 installation.

Wednesday, November 25, 2009

Text Parsing in SQL Server

There are lots scenarios in database procedure we may required to parse the test. Most common scenario is to parse the comma separated text.

For example if we want to get the details of few employees, we will send those employee ids separated by a delimiter as a parameter to the stored procedure.

Till SQL Server 2000 we will be parsing the text character by character and then we will split according to the delimiter.

Following is the general split function which we can use in any version of SQL Server:

Function Code:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER FUNCTION [dbo].[FNSplitString]
(
-- Add the parameters for the function here
@string nvarchar(4000),
@delimiter nvarchar(10)
)
RETURNS
@StringValueTable TABLE
(
-- Add the column definitions for the TABLE variable here
Pos int IDENTITY(1,1),
StringValue nvarchar(4000)
)
AS
BEGIN
-- Fill the table variable with the rows for your result set
DECLARE @delimiterPos int
DECLARE @StringValue nvarchar(4000)

SET @string = @string + @delimiter

-- Loop thru all the characters
WHILE(LEN(@string)>0)
BEGIN

SET @delimiterPos = CHARINDEX(@delimiter,@string)

SET @StringValue = SUBSTRING(@string,0,@delimiterPos)

-- Insert the record into table variable
INSERT INTO @StringValueTable VALUES (@StringValue)

SET @string = SUBSTRING(@string,@delimiterPos+1,LEN(@string))

-- End the loop if there no more elements
IF @delimiterPos = 0
BEGIN
Break
END

END

RETURN
END

Test Sample:

SELECT * FROM [dbo].[FNSplitString]('a,bc,def,ghij,klmno,pqrstu,vw,x,yz',',')

With the new feature "CTE" in SQL Server 2005 and above we can implement the same very easily without any explicit looping mentioned in the above code.

Following is the split function using CTE:

Function Code:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

CREATE FUNCTION [dbo].[FNSplitString_New]
(
-- Add the parameters for the function here
@string nvarchar(4000),
@delimiter nvarchar(1)
)
RETURNS
@StringValueTable TABLE
(
-- Add the column definitions for the TABLE variable here
Pos int IDENTITY(1,1),
StringValue nvarchar(4000)
)
AS
BEGIN

Declare @SourceString nvarchar(MAX)

SET @SourceString = ',' + @string + ',';

-- Query using CTE
WITH CTE (Indx, Position) AS
(
SELECT CHARINDEX(@delimiter, @SourceString) Indx, 1 AS Position
UNION ALL
SELECT CHARINDEX(@delimiter, @SourceString, Indx+1) , Position + 1
FROM CTE WHERE CHARINDEX(@delimiter, @SourceString , Indx+1) <> 0
)
INSERT INTO @StringValueTable(StringValue)
SELECT SUBSTRING(@SourceString, B.Indx+1, A.Indx - B.Indx - 1) Val
FROM CTE A INNER JOIN CTE B ON A.Position = B.Position + 1
OPTION (MAXRECURSION 5000)

-- In the above query recursive option is limited to 5000
-- By default it is 100, which means we cannot loop recursively more than 100 times

RETURN
END

Test Sample:

SELECT * FROM [dbo].[FNSplitString_New]('a,bc,def,ghij,klmno,pqrstu,vw,x,yz',',')

In most of our applications we are using first approach as we are reusing from long time. Now we started taking the power of new features like CTE in our regular design and development.

We can also think about passing the 'n' parameter values to a procedure as an xml. And by using XML query capability we can get the individual values as part of the query itself.

Tuesday, November 17, 2009

SQL Server Table Variables in Transactions

Today in one of the forum I found an intersting question to execute few SQL Statments as not part of the enclosed the transaction.

Let us consider we have a following Scenario:
We have lots of statements participating in the transaction as

Begin Transaction

SQL Inerts Statement 1
Log a message in Log Table
SQL Update Statement 1
Log a message in Log Table
SQL Delete Statement 1

Commit Transaction / Rollback Transaction

In the above block if the transaction is rollbacked then we will be loosing the enteries in Log table too. But if we need the data available in the Log tables without participating in the transaction...

Now the Question is How we can acheive it...?

Immediately after see the question, most of the people thinks about using inner transaction. we have to remember that:

"Committing inner transactions is ignored by the SQL Server Database Engine. The transaction is either committed or rolled back based on the action taken at the end of the outermost transaction. If the outer transaction is committed, the inner nested transactions are also committed. If the outer transaction is rolled back, then all inner transactions are also rolled back, regardless of whether or not the inner transactions were individually committed."

So the Inner/Nested Transaction are ruled out... Now we have to think that is there any way we can get the solution...?

Yes, we can do that by using Local Table Variables. One of the importatnt behaviour of the Local Table Variable will not have any impact of the transaction. Which means irrespective of the Commit/Rollback there will not be any change in the local table variables.

Following the sample demomstrating the same:

-- Create a Sample Table to test
Create Table tblSample(col1 varchar(10))

-- declare log table variable
Declare @Tbl table(Col1 varchar(10))

--
Begin TRansaction

-- Insert Data into table variable
INSERT INTO @Tbl values ('A11')

-- Insert data into actual table
INSERT INTO tblSample
SELECT * FROM
(
Select 'A' Col1
UNION ALL
Select 'B' Col1
) T

-- Insert data into table variable
INSERT INTO @Tbl values ('B11')

rollback Transaction
--commit Transaction

SELECT * from @Tbl
SELECT * from tblSample

Run the above block once with rollback and second time with commit transaction, you will find the same data in the log table @tbl.

Hope this provides some additonal info on local table variables and how we can use in these scenarios.