Dear Dojo,
I am trying to create a script which will filter out duplication and send me on email notification.
I have the following code to test for now:
public class Script
{
public void Run(Engine engine)
{
engine.GenerateInformation("Collecting duplicate elements: Started");
Element [] elements = engine.FindElementsInView(-1);
var List = elements.Where(x => x.HasProperty("Device IP Address") && x.HasProperty("Department"));
string message = "";
foreach (Element element in List)
{
message += element.ElementName + " - " + element.GetPropertyValue("Device IP Address") + " - " + element.GetPropertyValue("Department") + "<br>";
}
EmailOptions emailOptions = new EmailOptions
{
TO = "example@example.com",
Title = "test",
Message = message,
};
engine.SendEmail(emailOptions);
engine.GenerateInformation("Collecting duplicate elements: Email sent!");
}
}
No errors when I validate but the script fails to execute and I have the following error:
(Code: 0x80131500) Skyline.DataMiner.Net.Exceptions.DataMinerException: Create Dummy Failed: 0x80004005
at Skyline.DataMiner.Automation.Engine.CreateExtraDummy(Int32 dataMinerID, Int32 elementID, String key)
at Skyline.DataMiner.Automation.Element.get_Dummy()
at Skyline.DataMiner.Automation.Element.HasProperty(String propertyName)
at Script.<>c.<Run>b__0_0(Element x)
at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
at Script.Run(Engine engine)
Can you point me what I am doing wrong?
Thank you for your time
Best regards,
Catalin
Hi Catalin,
I believe this might be because you're potentially interacting with stopped elements.
Can you try to filter them out by updating your code like this:
var List = elements.Where(x => x.IsActive && x.HasProperty("Device IP Address") && x.HasProperty("Department"));