get path of sde file

1242
7
06-07-2017 06:55 AM
Highlighted
New Contributor II

Hello for all,
I have a problem and please help me.
I need to get path of sde file for enterprise geodatabase.

Up to 1.3 version for ArcGIS Pro, the Geodatabase class had GetPath() method which returned path for Geodatabase (File Geodatabase, Enterprise Geodatabase and so on) .

Starting with 1.4 version this method is depricated (and return empty string) and it's recomended to work with Conector and appropriate class (DatabaseConnectionFile, DatabaseConnectionProperties and so on)

I need to get path of sde file (Enterprise Geodatabase), but Connector is not DatabaseConnectionFile.
When Geodatabase is Enterprise, the Connector is only DatabaseConnectionProperties-type.
But DatabaseConnectionProperties does not allow to get path of sde file.

(_table.GetDatastore() as Geodatabase).GetConnector() is DatabaseConnectionFile is false

How can I get the path of sde file?


Thanks all,
Laurentiu Ichim

0 Kudos
7 Replies
Highlighted
New Contributor III

Laurentiu,

 

Could you please expand on the workflow where you require a connection file for an existing enterprise geodatabase connection?

 

Thanks,

Colin

0 Kudos
Highlighted
New Contributor II

Hello sir,

Yes, I do! 

On the workflow, I need to run a python script. For this python script, I need to send path of particular table (like this @"F:\PROIECTE\Utilitati\Pro\Date\Utilitati1\database.sde\utilitati.SDE.Documente").

Why run a python script?

I need to insert various files into BLOB field of  <utilitati.SDE.Documente> table.

Working with attachment file of Geodatabase does not cover the particular functionality.

In other words:

1. I have a table with a BLOB field:

Table documentTable = standaloneTable.GetTable();

2. I have a python script which insert file into table (table of point 1)

3. In the ArcGIS Pro Add-In, I have a ExecuteToolAsync(...) which call python script (script of point 2)

var parameters = Geoprocessing.MakeValueArray(
@"C:\Users\lichi_000\Pictures\eu1.jpg",
@"F:\PROIECTE\Utilitati\Pro\Date\Utilitati1\dataweb@utilitati@sde.sde\utilitati.SDE.Documente",
foreignKey,
extension,
dateTime,
no,
author
);
var result = await Geoprocessing.ExecuteToolAsync(@"F:\PROIECTE\Utilitati\Pro\scripturi\Utilitati.tbx\Insert0", parameters);

4. The <@"F:\PROIECTE\Utilitati\Pro\Date\Utilitati1\dataweb@utilitati@sde.sde\utilitati.SDE.Documente"> parameter of point 3  is documentTable object of point 1

Thank you very much,

Laurentiu Ichim

0 Kudos
Highlighted
Regular Contributor

Laurentiu,

I had the same problem with sde file path. I have made workaround:

1. Read all project geodatabases using Project.Current.GetItems<GDBProjectItem>().

GDBProjectItem contains Path property.

2. Read connection properties from your table object (pTable.GetDatastore().GetConnector() as DatabaseConnectionProperties).

3. Check all GDBProjectItem's from 1 step by comparing connection properties (item.GetDatastore().GetConnector() and try cast to DatabaseConnectionProperties). Equal method does not work for Connector or DatabaseConnectionProperties objects, so you need to check all DatabaseConnectionProperties object properties (DBMS, Database, Instance and etc.) one by one.

I hope it helps you

Gintautas

Highlighted
New Contributor II

Thank you very much sir Gintautas. Isn't a solution for me. The geoprocessor object wait path for processing input (as parameters). The DatabaseConnectionProperties class isn't solution for me.

Thank you very much for your answer!

0 Kudos
Highlighted
New Contributor III

Laurentiu, (and Gintautas)

This issue has sparked a lot of discussion between teams since its original posting. Giantautas's workaround is valid if a matching connection file exists (including the correct version). However the edge case that no matching file exists anywhere is still problematic and is the reason GetPath was deprecated. We will work towards a resolution to this in a  future release with your workflow in mind.

On a similar note the requirement to use a custom gp script for blob manipulation should be removed with the native core.Data support of blobs via memoryblobstreams in the ArcGIS Pro 2.0 timeframe.

Thanks,

Colin

Highlighted
New Contributor II

Good afternoon,

The suport of blobs for version 2.0 it's a really good news.

Thank you sir for your answer,

Laurentiu

0 Kudos
Highlighted
Regular Contributor

Laurentiu,

You must use DatabaseConnectionProperties only to find right geodatabase from 1 step. Then you need to read Path property from GDBProjectItem. It contains full path to sde file. I can send you detailed source code sample if you need.

0 Kudos