Community
Showing results for 
Search instead for 
Do you mean 
Reply

Load Plugin for specific database only

Nickel Elite Contributor
Posts: 508
Country: USA

Load Plugin for specific database only

I'm writing a plugin for some users who work for more than one company, and have more than one ACT db.  The plugin cannot interfer with the other databases, and therefore only needs to load for one particular.  Which, of course, since they are remotes, are not all named the same thing.

 

I have an if..then written that looks at an InStr value, but then I'm at the mercy of whoever creates remotes to remember this naming convention (see below).

 

Is there a way to load just for a specific, or is there another value I can search/compare on such as publisher db name, that will allow this functionality?

 

Here's what I'm using in testing:

 

Private Sub ActApp_AfterLogon(ByVal Sender As Object, ByVal e As System.EventArgs)

    '*****************************************************'
    '*** Add Handlers for Contact and Company Changing ***'
    '*****************************************************'
    Dim dbName As String = ActApp.ActFramework.CurrentDatabase
    Dim rdbACT As Integer = InStr(dbName, "X2")
    If dbName = "SvrACTMain" Or rdbACT <> 0 Then  ' SvrACTMain is the publisher
      'MessageBox.Show("Adding Handlers")
      AddHandler ActApp.CurrentContactChanged, AddressOf ActApp_CurrentContactChanged
      AddHandler ActApp.CurrentCompanyChanged, AddressOf ActApp_CurrentCompanyChanged
    Else
      'MessageBox.Show("Removing Handlers")
      RemoveHandler ActApp.CurrentContactChanged, AddressOf ActApp_CurrentContactChanged
      RemoveHandler ActApp.CurrentCompanyChanged, AddressOf ActApp_CurrentCompanyChanged
    End If

 

Richard Brust
ACT! Certified Consultant
richard@rbrDataSolutions.com
Platinum Elite Contributor
Posts: 14,384
Country: Australia

Re: Load Plugin for specific database only

Don't the plugins load with ACT! (before the database)? If so, you just want it to do nothing unless the db you want is open...

One way I did this (not the most elegant) is that a separate app run on Publisher only created a single cell custom table in the database with some text. Our app simply looked for that table/text and, if not there, just kept a stub to detect change of database and then try again
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Load Plugin for specific database only

You can use the IsSubscriber property of the ActDatabase class.

 

IF HostFramework.ActDatabase.IsSubscriber()

   ' Remote

ELSE

   ' Not a remote

Endif

 

Hope this helps

-- Jim Durkin

Platinum Elite Contributor
Posts: 14,384
Country: Australia

Re: Load Plugin for specific database only

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Load Plugin for specific database only

My understanding is IsSubscriber will return true if the current database is a remote.

 

-- Jim Durkin

Platinum Elite Contributor
Posts: 14,384
Country: Australia

Re: Load Plugin for specific database only

But (not sure if likely for Richard's scenario) can't tell if a subscriber to the specific db ... might have another that sync's with a different Publisher

Actually, I think I saw that in a Dashboard around here. Will have a look
Nickel Elite Contributor
Posts: 508
Country: USA

Re: Load Plugin for specific database only

Correct, these users are subscribers for all the people they work for - each of their dbs are remote, so I can't just check if it's a subscriber.

 

I like the idea of either a field value, or even a field name itself - check if exists, then load...

Richard Brust
ACT! Certified Consultant
richard@rbrDataSolutions.com
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Load Plugin for specific database only

Hi Richard,

 

You could use the SynchronizationManager Class from ActFrameWork.SynchronizationManager.

This Class exposes the following properties:

IsSubscriberDB

PubDBGuid

PubDBID

 

So if you know the GUID or ID of the publisher(s) you can then run a case ststement on the OnLoad() event?

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Platinum Elite Contributor
Posts: 14,384
Country: Australia

Re: Load Plugin for specific database only