Saturday, January 04, 2014

Microsoft’s Project Siena Needs a Windows Azure Mobile Services Sample App

imageS. “Soma” Somasegar ( @SSomasegar) asserts Microsoft’s new Project Siena is intended for “business experts, business analysts, consultants and other business users with the imagination to conceive an app for today’s mobile devices” in his Project Siena: Enabling Business Users to Create Mobile Apps for the Enterprise post of 12/19/2013 to TechNet’s Project Siena blog.

imageProject Siena’s tagline is

Build powerful business apps, no coding necessary.

Soma cites as examples:

  • Apps to support conversations, where a customer can reach over and touch the employee’s screen, make changes and ultimately own the solution
  • Apps with the smarts to help users make on-the-spot decisions by offering choices first and allowing trade-offs later
  • Apps for tasks that involve capturing real world information through photos, videos and voice

Project Siena’s Tagline Is an Oxymoron

I have never seen a real-world business app, powerful or not, that didn’t require at least some custom Visual Basic, VBA, C#, Java, JavaScript or code in another programming language. For its Visual Studio LightSwitch rapid application development (RAD) tool, Microsoft claims:

When you use LightSwitch, much of the repetitive work is done for you and, in fact, you can create a LightSwitch application without writing any code at all! For most applications, the only code you have to write is the code that only you can write: the business logic.

Tim Anderson’s ( @timanderson) Figuring out Project Siena: a Windows 8 app to build Windows 8 apps article of 1/4/2014 describes his frustrations with fathoming the functions required to program a simple todo list:

imageA couple of weeks back I took a look at Project Siena, a preview of a new tool for building Windows 8 apps. Project Siena features a simplified user interface builder, an Excel-like expression language, and data-bound controls. It generates Windows 8 JavaScript apps. Project Siena is itself a Windows Store app, and runs fine on Windows RT (the ARM version). I have been using it successfully on Surface 2, on which it runs sweetly. [Emphasis added.]

When I first looked at Project Siena I tried to build the same first app that I have used for numerous simple tests of development tools over the years: a to-do list. I was impressed by how easy it was to create the user interface, but unable to work out the code to complete it. Unless I missed it, the key information is not included in any of the initial documentation. I found this disappointing, since it has been easy to work out the code in every other programming environment I have tried. …

In Siena, data is stored in Collection objects, and you can bind a listbox to a collection. By default, a new listbox is bound to an object called ListboxSample, but you cannot use it for this; if you try, you get a squiggly line error with the message that ListboxSample is not a collection.

image

Instead, you have to create your own collection object. In Siena, you declare a variable by using it and its type is inferred. Enter this for the OnSelect property of the Add button:

Collect(mycollection,{Value: InputText1!Text})

This is the code that took me so long to work out. The Collect function adds an item to a collection. If the collection does not already exist, it creates it. The first argument to Collect is a collection object, and the second, an item. What is an item? In effect, a record or row in a table. The syntax for an item in Siena is:

{Fieldname1: fieldvalue1,Fieldname2: fieldvalue2,…}

where the dots represent additional fields as required. Therefore, the code I entered for the Add button creates or appends an item with a single field, called Value, to a collection called mycollection.

Now you can select the listbox and tap Data and then Items. The collection called mycollection magically appears for selection. Select it. In the case of multi-field collections, you can also choose which field appears in the list. Only one field it seems; yes, Siena needs a grid control. … [Emphasis added.’]

Defining function expressions to respond to events sounds like programming to me. The Microsoft Project Siena Function Reference lists two operators and 71 functions, many of which have complex argument lists. Even inline If() expressions are supported:

Usage:
  If(predicate1, expression1,
     [predicate2, expression2,
      ...
      predicateN, expression,
      default])

Returns the result of evaluating the expression that corresponds to the first matching predicate. If none of the predicates match, default is evaluated and its result gets returned.

The Project Siena expressions remind me of those available to Microsoft Access developers from the Jet Expression Service.

Instructions for Importing Windows Azure Mobile Services

From the Microsoft Project Siena Help Topics:

… How do I import Windows Azure Mobile Services ([W]AMS) data into my app?

If your enterprise uses Windows Azure Mobile Services, contact your IT department or the administrator of the account for the account details. Then add [W]AMS tables as data sources to your app:

  1. Click the + control in the Data Sources backstage.
  2. Click Azure Mobile Services in the Data Sources menu.
  3. You will be prompted for the URL (usually of the form https://<EnterpriseName>.azure-mobile.net) and AppKey (this is generated when the account is set up; use an application key and not the master key). Enter this information and click the search icon.
  4. All the tables in your [W]AMS instance are listed. Select one or more of the instances and then click Import Data to import the data into your app. 

Note that in the current release, we support a simplified and lightweight interface for accessing [W]AMS data. As part of the [W]AMS setup, your IT administrator will also need to create a table named "zz_config" in your [W]AMS instance for Siena to be able to interact with it. This table should contain the following columns:

  1. Key: This should be set to “table”.
  2. Value: String value that stores the table name.

The zz_config table should contain one row per table that you want to expose to Siena. For example, if you want to allow Siena to access Employee and Sales tables, your zz_config table will have the following entries:

Key Value
“table” “Employee”
“table” “Sales”

Apparently, the Project Siena team didn’t get the memo that “Windows Azure whatever,” not “Azure whatever,” is the naming convention.

Connecting a Project Siena App to Other Data Sources

More from the Microsoft Project Siena Help Topics:

How do I import data into my app?

Links to data sources can be added to your apps for importing data. Create these links through the Data Sources backstage, which can be accessed as follows:

  1. Display the app bar by right-clicking anywhere on the canvas or by swiping down from the top of the canvas.
  2. Click File, and then click Data Sources.
  3. Click the + control to bring up a list of possible data sources.

The current release of Siena supports the following types of data sources that are displayed as options when you click the + control.

  • Excel
  • Windows Azure Mobile Services (AMS)
  • REST
  • RSS Feed
  • SharePoint Lists

Note that your SharePoint site, REST web services, or RSS Feed should not be running on the same device as the published app. If this condition is not met, the app will not be able to access the service because of a security restriction with Windows 8 apps that prevents from calling into web services running on the same device. …

How do I import Excel data into my app?

Perform the following steps to import Excel data into your app:

  1. Click the + control in the Data Sources backstage.
  2. Click Excel in the Data Sources menu.
  3. This will bring up the Windows 8 file picker. Browse to the location where your Excel file is stored, select it, and click Open.
  4. All the tables within the Excel workbook you selected are displayed. Select one or more tables from the displayed list, and then click Import Data to import the data into your app.

Note that only Excel tables will be imported (see Create an Excel table). If the data has been imported successfully, the first three rows of the table will be displayed.

How do I use REST connectors?

Consume data from REST connectors in your app by following these steps:

  1. Click the + control in the Data Sources backstage.
  2. Click REST in the Data Sources menu.
  3. Enter the URL for your REST service.
  4. Choose an authentication method from the drop-down list box.
  5. Select the Enable headers check box, if you want to specify any additional custom headers.
  6. Import the data.
  7. All the tables exposed through your REST service are imported into your app.

Siena can fetch data from REST services using GET requests (your proxy must support GET requests at the supported endpoints) if the following requirements are satisfied. Please contact your IT administrator about these requirements if you are having trouble connecting to your enterprise’s REST services.

How do I import SharePoint lists into my app?

Perform the following steps to import data from SharePoint lists:

  1. Click the + control in the Data Sources backstage.
  2. Click SharePoint in the Data Sources menu.
  3. Enter the URL to your SharePoint site, and then click the search icon.
  4. All the lists on your SharePoint site to which you have access are displayed. Select one or more lists, and then click Import Data” to import the data into your app.

Note that in the current release of Siena, a link to SharePoint data is not live—changes made to the list on the server are not immediately reflected in the app. When loading, the app takes a "snapshot" of the data on the SharePoint server.

How do I import RSS feed data into my app?

Perform the following steps to import data from RSS feeds:

  1. Click the + control in the Data Sources backstage.
  2. Click RSS Feed in the Data Sources menu.
  3. Enter the URL to your RSS Feed and click the search icon
  4. All the RSS feeds in your specified URL to which you have access are displayed. Select one or more feeds, and then click Import Data to import the data into your app.

Note that in the current release of Siena, a link to RSS Feed data is not live—changes made to the feed on the server are not immediately reflected in the app. When loading, the app takes a "snapshot" of the data on the RSS Feed server. In the current version of Siena, only Atom and RSS 2.0 feeds are supported. …

The Missing Link

The question remains how to use the imported data and how to update it, if possible. This undoubtedly requires code but Project Siena’s three current sample apps, AdventureWorks, Real Coverage Finder and Personnel Manager, don’t appear to use external data sources.

The Project Siena Release Notes were the primary documentation for the app when this post was written. Paul Mather posted on 1/2/20114 an illustrated tutorial for a simple app with a Excel worksheet as the read-only data source: Win8 Apps using Project Siena:

image

WAMS provides ToDo demo tutorials for Windows 8 (C# and JavaScript), Windows Phone, iOS, Android, HTML, Xamarin.iOS and Xamarin.Android. My five-part Windows Azure Mobile Services Preview Walkthrough expands on the Windows 8 C# tutorial: 

I’ve requested the WAMS group to create a demo app and walkthrough for Project Siena. I’ll update this post when and if they do so.

0 comments: