Share via


Offline Support in the Issue Tracking Solution

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Issue Tracking solution makes it possible for users to access the solution and its associated data when not connected to the network. Users can add, modify, and delete issues offline and have the changes updated to the network database after reconnecting to the network.

Taking the Solution Pages Offline

In order to make it possible for the team solution to run while offline, all of the pages used in the solution must be available offline. Microsoft Internet Explorer makes it possible for the user to specify that a given page be available offline. However, by default, Internet Explorer only makes that one page available offline. The solution itself must make sure all of the pages are available offline.

Using the CDF File

The Issue Tracking solution makes sure all of the pages go offline by using a Channel Definition Format file (CDF). Originally, CDF files were designed as an application of the Extensible Markup Language (XML) that provides the ability to offer automatic information delivery to client browsers in the form of channels. CDF uses special data files to define logical groupings and scheduling for a set of channels.

CDF files makes it possible for you to specify that a set of files should be available offline by following the links in the file being made available offline. Access Workflow Designer takes advantage of this feature to ensure all the required team solution files are taken offline. When a team template is deployed, a CDF file called

MODREPL.CDF

is generated.

The CDF file contains code similar to the following example.

<?XML Version="1.0"?>
<CHANNEL HREF="http://servername/IssueTracking/default.htm" PRECACHE="YES" LEVEL="10">
    <ABSTRACT>MOD Replication CDF</ABSTRACT>
    <TITLE>Insert Title Here</TITLE>
    <ITEM HREF="http://servername/IssueTracking/default.htm"></ITEM>

</CHANNEL>

This file specifies the base channel using the <CHANNEL> tag, which, in this case, is the page in the solution that contains links to all of the files required by the solution. The PRECACHE parameter specifies that the files should be downloaded and cached on the user's system. The LEVEL parameter specifies the number of levels (or links) deep the client should "site crawl" and precache the files. By specifying 10, all of the solution files are precached and are available for use offline.

To use the CDF file, a link such as the following one must be placed on every page in the solution.

<LINK id=AppOffline rel="offline" href="modrepl.cdf">

The link tells Internet Explorer to use the CDF file when adding a page to the user's Favorites list.

Changing the Database in Use

Another aspect of team solution offline support is the ability to create a local replica of the network database on the user's local machine using the Microsoft Data Engine (MSDE). In order for offline to work properly, the Issue Tracking solution must be able to connect to the network database when online and the local MSDE database when offline. This is done by dynamically changing the ConnectionString at run time that is used to connect to the database.

Offline Redirect Code in the modConStr.vbs File

Each Web page that is required to connect to the database must contain support for dynamically changing the ConnectionString at run time. Each page uses the same technique for this, which consists of including a VBS file that returns the proper ConnectionString based on whether the user is online or offline. Then, the ConnectionString returned is used in all database access in the Web pages.

When a solution is created from a template, Access Workflow Designer generates the file modConStr.vbs. This file contains VBScript functions that return two versions of the ConnectionString: one for connecting to the online database and the other to the local offline database.

The following functions are used to redirect the ConnectionString when offline.

Functions Description
GetConnectionString
Returns a complete ConnectionString based on whether Internet Explorer is online or offline.
GetSystemDBConnectionString
Returns a complete ConnectionString to the modSystem database based on whether Internet Explorer is online or offline.
modGetConnectionStringEx
Used to get a specific online or offline ConnectionString.
modGetSystemDB
Returns the name of the system database. This always returns "modSystem."
modGetApplicationDB
Returns the name of the solution database. The database name is the name of the database used when creating the solution from the template.
modGetServer
Returns the name of the network SQL Server that holds the solution database.
modGetLocal
Returns the name of the local server. This always returns "(local)."
modGetOS
Returns either "Windows NT" or "Windows," based on the user's operating system.

Dynamically Changing the ConnectionString

Each Web page includes a VBScript file, Connect.vbs, that changes the ConnectionString used based on the functions in the modConStr.vbs file.

In order to use these VBScript files, these files must be made available in the Web page using <SCRIPT> tags that use the src parameter to specify an external script file. This tag makes available all of the functions in these files to any other scripts within the Web page.

<SCRIPT id=connectionStringVBS language=vbscript src="./modconstr.vbs"></SCRIPT>
<SCRIPT id=CreateConnectionScript language=vbscript src="./connect.vbs"></SCRIPT>

These <SCRIPT> tags must be placed within the <BODY> tag of the Web page to ensure the data access page MSODSC object has been loaded first.

Connect.vbs contains the functions that begin the work of dynamically changing the ConnectionString. The subroutine

CreateConnection

is executed immediately on start up of the Web page by placing the command

CreateConnection 

inside a script block but outside any subroutine or function block. This causes it to execute as soon as Internet Explorer encounters it.

The

CreateConnection

subroutine calls the modConStr.vbs function

GetConnectionString

to get the correct ConnectionString based on whether Internet Explorer is online or offline.

strConnectionString = GetConnectionString()

Once the correct ConnectionString is retrieved, a connection is attempted using a stand-alone ADO Connection object in the global variable, oConnection. If the user must be prompted for a login password, the Web page EnterPassword.htm is used. If the connection is successful, the ConnectionString of the MSODSC object is set to the ConnectionString of the oConnection object.

document.all("msodsc").ConnectionString = oConnection.ConnectionString

If the connection was not successful, a message is displayed to the user, and Internet Explorer is navigated to a blank page.