-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun.snippet
78 lines (73 loc) · 1.93 KB
/
Run.snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Run</Title>
<Author>TRE, Skyline Communications</Author>
<Description>Generates the default run method for Interactive Automation Scripts using the IAS Toolkit package.</Description>
<Shortcut>iasRun</Shortcut>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>Skyline.DataMiner.Utils.InteractiveAutomationScript</Namespace>
</Import>
</Imports>
<Code Language="csharp">
<![CDATA[public class Script
{
private InteractiveController app;
/// <summary>
/// The Script entry point.
/// IEngine.ShowUI();.
/// </summary>
/// <param name="engine">Link with SLAutomation process.</param>
public void Run(IEngine engine)
{
try
{
app = new InteractiveController(engine);
engine.SetFlag(RunTimeFlags.NoKeyCaching);
engine.Timeout = TimeSpan.FromHours(10);
RunSafe(engine);
}
catch (ScriptAbortException)
{
throw;
}
catch (ScriptForceAbortException)
{
throw;
}
catch (ScriptTimeoutException)
{
throw;
}
catch (InteractiveUserDetachedException)
{
throw;
}
catch (Exception e)
{
engine.Log("Run|Something went wrong: " + e);
ShowExceptionDialog(engine, e);
}
}
private void RunSafe(IEngine engine)
{
// TODO: Define dialogs here
Dialog dialog = null;
app.Run(dialog);
}
private void ShowExceptionDialog(IEngine engine, Exception exception)
{
ExceptionDialog exceptionDialog = new ExceptionDialog(engine, exception);
exceptionDialog.OkButton.Pressed += (sender, args) => engine.ExitFail("Something went wrong.");
if (app.IsRunning) app.ShowDialog(exceptionDialog); else app.Run(exceptionDialog);
}
}]]>
</Code>
</Snippet>
</CodeSnippet>