Saturday, August 20, 2011

MCPD: SharePoint Developer 2010

On Monday (15th Aug) I took the exam for PRO: Designing and Developing Microsoft SharePoint 2010 Applications (70-576) and I passed. Yea!! I'm now MCPD certified.

Thursday, January 20, 2011

MCTS: SharePoint 2010, Application Development

Yay!!! After much hard work I passed my very first MCTS Microsoft Certification: TS - Microsoft SharePoint 2010, Application Development (70-573), which I sat for today. I will post some tips/ recommendation on how to prepare yourself for this certification in the next couple of days.

Now..time to celebrate....

Wednesday, January 12, 2011

SharePoint Forum Sri Lanka Launched

Today we attended the launch and inaugural session of the SharePoint Forum Sri Lanka at Microsoft SL. There were two presentations - first one on Professional SharePoint Branding and the second on Claims Based Authentication.

Forum will meet every 2nd Wednesday of the Month for community sessions.

Tuesday, January 11, 2011

Creating a SharePoint WSP package through Visual Studio 2010 Build

To be part of our automated build process (NAnt) here I was wanting to create the WSP on invoking devenv.exe from the command line. From the VS2010 IDE it would be straightforward to select Package from the Project context menu.

But what would be the alternative if I were to build the project and create the WSP from the command line? There is no command line argument which you can provide to devenv.exe. The articles I came across mention that MSBuild does have a way to achieve this (/p:IsPackaging=True).

If you integrate with TFS it might be worth reading this MSDN technical article. I had no intention to include MSBuild in the build, therefore needed a way to create the WSP just using Visual Studio. As I was searching around I came across this blog post by Yaroslav Pentsarskyy.

Essentially, with this approach the WSP will be created whenever you build your solution.

In a SharePoint projects project definition file or simply the project file (.csproj) couple of parameters are defined such as the build platform, build configuration etc. Apart from these variables the project file can be manually edited to add your own build tasks.

Build tasks are somewhat similar to targets in NAnt. They define a set of operations to execute during build. Visual Studio 2010 defines a set of standard SharePoint tasks that are defined in C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets. In this case I will be using the CreatePackage task.

First unload the SharePoint Project from Visual Studio to enable manual editing of the project file. Then select to edit the project file.

Add the Create Package command.
Scroll down right to the bottom and you will see the import of the SharePoint targets:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets" />


This imports the Microsoft.VisualStudio.SharePoint.targets MSBuild taget file to the project. We can override specific predefined targets defined in Microsoft.VisualStudio.SharePoint.targets

Right below add the following:
<propertygroup>
<builddependson>$(BuildDependsOn);CreatePackage</builddependson>
</propertygroup>

This appends the CreatePackage task to the existing tasks defined for BuildDependsOn. Now when you build the project the WSP will be created as well.

Here are some How To articles relevant to this:

Wednesday, January 05, 2011

How to Restart/Change Project Server Workflow

Came across this blog post on how to restart or change a Project Server 2010 workflow. Was quite useful since you can test a workflow without creating new projects. Downside is that it won't skip if there are natural stop points such as creation of approval task, having an OnSubmit activity etc..

Sunday, November 07, 2010

How to reset BIOS Password in Toshiba M105-S3064

Two years back, my Toshiba M105-S3064 notebook got stuck and I gave it a cold start (used the power on button to switch off and switch on again). Since then it has been prompting me always at boot for authentication to the BIOS, either to swipe the finger or to enter the password. As I remember, I hadn't set a BIOS password and was unsure why it was prompting for authentication. Fortunately, it accepted my finger swipe and authenticated me. However, I didn't know what the password was.

Most recently I restored the OS (Windows XP) from the restore disk and after a couple of days of using the notebook it didn't recognize my finger swipe. Therefore, I decided I had to find a solution to this. I ran a search on google trying to find a fix for this issue, lo and behold this was a known bug in the BIOS in some Toshiba laptops. With doing a cold start, when the BIOS password is not set, some settings in the BIOS gets corrupted and sets a password. The articles I read suggested to short circuit the CMOS_CLR1. Although I located CMOS_CLR1 on the circuit board, I wasn't sure which pins I had to short circuit since I had no visual guide and I didn't want anything nasty to happen to my laptop. After some researching around and contemplating I managed to figure out what needs to be done.

First make sure the power cable and the battery is removed. Open the memory compartment at the bottom and take out the memory module. What you see below is the memory compartment cover removed and the memory module in place, which needs to be removed. There's a clamp at either end which holds the memory module in place. You just need to push them little outward and the memory module should lift it self up.


Then lift up the black insulation and you should be able to spot the text CMOS_CLR1 on the circuit board. Do not put too much force when lifting the black plastic insulation or it may tear. Just above the CMOS_CLR1 mark you should be able to spot something which looks like a zipper. Hold a screwdriver or something metal on that zipper like imprint on the circuit board for 15-30 seconds. Then put everything back together and you should be good to go. When you boot it will prompt saying the time has not been set. You can hit F1 to go with default settings or F2 to go to the BIOS setup. I selected F2 and set the BIOS password with something I will remember.

Friday, July 30, 2010

Convert Date Time to SharePoint Site Time Zone

Here was the requirement to default to the current date in a list field if there was no input by the user. You may think that's easy, just use DateTime.Now. The problem is the sharepoint site regional settings is set with a different time zone than that of the time zone of the machine hosting SharePoint.

So for example if the machine hosting sharepoint is in the time zone (UTC+05.30) Sri Jayawardenepura (Sri Lanka) and the current time is 06.00 PM and the SharePoint site has the regional settings time zone set to (GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London a call to DateTime.Now will return the date time in Sri Jayawardenepura - 06.00PM.
What we need is the time at London - 01.30 PM. Keep in mind that if the time zone observes daylight saving then we need to account for that. Given that the current date falls within the date span they observe daylight saving I'm going with a +04.30 time difference as opposed to a +05.30 time difference. I referenced this blog post before I came up with this code.


DateTime dateTime = DateTime.Now;
int timeZoneBiasMinutes = 0;

// convert to utc time
DateTime adjustedDateTime = dateTime.ToUniversalTime();

// timezone in site regional settings
SPTimeZoneInformation timezoneInformation =
SPContext.Current.Web.RegionalSettings.TimeZone.Information;

// timezone difference from utc time
timeZoneBiasMinutes = timezoneInformation.Bias;

// get daylight date start date
SPSystemTime timezoneDaylightDate = timezoneInformation.DaylightDate;

if (timezoneDaylightDate.Month > 0)
{
DateTime daylightDate = new DateTime(
dateTime.Year,
timezoneDaylightDate.Month,
timezoneDaylightDate.Day);

// get standard date start date
SPSystemTime timezoneStandardDate = timezoneInformation.StandardDate;

// handle daylight saving overlapping to next year
int standardDateYear = 0;
if (timezoneStandardDate.Month > timezoneDaylightDate.Month)
{
standardDateYear = dateTime.Year;
}
else
{
standardDateYear = dateTime.Year + 1;
}

DateTime standardDate = new DateTime(standardDateYear,timezoneStandardDate.Month, timezoneStandardDate.Day);

// adjust for daylight saving
if (((dateTime.CompareTo(daylightDate) > 0)
(dateTime.CompareTo(daylightDate) == 0)) &&
(dateTime.CompareTo(standardDate) &lt;> 0)
{
timeZoneBiasMinutes = -timeZoneBiasMinutes;
}
else
{
timeZoneBiasMinutes = Math.Abs(timeZoneBiasMinutes);
}

// adjust based on daylight saving
adjustedDateTime = ((DateTime)adjustedDateTime).AddMinutes(timeZoneBiasMinutes);

}