1/31/12

InfoPath 2010 - Sharepoint 2010 Custom Workflow Part 2



Create the Visual Studio Project for the Workflow Solution

Select New Project | Visual C# | .Net Framework 3.5 | Empty Sharepoint Project


Add a new item to the project

Right click on the project name and select Add | New Item - Select C# | Sharepoint 2010 | Sequential Workflow


The Sharepoint Customization Wizard dialog will open, select a name for the new workflow InfoPath_Workflow, Select List Workflow



Note: The site you selected must have a task and workflow history list available for the new workflow or you will receive the following error message. This might occur if you used the blank site template to create the new site.


Select the Sharepoint lists to associate the workflow with



Ensure the workflow starts automatically when a new item is created checkbox is selected and click finish


The workflow designer surface will open in Visual Studio



Select View Toolbox and pin the Toolbox open. Expand the Windows Workflow V3.0 Node

Drag a While Control into the line under the onWorkflowActivated1 shape

Drag a Code Control onto the line under the whileActivity1 shape

Expand the Sharepoint Workflow Node

Drag a OnWorkflowItemChanged activity onto the text Drop and Activity Here inside the whileActivity1 shape



Note: Workflows are stored in a gallery at the Site Collection level so the scope will be Site.

Configure the Workflow Feature

When I added the Sequential Workflow to the project a Sharepoint Feature was added, I'll now configure this Feature. 




I'll start by expanding the features folder and renaming the feature to InfoPathWorkflow. Next I'll double click the Feature name to open the Feature properties. 



I'll change the Feature title in the Title textbox and ensure the Feature scope is set to Site. I'll also verify the the InfoPathWorkflow is listed in the Items in the Feature control.

Verify/Validate the Package

In the Solution Explorer I'll double click on the Package folder.



This will bring up the properties for the package, I'll rename the package and ensure the InfoPathWorkflow is in the Items in the Package control. Next I'll Validate the package and sure there are no warnings or errors with the deployment package.

Select View | Other Windows | Package Explorer



Right click on the package and select Validate



You should see a successful validation in the output window

This completes part 2, in part 3 I'll add the custom code to log any exceptions, allow the custom workflow to start and complete when specific conditions are met and create a new site collection.

1/30/12

InfoPath 2010 - Sharepoint 2010 Custom Workflow Part 1

Workflow is one of the core features in Sharepoint, it is very flexible and very powerful, a handful of workflows are included out of the box but the real power of workflow is in custom workflows. For this example I'm going to create a new sequential list workflow that will create a new site collection when a InfoPath 2010 Form is submitted to a list that is running my custom workflow. The workflow will be initiated upon form submit but will not create a site collection until the site name list field is populated. The custom workflow will be deployed as a site feature.

In Part 2 I'll create a new Visual Studio solution for the custom workflow project, the project will include some exception handling in case any errors occur so I can see the output from the exception(s).

Prior to creating the Visual Studio project the following items need to be in place.

1. A demo Site Collection where the solution will be deployed
2. A customized forms list where I'll attach the workflow

Create the Sharepoint Site and List

First create a new site collection where the workflow will be deployed. Once this is in place create a new list, choose Site Actions - View All Site Content | Create. Select the Issue Tracking list type from the available list templates, for this example I will name the list Issues.

Once the Issues list has been created select the list and from the list tab in the ribbon choose customize form, this will open the form in InfoPath.


All of the default fields are ok for this example but we'll need to add a SiteName field to the form. I'll replace the Issue Status default field with the Site Name that I need for the custom workflow. Select the Issue Status text from the labels in the left column and change the text to Site Name, then select the dropdown to the right and delete this dropdown control.

Next with your cursor still in the area where the Issue Status dropdown control was double click the textbox control on the Home tab of the ribbon on the top of the page. This will add a new textbox control to the form.















The new textbox should be given a value of field1 by default. From the Fields dialog on the right side right click on the field1 property and select field properties.


Enter SiteName in the Display Name and Name properties, select ok.

Next select File and choose Quick Publish to save the changes to the form in Sharepoint.


This completes part 1, in part 2 I'll create the Visual Studio Solution with the custom workflow

1/24/12

Windows Server 2008 R2 - Disable Firewall



I always disable the Windows firewall on all of my development virtual machines, this is a quick and easy way to avoid frustration with connectivity issues.

Here is the command I use to disable the firewall. Open an elevated command prompt ( right click cmd.exe icon and select run as administrator)

netsh advfirewall set allprofiles state off


This will immediately disable all firewall profiles.



12/1/11

C# - Microsoft Word 2010 Automated Mail Merge Part 2 of 2


Back to Part 1


In this example I'll use a more dynamic approach that reads customer data from a SQL database and customizes the query before generating the mail merge.


The ASP.NET application pulls in all of the customer data from from the Northwind database and allows paging and sorting of the data via a Grid View Control. Checkbox controls allow selection of records that will be included in the mail merge. Clicking the Mail Merge button selects all of the checked customers and launches Microsoft Word with all of the customer data pre-populated into the mail merge template (shown below).

Download the Northwind Sample Database - Here
Download the Microsoft Mail Merge Sample Code - Here

First thing I noticed was that Microsoft no longer includes the sample databases with SQL 2008R2, after a couple of searches I found that you can still download them and run scripts or restore the database files.

After I downloaded the sql2000sampleDb.msi I ran the install. Once the install was complete I opened a command prompt and navigated to C:\SQL Server 2000 Sample Databases. Because my SQL server is installed as the default instance I typed sqlcmd -i instpubs.sql to perform the install, I verified that the Northwind database was now installed on my default SQL instance. Note: if you have a non-default SQL instance you can use the following syntax - sqlcmd -S .\InstanceName -i instpubs.sql

I created a new Visual Studio 2010 ASP.NET project, added a new reference to the project by expanding references from the solution explorer and selecting new reference. I selected the COM tab and chose the Microsoft Word 14 reference. This will add 2 new references to the project - Microsoft.Office.Core and Microsoft.Office.Interop.Word. 



This example uses the Microsoft MSDN sample code for the basic mail merge functions.

Add a using statement for the newly added reference as follows:
using Word = Microsoft.Office.Interop.Word;





I cut the first four lines of the Microsoft code and pasted it at the beginning of the class declaration to ensure proper scope for these variables.




Next I Selected the Server Explorer tab and created a connection to my local SQL Server and Northwind database.


I added GridView and button controls to the page

Next I configured the datasource for the Gridview control and selected the Northwind connection string from the dropdown


Next A select * statement is chosen from the Northwind Customers table on the configure the Select Statement screen


This completes the Gridview datasource

Next I added a checkbox control to the Gridview to allow selecting one or more customers. Select the source view of the aspx page and add the following code to the gridview under the columns node.


Back to the design view - double click on the button on the form and add the following code to the  button click event.


The code will iterate through the gridview control and select only the rows that were checked. I built a very simple customer class to hold the data from the selected rows. This can be customized to include any of the fields from the SQL database but for now I'm only including the ID, ContactName and ContactTitle fields. A Generic Dictionary <T> Collection is used to hold the customer objects and this will be passed to  the CreateMailMergeDataFile method.


In the same button click event that you added the snippet above add all of the code in the button1_click event from the MSDN sample code (not all code shown highlighted below)

Next add the remainder of the MSDN sample code into the aspx page just under the public partial class declaration.

Replace the highlighted code in the CreateMailMergeDataFile with the code shown below


Replace highlighted code with this code


I included my project files but you will have to modify the connection string information to your SQL database if it's not on the local machine in the default SQL instance.




C# - Microsoft Word 2010 Automated Mail Merge Part 1 of 2



I was recently tasked with building an add-on for a CRM application to allow the application to integrate with Microsoft Word and generate a mail merge.

I decided to use two examples for demonstrating how to generate the mail merge, the first will be from a Microsoft MSDN code sample and demonstrate a hard coded method of outputting data from my C# application to Microsoft Word.

For the second example, I'll demonstrate a more dynamic approach by connecting to a SQL sample database (Northwind). I'll build an ASP.NET user interface to allow selection and filtering of customers prior to sending the data to Microsoft Word for the mail merge.

Tools
Visual Studio 2010
Microsoft Word 2010
Microsoft SQL Server 2008R2

Part 1
Microsoft Mail Merge Code - Here

Microsoft created some sample code for integrating custom c# applications with Microsoft Word and automating the mail merge, the code provides the mechanism for programmatically generating the mail merge with some inline customer data.

From Visual Studio 2010 I created a new ASP.NET project, the Microsoft code was developed with a Windows Forms application in mind but I ported it into an ASP.NET application. First I added a new reference to the project by expanding references from the solution explorer and selecting new reference. I selected the COM tab and chose the Microsoft Word 14 reference. This will add 2 new references to the project Microsoft.Office.Core and Microsoft.Office.Interop.Word.

Add a using statement for the newly added reference as follows:
using Word = Microsoft.Office.Interop.Word;




I cut the first four lines of the Microsoft code and pasted it at the beginning of the class declaration to ensure proper scope for these variables.


Next I switched to the design view of the default.aspx page in my project and clicked on the toolbox and added a new button to the current page.


Next I double clicked the new button and pasted the remainder of the code from the Microsoft article into the click event handler of the new button.

I built the application with no errors and launched it for a test.

I clicked the button and it looks like everything is working as expected so far, Microsoft Word launches and displays three customer forms that are ready to be printed/mailed.


The standard form data is consistent on all of the user forms and the inline unique customer information is populated into the variable field locations.

This example can be modified to read from a text or csv file or any number of methods that would allow an automated extraction of customer data.


The data can also be kept inline in the code behind as is.

This completes the first example, this example provides a good look into the Word object model and what it takes to programmatically create and manipulate Word objects. Again this is a pretty static and simple method for demonstrating the mail merge. A more advanced approach will be described in Part 2.

Continue to Part 2

11/30/11

Microsoft Sysprep - Which Servers/Roles/Applications include support



This might not be big news to anyone reading this article but I just found out that Microsoft does not support using Sysprep on several of its own products.

I learned this while digging through the Lync 2010 documentation for a project that I'm currently working on. This got me thinking about other things that might not be supported when using Sysprep, until now I thought that as long as you used Sysprep you would not be compromising Microsoft support.

In this article I will try and list the details of what is and isn't supported by Microsoft when it comes to Sysprep. 

Microsoft does not support using Sysprep with Lync 2010, SQL Server 2008 Express and several other products, what does this mean? It means that you can use Sysprep to clone the Windows Operating system as long as you verify that no non-supported roles are enabled prior to cloning (see table below). It means do not have any of the non-supported application's components installed/configured prior to making the clone.

For Server 2008R2 only certain roles of the operating system support using Sysprep, in other words if you are going to clone a 2008 R2 machine, make sure none of the roles listed below that say no are enabled.
Server Role
Sysprep Support
Active Directory Certificate Server (AD CS)
No
Active Directory Domain Services (AD DS)
No
Active Directory Federation Services (AD FS)
No
Active Directory Lightweight Directory Services (AD LDS)
No
Active Directory Rights Management Server (AD RMS)
No
Application Server
Yes
DHCP Server
Yes
DNS Server
No
Fax Server
No
File Services
No
Network Policy and Access Services
No
Network Policy Routing and Remote Access Services
Yes
Print Services
No
Terminal Services
Yes
Not supported in scenarios where the master Windows image is joined to a domain.
UDDI Services
No
Web Server (Internet Information Services)
Yes
Does not support Sysprep with encrypted credentials in applicationhost.config.
Windows Deployment Services
No

Sharepoint 2010 - A Sysprep'd machine can be created with Sharepoint 2010 installed but must be prior to the configuration wizard being run.


SQL Server 2008R2 - There is an MSDN article explaining how to install SQL on a Sysprep'd image - Here

Microsoft Exchange Server - You cannot Sysprep an Exchange machine because of its integration with Active Directory. Recommended method would be to Sysprep the operating system and automate the installation.

Domain ControllersYou cannot deploy preconfigured domain controllers by using image-based installation with Sysprep. However, you can configure a domain controller by first deploying a member server and then automatically running a script that runs Dcpromo.exe, the Active Directory Installation Wizard.

Limited server configuration - According to Microsoft some server components must be installed and configured after an image-based installation with Sysprep is complete. These components include Certificate Services, Cluster service, and any software that is dependent on the Active Directory directory service. They also include any application or service that stores the computer name or the computer SID and cannot recover if the computer name or SID changes.


Security SettingsYou cannot use image-based installation with Sysprep to deploy computers that contain any files that are encrypted by using Encrypting File System (EFS). In addition, you cannot use image-based installation to deploy systems that have already been configured with NTFS security settings, such as file and folder permissions, unless the disk-imaging program supports the NTFS file system. However, you can use a script to configure these settings after the image-based installation is complete.

I usually opt to build fresh virtual machines and not Sysprep because of these kind of incompatibilities and to rule out strange behavior potentially caused by cloning machines.

I'll continue to update this post if I find any other incompatibilities, please feel free to respond if you know of any other incompatible software.

11/9/11

VMWare vCloud Director - Installation and Configuration Part 3



This is part 3 and the final part in a three part blog post, in this first post I'll briefly describe the process of configuring the vCloud Director application. I will also try and describe why vCloud Director is a useful application and what it brings to a development lab.

  1. vCloud Director - Configuration
  2. The Why - Why Clouds, what are the benefits?

vCloud Director Configuration





I won't cover the initial configuration step by step as there are many tutorials already available for establishing the initial vCloud Director configuration. I will point out the important things that will hopefully assist in successfully understanding and configuring your environment.


Steps - perform the following steps from the vDC home tab quick start menu
  1. Attach a vCenter server, the first step is to attach a vCenter server to the vCloud Director environment. The vCenter server must be in an available automated DRS configured cluster with an available resource pool. Note: for each vCenter server that you add to the vCloud Director environment you will first need a vShield Manager server configured and available.
    1. From the vDC home page select step 1 attach a vCenter
    2. Select the correct vCenter server to add to the vDC environment
  2. Create a Provider vDC - a Provider vDC combines the compute and memory resources of a single vCenter server resource pool with the storage resources of one or more datastores connected to that resource pool. A Provider vDC is the source for Organization vDCs (Org vDCs)
    1. From the vDC home page select step 2 create provider vDC
    2. Provide a Name
    3. Select a vCenter and Resource Pool
    4. Add Datastores
    5. Prepare the ESX(i) hosts
    6. Navigate to the Management Monitor tab and verify the ESX(i) hosts were prepared successfully, if you see a red x next to a host an error must have occurred. Note: I had an issue on both of my ESXi hosts where the preparation process was failing, it also affected HA on my vCenter cluster as this configuration would fail and pop an error stating the agent could not be installed. I ended up having to re-run the ESXi install to fix the issue on both hosts, and once HA would configure successfully then the vCloud host prepare finished successfully
    7. Once the Provider vDC has been created it should appear under the selected resource pool in the selected vCenter interface
    8.  
  3. Create external provider networks - a logically separated network based on a vSphere port group. It is the network created by the service provider to allow virtual machines and organizations to access the outside world (Internet). If you want your Organization (and also your vApps) to have connectivity to the external world you need to have External Networks. 
    1. From the vDC home page select step 3 create external network
    2. Choose a vCenter server
    3. Add the network mask, default gateway, DNS information and ip range
    4. Enter a name for the external network
    5. The provider is automatically added to the Provider vDC
  4. Create a network pool - a group of networks that is available for use within an Org vCD to create vApp networks and certain types of organization networks. A network pool is backed by vSphere network resources such as vlan ids, port groups, or cloud isolated networks. vCD uses network pools to create NAT routed and internal organization networks and all vApp networks. Network traffic on each network in a pool is isolated at layer 2 from all other networks. Each Org vCD can have one network pool, multiple Org vCDs can share the same network pool. The network pool for an Org vDC provides the networks created to satisfy the network quota for an Org vDC. There are three different kinds of network pools available within vCD and they are VLAN backed network pools, vCD isolation backed network pools and vSphere port group backed network pools.
    1. From the vDC home page select step 4 create a network pool
    2. Select a Network Pool Type
    3. Select vCenter Server
    4. Configure Pool
    5. Provide a name for the pool
  5. Create an Organization - Organizations provide resources to a group of users and set policies that determine how users can consume those resources. An organization is the fundamental vCD grouping that contains users the vApps that they create and the resources that the vApps use. It is a top level container in a cloud that contains one or more organization virtual datacenters (Org vDC's) and catalog entities.
    1. From the vDC home page select step 5 create and organization
    2. Provide a name
    3. Specify LDAP Settings (if desired) or create local users
    4. Specify if organization can publish its catalogs to other organizations
    5. Configure SMTP if email notifications are desired
    6. Specify leases and quotas (if desired)
    7. Create the Org vDC and specify which Provider vDC it is going to get its resources from
    8. Select an allocation model - example pay as you go
      1. Configure settings for model selected
      2. Specify how much storage is allocated (if desired)
      3. Specify which network pools the Org vDC is connected to
      4. Provide a name and description for Org vDC
  6. Catalog - a container for the following entities vApp templates, vApps, media images (floppy, ISO). Organizations will have their own catalog which they can populate and share with other organizations and users. 
    1. From the vDC home page select step 8 which is add a catalog to an organization
    2. Select the organization to add the catalog too
    3. provide a name for the catalog

The Why - Why Clouds? What are the benefits and why should I care?

"Cloud is all about giving the end-users an unprecedented level of flexibility that allows them to do things that were only available to vSphere administrators before. In a way you can think of vCloud Director as an interface (or a proxy) into the virtual infrastructure. This allows vSphere administrators to give end-users a lot more flexibility, but at the very same time it allows them to keep full control of what end-users can do"


The Virtual DataCenter - much like when you walk into a physical datacenter you will find some resources that you want to connect your virtual machines too. For example you will find network sockets, power sockets, storage resources that you can put your virtual machines on, you might find one or two sockets that state this socket goes to the internet.  Users are now empowered to provision vApps and workloads without having to talk to the IT administrator or the system administrator. They don't have to worry about connecting something to the wrong network or doing something that would require the IT administrator. Its all about Self Service

I'm still trying to understand and wrap my head around the whole vCloud infrastructure and how it changes a typical vSphere environment. vCloud Director provides another layer of abstraction to your environment, it reminds me of what vCenter did to my two ESX(i) hosts. Only vCD does this to vCenter.

What will vCD do to my existing infrastructure? You will go through a process where you surrender some of the resources of the infrastructure to the vCD at which point it will take over those resources and manage them but it will not touch any of the resources that you have left aside. 

I think my next post will be about configuring vCD networking