Lightning Tools Blog

SharePoint Tools, Web Parts and Discussions

Windows Azure tools for SharePoint–announcing Cloud Meta Man

The cloud certainly opens up many possibilities of how your organization can store and use documents, business data and any other type information it needs to run. We’ve been looking at SharePoint Online as part of Office 365 and Windows Azure and can see some exciting possibilities. Of course not all data belongs or will be moved to the cloud, and this is where a hybrid type solution is interesting. The first scenario we looked at was having data stored on premise, while using SharePoint Online – this can be accomplished using the Service Bus component of Azure as we demonstrated with the blog post Mobile Solutions for on Premise Data with Azure Service Bus.

From working on the above blog post we saw how much code has to be written to run on both the on-premise side as well as in the Cloud. Through our code generation work with BCS Meta Man we figured we could do all of the hard work based on the database tables you wanted to work with and create External Content Types around in SharePoint. So we are really happy to announce today an initial beta of something we’ve called Cloud Meta Man. From adding a table to an ADO.NET Entity Framework you can right click and generate:

1, Listener Service that will run on premise and execute calls from the Service Bus and return data

2, Caller Service that you can use to test the Service Bus and your projects are setup correctly

3, An ASP.NET MVC web application that gets the on premise data through the service bus

4, A WCF Service that can present the on premise data to SharePoint Online and be used with an External Content Type through the service bus

5, An Azure project to deploy either/both the ASP.NET MVC application or the WCF Service.

image

 

So within 5 minutes you can get your on-premise business data presented to the outside world through Azure Service Bus and Azure Hosting.

 

In this initial beta of Cloud Meta Man we only support one table or view right now, but the good news is this could be a table in an on premise SQL Server, Oracle or ODBC database.

To get started you can download the Cloud Meta Man beta from here:

Download Cloud Meta Man Beta

And check out the Getting Started Blog post written by Dmitry:

Cloud Meta Man – Getting Started

We are really keen to hear any feedback, ideas and thoughts – please send them through to contact@lightningtools.com

<nick/>

Cloud Meta Man – Getting Started

Cloud Meta Man is our tool that will generate all required code for you that you can easily provide the business data stored away on premise databases usually running behind multiple firewalls or NAT devices. You will be able to use generated WCF service, host it on Windows Azure and easily integrate it with the Business Connectivity Services running in the cloud or on-premise. You will be able to use generated ASP.NET MVC 3 Web Role, host it on Windows Azure and easily display the data returned across the Service Bus on the web page. In this walkthrough using Cloud Meta Man we will create Listener and Caller console applications, ASP.NET MVC 3 Web Role and WCF layer with CRUD operations for on-premise MS SQL database, host the roles on Windows Azure and make the data available on SharePoint page.

  1. Prerequisites
    • Cloud Meta Man version 1.0.0.4 or hire
    • Microsoft SharePoint Server 2010
    • Microsoft Visual Studio 2010 Professional or higher
    • Windows Azure SDK for .NET installed
    • A subscription on Windows Azure
    • We need to create a service bus within Azure.
  2. Login to Windows Azure and click the “Service Bus, Access Control & Caching” on the left pane
    click the “Service Bus, Access Control & Caching”
  3. Then click on the Service Bus node that is displayed in the tree
    click on the Service Bus node
  4. Create a new Service Namespace – type a Namespace name, pick a country and the subscription.
    Create a new Service Namespace
  5. Once the service bus is provisioned click on the service bus name under the Subscription node so you see the properties in the right hand pane
    Service Bus properties
  6. Click on the button to view the Default Key, you’ll need these details shortly
    Default Key
  7. Open Visual Studio 2010
  8. Add a New Project
  9. Select “Visual C#” node, then the “Cloud Meta Man” project type
  10. Give your project a name i.e “CloudMetaMan” and click “OK”

    Give your Cloud Meta Man project a name

  11. In the Solution explorer right-click on the “Data Source Library” node, select “Add”->”New Item”

    Add new ADO.NET Entity Data Model item to the project

  12. Select “Visual C# Items” node, then the “ADO.NET Entity Data Model” item type
  13. Give your item a name i.e “MSSQLModel” and click “Add”

    Give your project item a name

  14. In the “Entity Data Model Wizard” select “Generate from Database” and click “Next”

    Generate the model from database

  15. On the next step click “New Connection” or use existing one

    Create new connection

  16. If you clicked “New Connection”, select for example “Microsoft SQL Server (SqlClient)” and enter required information in order to connect to the database. Click “OK”

    Enter MS SQL connection properties

  17. Now click “Next”

    Choose your created data connection

  18. Select one object you want to include to the model. For example “Department” table and click “Finish”

    Select Department table

  19. Your diagram should look like this

    Created table on the diagram

  20. Expand “BCS Azure” project in the Solution explorer, right-click on “Roles” folder, select “Add”->“Web Role Project in solution”

    Add new Web Role

  21. In the “Associate with Role Project” dialog select “BCS Web Role” and click “OK”

    Add BCS Web Role

  22. Using the same way add "BCS WCF Role"

    Add WCF Web Role

  23. When you add both roles to your BCS Azure project it should look like this

    Added web roles

  24. Expand “Data Source Library” in the Solution explorer, right click on MSSQLModel.edmx-> “Generate projects with Cloud Meta Man”. Based on the table added to the Entity Data Model, Cloud Meta Man will then go and generate a BCS Listener service project, BCS Caller service project, BCS Web Role project and BCS WCF Role project.

    Generate projects with Cloud Meta Man

  25. You will be prompted for Service Namespace Domain(the name you gave the Service Bus instance you created), Issuer Name(the owner) and Issuer Secret(the default key you got once your Service Bus was created). Enter your values and click “OK”. After that the code will be generated.

    Enter Service Bus Namespace Information

  26. So now generated projects can be used to test in order to get data through the configured service bus. Build the solution. Select menu “Build”->”Build solution” in Visual Studio

    Build generated solution

  27. Let’s take mini steps and test things we created.
    • Right click on the “BCS Listener” project and choose Debug -> Start New Instance

      Run BCS Listener

    • Wait for the successfully established connection

      BCS listener connected to the Service Bus

    • Now right click on the “BCS Caller” project and also choose Debug -> Start New Instance
    • Wait for the successfully established connection

      BCS caller connected to the Service Bus

    • In the Caller console window you should press Enter in order to see a list of departments from your database table! This means the Caller program is calling the GetAll_Department_ReadList method over the Service Bus, and the Listener is executing this method and returning the data back across the Service Bus

      the data returned across the Service Bus

    • The “BCS Caller” application has served it's purpose. We can now move forward knowing the service bus is working. By pressing Enter we can close only Caller console window.
    • Now let’s test our Azure application locally on the emulator. Right click on the “BCS Azure” project and choose Debug -> Start New Instance. Two browser instances will be launched.
    • First one (BCS Web Role) shows the data is coming through the Service Bus

      The data on the page returned across the Service Bus

    • Second one (BCS WCF Role) shows an error message “403 - Forbidden: Access is denied”. That is correct

      403 - Forbidden: Access is denied

    • If you add to the URL “BCSService.svc” you will be able to see that WCF service was hosted correctly

      WCF service was hosted locally

  28. Now we are ready to publish to Azure our application. Lets go to do that.
  29. Right click on “BCS Azure” in the solution explorer and choose “Package...”

    Package BCS Azure application

  30. Leave the default options and click the Package button

    BCS Azure package configuration

  31. Open up www.azure.com and log in. Click on “Hosted Services, Storage Accounts & CDN” on the left pane

    Hosted Services

  32. Click on “New Hosted Service” in the ribbon

    Create a new hosted service

  33. Give your hosted service a name, url, pick a region, deployment name - and then browse to the BCS Azure.cspkg and ServiceConfiguration.Cloud.cscfg files that Visual Studio created for you as part of the Packaging process ( \BCS Azure\bin\Release\app.publish)

    New hosted service configuration

  34. The finally click OK. You can accept the warning that is displayed upon clicking OK as this is just a test app, but if it was a real production level app you'd want to take a bit more notice of it.
  35. Upon the Hosted Service being deployed and ready we can start testing it!

    Hosted service deployment

  36. Let’s take mini steps again and test deployed BCS Web Role.
    • Run “BCS Listener” service at the other end of our service bus. Right click the “BCS Listener” project and choose Debug -> Start new instance. Wait for the successfully established connection.

      BCS listener connected to the Service Bus

    • Run the browser on your PC or smartphone and enter the url you gave your application in Azure. Hopefully you will see something similar to below.

      The data on the page returned across the Service Bus

  37. Now let’s fully test BCS WCF Role with SharePoint 2010. Firstly check that our WCF service was hosted correctly in Azure.

    WCF service was hosted on Azure

  38. We need to create the External Content Type with CRUD operations exposed by our WCF Service. In order to do it we may use either SharePoint Designer or BCS Meta Man (you may follow one of these articles SPD External Content Type from WCF , WCF Web Service and BCS Meta Man)
  39. And voila, we now done it. We created an external list in SharePoint 2010 using a WCF service hosted on Azure and talking to on-premise SQL Server through Azure Service Bus.

    On premise external data are available on SharePoint page across the Service Bus

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

<Dmitry Kaloshin/>

Winner of Formula 1 competition Melbourne announced

In February this year we ran a competition to win a pair of tickets for the first Formula 1 race which is being held just a couple of days prior to the SharePoint Conference in Melbourne.

image

Congratulations to Debbie Timmins who won the tickets!

The following questions were answered correctly by Debbie and her name was selected by a random generator.

1. Which team had the fastest pit stop in 2011?

a. Red Bull

b. Mclaren

c. Mercedes

d. Ferrari

2. What is the fastest way to configure a rollup across multiple site collections and web application in your farm?

a. Use the Content Query Web Part

b. Configure the Core Search Results Web Part

c. Develop your own web part

d. Use the Lightning Conductor Web Part

3. What is faster, Rolling up 1,000 announcements from across your Farm with the Lightning Conductor or Red Bulls fastest Pit Stop?

a. Rolling up 1,000 items

b. Red Bulls fastest pit stop

4. What is faster: Michael Schumacher’s fastest lap around Nurburgring or Phill Duffy generating the BCS code to connect to Oracle using BCS Meta Man.

a. Michael Schumachers Fastest Lap

b. Phill Duffy generating code with BCS Meta Man

5. What has the most bugs?

a. Sebastian Vettel’s helmet after 60 laps around Melbourne’s Albert Park on a warm day

b. DeliverPoint Permissions Management

6. A great way to discuss Formula 1 within your organization would be:

a. Hanging around in the canteen on a Monday morning catching up on the F1 gossip

b. Start an email thread to everyone in your company with your thoughts on the days race

c. Post your thoughts on Facebook during work hours

d. Add a post to the Social Squared discussion forum, those who want to read it can.

If you are attending the SharePoint Conference in Melbourne, The Lightning Tools team very much look forward to meeting you there.

<Brett/>

CRM 2011 Online and SharePoint 2010 Integration through Business Connectivity Services

Integrating SharePoint and Microsoft CRM makes sense. Your sales team use CRM as they go about their daily work, but quite often non-sales people still need to be able to access and work with the same data. Although CRM 2011 has become part of the Office 365 package recently, they still run as separate instances in the cloud. Getting the data from CRM 2011 online displayed in SharePoint Online through the Business Connectivity Services is possible but needs a bit of coding and Azure magic. We are going to go through the steps to show you the kind of things involved to get this to happen. The scenario is we want to be able to display 30 days worth of orders in SharePoint Online through the Business Connectivity Services.

This post makes a number of assumptions:

1, You have an Azure account setup and the tools installed with Visual Studio 2010.

2, You know how to deploy a project to Azure

3, You have a CRM 2011 Online account and a SharePoint Online account (may be both are through Office 365)

4, You have downloaded the CRM 2011 SDK

 

Here’s an overview of what we are going to do:

1, Build a WCF Service that can pull data from CRM Online and present it in a BCS friendly manner

2, Run this WCF Service on Azure

3, Use SharePoint Designer 2010 to create an External Content Type that will display CRM data in SharePoint Online.

Generate Early Bound Types for CRM

Crm has a really flexible data model which allows you to add new custom fields to entities such as customers or sales. This also presents the problem that the web services are not strongly typed. There are some web service methods you can call to discover the data structure that is used within CRM, but Microsoft also ships a tool with the CRM SDK that can generate your CRM data model in code so you can use Linq to CRM to get access to your data.

Open a command prompt and move to the bin folder within the CRM SDK. crmsvcutil.exe is the tool we use to generate our code. At the command prompt type:

CrmSvcUtil.exe /url:https://[YourCrmSiteName].crm.dynamics.com/XRMServices/2011/Organization.svc /out:GeneratedCode.cs /username:"[your Live Id]" /password:"[your password]"

These are the parameters you need to use when using CRM 2011 online. If you are using CRM on premise or have any issues running this check out this page for some help:

http://msdn.microsoft.com/en-us/library/gg327844.aspx

Running the command above will generate a file called GeneratedCode.cs that we will add to our project shortly.

Create a WCF Azure Service

1, Open up Visual Studio 2010 and choose to Create a new Cloud –> Windows Azure Project called something like CrmBcsWcfLayer (see how many acronyms I can fit into a project name! Smile)

2, Select the WCF Service Web Role from the Azure project types available and once moved across to the right pane hover your mouse over it to rename it to something sensible

3, First thing we can do is add our GeneratedCode.cs file from earlier into our WCF project. This file is generated in the same directory where you ran the crmsvcutil tool.

4, Now we need to add some assembles from the CRM SDK. In the bin folder of the SDK select:

microsoft.xrm.sdk

Also add a reference to:

System.Security

5, To help us authenticate and run code against CRM Online we want to make use of a helper class from the CRM SDK. Add an existing item to your project and find \{YOUR CRM SDK}\sdk\samplecode\cs\helpercode\deviceidmanager.cs

6, Open up IService.cs and delete the CompositeType class. The SalesOrder CRM object has many fields, but we only want to return a small subset. We will therefore define our own class that contains this subset of fields

[DataContract]
public class BcsSalesOrder
{
    [DataMember]
    public Guid SalesOrderId { get; set; }

    [DataMember]
    public decimal TotalAmount { get; set; }

    [DataMember]
    public string CustomerName { get; set; }

    [DataMember]
    public DateTime OrderDate { get; set; }
}

7, Still in IService.cs, delete the two old operation contracts from there. Add in the following interface

[OperationContract]
IEnumerable<BcsSalesOrder> GetRecentOrders();
        

8, Right click on Service1.svc and chose View Code. Clear out the GetData and GetDataUsingDataContract method.

9, We’re going to add some code to help us Authenticate against CRM. This code is taken from samples in the CRM ask so I can’t take any credit for it! Within the Service1 class paste in:

/// <summary>
/// Obtain the AuthenticationCredentials based on AuthenticationProviderType.
/// </summary>
/// <param name="endpointType">An AuthenticationProviderType of the CRM environment.</param>
/// <returns>Get filled credentials.</returns>
private AuthenticationCredentials GetCredentials(AuthenticationProviderType endpointType)
{

    AuthenticationCredentials authCredentials = new AuthenticationCredentials();
    switch (endpointType)
    {
        case AuthenticationProviderType.ActiveDirectory:
            authCredentials.ClientCredentials.Windows.ClientCredential =
                new System.Net.NetworkCredential(_userName,
                    _password,
                    _domain);
            break;
        case AuthenticationProviderType.LiveId:
            authCredentials.ClientCredentials.UserName.UserName = _userName;
            authCredentials.ClientCredentials.UserName.Password = _password;
            authCredentials.SupportingCredentials = new AuthenticationCredentials();
            authCredentials.SupportingCredentials.ClientCredentials =
                Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();
            break;
        default: // For Federated and OnlineFederated environments.                    
            authCredentials.ClientCredentials.UserName.UserName = _userName;
            authCredentials.ClientCredentials.UserName.Password = _password;
            // For OnlineFederated single-sign on, you could just use current UserPrincipalName instead of passing user name and password.
            // authCredentials.UserPrincipalName = UserPrincipal.Current.UserPrincipalName;  //Windows/Kerberos
            break;
    }

    return authCredentials;
}

/// <summary>
/// Discovers the organizations that the calling user belongs to.
/// </summary>
/// <param name="service">A Discovery service proxy instance.</param>
/// <returns>Array containing detailed information on each organization that 
/// the user belongs to.</returns>
public OrganizationDetailCollection DiscoverOrganizations(
    IDiscoveryService service)
{
    if (service == null) throw new ArgumentNullException("service");
    RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
    RetrieveOrganizationsResponse orgResponse =
        (RetrieveOrganizationsResponse)service.Execute(orgRequest);

    return orgResponse.Details;
}

/// <summary>
/// Finds a specific organization detail in the array of organization details
/// returned from the Discovery service.
/// </summary>
/// <param name="orgFriendlyName">The friendly name of the organization to find.</param>
/// <param name="orgDetails">Array of organization detail object returned from the discovery service.</param>
/// <returns>Organization details or null if the organization was not found.</returns>
/// <seealso cref="DiscoveryOrganizations"/>
public OrganizationDetail FindOrganization(string orgFriendlyName,
    OrganizationDetail[] orgDetails)
{
    if (String.IsNullOrWhiteSpace(orgFriendlyName))
        throw new ArgumentNullException("orgFriendlyName");
    if (orgDetails == null)
        throw new ArgumentNullException("orgDetails");
    OrganizationDetail orgDetail = null;

    foreach (OrganizationDetail detail in orgDetails)
    {
        if (String.Compare(detail.FriendlyName, orgFriendlyName,
            StringComparison.InvariantCultureIgnoreCase) == 0)
        {
            orgDetail = detail;
            break;
        }
    }
    return orgDetail;
}

/// <summary>
/// Generic method to obtain discovery/organization service proxy instance.
/// </summary>
/// <typeparam name="TService">
/// Set IDiscoveryService or IOrganizationService type to request respective service proxy instance.
/// </typeparam>
/// <typeparam name="TProxy">
/// Set the return type to either DiscoveryServiceProxy or OrganizationServiceProxy type based on TService type.
/// </typeparam>
/// <param name="serviceManagement">An instance of IServiceManagement</param>
/// <param name="authCredentials">The user's Microsoft Dynamics CRM logon credentials.</param>
/// <returns></returns>
private TProxy GetProxy<TService, TProxy>(
    IServiceManagement<TService> serviceManagement,
    AuthenticationCredentials authCredentials)
    where TService : class
    where TProxy : ServiceProxy<TService>
{
    Type classType = typeof(TProxy);

    if (serviceManagement.AuthenticationType !=
        AuthenticationProviderType.ActiveDirectory)
    {
        AuthenticationCredentials tokenCredentials =
            serviceManagement.Authenticate(authCredentials);
        // Obtain discovery/organization service proxy for Federated, LiveId and OnlineFederated environments. 
        // Instantiate a new class of type using the 2 parameter constructor of type IServiceManagement and SecurityTokenResponse.
        return (TProxy)classType
            .GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(SecurityTokenResponse) })
            .Invoke(new object[] { serviceManagement, tokenCredentials.SecurityTokenResponse });
    }

    // Obtain discovery/organization service proxy for ActiveDirectory environment.
    // Instantiate a new class of type using the 2 parameter constructor of type IServiceManagement and ClientCredentials.
    return (TProxy)classType
        .GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(ClientCredentials) })
        .Invoke(new object[] { serviceManagement, authCredentials.ClientCredentials });
}

 

You’ll need to resolve some references once you paste this code in.

10, In Service1.svc we need to add a few class variables that we’ll set…

private String _discoveryServiceAddress = "https://dev.crm.dynamics.com/XRMServices/2011/Discovery.svc";
private String _organizationUniqueName = "";
// Provide your user name and password.
private String _userName = "Live Id";
private String _password = "Password";

// Provide domain name for the On-Premises org.
private String _domain = "mydomain";

Set the values for your Organization name, and the Live Id and password you want to connect as.

11, Add in the method that was defined in our interface:

public IEnumerable<BcsSalesOrder> GetRecentOrders()
{

}

12, Add in the following code to this method:

List<BcsSalesOrder> orders = new List<BcsSalesOrder>();

IServiceManagement<IDiscoveryService> serviceManagement =
            ServiceConfigurationFactory.CreateManagement<IDiscoveryService>(
            new Uri(_discoveryServiceAddress));
AuthenticationProviderType endpointType = serviceManagement.AuthenticationType;

// Set the credentials.
AuthenticationCredentials authCredentials = GetCredentials(endpointType);


String organizationUri = String.Empty;
// Get the discovery service proxy.
using (DiscoveryServiceProxy discoveryProxy =
    GetProxy<IDiscoveryService, DiscoveryServiceProxy>(serviceManagement, authCredentials))
{
    // Obtain organization information from the Discovery service. 
    if (discoveryProxy != null)
    {
        // Obtain information about the organizations that the system user belongs to.
        OrganizationDetailCollection orgs = DiscoverOrganizations(discoveryProxy);
        // Obtains the Web address (Uri) of the target organization.
        organizationUri = FindOrganization(_organizationUniqueName,
            orgs.ToArray()).Endpoints[EndpointType.OrganizationService];

    }
}


if (!String.IsNullOrWhiteSpace(organizationUri))
{
    IServiceManagement<IOrganizationService> orgServiceManagement =
        ServiceConfigurationFactory.CreateManagement<IOrganizationService>(
        new Uri(organizationUri));

    // Set the credentials.
    AuthenticationCredentials credentials = GetCredentials(endpointType);

    // Get the organization service proxy.
    using (OrganizationServiceProxy organizationProxy =
        GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceManagement, credentials))
    {
        // This statement is required to enable early-bound type support.
        organizationProxy.EnableProxyTypes();

        var service = (IOrganizationService)organizationProxy;
        OrganizationServiceContext orgContext = new OrganizationServiceContext(service);

        IEnumerable<SalesOrder> crmOrders = from s in orgContext.CreateQuery<SalesOrder>()
                                            where s.DateFulfilled.Value > DateTime.Now.AddMonths(-1)
                                            select s;

        foreach (var salesOrder in crmOrders)
        {
                        
            var bcsOrder = new BcsSalesOrder();
            bcsOrder.SalesOrderId = (Guid)salesOrder.SalesOrderId;
            bcsOrder.CustomerName = salesOrder.CustomerId.Name;
            bcsOrder.OrderDate = Convert.ToDateTime(salesOrder.DateFulfilled);
            bcsOrder.TotalAmount = salesOrder.TotalAmount.Value;

            orders.Add(bcsOrder);
        }

    }
}

return orders;

13, We can now test our WCF service to make sure it can return some data from CRM Online. Press F5 in Visual Studio and once the browser opens copy out the url from the address bar. Then open a Visual Studio command prompt from the start menu and type wcftestclient.

14, Once the WCF Test Client opens up go File –> Add a Service, and paste in your url

15, Click on the GetThisMonthsOrders from the tree view in the right Window and then click the Invoke button. This will try to execute your WCF method and if successful you should see data returned in the bottom window:

SNAGHTML41c7e1

If you get an error returned, you should be able to step through the code in Visual Studio and fix it. If you do not get any data returned, make sure you have some orders in CRM that have been fulfilled in the last month.

16, Now we can deploy this to Azure. Right click on the Azure project in Visual Studio and click Package

image

You will notice when you do this you get a warning about Microsoft.IdentityModel.dll being required. This is because microsoft.xrm.sdk has a dependancy on it. Follow the instructions in the Output console to add it as a reference to your project and also set it to ‘copy local’

17, Once the Service Package file and Cloud Service Configuration File have been produced you can deploy this to Azure.

18, Once your project has been deployed it is always a good thing to test it with the WcfTestClient again.

Getting the data into SharePoint Online

1, If you are at this stage then great! We can now get our data displaying in SharePoint Online. Open up SharePoint Designer and connect to your SharePoint Online site

2, Click on the External Content Types button in the Site Objects listing

image

3, Click the button in the ribbon to create a new External Content Type

4, Give your External Content Type a nice name such as Orders, and then click on the link to use the Operation Designer:

image

5, Click the button to ‘Add a connection’ and choose the type to be WCF Service

6, When viewing your service1.svc file running on Azure, you should see a link to the wsdl file. It’s basically the same as service1.svc but with ?wsdl on the end. Copy the whole url out and paste it into the Service Metadata Url field in SPD

7, Put the normal service1.svc full url into Service Endpoint URL, and you can then click OK:

SNAGHTML941779

8, With the Service Endpoint now displayed in the SPD connection manager, expand the tree so you can see the method we created and right click on it. Choose ‘New Read List Operation’ and step through the wizard. You do not actually need to change anything in the steps to get our simple example working except on the third screen select SalesOrderId as the Identifier for this ECT

image

9, Once the Operation Designer wizard has finished, click the Save button in the top left of SPD and your External Content Type will be created!

10, The final step! Woot! Log on to SharePoint Online and add a Business Data List web part to the page. Configure it to use your Orders External Content Type:

image

11, Click OK in the web part properties, and you should see Orders from your CRM system from the last 30 days (that the CRM users credentials you used in your WCF service have permission to see)

image

 

Authentication

You should be asking yourself right now – but this WCF web service is publically available and so anyone could call it and see my CRM data – and you are completely correct. As a ‘how-to’ article we are leaving things here, but if you were to be following this and using it as a basis for moving something into production you definitely need to consider how you will secure the WCF end point so only SharePoint Online and the BCS can call it. Steve Fox has a good blog post and a link to a lab to go through the different options around this, this should definitely be your next step:

SharePoint Online and Windows Azure: Developing Secure BCS Connections using WCF Services

Conclusion

Hopefully this post has given you a good introduction of the steps needed to get data from CRM 2011 Online displayed in SharePoint Online through the Business Connectivity Services. There are a few steps required to get this working, but the good news is we are working on some tools and services to make this a whole lot easier. If you’d like more information on these tools and be an early beta tester please drop me an email : nick@lightningtools.com

<nick/>

Social Squared version 6.1 release

Social Squared 6.1 has been released

A new version of Social Squared has been released with a couple of bug fixes and a few nice new features to kick start February

Click here to download Social Squared.

What’s new?

Email Digest

In the latest release of Social Squared users have the ability to sign up for digest emails to notify them of changes inside of the forums. It was always possible to have an email alert to come through when someone replies or a new topic is created but now it is possible to daily or weekly notifications instead!
clip_image002
The emails come through with a nice listing of what has changed
clip_image004

Email Timer Job Log

It is now easier to view information from the time job log via Site Settings. Any issues with sending or receiving emails to the Social Squared forums can be easily identified. If you want a reminder of what you can do with Social Squared and email check out the short video from Nick Swan here: http://lightningtools.com/blog/archive/2011/01/27/social-squaredndashreply-via-email.aspx

Search Forum Group

It is possible to now restrict searches using the Social Squared search to just the current forum group making it easier to find the content you want.

Next Version

We’re working really hard behind the scenes here at Lightning Tools to bring some great new improvements to Social Squared version 7! As soon as we can we will make details of these exciting additions available on our blog

If you have any feedback send it through to contact@lightningtools.com and I will see what you have to say!

Click here to download Social Squared.

 

<Phill />

Using Twilio with SharePoint to send SMS messages

Twilio is a Software as a Service platform that you can use when you want to integrate voice or SMS text messages into your applications. There are a few instances where this could be interesting for SharePoint such as sending SMS messages when certain things happen in SharePoint either through event handlers or workflows. Let’s see how we can easily register for an account, setup a number and start getting SharePoint sending SMS messages using an Event Handler!

1, Visit www.twilio.com and click Try Twilio button – the good news is at the time of writing you get $30 of credit to try Twilio out!

2, Once logged in click on the ‘Upgrade Now’ link to add a credit card to your Twilio account and add a small amount, say $20. You can’t purchase a phone number to send messages from with the trial account (you still get $30 free though once you upgrade)

3, Once upgraded, click Numbers from the main menu and then the ‘Buy a new Twilio Number’ link.

4, You can put in an area code if you like for your number to be based off, or if like me you are in the UK just press search and it will give you numbers to chose from with a London area code

Buy a Twilio number

[click the images for a larger view]

5, Find the number you like the look of, and click the ‘Buy’ button to grab it!

6, We need to get our AccountId and Password to use later on in our code. Click on the Dashboard link in Twilio. At the top you’ll see your AccountId, and if you click the padlock to the right your account password will also be displayed. Copy these down for later…

Get your Twilio account details

7, The Twilio rest API all runs under https which is a good thing, but means a little extra configuration if you want to use it with SharePoint 2010. We’ll need to do an extra step of uploading the client certificate to SharePoint 2010 for SharePoint to trust the url. Open the following url in Firefox:

https://api.twilio.com/2010-04-01

8, Click on the Twilio icon in the address bar that indicates the certificate for this url is trusted

Click the Twilio icon in Firefox

9, In the panel that opens up click on the ‘More Information’ button:

Click the More Information button

10, In the Page Information window that opens up click on ‘View Certificate’

11, In the certificate viewer window move to the details tab, and then click the top line in the ‘Certificate Hierarchy’ window and then click the ‘Export’ button. This should allow you to save the certificate.

Export the Twilio certificate

12, Now we can add the certificate to SharePoint 2010. Open up Central Administration, Click on the Security Link and then ‘Manage Trust’.

13, Click on the New button in the ribbon and a dialog form will pop up. Give the trust relationship a name of Twilio and browse to the certificate file you downloaded in step 10. Finally click on OK.

In Central Administration add the certificate

14, Hurrah – now we can start writing some code. Open up Visual Studio 2010 and create a new SharePoint 2010 Event Receiver project.

Create a new SharePoint Event Receiver project

15, In the proceeding windows that show as part of creating your Visual Studio project chose to deploy it as a Farm Solution.

16, When setting up the event receiver, pick List Item Events, the Announcement list type and finally the ‘An item was added’ event type – then click Finish

Connect to the announcement list and the added event

17, Open EventReceiver1.cs and paste in the following code:

private string CreateFormattedPostRequest(Dictionary<string, string> values)
{
    var paramterBuilder = new StringBuilder();
    var counter = 0;
    foreach (var value in values)
    {
        paramterBuilder.AppendFormat("{0}={1}", value.Key, HttpUtility.UrlEncode(value.Value));

        if (counter != values.Count - 1)
        {
            paramterBuilder.Append("&");
        }

        counter++;
    }

    return paramterBuilder.ToString();
}

private HttpWebRequest CreateWebRequest(string endPoint, Int32 contentLength)
{
    var request = (HttpWebRequest)WebRequest.Create(endPoint);

    request.Method = "POST";
    request.ContentLength = contentLength;
    request.ContentType = "application/x-www-form-urlencoded";

    return request;
}  

These two small helper methods will help us format out rest requests to the Twilio rest web service. Thanks to Derik for these two sections of code…

18, Add the following code to your ItemAdded method

string accountId = "";
string password = "";
string from = "";
string to = "";

string title = properties.ListItem["Title"].ToString();

string endPoint = string.Format("https://api.twilio.com/2010-04-01/Accounts/{0}/SMS/Messages.xml", accountId);


Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("From", from);
parameters.Add("To", to);
parameters.Add("Body", title);

var populatedEndPoint = CreateFormattedPostRequest(parameters);
byte[] bytes = Encoding.UTF8.GetBytes(populatedEndPoint);

HttpWebRequest request = CreateWebRequest(endPoint, bytes.Length);

request.Credentials = new NetworkCredential(accountId, password);

using (var requestStream = request.GetRequestStream())
{
    requestStream.Write(bytes, 0, bytes.Length);
}

using (var response = (HttpWebResponse)request.GetResponse())
{
    if (response.StatusCode != HttpStatusCode.Created)
    {
        string message = String.Format("POST failed. Received HTTP {0}", response.StatusCode);
        throw new ApplicationException(message);
    }
}

base.ItemAdded(properties);

Set the values of accountId and password to the values we got in step 6. The value for ‘from’ should be the number you bought at Twilio, and the ‘to’ value is the number you want to send an SMS to.

19, Tada – we are good to go. Press F5 and Visual Studio will compile and deploy your event receiver to SharePoint. If you do not have an Announcements list at the site Visual Studio opens up simply create one. Then go ahead and add an announcement and wait for the SMS text message to come through! Woot!

 

Hopefully this has given you a taster to see how easy it is to use Twilio to send SMS text messages from SharePoint. If you have any other ideas how this service would be useful with SharePoint leave them in the comments!

<nickswan/>

Mobile solutions for on premise data with Azure Service Bus

Note: I’m learning about Azure and Mobile Web App development as I go along. If you see any mistakes or better ways of doing things please drop me an email : nick@lightningtools.com

With more people becoming mobile workers, or working from home - business data that is stored away in on premise databases needs to be set free for people to use wherever they are, on whatever device they like. Accomplishing this can be a challenge for any size organization, opening firewall ports, active directory federated services, WCF service endpoints etc...

Setting the data free

If you have an on premise data source that you want to make available to mobile workers you do have a number of options:

1, SharePoint 2010, BCS + SharePoint Workspace
This is good for users who may not always have Internet connectivity as they can work offline and resync

2, Present the data to the outside world through a WCF service hosted on premise.
This does mean exposing parts of the network to the outside world and needing to manage authentication to the WCF service. Certainly not impossible, but it does present challenges and risks.

3, Using bits and pieces now available in Windows Azure
Using the Service Bus, we can expose the data through the firewall without needing to open up any extra ports. The authentication and security is managed through Azure Service Bus and ACS.

I'm presuming we are working with a business that does not want to configure and setup ADFSv2. With many companies these days allowing employees to buy and use their own mobile or tablet devices managing these internally becomes a challenge.

The actual data presentation solution will be an ASP.NET MVC web application running on Windows Azure. We'll use the jQueryMobile javascript library to present the data in a nice mobile looking way. This saves us having to build separate mobile applications for iPhone, Windows Phone, Android etc... Also having it as a web application allows us to easily rollout changes rather than expecting users to manually upgrade a native application.

We'll use a simple example. In our company we have a product stock control system, and our people on the road need to be able to check the stock levels before placing an order. Working with a simple Products table:

ProductId - int, primary key
Name - varchar(256)
Price – money
StockLevel - int

We will use the Azure Service Bus to allow on premise data to be made available to the outside world. The Service Bus has 2 endpoints. The Listener endpoints will sit inside the organization, constantly running and listening for calls to execute methods that return data. The second component is a caller application, that calls the Listener methods over the service bus. The service bus makes sure the connection between the caller and listener are secure.

Assumption : this walk through assumes you already have an Azure account up and running, with the necessary Azure SDK's and tools installed. To get an account setup and download the tools you need visit www.azure.com

 

Configure the Service Bus

1, Log in to www.azure.com and click the Manage button to open up the management portal.

2, Once in the management portal, click on the 'Service Bus, Access Control & Caching' tab

3, Click on the 'New' button within the 'Service Namespace' section

4, Give the new service bus you want to create a name, such as MobileProducts and select a location for the ServiceBus to run that makes sense geographically

5, Once your Service Bus is successfully created, click on the MobileProducts name in the list of buses available. This will display a list of properties down the right side.

6, Click on the 'View' button in the 'Default Key' section. Listed in the pop up you shall see the Default Issuer and Default Key that you will need shortly.

Create a Model project

1, Open Visual Studio 2010 and create a new blank solution called MobileProducts. Add a new Class Library project to the solution called MobileProducts.Model. The target Framework should be .NET 4.0

The Listener and Calling projects need to understand what object is being passed over the service bus, so it makes sense to create a project where you will define all these objects in classes in a central place where they can be referenced.

2, Add a reference to System.Runtime.Serialization

3, Rename the existing Class1.cs file to Product.cs, and amend/add the following attributes and properties to the class:

[DataContract]
public class Product
{
    [DataMember]
    public int ProductId { get; set; }
       
    [DataMember]
    public string Name { get; set; }
       
    [DataMember]
    public decimal Price { get; set; }
       
    [DataMember]
    public int StockLevel { get; set; }

}

I’m not going to list the using references you should add at the top of your code. If you get red squiggly lines when compiling, put your cursor on the code in question and do ctrl + . and Visual Studio will assist you in adding the necessary using references.

Creating the Listener project

1, Add a new Console application to the Visual Studio Solution called MobileProducts.Listener.

2, Ensure the project type is .NET Framework 4.0 (rather than .NET 4.0 client profile)

3, Add a reference to our local project MobileProducts.Model.

4, Add references to the necessary Azure libraries we will be using. There are:

System.ServiceModel.dll - this can be found from the standard .NET reference list

Microsoft.ServiceBus.dll - you'll need to browse to C:\Program Files\Windows Azure SDK\v1.6\ServiceBus\ref\Microsoft.ServiceBus.dll to find it.

5, Add a Linq 2 SQL class to the project and call it Database.dbml, add the Products table from the simple database you setup and created earlier.

6, We want to create a method that can be called over the Service Bus that returns a list of products. We'll use a contract/interface so add an interface class to your project called IGetData.cs and ensure it has the following code added:

 

[ServiceContract(Name = "MobileProductsContract", Namespace = "http://MobileProductsContract")]
public interface IGetData
{
    [OperationContract]
    IEnumerable<MobileProducts.Model.Product> GetProducts();

    [OperationContract]
    MobileProducts.Model.Product GetProductById(int Id);
}

7, Next we can add a class that implements this contract, add a class to the project called GetData.cs and implement the following code...

[ServiceBehavior(Name = "MobileProductsContract", Namespace = "http://MobileProductsContract")]
public class GetData : IGetData
{
    public IEnumerable<MobileProducts.Model.Product> GetProducts()
    {
        DatabaseDataContext db = new DatabaseDataContext();
        IEnumerable<MobileProducts.Model.Product> products = from p in db.Products
                                                             select new MobileProducts.Model.Product
                                                             {
                                                                 Name = p.Name,
                                                                 Price = p.Price,
                                                                 ProductId = p.ProductId,
                                                                 StockLevel = p.StockLevel
                                                             };

        return products;
    }

    public MobileProducts.Model.Product GetProductById(int Id)
    {
        DatabaseDataContext db = new DatabaseDataContext();
        var product = db.Products.SingleOrDefault(p => p.ProductId == Id);

        return new MobileProducts.Model.Product
                            { Name = product.Name,
                              Price = product.Price,
                              ProductId = product.ProductId,
                              StockLevel = product.StockLevel
                            };
    }
}

8, In App.Config we need to describe the bindings we want to use, add the following just beneath the connection strings elements:

<system.serviceModel>
    <services>
      <service name="MobileProducts.Listener.GetData">
        <endpoint contract="MobileProducts.Listener.IGetData" binding="netTcpRelayBinding" />
      </service>
    </services>
    <extensions>
      <bindingExtensions>
        <add name="netTcpRelayBinding" type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </bindingExtensions>
    </extensions>
  </system.serviceModel>

9, We can now write the code in Program.cs to connect to our service bus and start listening for calls to execute methods...add this code within the Main method:

Console.Title = "Mobile Products Listener Service";

string nsDmn = "";
string issrName = "";
string issrSecret = "";

Uri address = ServiceBusEnvironment.CreateServiceUri("sb", nsDmn, "MobileProducts");

TransportClientEndpointBehavior sharedCreds = new TransportClientEndpointBehavior();
sharedCreds.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issrName, issrSecret);

try
{
    ServiceHost serviceHost = new ServiceHost(typeof(GetData), address);
    IEndpointBehavior serviceRegSettings = new ServiceRegistrySettings(DiscoveryType.Public);
    foreach (ServiceEndpoint serviceEndpoint in serviceHost.Description.Endpoints)
    {
        serviceEndpoint.Behaviors.Add(sharedCreds);
    }

    serviceHost.Open();

    Console.WriteLine("Service Information: " + address);
    Console.WriteLine("Hit [Enter] to exit application...");
    Console.ReadLine();

}
catch (Exception ex)
{
    Console.WriteLine(ex.ToString());
    Console.ReadLine();
}

10, Set the following variables:

nsDmn = the name you gave the Service Bus instance you created

issrName = the owner

issrSecret = the default key you got once your Service Bus was created

 

Create a test Caller project

It's always good to take mini steps and test things a we go along. Eventually our caller project will be the ASP.NET MVC web application, but initially lets create another console application that will act as a caller. If we get any issues it will be much easier to debug each time, make sure we have the Service Bus component working, and then move onto the next stage of building a mobile web app.

1, Add a new console application to your solution called MobileProducts.Caller.

2, Change the project from .Net 4.0 Client Profile to standard .Net Framework 4.0 again.

3, Add a reference to our local project dll, MobileProduct.Model and also Microsoft.ServiceBus and System.ServiceModel

4, We want to define the contract again, so our program understands the method it will be calling over the Service Bus and the data it will be getting back. Add an interface class to the project called IGetData and add the same code as when we created the contract for our Listener class

[ServiceContract(Name = "MobileProductsContract", Namespace = "http://MobileProductsContract")]
public interface IGetData
{
    [OperationContract]
    IEnumerable<Product> GetProducts();

    [OperationContract]
    Product GetProductById(int Id);
}

5, Add an application configuration (app.config) file to the project and add the following service model definition:

  <system.serviceModel>
    <client>
      <endpoint name="RelayEndpoint" contract="MobileProducts.Caller.IGetData" binding="netTcpRelayBinding" />
    </client>
    <extensions>
      <bindingExtensions>
        <add name="netTcpRelayBinding" type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </bindingExtensions>
    </extensions>
  </system.serviceModel>

6, Add the following code to the Main method of Program.cs

Console.Title = "Mobile Products Test Caller";

string nsDmn = "";
string issrName = "";
string issrSecret = "";

Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", nsDmn, "MobileProducts");

TransportClientEndpointBehavior sharedCreds = new TransportClientEndpointBehavior();
sharedCreds.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issrName, issrSecret);

ChannelFactory<IGetData> channelFactory = new ChannelFactory<IGetData>("RelayEndpoint", new EndpointAddress(serviceUri));

channelFactory.Endpoint.Behaviors.Add(sharedCreds);

IGetData channel = channelFactory.CreateChannel();

((ICommunicationObject)channel).Open();

try
{
    IEnumerable<MobileProducts.Model.Product> products = channel.GetProducts();
    foreach (var product in products)
    {
        Console.WriteLine(product.Name);
    }
}
catch (Exception ex)
{
    Console.WriteLine(ex.ToString());
}

((ICommunicationObject)channel).Close();
channelFactory.Close();

Console.WriteLine("Press [Enter] to continue...");
Console.ReadLine();

7, As with the Listener project, set the same values for nsDmn, issrName and issrSecret.

8, Assuming you have some products created in your database table, you can now try the Service Bus out!

First right click on the MobileProducts.Listener project and choose Debug -> Start New Instance

Azure Service Bus Listener Application

Wait for the Service Information to be displayed in the console window

9, Now right click on the MobileProducts.Caller project and also choose Debug -> Start New Instance

Azure Service Bus Caller Application

In the Caller console window you should see a list of product names from your database table! Woot Woot! This means the Caller program is calling the GetData method over the Service Bus, and the Listener is executing this method and returning the data back across the Bus. Pretty awesome!

The MobileProducts.Caller application has served its purpose. We can now move forward knowing the service bus is working and look at building a mobile application to surface our data.

 

Create a mobile web app

Now that we know our Service Bus is setup and working through using the Listener and Caller projects we built, we can move forward and build a Mobile Web Application. We might as well host this in Windows Azure as well.

1, Right click on the Solution in Visual Studio and choose to Add -> New Project

2, From the Cloud section pick the Windows Azure Project and call it MobileProducts.Azure

3, When presented with the list of Azure Projects to create, move the ASP.NET MVC 3 Web Role over.

4, Right click on the project when it is in the right hand pane and choose 'Rename'. Give it a new name of MobileProducts.WebApp

5, In the ASP.NET MVC 3 new project dialog use the Empty project template, ensure Razor is selected as the view engine, and tick the box for using HTML 5 semantic markup

6, Lets do the backend work first and get our web application able to talk to the Service Bus. Add a reference to our local project MobileProducts.Model. Also add a reference to Microsoft.ServiceBus and System.ServiceModel. You should be able to easily pick these from the Recent tab in the 'Add Reference...' dialogue.

7, In solution explorer, right click on the Models folder in your MVC web app and add a new interface class called IGetData. Add the same code that we previously have done for this interface class:

[ServiceContract(Name = "MobileProductsContract", Namespace = "http://MobileProductsContract")]
public interface IGetData
{
    [OperationContract]
    IEnumerable<Product> GetProducts();

    [OperationContract]
    Product GetProductById(int Id);
}

8, Right click on the Models folder and choose to add a new class. Give the class a name of ProductWorker.cs

9, In the class add the following static methods:

public static IEnumerable<Product> GetProducts()
{
    string nsDmn = "";
    string issrName = "";
    string issrSecret = "";

    Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", nsDmn, "MobileProducts");

    TransportClientEndpointBehavior sharedCreds = new TransportClientEndpointBehavior();
    sharedCreds.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issrName, issrSecret);

    ChannelFactory<IGetData> channelFactory = new ChannelFactory<IGetData>("RelayEndpoint", new EndpointAddress(serviceUri));

    channelFactory.Endpoint.Behaviors.Add(sharedCreds);

    IGetData channel = channelFactory.CreateChannel();

    ((ICommunicationObject)channel).Open();

    return channel.GetProducts();
}

public static Product GetProductById(int Id)
{
    string nsDmn = "";
    string issrName = "";
    string issrSecret = "";

    Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", nsDmn, "MobileProducts");

    TransportClientEndpointBehavior sharedCreds = new TransportClientEndpointBehavior();
    sharedCreds.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issrName, issrSecret);

    ChannelFactory<IGetData> channelFactory = new ChannelFactory<IGetData>("RelayEndpoint", new EndpointAddress(serviceUri));

    channelFactory.Endpoint.Behaviors.Add(sharedCreds);

    IGetData channel = channelFactory.CreateChannel();

    ((ICommunicationObject)channel).Open();

    return channel.GetProductById(Id);
}

10, In the Views folder, right click and add a new folder called Home. Right click the Home folder and add a View called Index, and then add a View called Product

11, Right click the Controllers folder and add a new Controller called 'HomeController' created using the 'Empty controller' template

12, In HomeController.cs amend the code to look like this:

public ActionResult Index()
{
    return View(ProductWorker.GetProducts());
}

public ActionResult Product(int Id)
{
    return View(ProductWorker.GetProductById(Id));
}

13, Open up web.config and paste in the following XML fragment just after the opening <Configuration>

 

<system.serviceModel>
    <client>
      <endpoint name="RelayEndpoint" contract="MobileProducts.WebApp.IGetData" binding="netTcpRelayBinding" />
    </client>
    <extensions>
      <bindingExtensions>
        <add name="netTcpRelayBinding" type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </bindingExtensions>
    </extensions>
  </system.serviceModel>

14, Open up Index.cshtml and paste in the following:

@model IEnumerable<MobileProducts.Model.Product>
@{
    ViewBag.Title = "Available Products";
}

<h2>Available Products</h2>

@foreach (var product in Model)
{
    <p>@product.Name</p>
}

15, Hurrah - it's time to test again. Right click your Listener project and Debug - Start new instance, and once that has fired up and is connected to the Service Bus right click your MVC web app and do the same. You should get your list of products displayed.

Pretty simple, but it shows the data is coming through the Service Bus ok.

16, We want to make our application really nice to use on mobiles, so lets add in jQueryMobile. In Views -> Shared open _Layout.cshtml. Before the closing </head> tag add in:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>

Also change jQuery so it is using the latest version:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>

17, Final thing to add in the head section is:

<meta name="viewport" content="width=device-width, initial-scale=1">

18, Modify the html in your Index.cshtml file to look like this:

@model IEnumerable<MobileProducts.Model.Product>
@{
    ViewBag.Title = "Available Products";
}

<div data-role="page">

    <div data-role="header">
        <h2>Available Products</h2>
    </div>

    <div data-role="content">

        <ul data-role="listview" data-inset="true" data-filter="true">
            @foreach (var product in Model)
            {
                <li><a href="/home/product/@product.ProductId" data-transition="pop">@product.Name</a></li>
            }
        </ul>

    </div>

</div>

19, Open up Product.cshtml add get your code looking like:

@model MobileProducts.Model.Product

@{
    ViewBag.Title = "Product";
}

<h2>@Model.Name</h2>
<p>Price : @Model.Price</p>
<p>Stock Level : @Model.StockLevel</p>

<a href="#" data-rel="back">Back</a>

20, Go through the process of starting up your Listener project, and then your Web App. Hopefully the UI will look a lot nicer and more jQueryMobile like:

ASP.NET web app running in a standard browser

Now we are going to publish our web app to Azure so we can test it on our own mobiles.

 

Publish to Azure

Running locally is all good fun, but for our app to be viewable on mobile devices we want to publish it to Azure. Lets go do that...

1, Right click on MobileProducts.Azure in the solution explorer and choose 'Package...'

2, Open up www.azure.com and log in. Click on 'New Hosted Service in the ribbon

3, Give your hosted service a name, url, pick a region, deployment name - and then browse to the MobileProducts.Azure.cspkg and ServiceConfiguration.Cloud.cscfg files that Visual Studio created for you as part of the Packaging process.

4, The finally click OK. You can accept the warning that is displayed upon clicking OK as this is just a test app, but if it was a real production level app you'd want to take a bit more notice of it.

Once Azure has gone through the process of provisioning your new hosted service and uploading your application get out your smartphone and browse to the url you gave your application in Azure. Hopefully you will see something similar to below:

jQueryMobile app running in Windows Phone 7 browser

[Click for a larger image]

Check out how cool the search and page transitions are. jQueryMobile really is nice!

 

Things to think about

Authentication…We’ll be looking into this in future blog posts. At the moment our web app is open to the public so anybody can hit up our url. In most situation’s with company sensitive data we wouldn’t want this to happen.

Thanks for reading this far, hopefully this post has been useful and has got you excited about Azure and Mobile web apps. Any thoughts or feedback, please leave a comment or email nick@lightningtools.com

<nickswan />

Lightning conductor 2010 web part version 2.0.0.2

An interim release of the Lightning Conductor 2010 Web Part is available in the following versions:

Lightning Conductor 2010 Express – Free web part which aggregates from the current site collection only but provides an easier way to display your content through the SPGridView wizard.

http://www.lightningtools.com/lightning-conductor-2010-express-web-part.aspx

Lightning Conductor 2010 Web Part Trial – The 30 day trial of the Cross Site Collection and Cross Web Application rollup web part providing you with the ability to aggregate content and display meta data via a wizard.

http://www.lightningtools.com/lightning-conductor-2010-web-part.aspx

Lightning Conductor 2010 Web Part Full– The 30 day trial of the Cross Site Collection and Cross Web Application rollup web part providing you with the ability to aggregate content and display meta data via a wizard.

To download the full version, please download from the customer downloads centre on our site: www.lightningtools.com.

You can view the release notes of version 2.0.0.2 by navigating to: http://www.lightningtools.com/lightning-conductor-2010/LatestReleaseNotes.aspx

Regards

<Brett/>

Firebird and the Business Connectivity Services in SharePoint 2010

In this walkthrough we will demonstrate how to integrate Firebird database with Microsoft SharePoint 2010 through ODBC and display Firebird data on SharePoint 2010 page. In order to do that we will describe how to create a new external content type by means of BCS Meta Man.

  1. Prerequisites:
  2. Open Visual Studio 2010
  3. Add a New Project
  4. Expand the “SharePoint” node, select “Lightning Tools (2010)” node and then the “BCS Meta Man” project type
  5. Give your project a name i.e FirebirdBCSMetaManDemo and click “OK”

    Create FirebirdBCSMetaManDemo project

  6. On the next dialog box, enter the name of where you want to deploy your model, and click “Finish” button

    Deploy as a farm solution

  7. If prompted, click “Trial” on the licensing dialog
  8. To show the “BCS Meta Man Data Source Explorer” we need to enable it from the Menu item, this new window can be docked so it doesn’t get in your way

    Open the BCS MetaMan data source explorer

  9. Click the “Add Connection” button to show the “Connection Dialog”
  10. Select “ODBC Server” as Data Source type, enter Firebird ODBC connection string (for example it can be “DbName=cygnus:C:\Program Files\Firebird\Firebird_2_5\examples\empbuild\EMPLOYEE.FDB; Driver=Firebird/InterBase(r) driver;Uid=SYSDBA;Pwd=masterkey;Trusted_Connection=true;”), enter double quotes as left and right delimiters and “?” as parameter symbol and click “Connect” button

    Firebird ODBC connection string

  11. The Data Source Explorer will now be populated with your Firebird data

    See the tables and views available to use

  12. We will be working with the ”DEPARTMENT” table, to add it to the Model , just drag it from the “Data Source Explorer” onto the “Diagram”
  13. When you drop the table you will be shown the following dialog, we should choose “Database , click “OK”

    Choose the model type "Database"

  14. Accept the default entity name by clicking “Next”

    Accept the default entity name

  15. Accept the default “Identifiers” by clicking “Next”

    Accept the Identifiers selected

  16. Accept the default 3 methods to be created, click “Generate” (The default 3 methods are: “Finder” – Returns all items, “Specific Finder” – Returns a single item by identifier, “IdEnumerator” – Returns just the Identifiers for all of the items )

    Accept the methods

  17. Press F5 to deploy, this will load up your SharePoint Page once deployed
  18. Add a new External list by selection on SharePoint page “Site Action”->“More Options”->“External List”

    Add a new External List

  19. Click on the icon to show the available External Content Types

    Select the External Content Type

  20. Select our FirebirdBCSMetaManDemo.DEPARTMENT External Content Type, click “OK”

    Select the the Department External Content Type

  21. Click “Create”
  22. Your External System data from Firebird database is now displayed in the SharePoint External List

    External Data from Firebird is now shown within SharePoint 2010

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

<Dmitry Kaloshin/>

SharePoint technical support engineer

Lightning Tools is seeking the help of a support engineer with good SharePoint experience. We are a fast growing company who thrive on providing great SharePoint tools and web parts to companies of all sizes worldwide. We provide a great level of customer service, and in order to maintain that we need to expand our support team.

The role will involve answering technical questions from our customers either by email or telephone in a professional manner, providing remote assistance to the customer and feed back bug reports to our product managers.

The successful candidate will be professional, able to work within the hours of 8:30am US Eastern to 5pm US Eastern and will have good knowledge of SharePoint. Experience of SharePoint Business Connectivity Services, SharePoint administration and web part configuration would be very advantageous.

Full training will be given on all of our products as well as SharePoint Administration/Development.

This is an opportunity to work with a great team while expanding your SharePoint knowledge and have the ability to work from the comfort of your own home.

Salary will be negotiable depending on experience.

If you are interested in the role, please submit your resume to brett@lightningtools.com

Article by brett lonsdale on content aggregation techniques

In last months Dutch Information Workers Group e magazine Brett Lonsdale (co-founder of Lightning Tools) wrote an article on all of the possible ways to aggregate content in SharePoint 2010 and discussed the pro’s and cons of each method. You can subscribe and download the magazine for free from: http://www.diwug.nl/Pages/downloads.aspx

image

<Brett/>

sharepoint saturday uk–12th november 2011

Brett Lonsdale from Lightning Tools is co-hosting SharePoint Saturday UK with  Mark Macrae and Tony Pounder from ID Live. If you are interested in attending a totally free one day SharePoint event on Saturday 12th November, please sign up using the following url: http://www.sharepointsaturday.org/uk/default.aspx

The event is being held in Nottingham with over 30 speakers presenting from all over the world. Lightning Tools is one of the many sponsors of the event who make it possible for you as an attendee to receive expert SharePoint education.

If you are attending the event, we would love to meet you and show you our latest offerings.

image

<Brett/>

compare sharepoint site permissions and clone permissions

Have you ever spent hours trying to figure out SharePoint site permissions and perhaps wonder why you can access some sites but not others? If you rely on SharePoint’s out of the box permission reporting you will have probably become frustrated when trying to determine what permissions your users have to the sites, lists, and list items.

In our next release which is due in November, as well as all of the existing permission reports that DeliverPoint provides such as Permission Inheritance reports, and Unique Permission reports, DeliverPoint will offer comparison reports.  You can literally spend hours trying to figure out permissions for one site without having to compare them to others.  With DeliverPoint, you can now select as many sites as you like and compare the permissions across all of those sites within a matter of seconds.

image

Compare Permission Report (Click the image to enlarge)

Once you have compared the sites, you may decide that the permissions should be the same across all of the selected sites. Doing this manually using SharePoint would be cumbersome even for a small SharePoint environment. DeliverPoint allows you to select a source and a target site and then synchronise the permissions:

image

Clone Site Permissions (Click the image to enlarge)

Managing Permission inheritance can also be a frustrating task and also risky as changing your site inheritance options can often mean somebody is accidentally granted permissions. DeliverPoint allows you to easily see the Sites, Lists and List items that have unique permissions and also provides the option to re-inherit the permissions or break permission inheritance.

image

Manage Site Permission Inheritance (Click the image to enlarge)

Our treeview shows clearly which sites inherit permissions and which sites have unique permissions:

image

Legend for the DeliverPoint Treeview (Click the image to enlarge)

As well as showing the permission inheritance for the sites, we also allow you to report on Lists with unique permissions as well as List Items within a list:

image

Unique Inheritance Reports (Click the image to enlarge)

DeliverPoint also shows you exactly why users have the permissions that they have even if they are granted permissions through a Domain Group

image

Enumeration of AD Groups (Click the image to enlarge)

DeliverPoint is not just another Farm Administrators permission management tool, its a permission management tool that is fully embedded into SharePoint and is accessible for Site Collection Administrators and Site Administrators.

If you are interested in beta testing this version, please contact brett@lightningtools.com or visit our booth for a demo at SharePoint Conference Anaheim.

<brett/>

why visit lightningtools at spc?

Lightning Tools is proud to be sponsoring the SharePoint Conference again and this time will be there in force. Julia Ito, Chris Ryan, Nick Swan (SharePoint MVP), Brett Lonsdale, Phill Duffy, Richard Young and Phillip McMillan will be at the Lightning Tools booth to greet you!

At the Lightning Tools booth we’ll not only provide you with a warm welcome, but we’ll take the time to show you our up and coming product releases which include a new improved Social Squared, Permissions Management for the cloud, and content aggregation for the cloud. If you haven’t taken the chance to read about or try our Data Masher tool, come and ask us for a demo! The Data Masher now allows syncing data to Office 365!!

Not only do we have some fantastic new products to show you, but we also have the one and only Steve Fox giving away FREE signed copies of his Developing SharePoint Applications with Windows Azure book, Dux Raymond Sy will be providing FREE signed copies of his SharePoint for Project Management book and will be performing a rap at the Lightning Tools booth and finally Bill English (SharePoint MVP) and Ben Curry (SharePoint MVP) will also be giving away FREE signed copies of the Administrators Companion book. “I did actually contribute a chapter to this so i’ll be more than happy to sign it too Smile(Print the flyer below as a reminder of the times or come and get one from us at booth 651)

image

If you are a fan of the SharePoint Pod Show, you’ll find Rob Foster (SharePoint MVP), Nick Swan (SharePoint MVP), and myself hanging around the booth most of the time. We’ll be really happy to meet some of our listeners and perhaps share a beer or discuss some of Robs BBQ techniques with you.

image

Finally, this year we have a bit of a racing theme and you could be the lucky winner of a Nitro powered radio controlled car. Come and visit us for details.

If you don’t want to come and see us for any of the above, just pop by and say hi!

<Brett/>

MySQL Stored Procedures and the Business Connectivity Services in SharePoint 2010

Introduction

In this walkthrough we will demonstrate how to integrate MySQL stored procedures with Microsoft SharePoint 2010 and display the data on SharePoint 2010 page. In order to do that we will describe how to create a new external content type by means of BCS Meta Man.

Prerequisites

  • Microsoft SharePoint Server 2010
  • Microsoft Visual Studio 2010 Professional or higher
  • BCS Meta Man
  • Download and install “Windows (x86, 32-bit), MSI Installer Connector-ODBC” http://www.mysql.com/downloads/connector/odbc/ on a machine where BCS Meta Man runs
  • Download and install “Windows (x86, 64-bit), MSI Installer Connector-ODBC” http://www.mysql.com/downloads/connector/odbc/ on a machine where SharePoint 2010 runs
  • MySQL stored procedures for CRUD operations such as:
    1. CREATE DEFINER = 'root'@'localhost'
      PROCEDURE classicmodels.get_all_offices()
      BEGIN
        SELECT * FROM offices;
      END
    2. CREATE DEFINER = 'root'@'localhost'
      PROCEDURE classicmodels.get_office_by_id(IN p_id INT)
      BEGIN
      SELECT * FROM offices WHERE officeCode=p_id;
      END
    3. CREATE DEFINER = 'root'@'localhost'
      PROCEDURE classicmodels.get_office_ids()
      BEGIN
      SELECT officeCode FROM offices;
      END
    4. CREATE DEFINER = 'root'@'localhost'
      PROCEDURE classicmodels.create_office(IN p_id INT, IN p_city VARCHAR(50),
      IN p_phone VARCHAR(50), IN p_address_line1 VARCHAR(50),
      IN p_address_line2 VARCHAR(50), IN p_state VARCHAR(50),
      IN p_country VARCHAR(50), IN p_postal_code VARCHAR(15),
      IN p_territory VARCHAR(10))
      BEGIN
      INSERT INTO offices values(p_id, p_city, p_phone, p_address_line1, p_address_line2,
        p_state, p_country, p_postal_code, p_territory);
      END
    5. CREATE DEFINER = 'root'@'localhost'
      PROCEDURE classicmodels.update_office(IN p_id INT, IN p_city VARCHAR(50),
      IN p_phone VARCHAR(50), IN p_address_line1 VARCHAR(50),
      IN p_address_line2 VARCHAR(50), IN p_state VARCHAR(50),
      IN p_country VARCHAR(50), IN p_postal_code VARCHAR(15),
      IN p_territory VARCHAR(10))
      BEGIN
      UPDATE offices SET city=p_city, phone=p_phone, addressLine1=p_address_line1,
        addressLine2=p_address_line2, state=p_state, country=p_country, postalCode=p_postal_code,
         territory=p_territory WHERE officecode=p_id;
      END
    6. CREATE DEFINER = 'root'@'localhost'
      PROCEDURE classicmodels.delete_office(IN p_id INT)
      BEGIN
      DELETE FROM offices WHERE officecode = p_id;
      END

Walkthrough

  1. Open Visual Studio 2010
  2. Add a New Project
  3. Expand the “SharePoint” node, select “Lightning Tools (2010)” node and then the “BCS Meta Man” project type
  4. Give your project a name i.e MySQLStoredProceduresBCSMetaManDemo and click “OK”

    Create MySQLStoredProceduresBCSMetaManDemo project

  5. On the next dialog box, enter the name of where you want to deploy your model, and click “Finish” button

    Deploy as a farm solution

  6. If prompted, click “Trial” on the licensing dialog
  7. To show the “BCS Meta Man Data Source Explorer” we need to enable it from the Menu item, this new window can be docked so it doesn’t get in your way

    Open the BCS Meta Man Data Source Explorer

  8. Click the “Add Connection” button to show the “Connection Dialog”
  9. Select “ODBC Server” as Data Source type, enter MySQL ODBC connection string (for example it can be “Driver={MySQL ODBC 5.1 Driver};Server=taurus;Port=3306;Database=classicmodels; User=root;Password=12345;Trusted_Connection=yes;”), enter “`” as left and right delimiters and “?” as parameter symbol and click “Connect” button

    MySQL ODBC connection string

  10. The Data Source Explorer will now be populated with your MySQL data

    See the stored procedures available to use

  11. Drag and drop your Finder Stored Procedure onto the design surface and enter External Content type name, i.e “Office”, click “OK”

    Drag and drop a Finder stored procedure and Enter External Content type name

  12. Choose the Finder as the method type and click “OK”

    Choose the Finder as the method type

  13. The External Content Type will be created on the Diagram

    External Content Type created on diagram

  14. In order to set an identifier right-click on the External Content Type, select “Manage External Content type” menu item

    Manage External Content type

  15. Click “Edit Identifiers” button on the “Entity Management” dialog, select an identifier and click “OK” and “Update” button then

    Set identifier

  16. The External Content Type will update with the new identifier

    External Content Type with identifier

  17. From the “BCS Meta Man Data Source Explorer” drag and drop your Specific Finder stored procedure onto the existing External Content Type

    Drag and drop Specific Finder stored procedure onto existing External Content Type

  18. The “Stored Procedure Configuration” dialog will be displayed. Select “SpecificFinder” as the Method Type. Select the first Parameter – p_id and set the Filter Type as Comparison and the Default Value as ‘0’. Click “OK”.

    Configuring a Specific Finder stored procedure

  19. The External Content Type will update with the new Specific Finder Method

    External Content Type with Finder and Specific Finder methods

  20. Next drag and drop the Id Enumerator stored procedure onto the existing External Content Type

    Drag and drop Id Enumerator Stored Procedure onto existing External Content Type

  21. Select “IdEnumerator” as the Method Type, Click “OK”

    Configuring Id Enumerator stored procedure

  22. The External Content Type will update with the new Id Enumerator Method

    External Content Type with Finder, Specific Finder and ID Enumerator methods

  23. From the “BCS Meta Man Data Source Explorer” drag and drop your Creator stored procedure onto the existing External Content Type

    Drag and drop Creator stored procedure onto existing External Content Type 

  24. The “Stored Procedure Configuration” dialog will be displayed. Select “Creator” as the Method Type. For each Parameter select the appropriate column to map it to. Click “OK”.

    Configuring Creator stored procedure

  25. The External Content Type will update with the new Creator Method

    External Content Type with with Finder, Specific Finder, ID Enumerator, Creator methods

  26. Next drag and drop your Updater stored procedure onto the existing External Content Type
  27. Again the “Stored Procedure Configuration” dialog will be displayed. Select “Updater” as the Method Type. For each Parameter select the appropriate column to map it to. Click “OK”.
  28. The External Content Type will update with the new Updater Method

    External Content Type with with Finder, Specific Finder, ID Enumerator, Creator and Updater methods

  29. Finally drag and drop your Deleter stored procedure onto the existing External Content Type
  30. Again the “Stored Procedure Configuration” dialog will be displayed. Select “Deleter” as the Method Type. Click “OK”.
  31. The complete External Content Type will look like the following

    External Content Type with with Finder, Specific Finder, ID Enumerator, Creator, Updater and Deleter methods

  32. Press F5 to deploy The External Content Type, this will load up your SharePoint Page once deployed
  33. Add a new External list by selection on SharePoint page “Site Action”->“More Options…”->“External List”

    Add a new external list

  34. Give your External List a name and Click on the icon to show the available External Content Types

    Select the available External Content Type

  35. Select created MySQLStoredProceduresBCSMetaManDemo.Office External Content Type, click “OK”. Click “Create” button then.

    Select Office External Content Type

  36. The external data provided by MySQL stored procedure is now displayed in the SharePoint External List

    External data provided by MySQL stored procedure is now shown within SharePoint 2010

  37. You can hover over the first column of your list and you’ll see a drop down appear. If you click the drop down arrow you’ll get a number of options for that particular row of data – one of which will be View Item.

    View items through External List

  38. You will be presented with the View Item dialog

    View Item dialog

  39. Now click “Edit item” on the ribbon of the dialog. This option is only available if you create an Updater method for your External Content Type. Clicking on this link will open up a dialog form that allows you to edit that row of data and save it.

    Edit Item dialog

  40. While viewing the external list, if you click the Items tab on the ribbon you’ll see a New Item button

    Add new data to MySQL database through the external list

  41. This will bring up the “New Item” dialog where you can add a new Office. We will enter information about new Office and click “Save”

    New Item Dialog

  42. This will insert a new row directly to your MySQL database

    Updated External data provided by MySQL stored procedure is now shown within SharePoint 2010

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

<Dmitry Kaloshin/>

BCS filters and DB2 Stored Procedures with Parameters in SharePoint 2010

Introduction

In this tutorial we will show you how to connect to a DB2 Database using BCS Meta Man and a Stored Procedure to return filtered data to a SharePoint Business Data List. In this walkthrough we will be creating a Finder Method with filters so our DB2 Stored Procedure needs to have parameters defined.

Prerequisites

  • Microsoft SharePoint Server 2010
  • Microsoft Visual Studio 2010 Professional or higher
  • BCS Meta Man
  • Download and install “IBM Data Server Runtime Client (Windows 32-bit AMD and Intel x86)” http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217 on a machine where BCS Meta Man runs
  • Download and install “IBM Data Server Runtime Client (Windows AMD64 and Intel EM64T)” http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217 on a machine where SharePoint 2010 runs
  • DB2 stored procedure such as:
    1. CREATE PROCEDURE GET_EMPLOYEES_FILTERED(IN P_FIRST_NAME VARCHAR(12), IN P_BONUS DECIMAL(9,2))
      DYNAMIC RESULT SETS 1
      P1: BEGIN 
      DECLARE v_employees CURSOR WITH RETURN for 
      select * from EMPLOYEE where FIRSTNME like '%' || P_FIRST_NAME || '%' and BONUS > P_BONUS;
      OPEN v_employees;
      END P1

Walkthrough

  1. Open Visual Studio 2010
  2. Add a New Project
  3. Expand the “SharePoint” node, select “Lightning Tools (2010)” node and then the “BCS Meta Man” project type
  4. Give your project a name i.e BCSMetaManFilteredDB2StoredProcedure and click “OK”

    Create BCSMetaManFilteredDB2StoredProcedure project

  5. On the next dialog box, enter the name of where you want to deploy your model, and click “Finish” button

    Deploy as a farm solution

  6. If prompted, click “Trial” on the licensing dialog
  7. To show the “BCS Meta Man Data Source Explorer” we need to enable it from the Menu item, this new window can be docked so it doesn’t get in your way

    Open the BCS Meta Man Data Source Explorer 

  8. Click the “Add Connection” button to show the “Connection Dialog”
  9. Select “ODBC Server” as Data Source type, enter DB2 ODBC connection string (for example it can be “Driver={IBM DB2 ODBC DRIVER};Database=SAMPLE; Hostname=cygnus;port=50000;Protocol=TCPIP;Uid=Administrator;Pwd=12345;Trusted_Connection=false;”), enter double quotes as left and right delimiters and “?” as parameter symbol and click “Connect” button.

    DB2 ODBC connection string 

  10. The Data Source Explorer will now be populated with your DB2 data

    See the stored procedures available to use

  11. Drag and drop your Finder Stored Procedure with parameters onto the design surface and enter External Content type name, i.e “FilteredEmployee”, click “OK”

    Drag and drop a Finder stored procedure and Enter External Content type name

  12. Select the Method Type as “Finder’'
  13. Select the first Parameter (p_first_name) and set it’s Filter Type to Comparison and the Default Value to ‘A’

    Configuring Finder DB2 stored procedure and first parameter

  14. Next select the second Parameter (p_bonus) and also set it’s Filter Type to Comparison and the Default Value to ‘100’

    Configuring Finder DB2 stored procedure and second parameter

  15. Click ‘OK’
  16. The External Content Type will be created on the Diagram

    External Content Type created on diagram

  17. In order to set an identifier right-click on the External Content Type, select “Manage External Content type” menu item

    Manage External Content type

  18. Click “Edit Identifiers” button on the “Entity Management” dialog, select an identifier and click “OK” and “Update” button then

    Set identifier

  19. The External Content Type will update with the new identifier

    External Content Type with identifier

  20. Press F5 to deploy, this will load up your SharePoint Page once deployed
  21. Add a new Business Data List Web Part to your SharePoint page

    Add Business Data List Web Part

  22. Click on the ‘Open the tool pane’ link
  23. Click on the icon to show the available External Content Types

    Open the picker to select your External Content Type

  24. Select our ‘BCSMetaManFilteredDB2StoredProcedure.FilteredEmployee’ External Content Type, click ‘OK’

    Select the FilteredEmployee External Content Type

  25. Click ‘OK’ on the tool pane
  26. Click the ‘Add’ link on the Business Data List Web Part to add the second Filter option

    To use multiple BCS filters click the Add link

  27. Change the second Filter to be the P_BONUS and enter values for the filters and click ‘Retrieve Data’
  28. Your DB2 data provided by Stored Procedure is now displayed in the SharePoint Web Part

    View your filtered data provided by DB2 stored procedure

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

<Dmitry Kaloshin/>

Business Connectivity Service Associations using DB2 Stored Procedures in SharePoint 2010

Introduction

In this walkthrough we will demonstrate you how to connect to DB2 Database and use stored procedures to create an association between two External Content Types using BCS Meta Man.

We are going to follow on from the ‘DB2 Stored Procedures and the Business Connectivity Services in SharePoint 2010

Prerequisites

  • Microsoft SharePoint Server 2010
  • Microsoft Visual Studio 2010 Professional or higher
  • BCS Meta Man
  • Download and install “IBM Data Server Runtime Client (Windows 32-bit AMD and Intel x86)” http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217 on a machine where BCS Meta Man runs
  • Download and install “IBM Data Server Runtime Client (Windows AMD64 and Intel EM64T)” http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217 on a machine where SharePoint 2010 runs
  • DB2 stored procedures  such as:
    1. CREATE PROCEDURE GET_ALL_DEPARTMENTS()
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      DECLARE v_departments CURSOR WITH RETURN for
      SELECT * FROM DEPARTMENT;
      OPEN v_departments;
      END P1
    2. CREATE PROCEDURE GET_DEPARTMENT_BY_ID(IN P_ID CHAR(3))
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      DECLARE v_departments CURSOR WITH RETURN for
      select * from DEPARTMENT where DEPTNO=P_ID;
      OPEN v_departments;
      END P1
    3. CREATE PROCEDURE GET_ALL_EMPLOYEES()
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      DECLARE v_employees CURSOR WITH RETURN for
      SELECT * FROM EMPLOYEE;
      OPEN v_employees;
      END P1
    4. CREATE PROCEDURE GET_EMPLOYEE_BY_ID(IN P_ID CHAR(6))
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      DECLARE v_employees CURSOR WITH RETURN for
      select * from EMPLOYEE where EMPNO=P_ID;
      OPEN v_employees;
      END P1
    5. CREATE PROCEDURE GET_EMPLOYEE_BY_DEPARTMENT_ID(IN P_ID CHAR(3))
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      DECLARE v_employees CURSOR WITH RETURN for
      select * from EMPLOYEE where WORKDEPT=P_ID;
      OPEN v_employees;
      END P1

Walkthrough

  1. Using the ‘DB2 Stored Procedures and the Business Connectivity Services in SharePoint 2010’ Tutorial create two External Content Types “Department” and “Employee” with Finder (Read List operation) and SpecificFinder (Read Item operation) methods only.
  2. You should have the following External Content Types on your Diagram

    Both External Content Types on the design surface

  3. Switch to the ‘Toolbox’ pane in Visual Studio (Ctrl-Alt-X)
  4. Select the ‘Association’ toolbox item from the list

    Select the Association toolbox control

  5. With the Association selected, Click and Drag from ‘Department’ to ‘Employee’

    Drag and Drop between your two External Content Types

  6. When you release the ‘Association Configuration’ dialog will show
  7. Switch back to the ‘BCS Meta Man Data Source Explorer’ tool window pane
  8. Drag the Association Stored Procedure onto the Arrow in the ‘Association Configuration’ dialog, it will turn green when OK to release

    Drag and Drop the DB2 Association Stored Procedure

  9. The dialog will update with the selected Stored Procedure

    Association Configuration dialog

  10. Select ‘P_ID’ in the Parameter and ‘DEPTNO’ in the Identifier drop-down list boxes, Click ‘Save’

    Map the DB2 stored procedure parameter to identifier

  11. The diagram will update to show an arrow indicating we have an association between the two External Content Types

    Association has been created

  12. Press F5 to deploy, this will load up your SharePoint Page once deployed
  13. Add a new Business Data List Web Part to your SharePoint page

    Add Business Data List Web Part

  14. Click on the ‘Open the tool pane’ link
  15. Click on the icon to show the available External Content Types

    Open the picker to select your External Content Type

  16. Select our ‘BCSMetaMan1.Department’ External Content Type, click OK

    Select the Department External Content Type

  17. Click ‘OK’ on the tool pane
  18. The external data provided by DB2 stored procedure is now displayed in the SharePoint Web Part

    External data provided by DB2 stored procedure is now shown within SharePoint 2010

  19. Next, Add a new ‘Business Data Related List’ Web Part to the page
  20. Configure the Web Part to use the ‘BCSMetaMan1.Employee’ External Content Type
  21. The Web Part will display a message saying the following

    Need to setup web part connection

  22. To do this we can set up the connection using the small arrow from the top right of our Web Part

    Use a web part menu to create a connection

  23. Once this is done we can click on the arrows next to an item in our ‘Department’ web part and the employees related to this department will display on our ‘Employee’ web part

    Related list web part now shows the association data provided by DB2 stored procedure

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

<Dmitry Kaloshin/>

DB2 Stored Procedures and the Business Connectivity Services in SharePoint 2010

Introduction

In this walkthrough we will demonstrate how to integrate DB2 stored procedures with Microsoft SharePoint 2010 and display the data on SharePoint 2010 page. In order to do that we will describe how to create a new external content type by means of BCS Meta Man.

Prerequisites

  • Microsoft SharePoint Server 2010
  • Microsoft Visual Studio 2010 Professional or higher
  • BCS Meta Man
  • Download and install “IBM Data Server Runtime Client (Windows 32-bit AMD and Intel x86)” http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217 on a machine where BCS Meta Man runs
  • Download and install “IBM Data Server Runtime Client (Windows AMD64 and Intel EM64T)” http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217 on a machine where SharePoint 2010 runs
  • DB2 stored procedures for CRUD operations such as:
    1. CREATE PROCEDURE GET_ALL_DEPARTMENTS()
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      DECLARE v_departments CURSOR WITH RETURN for
      SELECT * FROM DEPARTMENT;
      OPEN v_departments;
      END P1
    2. CREATE PROCEDURE GET_DEPARTMENT_BY_ID(IN P_ID CHAR(3))
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      DECLARE v_departments CURSOR WITH RETURN for
      select * from DEPARTMENT where DEPTNO=P_ID;
      OPEN v_departments;
      END P1
    3. CREATE PROCEDURE GET_DEPARTMENT_IDS()
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      DECLARE v_department_ids CURSOR WITH RETURN for
      select DEPTNO from DEPARTMENT;
      OPEN v_department_ids;
      END P1
    4. CREATE PROCEDURE CREATE_DEPARTMENT(IN P_ID CHAR(3), IN P_NAME VARCHAR(36), IN P_MGRNO CHAR(6), IN P_ADMID CHAR(3), IN P_LOCATION CHAR(16))
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      insert into DEPARTMENT values(P_ID, P_NAME, P_MGRNO, P_ADMID, P_LOCATION);
      END P1
    5. CREATE PROCEDURE UPDATE_DEPARTMENT(IN P_ID CHAR(3), IN P_NAME VARCHAR(36), IN P_MGRNO CHAR(6), IN P_ADMID CHAR(3), IN P_LOCATION CHAR(16))
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      update DEPARTMENT set DEPTNAME=P_NAME, MGRNO=P_MGRNO, ADMRDEPT=P_ADMID, LOCATION=P_LOCATION where DEPTNO=P_ID;
      END P1
    6. CREATE PROCEDURE DELETE_DEPARTMENT(IN P_ID CHAR(3))
      DYNAMIC RESULT SETS 1
      P1: BEGIN
      delete from DEPARTMENT where DEPTNO=P_ID;
      END P1

Walkthrough

  1. Open Visual Studio 2010
  2. Add a New Project
  3. Expand the “SharePoint” node, select “Lightning Tools (2010)” node and then the “BCS Meta Man” project type
  4. Give your project a name i.e DB2StoredProceduresBCSMetaManDemo and click “OK”

    Create DB2StoredProceduresBCSMetaManDemo project

  5. On the next dialog box, enter the name of where you want to deploy your model, and click “Finish” button

    Deploy as a farm solution

  6. If prompted, click “Trial” on the licensing dialog
  7. To show the “BCS Meta Man Data Source Explorer” we need to enable it from the Menu item, this new window can be docked so it doesn’t get in your way

    Open the BCS Meta Man Data Source Explorer

  8. Click the “Add Connection” button to show the “Connection Dialog”
  9. Select “ODBC Server” as Data Source type, enter DB2 ODBC connection string (for example it can be “Driver={IBM DB2 ODBC DRIVER};Database=SAMPLE;Hostname=cygnus;port=50000;Protocol=TCPIP;Uid=Administrator;Pwd=12345;Trusted_Connection=false;”), enter double quotes as left and right delimiters and “?” as parameter symbol and click “Connect” button.

    DB2 ODBC connection string

  10. The Data Source Explorer will now be populated with your DB2 data

    See the stored procedures available to use

  11. Drag and drop your Finder Stored Procedure onto the design surface and enter External Content type name, i.e “Department”, click “OK”

    Drag and drop a Finder stored procedure and Enter External Content type name

  12. Choose the Finder as the method type and click “OK”

    Choose the Finder as the method type

  13. The External Content Type will be created on the Diagram

    External Content Type created on diagram

  14. In order to set an identifier right-click on the External Content Type, select “Manage External Content type” menu item

    Manage External Content type

  15. Click “Edit Identifiers” button on the “Entity Management” dialog, select an identifier and click “OK” and “Update” button then

    Set identifier

  16. The External Content Type will update with the new identifier

    External Content Type with identifier

  17. From the “BCS Meta Man Data Source Explorer” drag and drop your Specific Finder stored procedure onto the existing External Content Type

    Drag and drop Specific Finder stored procedure onto existing External Content Type

  18. The “Stored Procedure Configuration” dialog will be displayed. Select “SpecificFinder” as the Method Type. Select the first Parameter – P_ID and set the Filter Type as Comparison and the Default Value as ‘0’. Click “OK”.

    Configuring a Specific Finder stored procedure

  19. The External Content Type will update with the new Specific Finder Method

    External Content Type with Finder and Specific Finder methods

  20. Next drag and drop the Id Enumerator stored procedure onto the existing External Content Type

    Drag and drop Id Enumerator Stored Procedure onto existing External Content Type

  21. Select “IdEnumerator” as the Method Type, Click “OK”

    Configuring Id Enumerator stored procedure

  22. The External Content Type will update with the new Id Enumerator Method

    External Content Type with Finder, Specific Finder and ID Enumerator methods

  23. From the “BCS Meta Man Data Source Explorer” drag and drop your Creator stored procedure onto the existing External Content Type

    Drag and drop Creator stored procedure onto existing External Content Type

  24. The “Stored Procedure Configuration” dialog will be displayed. Select “Creator” as the Method Type. For each Parameter select the appropriate column to map it to. Click “OK”.

    Configuring Creator stored procedure

  25. The External Content Type will update with the new Creator Method

    External Content Type with with Finder, Specific Finder, ID Enumerator, Creator methods

  26. Next drag and drop your Updater stored procedure onto the existing External Content Type
  27. Again the “Stored Procedure Configuration” dialog will be displayed. Select “Updater” as the Method Type. For each Parameter select the appropriate column to map it to. Click “OK”.
  28. The External Content Type will update with the new Updater Method

    External Content Type with with Finder, Specific Finder, ID Enumerator, Creator and Updater methods

  29. Finally drag and drop your Deleter stored procedure onto the existing External Content Type
  30. Again the “Stored Procedure Configuration” dialog will be displayed. Select “Deleter” as the Method Type. Click “OK”.
  31. The complete External Content Type will look like the following

    External Content Type with with Finder, Specific Finder, ID Enumerator, Creator, Updater and Deleter methods

  32. Press F5 to deploy The External Content Type, this will load up your SharePoint Page once deployed
  33. Add a new External list by selection on SharePoint page “Site Action”->“More Options…”->“External List”

    Add a new external list

  34. Give your External List a name and Click on the icon to show the available External Content Types

    Select the available External Content Type

  35. Select created DB2StoredProceduresBCSMetaManDemo.Department External Content Type, click “OK”. Click “Create” button then.

    Select Department External Content Type

  36. The external data provided by DB2 stored procedure is now displayed in the SharePoint External List

    External data provided by DB2 stored procedure is now shown within SharePoint 2010

  37. You can hover over the first column of your list and you’ll see a drop down appear. If you click the drop down arrow you’ll get a number of options for that particular row of data – one of which will be View Item.

    View items through External List

  38. You will be presented with the View Item dialog

    View Item dialog

  39. Now click “Edit item” on the ribbon of the dialog. This option is only available if you create an Updater method for your External Content Type. Clicking on this link will open up a dialog form that allows you to edit that row of data and save it.

    Edit Item dialog

  40. While viewing the external list, if you click the Items tab on the ribbon you’ll see a New Item button

    Add new data to DB2 database through the external list

  41. This will bring up the “New Item” dialog where you can add a new Department. We will enter information about new Department and click “Save”

    New Item Dialog

  42. This will insert a new row directly to your DB2 database

    Updated External data provided by DB2 stored procedure is now shown within SharePoint 2010

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

<Dmitry Kaloshin/>

BCS filters and Oracle Stored Procedures with Parameters in SharePoint 2010

Introduction

In this tutorial we will show you how to connect to a Oracle Database Server using BCS Meta Man and a Stored Procedure to return filtered data to a SharePoint Business Data List. In this walkthrough we will be creating a Finder Method with filters so our Oracle Stored Procedure needs to have parameters defined.

Prerequisites

  • Microsoft SharePoint Server 2010
  • Microsoft Visual Studio 2010 Professional or higher
  • BCS Meta Man
  • Oracle clients (This FAQ describes what should be installed)
  • Oracle stored procedure for such as:
    1. create or replace function get_employees_filtered(p_last_name in varchar2, p_salary in number)
      return sys_refcursor
      is
        v_employees sys_refcursor;
      begin
        open v_employees for select * from employees where last_name like '%' || p_last_name || '%' and salary < p_salary;
        return v_employees;
      end get_employees_filtered;

Walkthrough

  1. Open Visual Studio 2010
  2. Add a New Project
  3. Expand the “SharePoint” node, select “Lightning Tools (2010)” node and then the “BCS Meta Man” project type
  4. Give your project a name i.e BCSMetaManFilteredOracleStoredProcedure and click “OK”

    Create BCSMetaManFilteredOracleStoredProcedure project

  5. On the next dialog box, enter the name of where you want to deploy your model, and click “Finish” button

    Deploy as a farm solution

  6. If prompted, click “Trial” on the licensing dialog
  7. To show the “BCS Meta Man Data Source Explorer” we need to enable it from the Menu item, this new window can be docked so it doesn’t get in your way

    Open the BCS Meta Man Data Source Explorer

  8. Click the “Add Connection” button to show the “Connection Dialog”
  9. Select “ODBC Server” as Data Source type, enter Oracle ODBC connection string (for example it can be “Driver={Oracle in OraClient11g_home1};Dbq=XE_AURIGA;Uid=hr;Pwd=hr;Trusted_Connection=yes;”), enter double quotes as left and right delimiters and “?” as parameter symbol and click “Connect” button.

    Oracle ODBC connection string

  10. The Data Source Explorer will now be populated with your Oracle data

    See the stored procedures available to use 

  11. Drag and drop your Finder Stored Procedure with parameters onto the design surface and enter External Content type name, i.e “FilteredEmployee”, click “OK”

    Drag and drop a Finder stored procedure and Enter External Content type name

  12. Select the Method Type as “Finder’'
  13. Select the first Parameter (p_last_name) and set it’s Filter Type to Comparison and the Default Value to ‘a’

    Configuring Finder Oracle stored procedure and first parameter

  14. Next select the second Parameter (p_salary) and also set it’s Filter Type to Comparison and the Default Value to ‘4000’

    Configuring Finder Oracle stored procedure and second parameter

  15. Click ‘OK’
  16. The External Content Type will be created on the Diagram

    External Content Type created on diagram

  17. In order to set an identifier right-click on the External Content Type, select “Manage External Content type” menu item

    Manage External Content type

  18. Click “Edit Identifiers” button on the “Entity Management” dialog, select an identifier and click “OK” and “Update” button then

    Set identifier

  19. The External Content Type will update with the new identifier

    External Content Type with identifier 

  20. Press F5 to deploy, this will load up your SharePoint Page once deployed
  21. Add a new Business Data List Web Part to your SharePoint page

    Add Business Data List Web Part

  22. Click on the ‘Open the tool pane’ link
  23. Click on the icon to show the available External Content Types

    Open the picker to select your External Content Type

  24. Select our ‘ BCSMetaManFilteredOracleStoredProcedure.FilteredEmployee’ External Content Type, click ‘OK’

    Select the FilteredEmployee External Content Type

  25. Click ‘OK’ on the tool pane
  26. Click the ‘Add’ link on the Business Data List Web Part to add the second Filter option

    To use multiple BCS filters click the Add link

  27. Change the second Filter to be the P_SALARY and enter values for the filters and click ‘Retrieve Data’
  28. Your Oracle data provided by Stored Procedure is now displayed in the SharePoint Web Part 

    View your filtered data provided by Oracle stored procedure

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

<Dmitry Kaloshin/>

Business Connectivity Service Associations using Oracle Stored Procedures in SharePoint 2010

Introduction

In this walkthrough we will demonstrate you how to connect to Oracle Database Server and use stored procedures to create an association between two External Content Types using BCS Meta Man.

We are going to follow on from the ‘Oracle Stored Procedures and the Business Connectivity Services in SharePoint 2010

Prerequisites

  • Microsoft SharePoint Server 2010
  • Microsoft Visual Studio 2010 Professional or higher
  • BCS Meta Man
  • Oracle clients (This FAQ describes what should be installed)
  • Oracle stored procedures for such as:
    1. create or replace function get_all_countries 
      return sys_refcursor
      is
        v_countries sys_refcursor;
      begin
        open v_countries for select * from countries;
        return v_countries;
      end get_all_countries;
    2. create or replace function get_country_by_id(p_id in char) 
      return sys_refcursor
      is
        v_countries sys_refcursor;
      begin
        open v_countries for select * from countries where country_id=p_id;
        return v_countries;
      end get_country_by_id;
    3. create or replace function get_all_regions 
      return sys_refcursor
      is
        v_regions sys_refcursor;
      begin
        open v_regions for select * from regions;
        return v_regions;
      end get_all_regions;
    4. create or replace function get_region_by_id(p_id in number)
      return sys_refcursor
      is
        v_regions sys_refcursor;
      begin
        open v_regions for select * from regions where region_id=p_id;
        return v_regions;
      end get_region_by_id;
    5. create or replace function get_countries_by_region_id(p_id in number)
      return sys_refcursor
      is
        v_countries sys_refcursor;
      begin
        open v_countries for select * from countries where region_id=p_id;
        return v_countries;
      end get_countries_by_region_id;

Walkthrough

  1. Using the ‘Oracle Stored Procedures and the Business Connectivity Services in SharePoint 2010’ Tutorial create two External Content Types “Country” and “Region” with Finder (Read List operation) and SpecificFinder (Read Item operation) methods only.
  2. You should have the following External Content Types on your Diagram

    Both External Content Types on the design surface 

  3. Switch to the ‘Toolbox’ pane in Visual Studio (Ctrl-Alt-X)
  4. Select the ‘Association’ toolbox item from the list

    Select the Association toolbox control 

  5. With the Association selected, Click and Drag from ‘Region’ to ‘Country’

    Drag and Drop between your two External Content Types 

  6. When you release the ‘Association Configuration’ dialog will show
  7. Switch back to the ‘BCS Meta Man Data Source Explorer’ tool window pane
  8. Drag the Association Stored Procedure onto the Arrow in the ‘Association Configuration’ dialog, it will turn green when OK to release

    Drag and Drop the Oracle Association Stored Procedure 

  9. The dialog will update with the selected Stored Procedure

    Association Configuration dialog 

  10. Select ‘P_ID’ in the Parameter and ‘REGION_ID’ in the Identifier drop-down list boxes, Click ‘Save’

    Map the Oracle stored procedure parameter to identifier

  11. The diagram will update to show an arrow indicating we have an association between the two External Content Types

    Association has been created

  12. Press F5 to deploy, this will load up your SharePoint Page once deployed
  13. Add a new Business Data List Web Part to your SharePoint page

    Add Business Data List Web Part

  14. Click on the ‘Open the tool pane’ link
  15. Click on the icon to show the available External Content Types

    Open the picker to select your External Content Type

  16. Select our ‘BCSMetaMan1.Region’ External Content Type, click OK 

    Select the Region External Content Type

  17. Click ‘OK’ on the tool pane
  18. The external data provided by Oracle stored procedure is now displayed in the SharePoint Web Part

    External data provided by Oracle stored procedure is now shown within SharePoint 2010

  19. Next, Add a new ‘Business Data Related List’ Web Part to the page
  20. Configure the Web Part to use the ‘BCSMetaMan1.Country’ External Content Type
  21. The Web Part will display a message saying the following

    Need to setup web part connection

  22. To do this we can set up the connection using the small arrow from the top right of our Web Part

    Use a web part menu to create a connection

  23. Once this is done we can click on the arrows next to an item in our ‘Region’ web part and the countries related to this region will display on our ‘Country’ web part

    Related list web part now shows the association data provided by Oracle stored procedure

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

<Dmitry Kaloshin/>