06-27-2016 02:43 PM
I would like to update the geometry of a feature via a C# GeoMedia command. I am using GeoMedia 16.000 with PostGIS. What is the correct way to do this? I have created a button (which works) but I would like the geometry to refresh with the latest value in the database when the button is pressed. Here is what I have tried:
public void Activate()
Document doc = gobjGeoApp.Document as Document;
Connections conList = doc.Connections as Connections;
Connection connection = conList.Item(1); // returns the correct connection
LegendEntry entry = null;
var legendEntries = mapView?.Legend?.DisplayEntries;
entry = legendEntries as LegendEntry; // returns the correct legendEntry
pipe.GeometryFieldName = "Geometry"; // ???
pipe.Table = "Table";
pipe.Filter = "name = 'RecordName'";
Intergraph.GeoMedia.PClient.GRecordset recordSet = pipe.OutputRecordset;
entry.InputRecordset = (Intergraph.GeoMedia.GDO.GRecordset) recordSet;
This gives me error: "Invalid geometry field name XXX_geomedia for the given recordset"
The XXX is my geometry column which displays (until I run this command) and the XXX_geomedia is the associated bytea column. I have these setup using the Database Utilities and everything renders normally via Analysis->Queries.
Solved! Go to Solution.
06-28-2016 04:26 AM
you cannot simply replace the InputRecordset of an existing legend entry.
To load changes made by a 3rd party application into GeoMedia, you must correctly fill the records in the ModifiedTables and ModificationLog tables. If you manage this, you then have two ways how to actually refresh the data in GeoMedia. You can either use the Connection.BroadcastDatabaseChanges, which reloads all changes detected in the ModificationLog table, or you can use the Notification object. The pseudocode using Notification object would look like this:
LegendEntry entry = ... get the correct legend entry;
GRecordset objRS = entry.InputRecordset;
Notification objN = objRS.GetExtension("Notification");
This will refresh just one particular recordset. However, the overhead introduced by BroadcastDatabasChanges is usually negligible, so BroadcastDatabaseChanged should be the preferred method.
06-28-2016 12:16 PM
Hi Pavel! Thanks for the quick response! I will give that a try, but I have a technical requirement that I cannot use ModificationLog/ModificationTables. There is requirement to use third-party Notification as well (e.g. SignalR). Is it possible to update via an external request with possible external data as well?
06-29-2016 12:17 AM
Unfortunately, there is no way how to refresh data without modification log, except closing and reopening the whole connection. This is given by the GDO architecture. The data may be locally cached and there is no way to force GDO server to reload them without the modification log.
06-29-2016 11:59 AM
Ok thanks I am using the modificationlog approach, and I am using a PostgreSQL trigger to insert updates using sessionid. Everything seems to work. However every time GeoMedia restarts it changes the sessionid. Is there a way to get a persistent sessionid or a way to store the current sessionid in the database to look it up?
06-30-2016 01:41 AM
You should get the session id from ExtendedPropertySet. The code would be like:
GDatabase objDB = myConn.Database;
ExtendedPropertySet objEPS = objDB.GetExtension("ExtendedPropertySet");
int iSessionId = objEPS.GetValue("SessionID");
However, when using myConn.BroadcastDatabaseChanges(false); the session id does not matter and you can put whatever you want in it.