I am trying to redirect users to replica on server A when they access a database server B or Server C, providing that Server A is accessible, and close the other database they originally opened. This code works for Notes Client 6.0.3 but when ran on Client 7.0.2 the Notes Client status bar states - “Error - script is busy” and the Client shuts down. When I rem out the Call uidb.close line then the 7.0.2 client does not shut down and both db’s are open on the client. Is this a bug in Notes 7.0.2 or is there a work around.
Here is my code in the Database script:
Sub Postopen(Source As Notesuidatabase)
'01/05/2007 (mdz) this script checks the current server and if it is “ServerB” then it will attempt to open the
'production database on “ServerA”. If open is successful then it redirects the user to the production replica
'and closes the source database and also removes the icon on the desktop for the offending database when the database closes.
removeIcon = False 'this will flag to remove the Icon being used if set to true
Dim ws As New NotesUIWorkspace
Dim ses As New NotesSession
Dim uidb As NotesUIDatabase
Dim thisdb As NotesDatabase
Dim prodDBA As New NotesDatabase ("","")
Dim prodDBB As New NotesDatabase ("","")
Dim configDoc As NotesDocument
Dim nam As NotesName
Dim repID As String, msgTitle As String, message As String
'setup Notes Stuff
Set uidb = source
Set thisdb = uidb.Database
Set nam = ses.CreateName(thisDB.Server)
Set configDoc = thisDb.GetProfileDocument("Systemdoc")
'get replica of Db and try to open the Production Database
repID = thisDb.ReplicaID 'used to find replica on production server
thisServer = nam.Abbreviated
thisDbPath = thisDB.filePath
'get the names of the servers from the system document
prodServerA = configDoc.GetItemValue("prodServerA") 'first production copy
prodServerAName = prodServerA(0)
prodServerB = configDoc.GetItemValue("prodServerB") 'second Production Server
prodServerBName = prodServerB(0)
DRServer = configDoc.GetItemValue("drServer") 'disaster recovery server
drServerName = DRServer(0)
If thisServer = prodServerAName Then Exit Sub 'it is the production server so allow access
If thisServer = prodServerBName Then 'it is on the 1st backup server
'check availablity of production database on production server
If ProdDbA.OpenbyReplicaID(prodServerAName,repID) Then 'production is up and running
removeIcon = True
Call ws.OpenDatabase(ProdDbA.Server,ProdDbA.filePath,"(All Wires)") 'open the production database
’ Call uidb.Close 'close the original database used
Set thisDB = Nothing
Set ProdDb = Nothing
Exit Sub 'done with script
Else
Exit Sub 'allow access to the current database
End If
End If
If thisServer = drServerName Then 'then it is on the disaster recovery server
'try to open production db based on source db replica id, then try 1st backup server after that.
'If both are down then allow access to DR Db.
If ProdDbA.OpenbyReplicaID(prodServerAName,repID) Then 'production is up and running
removeIcon = True
Call ws.OpenDatabase(ProdDbA.Server,ProdDbA.filePath,"(All Wires)") 'open the production database
’ Call uidb.Close 'close the original database used
Set thisDB = Nothing
Set ProdDbA = Nothing
Set ProdDbB = Nothing
Exit Sub 'done with script
Elseif ProdDbB.OpenbyReplicaID(prodServerB(0),repID) Then 'production server down - check for 1st back up server
removeIcon = True
Call ws.OpenDatabase(ProdDbBB.Server,ProdDbB.filePath,"(All Wires)") 'open the 1st backup database
’ Call uidb.Close 'close the original database used
Set thisDB = Nothing
Set ProdDbA = Nothing
Set ProdDbB = Nothing
Exit Sub 'done with script
Else
'looks like both Server A and Server B are down - open the DR server replica AKA Server C
End If
End If
Goto EndofCode
EndOfCode:
End Sub