Chapter 2. Visio Services

You've probably heard that a picture is worth 1,000 words, and also that actions speak louder than words. If you put those two axioms together, you get the idea of Visio. It is often far easier to understand and simpler to explain a concept, a theory, or even a story by presenting actions visually in blocks and diagrams rather than words. Visio is a very powerful vector graphic tool you can use for exactly that.

Introduction

Let me walk you through a small story called "My day begins with...". I wake up early in the morning, get ready, and start from home at about 7:15AM. On my way driving to office, I stop by the nearest coffee shop to pick up my morning beverage. I choose hot chocolate and head for the office—yet another decision to make, whether or not take the freeway. I quickly look over my shoulder and as there's not a lot of traffic, I choose to drive on local streets. At 8:45AM, I arrive at the office.

Notice the italicized words in my little story. It's all about initiation, actions, decisions, and concluding. Well, of course these four elements and maybe few others are required to run our lives and, in fact, any job too. Simply put, if I want to tell my story in the form of diagram or a flow chart, it becomes a sort of storyboard—a logical sequence of boxes connected together, as shown in Figure 2-1.

"My day begins with..." storyboard

Figure 2-1. "My day begins with..." storyboard

This chapter introduces you to Visio Services and discusses using Visio with SharePoint 2010. If you're familiar with Visio 2007, a few concepts might be redundant. You might want to either skip them or parse them quickly.

What Will You Learn?

By the end of the chapter, you'll learn about:

  • The essentials of Visio Services.

  • Setting up Visio Services on SharePoint 2010.

  • Publishing a basic Visio diagram to SharePoint.

  • Connecting Visio diagram to

    • A SharePoint List.

    • SQL Server with and without Secure Store Services.

    • Data using a custom data provider (using Visual Studio and WCF).

    • Workflows and Visio with SharePoint Designer 2010.

  • Management of Visio Services using Central Administration (CA).

  • Management of Visio Services using Windows PowerShell.

To be able to use this book successfully, you'll need the following software:

  • SharePoint Server 2010 Enterprise Edition

  • SQL Server 2008 R2 Developer Edition x64 / SQL Server 2008 x64

  • Visio 2010 x64

  • SharePoint Designer 2010 x64, available for download at www.microsoft.com/downloads/en/details.aspx?FamilyID=566D3F55-77A5-4298-BB9C-F55F096B125D

  • Visual Studio 2010 Professional Edition, trial version available for download at www.microsoft.com/visualstudio/en-us/products/2010-editions/professional

  • If you'd prefer using the Express editions of Visual Studio and SQL Server, you can download them from www.microsoft.com/express/

Why Visio?

With Visio you can create a wide range of diagrams easily with the help of inbuilt shapes, stencils, and templates. The diagram scope can encompass the simple, like my storyboard, or the complex, like the network representation of an entire organizational infrastructure. It can target various audiences, from business analyst to a developer to a solutions architect. A construction engineer or an interior designer can create a floor plan. An electrical engineer can create a basic electrical circuit or a logic diagram. There are endless possibilities using Visio; you just need to focus your imagination on the available templates to create your own diagrams.

Now, what if your Visio diagrams could come to life? What if you could power these diagrams with data and share them with your colleagues?

Let me give you a real-time example. As an architect in the organization where I work, I'm often asked to give introductory sessions to many people on the project team, and I typically use a Visio diagram to explain the project details. Whenever there are enhancements, updates, or changes to the project, I have to redo my Visio diagram and present it to the team.

Instead of calling for another meeting, I could update and e-mail a new version of the Visio diagram and get final approval. But not everyone has Visio installed. Moreover, where does this information end up? E-mails! Or maybe in yet another set of printed documents that will just collect dust on the shelf. What's missing here?

  1. Collaboration.

  2. Easy viewing. For a Visio diagram you need either the Visio client and related licenses, or at least a Visio viewer (there's a free viewer available at www.microsoft.com/downloads/details.aspx?FamilyID=f9ed50b0-c7df-4fb8-89f8-db2932e624f7&displaylang=en).

  3. Instant update of the diagrams.

  4. Data connectivity

You've all probably thought at some point, wouldn't it be great to be able to share a Visio diagram that's connected to data, where the diagram updates automatically when the data changes. And wouldn't it be wonderful to be able to have end users view the diagram in their browsers, without having to install the actual Visio client.

Well, that solution is here. With Visio Services in SharePoint 2010, you can publish Visio diagrams to SharePoint, drive them with real-time data, and share them easily even when the client is not installed. All of this by using Visio Services in SharePoint 2010.

Presenting Visio Services

Visio Services is new in the SharePoint 2010 service layer. These services are available as part of the Enterprise Client Access License (CAL) and they provide a platform where users can share the Visio diagrams using the SharePoint infrastructure. Visio Services provide various data connectivity models to drive Visio diagrams with data, both real-time and historic.

Setting up Visio Services

Setting up Visio Services is quite simple, requiring just few basic steps. Before beginning, however, ensure you have Farm Administrator privileges.

There are two approaches. In the first, in SharePoint 2010, simply go to Central Administration

Setting up Visio Services

Tip

If you are installing SharePoint for the first time, you'll be prompted to run this step toward the end of the installation. If you prefer, you can just skip it for now and run it later.

Launching the Farm Configuration wizard

Figure 2-2. Launching the Farm Configuration wizard

Now you are prompted to start the wizard, as Figure 2-3 shows.

Choosing to configure the farm using the wizard

Figure 2-3. Choosing to configure the farm using the wizard

To set up the services, you need to have a service account and choose required services from the wizard (Figure 2-4). Be sure you have Visio Graphics Service checked. If this is a fresh installation, this option will be enabled.

Click Next. SharePoint will provision all services selected in this step, and prompts to create a new site collection with the selected services. You cannot choose a service that's already installed since it will be disabled as shown in below figure 2-4.

Select the desired services using the Farm Configuration wizard.

Figure 2-4. Select the desired services using the Farm Configuration wizard.

Note

With this default mode and the service application already available to the default web application, you can now create a site collection using one of the available templates.

This approach is very straightforward. Things get a little more interesting when you haven't set up the services during installation or if you later upgrade your licensing model. In such situations, you can set up Visio Services using the following approach.

Go to Application Management

Select the desired services using the Farm Configuration wizard.
Setting up a new Visio Graphics Service application

Figure 2-5. Setting up a new Visio Graphics Service application

Your new service application will now appear in the list of available service applications and you can configure it, as we'll discuss later in this chapter.

Note

Once you create the new service application, you have to associate it with a web application. You can associate a new service application with a new web application or existing web application.

To associate a new service application with a web application, on the Central Administration go to Application Management

Setting up a new Visio Graphics Service application

Let's now look at an example and see how to perform basic operations using Visio and Visio Services in SharePoint 2010.

As you've seen, it's very easy to create, publish, and view Visio drawings on SharePoint platform. Now let's discuss some of the features and capabilities of Visio Services.

Visio Services Features

  • Visio diagrams are compatible with Internet Explorer, Mozilla Firefox, and Apple Safari.

  • Diagrams are rendered using Silverlight. If Silverlight is not installed on the client machine, diagrams are rendered as PNG image files.

    • You can connect data to shapes [1] in a diagram from various supported data sources.

    • You can use a variety of data graphics [2] for a given data field, and corresponding shapes based on the conditions and data. Figure 2-8 show the idea at a very high level.

    Data graphics that can be used on shapes

    Figure 2-8. Data graphics that can be used on shapes

  • You can set hyperlinks on the shapes. You can link to an Internet address or another local Visio diagram, as shown in Figures 2-9 and 2-10.

    Adding a hyperlink to a shape

    Figure 2-9. Adding a hyperlink to a shape

    Linking a shape to an Internet address or local file

    Figure 2-10. Linking a shape to an Internet address or local file

  • No client-side installation is required—diagrams are fully loaded in the client browser.

  • Real-time data refresh means you can connect your diagrams with real-time data using various data sources, including

    • SQL Server

    • Excel

    • SharePoint Server Lists

    • OLE DB

    • ODBC

    • Custom data providers

Warning

Note that some data sources, such as SQL Server Analysis Services, are not supported.

  • Publish once, use multiple times. You can create the diagrams, connect them to data, and publish them to your SharePoint environment. The diagrams load data from the underlying data sources and you won't have to modify them unless and until the source diagrams change. When the data changes, the shapes will automatically reflect the changes.

  • Various authentication models [3] are supported, including

    • Secure Store Services (SSS)[4]

    • Kerberos or Integrated Windows Authentication

    • Unattended Authentication

Note

In this chapter, we will discuss how to connect to a SQL Server data source, a SharePoint Server list, and a custom data provider, with examples.

In our first example, you saw how to publish a Visio drawing to SharePoint and view it. That's one of the ways to integrate Visio with SharePoint. There are a number of other methods for loading and interacting with a Visio drawing on SharePoint 2010, including

  • Visio Web Access Web Part—Use a Web part that can load a .vdw file.

  • JavaScript Mashup API—Communicate with a Visio Web Access Web part and change HTML content as needed asynchronously.

  • Web Part connections—Connect and communicate with other Web parts on the page.

  • SharePoint Designer with Visio—Create diagrams in Visio, import them into SharePoint Designer, and publish them to the SharePoint environment.

We'll discuss these later in this chapter, but first we'll take a look the architecture and building blocks of Visio Services.

Architecture

Figure 2-11 shows the components a Visio Services environment. Visio Services is loaded into and becomes an integral part of SharePoint Server 2010, which runs on Windows Server 2008 in conjunction with IIS, SQL Server, and Windows Identity foundation (formerly known as Geneva Framework). Visio Services can run in both hosted and non-hosted environments.

Note

Hosted environments are platforms provided by external vendors on which you can run your own applications. You may have some access to the physical servers and file system, but it can be rather limited. Still, this can be a very cost-effective solution and may reduce a lot of your operating costs. Non-hosted or in-house environments, on the other hand, are fully controlled by your own organization. These are physical servers commissioned in your own network that you have full access to.

The architecture of a Visio Services 2010 environment

Figure 2-11. The architecture of a Visio Services 2010 environment

To understand the architecture, let's take a look at the life cycle of a Visio drawing, as shown in Figure 2-12. A designer or a business analyst retrieves data from one of the supported data sources and creates a Visio diagram. He saves it as a drawing file (.vsd), then uploads or publishes the diagram into the SharePoint Server document library as a web drawing file (.vdw). Visio Services then renders this document by accessing the data source and displaying the output to the end user(s) in either Silverlight or as a PNG file. Note that you don't actually need a data source.

Now here's the interesting part: the designer who creates the diagram may not be a part of the entire life cycle of the diagram. He doesn't need to have any knowledge of SharePoint. He can simply create the designs and provide them to the next level in the hierarchy who can publish them to SharePoint. End users' will access the diagrams through application servers and view them in the browser directly. However, the process of publishing a diagram to Visio Services is simple.

Life cycle of a Visio diagram

Figure 2-12. Life cycle of a Visio diagram

Now let's see how Visio lets you bind your web drawings to data.

The Visio 2010 Client's Data Tab

To bind data to a data source in the Visio 2010 client, you use the options accessed by clicking on the Data tab of the ribbon (Figure 2-13). To enable all the buttons that belong to this tab, you should have at least one diagram open. Let's understand what each button does.

Data tab in Vision 2010

Figure 2-13. Data tab in Vision 2010

Link Data to Shapes

Link Data to Shapes is one of the ways you can connect a data source to a shape. You get a simple Data Selector wizard that connects to various supported data sources, as shown in Figure 2-14. You can create more than one data source using this option and use them to connect data to the shapes.

The Data Selector window

Figure 2-14. The Data Selector window

Note

Another way to create a data source is by using VBA code, as you'll see when we look at designing a custom data provider.

Data Graphics

Data Graphics is the mechanism that lets you can connect data to the shape and customize the appearance of the shape. It allows you to add visual information about the data to the shape on the Visio diagram. You can build your own data graphic, assign it to any data field and display the corresponding value in one of these forms: Text, Data Bar, Icon Set, or Color by Value. Data fields are the columns that belong to a list or data table available through the data source you selected.

Data Graphics define additional design structures for the shape, and you can create more than one. Once you set your own custom data graphics, they can be used on any other shapes on the Visio diagram using the Automatically Link button.

Data Graphics get data from the data source specified in Link Data to Shapes or Shape Data Window[5]. When you link to the data source, the data graphics display real-time or historical information based on the customizations you've set on the Visio Graphics Services in the Central Administration.

Here's how to create new Data Graphics:

  1. Click on the Data Graphics icon on the Data tab. This pops up a settings window as shown in Figure 2-15.

    Creating a new Data Graphic

    Figure 2-15. Creating a new Data Graphic

  2. Click Create New Data Graphic... to open a New Data Graphic window.

  3. Click New Item and a new window opens that with settings for display and position as shown in Figure 2-16.

    The Data Graphics New Item window

    Figure 2-16. The Data Graphics New Item window

  4. In the display section, the Data field drop-down consists of the available fields from the connected data source. When there's no data source, few fields are displayed. If you need a data field and don't have a data source, you can define a custom shape data label that can be used as a data field in this context.

  5. To create a custom shape data label, right-click on the shape on your diagram and, from the Data menu, select Define Shape Data.... In the window that opens, enter the Label as "Text" (or your own custom label); select the Type as String (or whatever data type you need); set the Value to a specific data value, and optionally configure other settings if necessary, and click OK.

  6. The label will now appear in the Data field drop-down in the data graphics New Item window.

  7. Once you select your new Data field label, the Displayed as drop-down is enabled and has options for Text, Data Bar, Icon Set, and Color by Value.

For this example, let's go with the Text option.

  1. Choosing Text in the Displayed as field displays the Style drop-down, with various options.

  2. Once you've chosen the style, you can use the Position section to set the style either horizontally or vertically for the shape. For instance, if you want to display the value of the Text within a Circle callout and position it horizontally to the Right and vertically at the Bottom of the shape, the settings would be similar to those in Figure 2-17.

  3. In the Details section, you can set the data field metadata values. For instance, @ in the Value Format field represents Text format.

    Set data field styles, position, and details

    Figure 2-17. Set data field styles, position, and details

  4. Clicking OK returns you to the New Data Graphic window.

  5. You can edit an existing item by clicking Edit Item, and you can delete an item by clicking the Delete button. Click OK to close the wizard.

  6. You can also set the value of the shape using the Shape Data Window that's available when you check this option in the Show/Hide section of the Data tab. You can set the Text value and view how the value is displayed for the shape. For instance, to set the Text value for the flight shape as "Passenger Airplane," select the shape and on the Shape Data Window, type in Passenger Airplane. The text will appear in the bottom right corner of the image as a call out, as per the previous position settings (Figure 2-18).

    Adding text to the shape

    Figure 2-18. Adding text to the shape

Note

You can obtain this shape from More Shapes

Adding text to the shape

Tip

You'll notice the same text label beneath the shape; this is the general text that comes with the shape and it's what would be used as a condition for automatically linking other shapes.

Automatically Link

To use the Data tab's Automatically Link functionality, first you need to set a Text value either by double-clicking on the shape or by using the Shape Data Window on all the shapes. Using the Data Graphics option, you can create items based on data fields (as shown in the previous section). First, you will have to create a complete data graphic for at least one shape. After you create the data sources, you can bind a shape to a row of data by simply dragging and dropping the row onto the shape. This process creates a link between the shape text, the data column name (for instance Title), and the column values of the row. This is the final step before linking all the shapes. Click on the Automatically Link button in the External Data section of the Data tab. The wizard lets you decide whether to link Selected shapes or All shapes on this page, as shown in Figure 2-19.

Automatically link data to shapes

Figure 2-19. Automatically link data to shapes

Choosing one of these options takes you to the next step—mapping the Data Column to the Shape Field, as shown in Figure 2-20. Click Next to reach the Details page, or click Finish to complete the automatic linking. This step links all shapes with the text matching the Data Column name.

Link a data column to a shape field

Figure 2-20. Link a data column to a shape field

Refresh All

Once you create the data sources using Link Data to Shapes, you can refresh them either individually or all at once to get the updated data. When you hover on the Refresh All button, it opens a context menu as shown in Figure 2-21.

Refresh All data window

Figure 2-21. Refresh All data window

Note

Using Refresh All or Refresh Data doesn't affect SharePoint in any way. These options work only with respect to the Visio diagram and the related data source.

You can choose the data source (if one is available) and click on either Refresh or Refresh All to refresh the available data sources as shown in the Figure 2-22. Either action will connect to the data source and retrieve the most recent data. Choosing the data source and clicking on Configure... opens the data source configuration wizard. If no data source was configured earlier, none would be listed in this window.

Refresh Data window

Figure 2-22. Refresh Data window

Insert Legend

Use Insert Legend to display information regarding Data Bar, Icon Set, or Color by Value display options available from the Data Graphics dialog. Legends display information related to the existing page. You can set the legend direction to be either horizontal or vertical. However, legends are not automatically updated. If you modify the diagram, legends need to be manually deleted and inserted once again to reflect the changes.

Insert Legend wizard

Figure 2-23. Insert Legend wizard

Shape Data Window

The Shape Data Window is available by checking the appropriate box on the Data tab. It displays data information about the shape, and you can also set the data values for the shape, as shown in the Figure 2-24.

Shape Data window

Figure 2-24. Shape Data window

External Data Window

You can check the External Data Window box on the Data tab to make this window accessible. It displays all the available data sources for a given page of the Visio diagram, and you can create a new data source by clicking on Link Data to Shapes... as shown in Figure 2-25.

External data window

Figure 2-25. External data window

With the help of these options and settings, you can design the Visio diagrams with shapes, connect the shapes to data, and then publish the drawings to a SharePoint environment. In the next section, you'll see how to integrate all that you've learned so far with Visio and Visio Services.

Integrating Visio with SharePoint

So far you saw at a very high level how to integrate Visio diagrams with SharePoint. Now you'll learn this practically, using some examples.

Let's create a Visio diagram using a SharePoint list as a data source and see how to deploy the diagram to the SharePoint platform.

Using the Visio Web Access Web Part

To have this functionality, be sure to activate the SharePoint Server Enterprise Site Collection Feature feature. You can access the Visio Web Access (VWA) web part, which is available out of the box, under the Business Data Category. To add this web part, click on Edit Page icon.. Click on web part zone and then on the Insert menu under Editing Tools tab on the ribbon. Press the Web Part button, select Office Client Applications, and then Visio Web Access web part. Now click Add to add the Web Access web part to the page. The VWA web part seeks the .vdw file path to display the drawings. Use the Click here to open the tool pane link and choose the .vdw file from your Visio Library as shown in Figure 2-35, then click OK.

Choosing a Visio drawing file for the Visio Web Access web part

Figure 2-35. Choosing a Visio drawing file for the Visio Web Access web part

On the tool pane, leave all the defaults as is and click the OK button at the bottom. The .vdw file is now loaded and you can view the diagram with data as in Figure 2-36.

Visio web drawing file loaded using Visio Web Access web part

Figure 2-36. Visio web drawing file loaded using Visio Web Access web part

The Visio Web Access web part header includes a number of options:

  • Open in Visio: opens the file in either Read-Only or Edit mode, assuming you have the Visio client installed on your machine.

  • Refresh: refreshes the data on the current page of the diagram. You can have more than one page in a diagram.

  • Choose Page: displays any page from the web drawing.

  • Zoom in/out: zooms the image from 10-400percent.

  • Zoom to fit page to view: fits the diagram to the web part height and width.

  • Shape Information: displays a Shape Information pane (movable on the diagram) that provides Shape Data and any hyperlinks on the shape.

Note

You can move the image in any direction by clicking and holding the left mouse button. You can use the scroll button on your mouse to zoom the diagram in or out.

Visio Web Access Web Part Connections

Visio Web Access web parts support two-way communications, providing rich interaction with other web parts on the page. They can act as both consumer and provider. Web part connections can be directly configured in the browser.

Tip

After configuring the connections, if you use the view source option of the browser to view the page, you'll notice that these web part connections are built using JavaScript.

There are many scenarios in which these connections can be helpful. You have already seen how to use a VWA web part that can load a .vwd file and connect to a SharePoint list. Let's use the same SharePoint list and try to filter the information and reveal the shape that results from the filter criteria.

  1. Create a new site page (Airport Stats.aspx in this case) and add the VWA web part. Configure it to load the airport_with_data.vdw drawing file or the Airport.vdw file if you haven't saved the file with a different name. Also add the list web part (Airport Flight Stats) as shown in Figure 2-37.

    Adding the drawing file (using a VWA web part) and custom list to the page

    Figure 2-37. Adding the drawing file (using a VWA web part) and custom list to the page

  2. From the VWA web part menu, click on 'Edit Web Part' link. Once again from the VWA web part menu, choose Connections

    Adding the drawing file (using a VWA web part) and custom list to the page
    Visio Web Access web part connections

    Figure 2-38. Visio Web Access web part connections

  3. Click on Apply or OK on the editor pane.

  4. Now apply the filter on the Airport Flight Stats list for the Number of cancelled flights column and choose 15.

  5. As soon as the filter is applied, notice that the shape with corresponding value is selected, as Figure 2-39 shows.

    Visio Web Access web part connections with filtered data

    Figure 2-39. Visio Web Access web part connections with filtered data

    Tip

    You can use web part connections with any list to obtain filtered data results on the drawing, assuming there is information to filter. If there's no filtered information, you will not see any results.

Here are the various connection options:

  • Send Shape Data To (provider): sends shape data to any other web part on the page.

  • Get Web Drawing URL and Page Name From (consumer): gets diagram URL from another web part on the page to render.

  • Get Shapes to Highlight From (consumer): gets shape name from another web part to highlight the corresponding shape.

  • Get Filter Results From (consumer): gets shape data values from another web part to highlight the shapes based on the values provided.

  • Get Shape to View: gets and zooms to the shape provided.

Note

If you need to configure advanced options, you might have to use SharePoint Designer. You can extend and build custom interfaces to address connections to other web parts on the page using the IWebPartParameters interface. For more details, visit msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.iwebpartparameters.aspx.

So far you've seen publishing Visio drawings either with data (using a SharePoint list) or without data. Now let's see how to connect using SQL Server as a data source, publish the diagrams to SharePoint, and configure security options.

Using a SQL Server Data Source

Now that you've seen how to establish a data connection with a SharePoint list, let's try to connect a Visio diagram to a SQL Server table. First, of course, you'll need to create a database table and then populate the table with some data.

The Double-Hop Issue

Take a look at the error message in Figure 2-44. Basically it means that although you can use impersonated credentials locally, Windows won't forward impersonated credentials to a remote resource (the second hop), so the user's identity is lost even before he reaches the back end. And in this scenario SharePoint can't pass the credentials of the logged-in user all the way to the back end via the services.

What you need is a mechanism by which the logged-in user is impersonated "as someone else" to use Visio services and connect to the back end data. You can achieve this by using the Secure Store Services (SSS) in SharePoint.

Secure Store Services

You can consider Secure Store Services the next generation of the single sign-on service in MOSS 2007. SSS is a credential store that saves account information securely in the database.

You can create and set these credentials on a per application basis associated to an Application Id and use this Application Id for different services that are subject to the double-hop issue. You can consider SSS as a gatekeeper service for authenticating a user (or a group) against an application. You can also set ID for each target application at the farm level.

Configuring Secure Store Services

  1. Make sure you are a Farm Administrator and log on to the Central Administration site.

  2. Click on Application Management and choose Manage Service Applications from the Service Applications group (Figure 2-45).

    Choose Manage service applications on the Central Administration site.

    Figure 2-45. Choose Manage service applications on the Central Administration site.

  3. From the list of available services, click on the Secure Store Service (Figure 2-46).

    Choose Secure Store Service

    Figure 2-46. Choose Secure Store Service

    On the Secure Store Service page, set the following options:

    • Generate New Key: Before beginning to create a new target application, you need to generate a new key from a pass phrase (Figure 2-47). This key is used to encrypt and decrypt credentials that are stored in the database. You must have Administrator rights to create a key.

      The Generate New Key dialog

      Figure 2-47. The Generate New Key dialog

    • Refresh Key: To refresh a key (Figure 2-48), you again need Administrator rights, as well as the pass phrase you set when you created the key.

    Note

    Refreshing a key will be necessary if you add a new application server to the existing server farm, or if you restore a secure store service database, or if you receive errors such as "Unable to get master key."

    Enter the pass phrase to refresh a key.

    Figure 2-48. Enter the pass phrase to refresh a key.

    Warning

    Secure Store Services has its own database. Whenever you create a new key or refresh an existing key, be sure to back up the database.

  4. After you have successfully created the new key, click the New button under Manage Target Applications on the Edit tab of the ribbon and provide the following information in the Target Application Settings window.

    • Target Application ID: A unique identifier that will be used in service applications as the unattended service account reference for authentication. You can't change the Target Application ID once created.

    • Display Name: A name used for display purpose only.

    • Contact E-mail: The primary e-mail for this Application ID.

    • Target Application Type: Specify Individual for individual users and Group for group credentials.

    • Target Application Page URL: Selecting Use default page will use the sign-up page http://yoursite/_layouts/SecureStoreSetCredentials.aspx?TargetAppId=<applicationId>; this option is only available when you select the Individual Target Application Type. If you select Use custom page, you need to create a page first and provide its URL. This page is used to authenticate users. Choose None if you don't want a sign-up page.

  5. Enter VisioServices for the Target Application ID; SSS for Visio Services for the Display Name; <YourValidEmailAddress> for the Contact E-mail; Individual for the Target Application Type; Use default page for the Target Application Page URL (see Figure 2-49). Click Next.

    Configuring target application settings for SSS

    Figure 2-49. Configuring target application settings for SSS

  6. In the Add Field window (Figure 2-50), leave the defaults as is and click on Next to continue.

    Secure Store Service fields

    Figure 2-50. Secure Store Service fields

  7. Add administrator users who need to have access to this Application ID on the Target Application Administrators and click OK.

  8. Return to the Secure Store Services window and choose the Target Application ID created in the previous step. Click the Set button on the Credentials tab of the Edit tab, as shown in Figure 2-51.

    Set Secure Store Service Application ID credentials.

    Figure 2-51. Set Secure Store Service Application ID credentials.

  9. On the Set Credentials for Secure Store Target Application screen (Figure 2-52), enter the Credential Owner, Windows user name and password (and confirm password) and click OK. Credential owners are the members (individuals or group) of the target application that will impersonate credentials when accessing external data.

    Setting credentials for target application.

    Figure 2-52. Setting credentials for target application.

    Note

    Since you will be using SSS for your Visio diagram to connect to the SQL server, you need to enter the user credentials of those who have permissions to the VisioServices database from where you will load data. It must be a low-privilege user, not an administrator.

The previous step creates a new SSS Application ID that can be used to connect to SQL Server from service applications that require additional authentication to retrieve data.

Using Visio with SQL Server and SSS

Now let's configure Visio Services to use the new Application ID.

  1. Go to Central Administration

    Using Visio with SQL Server and SSS
  2. Click on the Global Settings in the External Data section and enter VisioServices under Application ID (Figure 2-53). Click OK.

    Set the External Data Unattended Service Account Applicaion ID.

    Figure 2-53. Set the External Data Unattended Service Account Applicaion ID.

    Tip

    Application IDs are set for each service application, such as Visio Graphics Service. You can also have two Visio Graphics Service applications set for one Web application, one default and the other a Custom Visio Graphics service application. For that, create a new Application ID with different credentials and set them to a new Custom Service Application. You can then add the new custom service application to the web application Service Connections.

    This sets the authorization proxy for the Visio Graphics Services to connect to the SQL Server database and retrieve data without losing the user context.

    Note

    Other settings on Visio Graphics Services under Global Settings include:

    Maximum Web Drawing Size:

    This is the size of web drawing file that can be set, between 1-50MB. The bigger the file size, the slower the rendering and performance.

    Minimum Cache Age:

    This is the minimum duration in minutes each drawing is cached in memory. Set the value to zero if you need real-time data. However, setting this value to zero or too low puts a load on CPU and memory usage. The allowable range is 0-34560. This parameter is valid only for data-driven web drawings.

    Maximum Cache Age:

    This is the value in minutes after which the cached drawings are removed from memory. You need to set this to zero (in addition to setting the Minimum Cache Age value to zero) to get real-time data. Setting this value too high will increase memory consumption but it decreases file I/O and load on the CPU. This parameter is valid only for static web drawings.

    Maximum Recalc Duration:

    This is the value in seconds of the period before an operation times out before a data refresh. The allowable range is between 10 −120.

  3. Open your SharePoint site and click on Mall.vdw in the Visio Library document library to open the Visio diagram in full-screen mode.

  4. Since you have set the SSS, data should display accurately from the database, with the data graphics populating the correct information on the shapes.

  5. On SQL Server, go to the tblLandmarks table and change the data in the rows.

  6. Return to the SharePoint site and refresh the Visio diagram to view the real-time changes in the diagram for the shapes as shown in Figure 2-54.

    Visio drawing connected to a SQL Server data source and published to SharePoint

    Figure 2-54. Visio drawing connected to a SQL Server data source and published to SharePoint

You can also interact with these Visio diagrams and shapes. For example, suppose you want to get more information by clicking on a shape or to pass the information from a shape to another web part. You can achieve these scenarios by using the JavaScript API with Visio Services.

Visio Services JavaScript Mashup API

The Visio Services JavaScript Mashup API provides great functionality for accessing or manipulating the shapes of published diagrams. Using the API, you can alter data, shapes, and pages to make the diagrams more interactive. There are many operations you can perform on the drawings, some of which are discussed below:

  • At the Control level, you can retrieve the version, display mode (Silverlight or Image), active page, and events such as shape selection changed, diagram render complete, etc.

  • At the Page level, you can get the available shapes, selected shape, shape, position, and other details.

  • At the Shape Collection level, you can get the count, items, and metadata, etc.

  • At the Shape level, you can get the shape data and hyperlink, and set highlighting to the shape, overlays, etc.

The Visio Services JavaScript Mashup API lets you create a rich user interface that combines shapes, data, and events.

The API consists of a hierarchy of classes, methods, and events as shown in Figure 2-55. To obtain the reference of the Visio Web Access web part on a page you need to get the corresponding object, which can be accessed via the Vwa.VwaControl object. The next level would be the Page object.

Note

It is very important to understand that the page object in this context is the active web drawing page that is inside VWA web part—not the .aspx page.

On the page, you can have one or more shapes that can be retrieved using the ShapeCollection object. And, finally, you can access the individual shape from the shape collection and its properties.

Visio Services JavaScript Mashup API

Figure 2-55. Visio Services JavaScript Mashup API

To use the JavaScript Mashup API and understand it more clearly, let's begin with a simple exercise.

Now that you have successfully created a simple JavaScript mashup with a Visio diagram, let's understand the code. One of the major reasons JavaScript was chosen to build the API is because of its simplicity.

Understanding the assets.js Code

First we need to get to the application object and create the event handler for the application load.

_application.add_load(onApplicationLoad);

Once the application loads, we get the instance of the Visio web access from the page and add two more event handlers—one when the diagram completes loading and the other when the shape selection is changed. In the life cycle of these events, the onDiagramComplete event fires first, and onShapeSelectionChanged is the last event.

_visioWebPart= new Vwa.VwaControl("WebPartWPQ2");
_visioWebPart.addHandler("diagramcomplete", onDiagramComplete);
_visioWebPart.addHandler("shapeselectionchanged", onShapeSelectionChanged);

After the diagram loads, all the objects are available and the diagram is rendered to the browser. This means that the diagram is completely available on the page and we can get to the page-level properties and methods. For example, we can set the diagram current page zoom value percentage:

var _page = _visioWebPart.getActivePage();
_page.setZoom(85);

Alright, once any shape is selected or changed on the active page, we need the corresponding shape and the shape data. We need to get to Shape Data in order to get the column values. We use the method getItemById() that's submitted through the event arguments.

var _activePage = _visioWebPart.getActivePage();
var _shape = _activePage.getShapes();
var _shapeItem = _shape.getItemById(args);
var _shapeData = _shapeItem.getShapeData();
var _description = "";
for (var j = 0; j < _shapeData.length; j++)
    {
     if (_shapeData[j].label == "Details"){
            _description = _shapeData[j].value;
            continue;
        }
    }

Finally, we get the description and assign it to the div text, like so:

document.getElementById('landmarkDetails').firstChild.data = _description;

Now, suppose your business analyst wants to create a simple workflow using a Visio diagram? Is there a way to connect this diagram to one of the available workflows easily?

Working with SharePoint Designer 2010

The answer is yes. This scenario can be achieved using Visio 2010 diagrams with SharePoint Designer 2010, which now allows importing and exporting Visio diagrams, attaching workflows to them, and then publishing to SharePoint environment.

Warning

You can now visualize the status of the Visio workflow using the workflow visualization web part. However, to use this functionality you need to set Show workflow visualization on the status page from SharePoint Designer.

In some instances, the requirement may not be as simple as just connecting to an Excel file or SharePoint list or even using a SQL Server database. A more interesting scenario would be consuming data from a web service or from a different data source that Visio Services doesn't support natively. In such cases, you would have to write a custom data provider.

Creating Your Own Custom Data Providers

The Visio Services API provides features to build custom data modules or custom data providers. Using the API you can create custom data sources and refresh the data on the Visio diagrams that are deployed to a SharePoint site.

Let's take a look now at how to support non-natively supported data sources by designing a custom data provider.

So far, you've seen a lot of information on Visio and Visio Services. Now it's time to get to know some more references and information. You have seen the administration of Visio services using the UI in Central Administration. Now, you will learn more options for administering Visio Services using both CA and Windows PowerShell.

Administration of Visio Services

Creating a New Visio Graphics Service Application

Administering Visio Services can be done using both Central Administration (CA) or using PowerShell (PS).

Tip

To access PowerShell, simply click on Start

Creating a New Visio Graphics Service Application

Note

  1. Set up an application pool and a managed account before you begin; most of the settings and configurations require both application pool accounts and managed accounts and you really don't want to go back to create them in the middle of operation. Plan ahead and make a list of all these accounts before you begin setting up your farm/application.

  2. Make sure you are member of the Administrators group. Again, you definitely need to be the localadministrator for many obvious reasons. You don't want to start your application with a low privilege account and get access denied for an administration job.

From CA: from Application Management

Creating a New Visio Graphics Service Application

Using PS: at the PS prompt type:

New-SPVisioServiceApplication <ServiceApplicationName> - serviceapplicationpool
<ServiceApplicationPoolName> -AddToDefaultGroup

Deleting an Existing Visio Graphics Service Application

From CA: from Application Management

Deleting an Existing Visio Graphics Service Application

Using PS: at the PS prompt type:

Remove-SPServiceApplication <VisioServiceApplicationName>

List all Existing Visio Graphics Service Applications

From CA: from Application Management

List all Existing Visio Graphics Service Applications

Using PS: at the PS Prompt type:

Get-SPVisioServiceApplication

Creating a New Visio Graphics Service Application Proxy

From CA: You can only create an application proxy when creating a new Service application.

Using PS: at the PS prompt type:

New-SPVisioServiceApplicationProxy <ServiceApplicationName>

Note

Service application proxies stand as the gateway or channel for connecting with service applications. They are deployed along with the service applications and encapsulate the components used to execute the calls on the service application.

Delete an Existing Visio Graphics Service Application Proxy

From CA: from Application Management

Delete an Existing Visio Graphics Service Application Proxy

Using PS: At the PS Prompt type:

Remove-SPServiceApplicationProxy <ProxyID>

List All Existing Visio Graphics Service Application Proxies

From CA: from Application Management

List All Existing Visio Graphics Service Application Proxies

Using PS: At the PS Prompt type:

Get-SPVisioServiceApplicationProxy

Setting Up Visio Graphics Service Global Settings

From CA: from Application Management

Setting Up Visio Graphics Service Global Settings

Using PS: To set the performance parameters, at the PS Prompt type:

Set-SPVisioPeformance -MaxDiagramCacheAge <InMinutes> -MaxDiagramSize <SizeInMB> -
MaxRecalcDuration <InSeconds> -MinDiagramCacheAge <InMinutes> - VisioServiceApplication
<VisioServiceApplicationName>

To set the data configuration, at the PS Prompt type

Set-SPVisioExternalData -VisioServiceApplication <VisioServiceApplicationName> -
UnattendedServiceAccountApplicationID <ApplicationID>

Setting Up a Graphics Service Trusted Data Provider

From CA: from Application Management

Setting Up a Graphics Service Trusted Data Provider

Using PS: To create a new Trusted Data Provider, at the PS Prompt type

New-SPVisioSafeDataProvider -DataProviderId <ProviderID> -DataProviderType <Int32> -
VIsioServiceApplication <VisioServiceApplication>

To edit an existing Trusted Data Provider, at the PS prompt type

Set-SPVisioSafeDataProvider -DataProviderId <ProviderId> -DataProviderType <Int32> -
Description <String> -VisioServiceApplication <VisioServiceAPplicationName>

To delete an existing Trusted Data Provider, at the PS Prompt type

Remove-SPVisioSafeDataProvider -DataProviderId <ProviderId> -DataProviderType <Int32> -
VisioServiceApplication <VisioServiceApplicationName>

Factors Affecting the Performance of Visio Services

Many factors are involved in the performance of the Visio Services. One of the key factors is often the infrastructure itself. If the following items don't help you achieve optimum performance, keep in mind that the weakest link may well be your infrastructure.

  • Complexity of the drawing. This involves the number of shapes, data sources, and pages used, and so forth.

  • Number of users accessing the drawing. The number of end users accessing a drawing simultaneously, especially during peak load hours, affect performance.

  • Size of the drawing. The size of the drawing itself can be a factor; the more complex the drawing, the greater the size and this takes more time to render.

  • Data source performance. External data sources connectivity, access, and performance all influence performance.

  • Data refresh settings. As we discussed earlier, when you have a smaller data refresh interval, you get more real-time access and less from the cache, which can hit performance badly.

Note

For more information please read the TechNet article "Plan Visio Services deployment" at http://technet.microsoft.com/en-us/library/ff356849.aspx.

Summary

In this chapter we have looked at the following (see Figure 2-83):

  • Why we should use Visio and what the new Visio Services in SharePoint Server 2010 are.

  • The Visio client and its new features.

  • Integrating Visio with SharePoint using a Visio Web Access (VWA) web part and the JavaScript Mashup API.

  • Implementing Secure Store Services and using it in conjunction with Visio, SQL server, and SharePoint.

  • Designing custom data providers with Visio Services.

  • Administering Visio Services.

Visio Services in SharePoint 2010

Figure 2-83. Visio Services in SharePoint 2010

What's Next?

In the next chapter, you will learn about Reporting Services in SQL Server 2008 R2, architecture and installation, Reporting Services Add-in, data source management, Report authoring tools, and integration of Reporting Services with SharePoint. You will also learn about publishing reports in native and SharePoint mode, Access Services, and managing Reporting Services.



[1] Connecting data to shapes is explained in the "Understanding Data Tab in Visio 2010 Client" section.

[2] Data graphics are explained in the "Understanding Data Tab in Visio 2010 Client" section.

[3] Explained in the "Using SQL Server Data Source" section.

[4] Explained in the "Secure Store Services" section.

[5] Explained in the "Shape Data Window" section.

[6] The .odc file can be repurposed to create a new data source connection from the Data Selector window by choosing the option Previously created connection.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset