Docstoc

Designing Visio Automation Solution

Document Sample
Designing Visio Automation Solution Powered By Docstoc
					Contents
Overview & Scope ......................................................................................................................................... 2
Architecture & Framework ........................................................................................................................... 2
   Technology evaluation .............................................................................................................................. 2
   Base framework ........................................................................................................................................ 2
   Object model graph .................................................................................................................................. 3
Visio features ................................................................................................................................................ 4
   Visio active-x drawing control................................................................................................................... 4
   Out-of-the-box features ............................................................................................................................ 4
   Custom features........................................................................................................................................ 5
Architectural Extension ................................................................................................................................. 6
   Service Map to Service Catalog................................................................................................................. 6
Designing Visio Automation Solution
Overview & Scope
This document describes suggestive approach for designing solutions which involve office automation
using Microsoft Visio. Shared are the learning derived from successful delivery of Managed Solutions
project – ‘ServiceMap’. Scope of the document is not to cover on explaining design patterns, instead
illustrates how applying relevant patterns help building effective solution.


Architecture & Framework


Technology evaluation
Microsoft Visio is diagramming and information visualization tool for modeling business and technical
diagrams. Visio provides drawing control tied with SDK for programming. DotNet windows form
application hosting Visio drawing control will provide canvas-like drawing surface. Visio drawing
functionalities can be implemented using Visio’s SDK which makes programming more API model driven
and hence increases developer’s productivity. Visio shapes has shape sheet which allows developer to
add custom attributes to the shape. Persisting custom attributes is achieved as and when the Visio
document is saved. Shape also have data linking facility by which external data source like share point
list or database can be connected and data can be linked to the shape inside the drawing. In-built
shapes or user defined shapes can be created and added to Visio stencil to hold list of master shapes
which can be used while drawing.

Base framework
The base framework to interpret user interaction with the designer surface is via ‘Command Pattern’
and the concern of separation between the view and core operation logic is through ‘Presentation
Model’.

View: Contains the windows form which hosts the Visio drawing activex control as designer surface. The
view also includes interactive menu bars / tool strips and context sensitive menu items. View includes
other windows like managing attributes of shapes, setting color to shapes, panning and Zooming
window.

Model: Contains command handler classes which realizes the Execute() method of ICommandHandler
interface. Each command handler is associated to command(s), accepts Event Argument as parameter
and perform respecting operational logic.

PresentationModel: Contains instance of view. Each view (windows form) creates their own instance of
Presentermodel and passes view (themselves) as parameter to presentermodel. Presenter model is
view specific which contains Command Invoker that prepares event arguments and invokes model’s
command handler.


                           View




                       Visio Drawing
                           control




                      PresenterModel


                                   ICommandInvoker
                                       +Invoke()

            Object
            Model


                                       IEventArgrs




                           Model




                     ICommandHander
                        +Execute()




Object model graph
Need for object model graph:

Programming model limitation with Visio is to arrive at relation between shapes. Two shapes can be
connected by a connector and this linked relation does not imply underlying business relationship like
parent-child / tree / hierarchy. Diagram has list of shapes; shapes are either linked or overlapped to
show relation among them. Hence there is need to capturing an in-memory object model which can
depict both individual shape’s instance and relation with other linked shapes.

What does object model contain?
A Visio shape is mapped to .net entity object which could hold ID of the shape and shape collection
which holds list of children shapes. This collection can hold related shapes / children shapes /
overlapping shapes based on the nature of drawing and its business need. Along with it, the shape
entity can have programmer friendly methods like add, delete, find, sort methods on the shape
collection. To add more business dependent logic, custom events can be introduced to shape entity
which will trigger events on add/delete operations (as per requirement).

How is object model graph created?

Whenever a new shape is added to the drawing surface, in the corresponding event handler an instance
of shape entity class is created passing the shape’s unique Id. When children shapes are added to a
shape, list of children shape entities are created and added to parent shape instance’s shape collection.
Similar is delete functionality.


Visio features


Visio active-x drawing control
The Visio Drawing Control is a Microsoft ActiveX control that provides full access to the Visio object
model (API) and user interface so that you can integrate the Visio user interface, customize its
appearance, and automate Visio in your applications. The Visio Drawing Control is provided with both
Microsoft Office Visio Standard 2007 and Microsoft Office Visio Professional 2007, and is installed when
you install Visio. Microsoft Office Visio 2007, or another version of Visio that supports the Visio Drawing
Control must be installed on any computer where the Visio Drawing Control will be used. When you
distribute your application, all users must have licensed copies of a version of Visio that supports the
Visio Drawing Control on their computers to use it. To gain access to the Visio object model, use the
Window or Document property of the Visio Drawing Control. Once you have access to the Visio object
model, you can use all the standard objects, methods, properties, and events of the model to automate
and customize the control in your program.

Out-of-the-box features
Most of the drawing capabilities and other related features provided by Visio can be achieved using
Visio SDK and drawing control.

Pan & zoom

Visio’s Pan & zoom window can be incorporated to your custom application. Panning / zooming
performed through this window will reflect changes of underlying drawing control.

Hyperlinks
Shapes dropped into drawing control can have hyperlink(s). Adding hyperlink can either be a file or url.
Multiple links can be added and can be made available in the right click context menu. Follow command
will help navigating to the respective hyperlink.

Export to feature

Document object provides SaveAs and Export functions through which the drawing can be saved into
multiple formats like VSD, VDX, JPEG, etc. Using Save As Web API, the drawing can be exported to HTML
file which has rich client scripting added to it that provides pan/zoom, search shape, view shapes’
attributes and hyperlinking features enabled on the exported file.

Visio XML schema

Visio drawing can be saved in binary format VSD file. Alternatively, it support saving into xml format as
VDX file which follows Visio XML Schema. This allows reading and manipulating content of the drawing
through programming. Also, the VDX format provides flexibility and support to save custom data into
the SolutionXML tag. The VDX file can contain multiple solution xml tag which should be uniquely
named and can have well formed XML content in it. Saving your custom application related information
can be achieved using get / set solutionxml methods of Document object.

Custom features
Layout management

Aligning & positioning shapes or group of selected shapes in a page is available in Visio. But this requires
additional programming. Methods like CentreDrawing, Layout and properties like ResizePage are used
based on need to manage layout along with applying styles like Hierarchy or flowchart to arrange
shapes. Arranging based on selected style also ties up with direction like Left to right, top to down etc.
Moreover, style to connectors can also be set namely, straight or curved. Based on nature of drawing
and how shapes are linked, programming arranging and positioning shapes are bit complexity involved
and needs care.

Expand / collapse

Object model graph plays vital role in implementing many features which cannot be achieved out-of-
the-box using Visio APIs. Since object model graph can be traversed and searched through, when user
selects a shape and collapses it, all children shapes are moved to a layer which is marked visible = false.
Every page has two default layers – one for the shapes and other for connectors. Create new layer and
hide it. Move the list of shapes under selected parent from default layer to hidden layer on collapse
command. Note, the object model graph still has the relationship maintained in it alive. When user
selects a collapsed shape and calls expand, find list of children shapes to the selected parent shape from
object model graph. Move these shapes from hidden layer back to default layer. Using Layers in Visio
and in-memory object model graph helps achieving this feature which is not available in Visio.
Note: similar logic can be applied to create a tree view of all shapes in a separate window where each
node in tree view maps to shape in the drawing. For example: showing WBS items in a tree view for an
elaborate Work breakdown structure diagram.


Architectural Extension


Service Map to Service Catalog
Service Catalog is server component to manage list of service maps in the organization. From service
map designer, user can load / publish / edit a service map in is hosted on service catalog. Service
catalog exposes WCF service with BasicHTTP binding and is hosted on IIS along with service catalog
website. Service Map .NET 2.0 client consumes WCF service by adding web reference to service.
Dedicated Command Handler in service map’s model will perform communication with service catalog
web service.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:7
posted:11/23/2011
language:English
pages:6