Hi all,
I have a quick question I am working on an automation script and have run into an issue. I have created a dialog button and I am trying to run a method when the butto is pressed. so far I have this:
public event EventHandler<EventArgs> Pressed;
public void Button_Pressed(object sender, EventArgs e)
{
controller.Engine.Log("Entering Event");
AddPort(sender, e, protocol.Protocol);
controller.Engine.ExitSuccess("0");
}
I have tried both of these but the method does not trigger when button is pressed
dialog.Button.Pressed += new EventHandler<EventArgs>(Button_Pressed);
dialog.Button.Pressed += (sender,e) => Pressed(sender,e);
I have a drop down list and everything works for the OnChange event but for the button I can't get it to work.
Thank you so much in advance.
Hi Amer,
Together with Thomas, I made an IAS that handles a button press that we tested our local DMA. Maybe this can serve as an example?
IAS_Button_Pressed/DOJO_1.cs at RC · FlorisCO/IAS_Button_Pressed · GitHub
From the code you posted, it looks like you're registering the event outside of your Dialog class, which we also did in our example. Is it possible that you are adding the event after calling controller.Run(dialog)?
Also note that the ExitSuccess is throwing a ScriptAbortException, which should be caught in the Run function, or it will be rethrown as a fail.
The Engine.Log statement will be logged in SLAutomation.txt .
Hi Amer,
If the example fails on your system, can you let us know what DataMiner version you are using?
Could you also check what toolkit version you are using? The linked example should be using the latest stable version.
Hi Floris,
You are correct it is outside the dialog class and I am adding the event before the controller.Run(dialog) as that is the last thing that I do and yes I am aware of this and handleing the exceptions properly. I will look and try the sample that you have shared thank you so much