Sunday, August 15, 2010

HOW TO: Create a Sharepoint 2010 VM in 32 bits host machine

The objetive of this serie of posts is to explain in detail how to create a 64 bits virtual machine with Sharepoint 2010 in a 32 bits host machine.
The first thing we have to do is download all the necessary software for our Sharepoint 2010 VM.  This is the list of software we need:

1.       SUN VirtualBox 3.0: this software enables create 64 bits guest machine into 32 bits host machines. You can download this free software from http://www.virtualbox.org/wiki/Downloads.
2.       Microsoft Windows Server 2008 64 bits: you can download a trial version from Microsoft site (http://www.microsoft.com/windowsserver2008/en/us/trial-software.aspx).
3.       Microsoft SQL Server 2008 64 bits: you can download a trial version from Microsoft site (http://www.microsoft.com/sqlserver/2008/en/us/trial-software.aspx).


Before we can start the installation we have to enable Intel® VT and AMD-V virtualizations extension in BIOS. You must open the BIOS setup utility of your computer, then access the processor section and enable intel®virtualization technology or AMD-V.
Now that we already have all the necessary software to create the virtual machine, we are going to start installing VirtualBox 3.0.
I won’t explain the steps to install VirtualBox. You have all the necessary information in the user manual (http://www.virtualbox.org/manual/UserManual.html).

Once we have installed VirtualBox we’re going to create the virtual machine:
1.       Run VirtualBox 3.0: double click in desktop icon.
2.       Click New and you’ll see the wizard window:





3.       Once you have created the shared folder you are able to access its content through the windows explorer of the VM with the following URL \\vboxsvr\<shared folder name>:















 
3.       Introduce the VM name (for example “Sharepoint 2010”) and select the OS version (Microsoft Windows 2008 64 bit):



4.       Microsoft Sharepoint Server 2010 TP: you only can obtain this software through the Microsoft Technical Preview Program.
5.       Microsoft Office 2010 TP: you only can obtain this software through the Microsoft Technical Preview Program.

4.       Next define the RAM memory to asign to VM:


5.       Next define the name, size and location of a new virtual disk:




6.       Finally click Finish is the summary windows and you’ll have your VM created:


Now we have the VM ready to install all the software. First of all we have to install Windows Server 2008 64 bit:
1.       Select the VM is VirtualBox and click Configuration button.
2.       Select CD/DVD-ROM section and introduce the location of the ISO image file downloaded from Microsoft site:
3.       Save the changes and the Start button to iniciate the VM
4.       VirtualBox will execute the installation of Windows Server 2008. Select language, date format and keyboard and click Next:


5.       Wait till all steps of installation have been completed and then enter the new password for Administrator.
6.       Once you have logged in the VM, change other settings like date and time, keyboard, display resolution, etc.
Finally you have to install Sun VirtualBox Guest Addtions 3.0 clicking In the option Install Guest Additions of the Devices menu:


After the installation you must restart the virtual machine.
Continuing with the installation of our Sharepoint 2010 VM, in this post we’re going to install SQL Server 2008.
Before we can start, we need to create a shared forlder in order to access the installation software stored in the host machine.
To create a shared folder:
1.       Click in Shared Folder option of the devices menu of your VM.
2.       Click the icon to create a new Shared folder and select the path of your host machine where you have downloaded the SQL Server 2008 software:

12.   Next you have to enter the account for SQL Server Administration:

13.   Next you have to decide if send errors and logs to Microsoft:

14.   Then installation rules are checked:

15.   Next a installation summary is shown and when you click Install the installation process begins:

16.   After installation is finished you are able to view the log file:


Finally we’re going to install Sharepoint Server 2010 TP.
Before we proceed with the installantion, we’ll create a second virtual disk to stored all data.
To create a second virtual disk:
1.       With the VM off, click in Configuration button and select virtual disks section:

2.       Click the icon to create a new Virtual Disk and select the path and size of the virtual disk:

3.       Then click Ok in the configuration window of VM.
4.       Then start the VM, run the Server Manager and message box will be shown to activate the new disk. Click Ok and create a volume with the new disk:

5.       Finally run the SQL Management Studio, open the Server Properties, select the Database Settings section and change the Database Default Location to a path of the new virtual disk:



11.   Next you have to enter the account credentials for different services:

10.   Next disk space requirements are cheked:

9.       Next you have to select the instance ID and the instance root directory:

7.       If no errors ocurres you can change to the Installation section and execute the stand-alone installation.
8.       First you have to select the feature you want to install:

6.       In the planning section you have to execute the System Configuration Checker:

3.       SQL Server 2008 also requires Hotfix KB942288. Click ok in the message box and the Hotfix will be installed.
4.       At this point you must restart the virtual machine.
5.       After you restart the virtual machine you must execute Setup again, and this time the SQL Server Installation center is opened:

Now we are ready to install SQL Server 2008 64 bit:
1.       Execute the Setup program.
2.       A message box is shown advicing you that SQL Server 2008 requires Microsoft .NET framework 3.5 SP1. Click Ok and .NET framework will be installed:

Friday, June 18, 2010

SharePoint 2010 Visio Workflows and Nintex

As you most likely know, especially if you have a SharePoint 2010 Beta subscription, SharePoint 2010 will support designing workflows in Visio 2010. You may think that this will make third-party workflow design tools, such as Nintex Workflow 2007, less important. I beg to differ.

Mike Fitzmaurice of Nintex just wrote a blog post about this, explaining the reasons why Visio 2010 Workflows is not the end of third-party add-ons.

Now, Mike is a very nice guy, I worked with him while writing the Using Nintex Workflow 2007 issue of USPJ, and after we had a particularly constructive telephone meeting, he even said ‘Thank you’ in Norwegian. That sort of thing leaves an impression. I have a few heroes in the SharePoint world, and Mike is definitely on that list.

However, in this case, he’s too shy. Here’s my perspective.

Third-party developers have been developing products for Windows for years, despite there being free Microsoft alternatives. There’s a reason why there is a plethora of software such as UltraEdit, NotePad++, etc, despite the fact that a text editor ships with Windows. There’s a reason why media players such as Media Player Classic still enjoy widespread adoption, despite Microsoft including Windows Media Player with virtually any piece of software. Browsers continue to flourish, regardless of how much Internet Explorer is now a critical update to Windows.

The reason for this rich and competing product offering is that third-party developers are simply more creative. I’m not saying Microsoft isn’t innovative or creative, but considering they only have a limited number of employees, they can’t imagine everything. Also, when Microsoft releases a product, people start learning the technology and quickly find ways to improve the experience.

A very good example of how this works is Nintex Workflow 2007. Microsoft has designed a rich and massive workflow framework, and Nintex has designed a vastly improved interface to that framework. Even when considering the apparent ease of SharePoint Designer, Nintex WF is years ahead.

Nintex simply is better at doing workflow than Microsoft. In fact, Nintex is so much better at doing workflow than Microsoft, that I perceive the Visio 2010 workflow integration to be an attempt from Microsoft to narrow the gap.

Does this mean that with the release of SharePoint 2010, that Microsoft will catch up? Not by a long shot. I’m not privy to any NDA material, but based on what I have seen from the Visio 2010 beta, Nintex could quite comfortably sit quite still and do quite nothing, and still be quite ahead.

So no, Visio 2010 workflow integration wont be the end of third-party workflow development. Quite the contrary, I suspect Nintex and other developers to put out products that will make your workflow experience a lot better than what you get out-of-the-box.

But that’s just my 2 cents.

Saturday, June 12, 2010

CRUD for SharePoint 2010 external lists using Visual Studio 2010

In our last blog of this series Walkthrough of creating a SharePoint 2010 external list using Visual Studio 2010 , we introduced how to create a simple “Hello world” external list in SharePoint 2010 using Business Data Connectivity Designer in Visual Studio 2010.

In this blog, we will show you how to pull data from an external database into an external list and enable Create, Read, Update and Delete (CRUD) functions to the external list.

If you already have a “Northwind” database, you can skip this section. Otherwise, please download SharePoint2010_BDCSamples.zip from here and extract the SQL script file CreateSampleNorthwindDB.sql.

Open Visual Studio. Go to View->Server Explorer. Right click Data Connections in Server Explorer, and select Create New SQL Server Database.
1. In the prompt dialog, type “localhost\sqlexpress” in Server Name text box, and give the new database name “SampleNorthwind”.
* If you're using the SQL Express that comes with SharePoint Server, please replace “localhost\sqlexpress" with "localhost\sharepoint”.
2. Start a Command Prompt. Go to Start->Run, type “Cmd” in the text box and click OK.
3. In the Command Prompt, type in following command and press enter:

sqlcmd -S localhost\sqlexpress -d samplenorthwind -i <Path of CreateSampleNorthwindDB.sql file>

Create BDC Project

Create a new C# BDC Model project and rename it “BdcSampleCSharp”. VB code snippets will also be provided, so you can create VB BDC Model project if you want. In this walkthrough, we will use C# project as an example. (Check this blog for how to create a BDC project)

Connect to external data source

To use the SampleNorthWind database, we add a LINQ to SQL model to the project:
1. On the Project menu, click Add New Item, in the prompt Add New Item dialog select Data in the Installed Templates pane, in the Templates pane select LINQ to SQL Classes, in the Name box, type “Customer”, and then click Add.

2. In the Server Explorer, go to Data Connections->[hostname]\sqlexpress.SampleNorthWind.dbo->Tables->Customers, drag the Customers table and drop it on the Customer.dbml design surface.
3. Add a new class file and rename it “CustomerDataContext.cs”. Replace the code of the class with the following code snippet.
Note: We made the connection string a constant in the code only for demo purpose, if you’re using your own database, modify the connection string as needed. In our future post we will introduce how to set the connection string in a custom property on LobSystemInstance inside the BDC model and read the value through IContextProperty interface at runtime.

C#:



public partial class CustomerDataContext

{


private const string ConnectionString = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=SampleNorthwind;Integrated Security=True;Pooling=False";


public CustomerDataContext() :


base(ConnectionString, mappingSource)


{


OnCreated();


}


}

VB:


Partial Public Class CustomerDataContext

Private Const ConnectionString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=SampleNorthwind;Integrated Security=True;Pooling=False"


Public Sub New()


MyBase.New(ConnectionString, mappingSource)


OnCreated()

End Sub


End Class
 
 
Design BDC Model



1. On the design surface, delete entity Entity1 which is created by default. On the View menu, click on Toolbox if it is not shown. Create a new entity by drag and drop the Entity icon from Toolbox onto design surface (see the screenshot below). In the Properties Browser, change the value of Entity’s Name property to “Customer”.


2. Create a new Identifier CustomerID on entity Customer. To do so, on the design surface, right click the entity, click Add->Identifier. A new identifier appears on the entity, and then rename it to “CustomerID”.


3. Create a Specific Finder method for the entity. To do so, on the design surface, select entity Customer, you could find a <Add a Method> command in the Method Details Window. If the Method Details Window is not opened, you can find it in menu View->Other Windows->BDC Method Details. From the <Add a Method> drop-down list, select Create Specific Finder Method:




A method named ReadItem appears on entity Customer. In the Method Details Window, you will find that the method takes a In parameter and a Return parameter. In the next step we will define TypeDescriptors associated with these parameters.

4. Add TypeDescriptors for the return parameter Customer. The edit need to be done in BDC Explorer. You can find it by going to View->Other Windows->BDC Explorer.


a) In the Method Details Window, click <Edit> command in the drop down control from TypeDescriptor Customer as depicted below. After the click the BDC Explorer will get focused on the TypeDescriptor Customer.

 
b) In BDC Explorer right click the focused TypeDescriptor Customer and select Add Type Descriptor:
 
 

A new TypeDescriptor is created under TypeDescriptor Customer. In the Properties Browser, rename it to “CustomerID”. Next you need to set the Identifier property to “CustomerID” to tell the BCS runtime which identifier this TypeDescriptor represents. Here is a screenshot of Properties Browser after this step:



c) Continue to add following TypeDescriptors under Customer by repeating the operation described above: Address, City, CompanyName, ContactName, Country, Fax, Phone, PostalCode and Region, for each TypeDescriptor, you need to change its Type Name to make sure they match the type defined in the LINQ to SQL model. In this example, all the TypeDesriptors have a type of System.String which is the default one so we do not need to change them. After this step, we get the following TypeDescriptors in BDC Explorer:


d) Next we need to define the actual type of the TypeDescriptor Customer. Click TypeDescriptor Customer in BDC Explorer. You will find in the Properties Browser the value of Type Name property is System.String by default, we need to change it to “BdcSampleCSharp.Customer, BdcModel1” which is a LobSystem qualified type name. This specifies the actual the data type of the data structure that is represented by this TypeDescriptor Customer.


5. Create the other types of methods by the same way described in step 6. After this step we will have five methods in the entity Customer: ReadItem, ReadList, Create, Update and Delete. If you check the ReadList method in Method Details Window, the TypeDescriptors of the return parameter have already been defined with the same structure as we just built above. This is because when creating a new method, BDC designer will search the possible TypeDescriptors defined in the other methods of this entity and copy them to the newly created methods. This saves the developers so much time to define them repetitively.

Add code behind to access external data source
Now it’s time to add code to implement the CRUD functions. In Solution Explorer, find and open CustomerService.cs, and then replace the implementation with the following code snippet:

C#:



public static Customer ReadItem(string customerID)


{


CustomerDataContext context = new CustomerDataContext();

Customer cust = context.Customers.Single(c => c.CustomerID == customerID);

return cust;

}


public static IEnumerable<Customer> ReadList()


{

CustomerDataContext context = new CustomerDataContext();

IEnumerable<Customer> custList = context.Customers;

return custList;

}

 
public static Customer Create(Customer newCustomer)


{

CustomerDataContext context = new CustomerDataContext();


context.Customers.InsertOnSubmit(newCustomer); context.SubmitChanges();


Customer cust = context.Customers.Single(c => c.CustomerID == newCustomer.CustomerID);

return cust;

}


public static void Delete(string customerID)


{

CustomerDataContext context = new CustomerDataContext();

Customer cust = context.Customers.Single(c => c.CustomerID == customerID);

context.Customers.DeleteOnSubmit(cust);

context.SubmitChanges();

}


public static void Update(Customer customer, string customerID)


{

CustomerDataContext context = new CustomerDataContext();


Customer cust = context.Customers.Single(c => c.CustomerID == customer.CustomerID);

cust.CustomerID = customer.CustomerID;

cust.Address = customer.Address;

cust.City = customer.City;

cust.CompanyName = customer.CompanyName;

cust.ContactName = customer.ContactName;

cust.ContactTitle = customer.ContactTitle;

cust.Country = customer.Country;

cust.Fax = customer.Fax;

cust.Phone = customer.Phone;

cust.PostalCode =customer.PostalCode;

cust.Region = customer.Region;

context.SubmitChanges();

}


VB:

 
Public Shared Function ReadItem(ByVal customerID As String) As Customer

Dim context As New CustomerDataContext

Dim cust = (From c In context.Customers _

Where c.CustomerID = customerID _

Select c).Single()

Return cust

End Function

 
Public Shared Function ReadList() As IEnumerable(Of Customer)

Dim context As New CustomerDataContext

Return context.Customers

End Function


Public Shared Function Create(ByVal newCustomer As Customer) As Customer

Dim context As New CustomerDataContext

context.Customers.InsertOnSubmit(newCustomer)

context.SubmitChanges()

Dim cust = (From c In context.Customers _

Where c.CustomerID = newCustomer.CustomerID _

Select c).Single()

Return cust


End Function


Public Shared Sub Delete(ByVal customerID As String)

Dim context As New CustomerDataContext

Dim cust = (From c In context.Customers _

Where c.CustomerID = customerID _

Select c).Single()

context.Customers.DeleteOnSubmit(cust)

context.SubmitChanges()

End Sub


Public Shared Sub Update(ByVal customer As Customer, ByVal customerID As String)

Dim context As New CustomerDataContext

Dim cust = (From c In context.Customers _

Where c.CustomerID = customer.CustomerID _

Select c).Single()

cust.Address = customer.Address

cust.City = customer.City

cust.CompanyName = customer.CompanyName

cust.ContactName = customer.ContactName

cust.ContactTitle = customer.ContactTitle

cust.Country = customer.Country

cust.Fax = customer.Fax

cust.Phone = customer.Phone

cust.PostalCode = customer.PostalCode

cust.Region = customer.Region

context.SubmitChanges()

End Sub
 
Create an external list to test out the BDC Model!
Now we are done! Let’s deploy the solution and create an external list to test it out (Check this blog to see how to create an external list). After the list is created, you will see the following page appears when you click on the list name:




 
 
 
 
 
 
 
 
 
 
 
 
All the data are pulled out to SharePoint successfully, now you can create, delete or edit customer records.
To create a new Customer, find the List Tools->Items->New Item button on the ribbon shown in the following screenshot:

 
 
 
 
 
 
 
 
 
Click on the button, New Item dialog will pop out as below:
 
 

Fill in the dialog and click Save, you will find the item created in the list right away.

To edit or delete the item, just click the down arrow at the right side of CustomerID, all the operations you need are there.




Professional SharePoint 2010 Development (Wrox Programmer to Programmer)