cs 8628 – n-tier client-serverarchitectures, dr. guimaraes bookeeper sridevi srinivasan cs 8628,...

15
CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes BooKeeper Sridevi Srinivasan CS 8628, Summer 2003 Replication in Pocket PC Environment using Mobilink

Upload: lucinda-morris

Post on 27-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

BooKeeper

Sridevi Srinivasan

CS 8628, Summer 2003

Replication in Pocket PC Environment using Mobilink

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Introduction

• BooKeeper is an application developed for Pocket PC environments using MobileVB.

• This application demonstrates the capabilities of the synchronizing capabilities of Mobilink

• For this application Adaptive Server Anywhere database is used as the Consol database (Sync Server) and Ultralite database is used as the Remote database(Sync Client

• Sql Anywhere is chosen since it has all synchronization setups built into it.• Ultralite is chosen for client since the API supports synchronization from within code.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Abstract

• Bookeeper schema consists of three tables. (Author, Publisher and Books).

• The schema is identical between the consol and the remote databases.

• Synchronization has been implemented only for the Author and Publisher tables.

• A step by step setup document has been created to illustrate the synchronization.(BooKeeper Setup.doc)

• The Setup document describes how to create and populate the Consol database.• The ultralite schema file already has the table and publication definitions built into it.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Sequence of Tasks

In a nutshell, the steps are • Create a Consolidated Database • Create Tables and Insert Data in Consolidated Database • Create an ODBC Data Source for Consolidated Database• Create Synchronization Scripts• Create the Remote Database using Schema Painter• Create Tables and Publication for the remote database.• Create Syncrhonization Subscription• Develop the App using MobileVB to read write and sync

from these tables.• Deploy the app to the Pocket PC.• Start Mobilink Synchronization Server• Start the application and Sync the databases from the

Pocket PC

• The steps involving creating the remote database,the tables and the publication is all done using the schema painter.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Project Description

• The BooKeeper App consists of three forms. frmDetail – This form has the ability to read & insert & Sync data for all the three entities of the

schema.form_sync – Default Sync template form provided by ultralite to indicate the progress of syncing.

frmMain – This is a launcher pad

• The idea is to be able to add a new author from the pocket pc and sync it to the Sync Server database and vice versa.

• The synchronization scripts have been written “upload_insert” and “download_cursor” events only for the tables Author and Publisher.

• Since the sync scripts have been written for only upload_insert and “download_cursor” only, the databases are in kept in sync only for Insertions.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

E-R Diagram

• The actual database does not have all the columns depicted in here for simplicity.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Logical Schema

Author AuID (PK) AuName Publisher PubID(PK) PubName Books BkID Title AuID(FK) PubID(FK)

• Assumption – A book has only one Author and one Publisher.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Physical Schema (DDL)

create table Author (AuID char(12) primary key,AuName varchar( 50 ))

go

create table Publisher (PubID char(12) primary key,PubName varchar( 50 ))

go

create table Books (BkID int primary key,Title char(64),AuID char(12) references Author(AuID ),PubID char(12) references Publisher(PubID))

go

• All the columns mentioned in the ER diagram are not implemented in the DDL.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Matrix: Forms vs. Tables

• frmDetail is the only form that reads and writes to the database• modConst is a bas module that has not been displayed here. It just has some global const

declarations.• The code behind Form_sync is auto generated.

Author Publisher Books FrmMain -- -- -- frmDetail CRU CRU CRU Form_sync -- -- --

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Publication Script # 1

• The publication scripts for this project were created using the ultralite schema painter.

• The Name of the publication is pubMain and it includes all the three tables in the schema (Author, Publisher & Books)

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Synchronization Script

• call ml_add_table_script( 'default','Author','upload_insert','insert into Author(AuID,AuName) values(?,?)')

• call ml_add_table_script( 'default','Author','download_cursor','select AuID,AuName from Author')

• call ml_add_table_script( 'default','Publisher','upload_insert','insert into Publisher(PubID, PubName) values (?, ?)')

• call ml_add_table_script( 'default','Publisher','download_cursor','select PubID, PubName from Publisher')

• Prior to running this script the actual tables & the Script version “default” needs to be created in the Consol database. The step by step instructions in the setup guide walks you thro’ this.

• As you can see the synchronization is implemented for only the “upload_insert” and “download_cursor” events only. The idea is to depict that synchronization can be done.

• This script needs to be run on the consol database from interactive SQL.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Difficulties Encountered

• Appforge Licence Key Problem. (Apps can be created and run on the pkt pc for only two days with the evaluation license. You need to get a new one after that for every two days)

• SQLE_UNABLE_TO_START error while connecting to the database from the pocket pc. (This was due to a path problem. Once I fixed the connect string to have the right paths, the problem went away)

• When I deploy a database created on the desktop to the pocket PC, for some reason the database is not opened correctly. Therefore, I had to ship only the ultralite schema file and create a new database off of that from the PocketPC.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Screen Snapshot # 1

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Code Sample # 1

• To connect to the database#If appforge Then sAppPath = "\BooKeeper"#Else sAppPath = App.Path#End Ifconn_parms = "uid=DBA;pwd=SQL;"open_parms = conn_parms & "FILE_NAME=" & sAppPath & "\" & dbName & ".udb;ce_file=" & sAppPath & "\" & dbName & ".udb"schema_parms = open_parms & ";schema_file=" & sAppPath & "\" & dbName & ".usm;ce_schema=" & sAppPath & "\" & dbName & ".usm“Set Connection = DatabaseMgr.OpenConnection(open_parms)

• To insert to the Author tabledesTable.InsertBegin

desTable.Column("AuID").StringValue = txtID.Text desTable.Column("AuName").StringValue = txtName.Text desTable.Insert

' Perform this transaction Connection.Commit

• To Perform Synchronization With Connection.SyncParms .UserName = "dba" .Password = "sql" .Stream = ULStreamType.ulTCPIP .Version = "default" .SendColumnNames = True .StreamParms = "host=SRIVASAN1" 'Needs to be changed to the name of the server machine End With ' Initialize the sync form to allow sync event callbacks Form_Sync.InitSyncForm Connection

Connection.Synchronize

• The sAppPath variable the forms the connection parameters needs to bet according to whether the app is running on the IDE or on the pocket pc.

• While navigating between records, the code detects eof and bof conditions and informs the user whether it is the last or first record.

CS 8628 – n-tier Client-ServerArchitectures, Dr. Guimaraes

Conclusion

• The lifecycle for developing to implementing this project was very similar to a normal three tier application development.

• Since the mobileVB IDE was easier to use and it integrated well with the ultralite databases, there were no surprises.

• This has been a good learning experience and thank you very much Prof. Mario Guimaraes.

• It would have been really cool to have performed some wireless application development along with this.

• .NET Compact framework would have been my choice of product for that.