Skip to content

Commit b3c9bcf

Browse files
Merge pull request #11 from BrechtDeconinck/IAS_MVP
Ias mvp
2 parents 186edb7 + 9e313a6 commit b3c9bcf

29 files changed

+1344
-623
lines changed
Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,52 @@
1-
namespace IAS_CheckBoxList_1
1+
// Ignore Spelling: IAS
2+
3+
namespace IAS_CheckBoxList_1
24
{
3-
using Skyline.DataMiner.Automation;
4-
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
5-
using System;
6-
using System.Collections.Generic;
7-
8-
public class CheckBoxListDialog : Dialog
9-
{
10-
private readonly CheckBoxList checkBoxList;
11-
private readonly TextBox checkedOptionsTextBox;
12-
private readonly Button exitButton;
13-
14-
private readonly IEnumerable<string> options = new string[]
15-
{
16-
"Yes",
17-
"An Option",
18-
"Another One",
19-
"Option X",
20-
"Something something Dark Side"
21-
};
22-
23-
public CheckBoxListDialog(IEngine engine) : base(engine)
24-
{
25-
Title = "Select Option(s)";
26-
27-
// Set up checkboxlist
28-
checkBoxList = new CheckBoxList(options) { IsSorted = true };
29-
checkBoxList.Changed += (s, e) => checkedOptionsTextBox.Text = String.Join(Environment.NewLine, checkBoxList.Checked);
30-
31-
// Set up textbox
32-
checkedOptionsTextBox = new TextBox { IsMultiline = true, Height = 150 };
33-
34-
// Set up exit button
35-
exitButton = new Button("Exit");
36-
exitButton.Pressed += (s, e) => OnExitButtonPressed?.Invoke(this, EventArgs.Empty);
37-
38-
// Generate Ui
39-
AddWidget(new Label("Select Option(s)"), 0, 0, verticalAlignment: VerticalAlignment.Top);
40-
AddWidget(checkBoxList, 0, 1);
41-
AddWidget(checkedOptionsTextBox, 1, 0, 1, 2);
42-
AddWidget(exitButton, 2, 0, 1, 2);
43-
}
44-
45-
public event EventHandler OnExitButtonPressed;
46-
}
47-
}
5+
using System;
6+
using System.Collections.Generic;
7+
8+
using Skyline.DataMiner.Automation;
9+
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
10+
11+
public class CheckBoxListDialog : Dialog
12+
{
13+
private readonly CheckBoxList checkBoxList;
14+
15+
private readonly TextBox checkedOptionsTextBox;
16+
17+
private readonly Button exitButton;
18+
19+
private readonly IEnumerable<string> options = new[]
20+
{
21+
"Yes",
22+
"An Option",
23+
"Another One",
24+
"Option X",
25+
"Something something Dark Side",
26+
};
27+
28+
public CheckBoxListDialog(IEngine engine) : base(engine)
29+
{
30+
Title = "Select Option(s)";
31+
32+
// Set up checkboxlist
33+
checkBoxList = new CheckBoxList(options) { IsSorted = true };
34+
checkBoxList.Changed += (s, e) => checkedOptionsTextBox.Text = String.Join(Environment.NewLine, checkBoxList.Checked);
35+
36+
// Set up textbox
37+
checkedOptionsTextBox = new TextBox { IsMultiline = true, Height = 150 };
38+
39+
// Set up exit button
40+
exitButton = new Button("Exit");
41+
exitButton.Pressed += (s, e) => OnExitButtonPressed?.Invoke(this, EventArgs.Empty);
42+
43+
// Generate Ui
44+
AddWidget(new Label("Select Option(s)"), 0, 0, verticalAlignment: VerticalAlignment.Top);
45+
AddWidget(checkBoxList, 0, 1);
46+
AddWidget(checkedOptionsTextBox, 1, 0, 1, 2);
47+
AddWidget(exitButton, 2, 0, 1, 2);
48+
}
49+
50+
public event EventHandler OnExitButtonPressed;
51+
}
52+
}
Lines changed: 74 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Ignore Spelling: IAS
2+
13
/*
24
****************************************************************************
35
* Copyright (c) 2024, Skyline Communications NV All Rights Reserved. *
@@ -51,68 +53,76 @@ DATE VERSION AUTHOR COMMENTS
5153

5254
namespace IAS_CheckBoxList_1
5355
{
54-
using System;
55-
using Skyline.DataMiner.Automation;
56-
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
57-
58-
/// <summary>
59-
/// Represents a DataMiner Automation script.
60-
/// </summary>
61-
public class Script
62-
{
63-
private InteractiveController app;
64-
65-
/// <summary>
66-
/// The Script entry point.
67-
/// IEngine.ShowUI();.
68-
/// </summary>
69-
/// <param name="engine">Link with SLAutomation process.</param>
70-
public void Run(IEngine engine)
71-
{
72-
try
73-
{
74-
app = new InteractiveController(engine);
75-
76-
engine.SetFlag(RunTimeFlags.NoKeyCaching);
77-
engine.Timeout = TimeSpan.FromHours(10);
78-
79-
RunSafe(engine);
80-
}
81-
catch (ScriptAbortException)
82-
{
83-
throw;
84-
}
85-
catch (ScriptForceAbortException)
86-
{
87-
throw;
88-
}
89-
catch (ScriptTimeoutException)
90-
{
91-
throw;
92-
}
93-
catch (InteractiveUserDetachedException)
94-
{
95-
throw;
96-
}
97-
catch (Exception e)
98-
{
99-
engine.Log("Run|Something went wrong: " + e);
100-
ShowExceptionDialog(engine, e);
101-
}
102-
}
103-
104-
private void RunSafe(IEngine engine)
105-
{
106-
CheckBoxListDialog dialog = new CheckBoxListDialog(engine);
107-
dialog.OnExitButtonPressed += (s, e) => engine.ExitSuccess("Exit button pressed");
108-
app.Run(dialog);
109-
}
110-
111-
private void ShowExceptionDialog(IEngine engine, Exception exception)
112-
{
113-
ExceptionDialog exceptionDialog = new ExceptionDialog(engine, exception);
114-
exceptionDialog.OkButton.Pressed += (sender, args) => engine.ExitFail("Something went wrong.");
115-
if (app.IsRunning) app.ShowDialog(exceptionDialog); else app.Run(exceptionDialog);
116-
}
117-
}
56+
using System;
57+
58+
using Skyline.DataMiner.Automation;
59+
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
60+
61+
/// <summary>
62+
/// Represents a DataMiner Automation script.
63+
/// </summary>
64+
public class Script
65+
{
66+
private InteractiveController app;
67+
68+
/// <summary>
69+
/// The Script entry point.
70+
/// IEngine.ShowUI();.
71+
/// </summary>
72+
/// <param name="engine">Link with SLAutomation process.</param>
73+
public void Run(IEngine engine)
74+
{
75+
try
76+
{
77+
app = new InteractiveController(engine);
78+
79+
engine.SetFlag(RunTimeFlags.NoKeyCaching);
80+
engine.Timeout = TimeSpan.FromHours(10);
81+
82+
RunSafe(engine);
83+
}
84+
catch (ScriptAbortException)
85+
{
86+
throw;
87+
}
88+
catch (ScriptForceAbortException)
89+
{
90+
throw;
91+
}
92+
catch (ScriptTimeoutException)
93+
{
94+
throw;
95+
}
96+
catch (InteractiveUserDetachedException)
97+
{
98+
throw;
99+
}
100+
catch (Exception e)
101+
{
102+
engine.Log("Run|Something went wrong: " + e);
103+
ShowExceptionDialog(engine, e);
104+
}
105+
}
106+
107+
private void RunSafe(IEngine engine)
108+
{
109+
CheckBoxListDialog dialog = new CheckBoxListDialog(engine);
110+
dialog.OnExitButtonPressed += (s, e) => engine.ExitSuccess("Exit button pressed");
111+
app.Run(dialog);
112+
}
113+
114+
private void ShowExceptionDialog(IEngine engine, Exception exception)
115+
{
116+
ExceptionDialog exceptionDialog = new ExceptionDialog(engine, exception);
117+
exceptionDialog.OkButton.Pressed += (sender, args) => engine.ExitFail("Something went wrong.");
118+
if (app.IsRunning)
119+
{
120+
app.ShowDialog(exceptionDialog);
121+
}
122+
else
123+
{
124+
app.Run(exceptionDialog);
125+
}
126+
}
127+
}
118128
}
Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<TargetFramework>net48</TargetFramework>
4-
<Company>Skyline Communications</Company>
5-
<Copyright>© Skyline Communications</Copyright>
6-
<GenerateDocumentationFile>True</GenerateDocumentationFile>
7-
</PropertyGroup>
8-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
9-
<DebugType>full</DebugType>
10-
<CodeAnalysisRuleSet>..\Internal\Code Analysis\qaction-debug.ruleset</CodeAnalysisRuleSet>
11-
</PropertyGroup>
12-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
13-
<DebugType>pdbonly</DebugType>
14-
<CodeAnalysisRuleSet>..\Internal\Code Analysis\qaction-release.ruleset</CodeAnalysisRuleSet>
15-
</PropertyGroup>
16-
<PropertyGroup>
17-
<DefineConstants>$(DefineConstants);DCFv1;DBInfo;ALARM_SQUASHING</DefineConstants>
18-
</PropertyGroup>
19-
<ItemGroup>
20-
<PackageReference Include="Skyline.DataMiner.Dev.Automation" Version="10.3.7" />
21-
<PackageReference Include="Skyline.DataMiner.Utils.InteractiveAutomationScriptToolkit" Version="7.0.5" />
22-
</ItemGroup>
23-
<ProjectExtensions>
24-
<VisualStudio>
25-
<UserProperties DisLinkedXmlFile="..\IAS_CheckBoxList.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
26-
</VisualStudio>
27-
</ProjectExtensions>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<TargetFramework>net48</TargetFramework>
5+
<Company>Skyline Communications</Company>
6+
<Copyright>© Skyline Communications</Copyright>
7+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
8+
</PropertyGroup>
9+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
10+
<DebugType>full</DebugType>
11+
<CodeAnalysisRuleSet>..\Internal\Code Analysis\qaction-debug.ruleset</CodeAnalysisRuleSet>
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
14+
<DebugType>pdbonly</DebugType>
15+
<CodeAnalysisRuleSet>..\Internal\Code Analysis\qaction-release.ruleset</CodeAnalysisRuleSet>
16+
</PropertyGroup>
17+
<PropertyGroup>
18+
<DefineConstants>$(DefineConstants);DCFv1;DBInfo;ALARM_SQUASHING</DefineConstants>
19+
</PropertyGroup>
20+
<ItemGroup>
21+
<PackageReference Include="Skyline.DataMiner.Dev.Automation" Version="10.3.7" />
22+
<PackageReference Include="Skyline.DataMiner.Utils.InteractiveAutomationScriptToolkit" Version="7.0.5" />
23+
<PackageReference Include="Skyline.DataMiner.Utils.SecureCoding.Analyzers" Version="2.0.1">
24+
<PrivateAssets>all</PrivateAssets>
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
</PackageReference>
27+
</ItemGroup>
28+
<ProjectExtensions>
29+
<VisualStudio>
30+
<UserProperties DisLinkedXmlFile="..\IAS_CheckBoxList.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
31+
</VisualStudio>
32+
</ProjectExtensions>
2833
</Project>
Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
namespace IAS_DropDownFilter_1
22
{
3-
using System;
4-
using System.Linq;
5-
using Skyline.DataMiner.Automation;
6-
using Skyline.DataMiner.Core.DataMinerSystem.Automation;
7-
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
8-
9-
public class DropDownFilterDialog : Dialog
10-
{
11-
private readonly DropDown elementDropDown;
12-
private readonly Button exitButton;
13-
14-
public DropDownFilterDialog(IEngine engine) : base(engine)
15-
{
16-
Title = "Select an Element";
17-
18-
// Set up dropdown
19-
var dms = engine.GetDms();
20-
elementDropDown = new DropDown(dms.GetElements().Select(x => x.Name))
21-
{
22-
IsDisplayFilterShown = true, // Allows user to filter in dropdown options
23-
IsSorted = true, // Sorts the options alphabetically
24-
};
25-
26-
elementDropDown.Changed += (s, e) => OnElementSelected?.Invoke(this, new ElementSelectedEventArgs(e.Selected));
27-
28-
// Set up exit button
29-
exitButton = new Button("Exit");
30-
exitButton.Pressed += (s, e) => OnExitButtonPressed?.Invoke(this, EventArgs.Empty);
31-
32-
// Generate Ui
33-
AddWidget(new Label("Hint: you can type in the dropdown to filter options"), 0, 0);
34-
AddWidget(elementDropDown, 1, 0);
35-
AddWidget(exitButton, 2, 0);
36-
}
37-
38-
public event EventHandler<ElementSelectedEventArgs> OnElementSelected;
39-
40-
public event EventHandler OnExitButtonPressed;
41-
}
42-
}
3+
using System;
4+
using System.Linq;
5+
6+
using Skyline.DataMiner.Automation;
7+
using Skyline.DataMiner.Core.DataMinerSystem.Automation;
8+
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
9+
10+
public class DropDownFilterDialog : Dialog
11+
{
12+
private readonly DropDown elementDropDown;
13+
14+
private readonly Button exitButton;
15+
16+
public DropDownFilterDialog(IEngine engine) : base(engine)
17+
{
18+
Title = "Select an Element";
19+
20+
// Set up dropdown
21+
var dms = engine.GetDms();
22+
elementDropDown = new DropDown(dms.GetElements().Select(x => x.Name))
23+
{
24+
IsDisplayFilterShown = true, // Allows user to filter in dropdown options
25+
IsSorted = true, // Sorts the options alphabetically
26+
};
27+
28+
elementDropDown.Changed += (s, e) => OnElementSelected?.Invoke(this, new ElementSelectedEventArgs(e.Selected));
29+
30+
// Set up exit button
31+
exitButton = new Button("Exit");
32+
exitButton.Pressed += (s, e) => OnExitButtonPressed?.Invoke(this, EventArgs.Empty);
33+
34+
// Generate Ui
35+
AddWidget(new Label("Hint: you can type in the dropdown to filter options"), 0, 0);
36+
AddWidget(elementDropDown, 1, 0);
37+
AddWidget(exitButton, 2, 0);
38+
}
39+
40+
public event EventHandler<ElementSelectedEventArgs> OnElementSelected;
41+
42+
public event EventHandler OnExitButtonPressed;
43+
}
44+
}

0 commit comments

Comments
 (0)