UA Bundle SDK .NET  2.2.0.255
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Groups Pages
Browse/Translate – Translate Browse Paths

Prerequisites

A session with the server must be established.

Description

The following dialog shows a dialog window which demonstrates an implementation of the Translate Browse Paths operation. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.

Enter a Node ID into the input field “Node ID” or press the button “...” to open a browse window and select a node.

It is possible to list two browse paths starting at the node specified above by entering their browse names into the fields “Path to Translate 1” and “Path to Translate 2”. After pressing the button “Translate” the corresponding NodeIDs are displayed at “Translate Response”. Check the box in front of “Use Asynchronous Pattern” to call “BeginTranslate” instead of “Translate”.

Sample Code

The following code finds the Nodes at the end of a browse path, starting at a specified node, and displays the response in the dialog window.

try
{
// get the current session from the parent form.
Session session = m_parent.Session;
// nothing to do if no session.
if (session == null)
{
return;
}
// parse the node id.
NodeId startingNodeId = NodeId.Parse(NodeIdTB.Text);
// get the browse paths.
List<BrowsePath> pathsToTranslate = new List<BrowsePath>();
pathsToTranslate.Add(GetBrowsePath(startingNodeId, AbsoluteName.ToQualifiedNames(PathToTranslate1TB.Text)));
pathsToTranslate.Add(GetBrowsePath(startingNodeId, AbsoluteName.ToQualifiedNames(PathToTranslate2TB.Text)));
// this is a blocking call so show the wait cursor.
Cursor = Cursors.WaitCursor;
// translate the references (setting a 10 second timeout).
List<BrowsePathResult> results = session.TranslateBrowsePath(
pathsToTranslate,
new RequestSettings() { OperationTimeout = 10000 });
// update controls.
UpdateControl(TranslatedNode1TB, results[0]);
UpdateControl(TranslatedNode2TB, results[1]);
}
catch (Exception exception)
{
ExceptionDlg.Show(this.Text, exception);
}