Community
Showing results for 
Search instead for 
Do you mean 
Reply

Getting UNC-Path of act! database

Accepted Solution Solved
Copper Contributor
Posts: 42
Country: Germany
Accepted Solution

Getting UNC-Path of act! database

[ Edited ]

Hi,

 

we have created a custom button control which loads one of the .adt templates and fills it with data from multiple contacts (the current contact and it's associations).

Our problem here is, that I have no idea, how to get the path to the template folder. For now, the path is hardcoded and if some time the Database would be moved to another server or something, our Plug-In won't work any longer.

I've tryed:

string strFileName=Act.UI.ActApplication.Instance.ActFramework.ActDatabase.DatabasePath.ToString().Replace(".ADF","-database files\\Templates\\<Folder>\\<File>.adt");

but this gives me the LOCAL path (C:\Users\<account name>\Documents\ACT\ACT Data\Databases\<DB-File>.ADF) to the database, even on remote-machines. So the Plug-In will work only on my developement-machine with a local Test-Database but not on remote clients connecting to my test-environment, as they try to open the files from the local C:\ path instead from the correct UNC-Path: \\<myPC>\<DB-Name>-database files\

 

Any ideas how to obtain the current path of the Share?


Accepted Solutions
Solution
Accepted by topic author twolfram
‎09-25-2015 03:20 AM
Nickel Contributor
Posts: 175
Country: USA

Re: Getting UNC-Path of act! database

I just tried this out: 

  Dim actf As New Act.Framework.ActFramework
   actf.LogOn(strLiveDB, "User", "Pass")

   Dim x As String = actf.ActDatabase.DatabasePath
  

The value I got was the remote path, but it returned the drive letter of the remote machine it was on, not a UNC path. Maybe this will help you out though. FYI, the variable "strLiveDB" is the path to the PAD file.

 

One other idea I had is kind of a middle of the road approach. Instead of hardcoding the path or getting it automatically from ACT, you could toss the path into an XML "config" file to read from. That file would need to go with the plug-in, and if the database ever got moved, you'd just have to update the file (in all locations). But, the plug-in wouldn't need to be changed. Hopefully this gives you some ideas.

View solution in original post


All Replies
Solution
Accepted by topic author twolfram
‎09-25-2015 03:20 AM
Nickel Contributor
Posts: 175
Country: USA

Re: Getting UNC-Path of act! database

I just tried this out: 

  Dim actf As New Act.Framework.ActFramework
   actf.LogOn(strLiveDB, "User", "Pass")

   Dim x As String = actf.ActDatabase.DatabasePath
  

The value I got was the remote path, but it returned the drive letter of the remote machine it was on, not a UNC path. Maybe this will help you out though. FYI, the variable "strLiveDB" is the path to the PAD file.

 

One other idea I had is kind of a middle of the road approach. Instead of hardcoding the path or getting it automatically from ACT, you could toss the path into an XML "config" file to read from. That file would need to go with the plug-in, and if the database ever got moved, you'd just have to update the file (in all locations). But, the plug-in wouldn't need to be changed. Hopefully this gives you some ideas.

Copper Contributor
Posts: 42
Country: Germany

Re: Getting UNC-Path of act! database

Hi,

thanks you for your reply.

In the meanwhile I tryed:

ActApp.ActFramework.CurrentDatabase.ToString(); //-> gives name of Database, e.g. TestDB
ActApp.ActFramework.ActDatabase.DatabasePath.ToString(); //-> gives local path to database-file on the DB-Server
ActApp.ActFramework.ActDatabase.Machine.ToString(); //-> gives SQL-Server and instance-name: SRV-ACT\ACT7

Your suggestion returns the local path to the DB on the server, which in our case has nothing in common with the share name.

 

Using a xml-config file also came up my mind, I would get the path where the .dll actually resides with one of theese:

System.Reflection.Assembly.GetExecutingAssembly().Location;
System.Reflection.Assembly.GetExecutingAssembly().CodeBase;