I've got a regular MicroStation drawing with shape elements that include a User Data Linkage that points back to an Oracle table. What happens to that linkage when I open that drawing in Map Enterprise, and use the "Promote" tools to convert that simple shape into a native feature residing in a SQL*Server database? Is it lost? Is there any way to "capture" that linkage? The MSLINK value is the record ID of the Oracle data that I would want to insert into the data columns of the SQL*Server spatial table. We've got many shapes, so I'm hoping there is some automated process that can be set up to "preserve" that linkage information so it can be used to ensure the right record from Oracle is associated with the right record in SQL*Server.
Thanks,
Bruce
Bruce,
During the "Promote" process the database linkages should be preserved and remain available on the elements. However database linkage information is not automatically available on the feature instance or inserted into the spatial database during a post operation. The good news is that with a few lines of VBA code the polygon features can be located and database MSLINK values can be copied to a business property that when posted to the spatial database would "preserve" the Oracle association.
database_links1.mvba
Attached is the complete MVBA example but the key portions of the code are shown below. Please note that you will have to update the database linkage type, database entity number and XFM business property name for your spatial feature class to accommodate your specific needs.
Perform Locate Operation (for file, fence or selection set processing of specific feature class(es))
Private Sub performLocateOperation() Dim oLocateOp As New locateOp oLocateOp.ClearHilited = True oLocateOp.IncludeOnlyFeatures = True oLocateOp.IncludeFeatureName "MyPolygonFeature1" If ActiveDesignFile.Fence.IsDefined = True Then oLocateOp.Mode = LocateOpMode.locateOpModeFence oLocateOp.AutoAcceptFence = True ElseIf ActiveModelReference.AnyElementsSelected Then Dim selectionSetValue As New InputValue selectionSetValue.SetTypeAndValue ValueType_VALUE, "1" oLocateOp.UseSelectionSet = selectionSetValue oLocateOp.AutoAcceptSelectionSet = True oLocateOp.Mode = LocateOpMode.locateOpModeIdentify Else oLocateOp.Mode = LocateOpMode.locateOpModeScan oLocateOp.AutoAcceptScanFile = True End If CmdMgr.StartLocateOperation oLocateOp, New clsLocateFeatureOp End Sub
Process Located Feature Instances (copy MSLINK value from database link to XFM business property)
With fe.Current If .GetFeatureDefinition.IsCollection Then Dim index As Long For index = 0 To (.SubFeatureCount - 1) Dim oSubFeature As feature Set oSubFeature = .GetSubFeature(index) With oSubFeature If .GeometryType = GEOMETRYTYPE_Polygon Then Dim databaseLinks() As databaseLink If .Geometry.IsGraphical Then databaseLinks = .Geometry.GetDatabaseLinks _ (msdDatabaseLinkageOdbc, cDatabaseLinkEntitynum) mslinkValue = databaseLinks(0).Mslink End If End If End With Next End If .SetProperty cDatabaseLinkColumnName, Str(mslinkValue) .Write (False) End With
Regards,
Jeff Bielefeld [Bentley]
The provided MVBA example code demonstrates how one could read the MSLINK value from the graphical element in the promoted polygon collection feature instances and write the value to a business property, which after posting would appear in a column of your Microsoft SQL Server spatial database.
There are several ways to approach this depending on your specific needs. For example you might do the following:
Again, this is just one approach that leverages the Bentley Map API to help solve a data migration challenge.
Please zip up and send me via private message...
...and I will review.