Microsoft Office Tutorials and References
In Depth Information
Custom Data provider Class (Listing 2-6)
Before beginning, it is important to understand some of the key concepts. First, prepare to query data from data
sources that are not natively supported. second, these operations must be asynchronous in order to perform the
tasks in a timely fashion. and most importantly, the methods used must be thread safe.
Microsoft.Office.Visio.Server assembly provides these functionalities with its abstract class
AddonDataHandler and its abstract methods that deal with all the necessary data-module implementations.
add a reference to Microsoft.Office.Visio.Server because the derived class will be inheriting the
AddonDataHandler abstract class. it needs to also inherit the IAsyncResult interface from the System
namespace to get the result of the asynchronous operation. though there are many methods to override, the most
important to understand are BeginGetData and EndGetData .
Visio services calls the custom data provider’s BeginGetData() method as soon as the request begins. Under the
BeginData() method, create a thread and delegate a method to it. Create a callback method to be aware of when
the thread completes its job:
ThreadPool.QueueUserWorkItem(new WaitCallback(GetData), callback);
in the GetData() method, create an instance to the WCF service object and call the GetServerStatusDetails
method to retrieve the server status details:
ServerStatusClient oServerStatus = new ServerStatusClient();
DataTable dt = oServerStatus.GetServerStatusDetails();
this.Data.Reset();
this.Data.Tables.Add(dt);
this.Data.AcceptChanges();
after the set operation completes its job by retrieving the data, Visio services calls the EndGetData() and returns
the Data object as DataSet :
return this.Data;
VBa Code (Listing 2-8)
the VBa code is used it to create and populate a data source that can be used by the Visio diagrams.
this is similar to creating a data source using macros.
the code is very simple. it begins by initializing the data objects such as recordset, connection strings,
command text, etc.
Dim diagramServices As Integer
Dim vsoDataRecordset As Visio.dataRecordset
Dim dataRecordset As Visio.dataRecordset
Dim connectionString As String
Dim commandText As String
 
Search JabSto ::




Custom Search