The Arcade Console app would be helpful for debugging Arcade scripts if I can access the Arcade Console function output in a WPF application that is using styles. Does the output go to the application standard output stream? Or, is there an API to access Arcade's Console output stream? How is the Arcade Console function output accessed in a WPF application?
Solved! Go to Solution.
You can use ArcGISRuntimeEnvironment.ArcadeConsoleMessage event and write to file or standard console.
For example, if adding a new feature triggers an attribute rule that contains Console function in the ScriptExpression, we would expect this event to be raised with the message from Console function and some information about the rule and table.
ArcGISRuntimeEnvironment.ArcadeConsoleMessage += (sender, eventArgs) =>
{
// eventArgs.Context.Profile (i.e. ArcadeProfile.AttributeRuleCalculation)
// eventArgs.Context.Information (i.e. ruleName, tableName for attribute rules)
// eventArgs.Message (i.e. Console(<message>))
};
var sgdb = await ServiceGeodatabase.CreateAsync(new Uri(featureServerUrl));
var table = sgdb.GetTable(1);
await table.LoadAsync();
var feature = table.CreateFeature();
await table.AddFeatureAsync(feature); // triggers attribute rule with Console(<message>)
You can use ArcGISRuntimeEnvironment.ArcadeConsoleMessage event and write to file or standard console.
For example, if adding a new feature triggers an attribute rule that contains Console function in the ScriptExpression, we would expect this event to be raised with the message from Console function and some information about the rule and table.
ArcGISRuntimeEnvironment.ArcadeConsoleMessage += (sender, eventArgs) =>
{
// eventArgs.Context.Profile (i.e. ArcadeProfile.AttributeRuleCalculation)
// eventArgs.Context.Information (i.e. ruleName, tableName for attribute rules)
// eventArgs.Message (i.e. Console(<message>))
};
var sgdb = await ServiceGeodatabase.CreateAsync(new Uri(featureServerUrl));
var table = sgdb.GetTable(1);
await table.LoadAsync();
var feature = table.CreateFeature();
await table.AddFeatureAsync(feature); // triggers attribute rule with Console(<message>)