Hello Dojo,
I'm updating some automation scripts that I wrote four years ago. The scripts need to iterate through all positions of persistent memory files. As far I can see, there is no method in the ScriptMemory object instance that returns all positions (rows) as i.e. object [] nor the size of the memory file.
In our case, we cannot simply retrieve specific position index or description using the .Get(x) method. The current solution is to use a pre-compiled code which converts the memory file and returns List<string>.
Is there a better way of implementing this using the DataMiner Class library?
Regards,
Pawel.
Hi Pawel,
I had a quick look at the methods available for the ScriptMemory class, the class library and indeed, it seems that there is no method that can return all positions from a script memory. A possible option is to use the SLNet message GetScriptMemoryValuesMessage. Below a snippet:
using Skyline.DataMiner.Automation;
using Skyline.DataMiner.Net.Messages;public class Script
{
public void Run(Engine engine)
{
Skyline.DataMiner.Net.Messages.GetScriptMemoryValuesMessage scriptMemoryValues = new GetScriptMemoryValuesMessage()
{
Name = "testMemory1"
};Skyline.DataMiner.Net.Messages.DMSMessage[] response = Engine.SLNet.SendMessage(scriptMemoryValues);
foreach (Skyline.DataMiner.Net.Messages.ScriptMemoryValuesResponseMessage responseMessage in response)
{
ScriptMemoryValue[] memoryValues = responseMessage.Values;
foreach (ScriptMemoryValue memoryValue in memoryValues)
{
engine.GenerateInformation("[INFO]|Run|memoryValue.Description:" + memoryValue.Description);
engine.GenerateInformation("[INFO]|Run|memoryValue.Value:" + memoryValue.Value);
}
}
}
}
The memoryValues array contain all the values available in the script memory with name TestMemory1.
Disclaimer:
Note that this is an internal call and we do not recommend using this, as it is not officially supported and we cannot guarantee that it will still work in the future. As a rule, you should avoid using SLNet calls, as these are subject to change without notice. We recommend to instead always use the correct UI or automation options provided in DataMiner Automation or through our web API.
Hope it helps.
Thanks Miguel. Disclaimer noted.