Skip to content

Commit 6f4cb2d

Browse files
committed
new example script for HideUI method
1 parent 452d83a commit 6f4cb2d

File tree

5 files changed

+247
-0
lines changed

5 files changed

+247
-0
lines changed

IAS_HideUI.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<DMSScript options="272" xmlns="http://www.skyline.be/automation">
3+
<Name>IAS_HideUI</Name>
4+
<Description></Description>
5+
<Type>Automation</Type>
6+
<Author>SKYLINE2\RijadCO</Author>
7+
<CheckSets>FALSE</CheckSets>
8+
<Folder></Folder>
9+
10+
<Protocols>
11+
</Protocols>
12+
13+
<Memory>
14+
</Memory>
15+
16+
<Parameters>
17+
</Parameters>
18+
19+
<Script>
20+
<Exe id="1" type="csharp">
21+
<Value><![CDATA[[Project:IAS_HideUI_1]]]></Value>
22+
<!--<Param type="debug">true</Param>-->
23+
<Message></Message>
24+
</Exe>
25+
</Script>
26+
</DMSScript>

IAS_HideUI_1/HideUIPanel.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
namespace IAS_HideUI_1
2+
{
3+
using Skyline.DataMiner.Automation;
4+
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
9+
public class HideUIPanel : Dialog
10+
{
11+
private readonly Label hideUiLabel = new Label("Hide UI:");
12+
13+
private readonly Label showUiAgainLabel = new Label("Show UI again after background action?");
14+
15+
public HideUIPanel(IEngine engine) : base(engine)
16+
{
17+
Title = "Hide UI";
18+
19+
Initialize();
20+
GenerateUi();
21+
}
22+
23+
public Button HideUiButton { get; set; }
24+
25+
public CheckBox HideUiCheckBox { get; set; }
26+
27+
private void Initialize()
28+
{
29+
HideUiButton = new Button("Hide");
30+
HideUiCheckBox = new CheckBox { IsChecked = false };
31+
}
32+
33+
private void GenerateUi()
34+
{
35+
Clear();
36+
37+
int row = -1;
38+
AddWidget(hideUiLabel, ++row, 0);
39+
AddWidget(HideUiButton, row, 1);
40+
AddWidget(showUiAgainLabel, ++row, 0);
41+
AddWidget(HideUiCheckBox, row, 1);
42+
}
43+
}
44+
}

IAS_HideUI_1/IAS_HideUI_1.cs

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
****************************************************************************
3+
* Copyright (c) 2024, Skyline Communications NV All Rights Reserved. *
4+
****************************************************************************
5+
6+
By using this script, you expressly agree with the usage terms and
7+
conditions set out below.
8+
This script and all related materials are protected by copyrights and
9+
other intellectual property rights that exclusively belong
10+
to Skyline Communications.
11+
12+
A user license granted for this script is strictly for personal use only.
13+
This script may not be used in any way by anyone without the prior
14+
written consent of Skyline Communications. Any sublicensing of this
15+
script is forbidden.
16+
17+
Any modifications to this script by the user are only allowed for
18+
personal use and within the intended purpose of the script,
19+
and will remain the sole responsibility of the user.
20+
Skyline Communications will not be responsible for any damages or
21+
malfunctions whatsoever of the script resulting from a modification
22+
or adaptation by the user.
23+
24+
The content of this script is confidential information.
25+
The user hereby agrees to keep this confidential information strictly
26+
secret and confidential and not to disclose or reveal it, in whole
27+
or in part, directly or indirectly to any person, entity, organization
28+
or administration without the prior written consent of
29+
Skyline Communications.
30+
31+
Any inquiries can be addressed to:
32+
33+
Skyline Communications NV
34+
Ambachtenstraat 33
35+
B-8870 Izegem
36+
Belgium
37+
Tel. : +32 51 31 35 69
38+
Fax. : +32 51 31 01 29
39+
E-mail : info@skyline.be
40+
Web : www.skyline.be
41+
Contact : Ben Vandenberghe
42+
43+
****************************************************************************
44+
Revision History:
45+
46+
DATE VERSION AUTHOR COMMENTS
47+
48+
dd/mm/2024 1.0.0.1 XXX, Skyline Initial version
49+
****************************************************************************
50+
*/
51+
52+
namespace IAS_HideUI_1
53+
{
54+
using System;
55+
using System.Collections.Generic;
56+
using System.Globalization;
57+
using System.Text;
58+
using System.Threading;
59+
using Skyline.DataMiner.Automation;
60+
using Skyline.DataMiner.Utils.InteractiveAutomationScript;
61+
62+
/// <summary>
63+
/// Represents a DataMiner Automation script.
64+
/// </summary>
65+
public class Script
66+
{
67+
private InteractiveController app;
68+
private IEngine engine;
69+
private HideUIPanel hideUiPanel;
70+
71+
/// <summary>
72+
/// The script entry point.
73+
/// </summary>
74+
/// <param name="engine">Link with SLAutomation process.</param>
75+
public void Run(IEngine engine)
76+
{
77+
try
78+
{
79+
app = new InteractiveController(engine);
80+
this.engine = engine;
81+
82+
engine.SetFlag(RunTimeFlags.NoKeyCaching);
83+
engine.Timeout = TimeSpan.FromHours(10);
84+
85+
RunSafe(engine);
86+
}
87+
catch (ScriptAbortException)
88+
{
89+
// Catch normal abort exceptions (engine.ExitFail or engine.ExitSuccess)
90+
throw; // Comment if it should be treated as a normal exit of the script.
91+
}
92+
catch (ScriptForceAbortException)
93+
{
94+
// Catch forced abort exceptions, caused via external maintenance messages.
95+
throw;
96+
}
97+
catch (ScriptTimeoutException)
98+
{
99+
// Catch timeout exceptions for when a script has been running for too long.
100+
throw;
101+
}
102+
catch (InteractiveUserDetachedException)
103+
{
104+
// Catch a user detaching from the interactive script by closing the window.
105+
// Only applicable for interactive scripts, can be removed for non-interactive scripts.
106+
throw;
107+
}
108+
catch (Exception e)
109+
{
110+
engine.ExitFail("Run|Something went wrong: " + e);
111+
}
112+
}
113+
114+
private void RunSafe(IEngine engine)
115+
{
116+
// engine.ShowUI()
117+
hideUiPanel = new HideUIPanel(engine);
118+
hideUiPanel.HideUiButton.Pressed += HideUiButton_Pressed;
119+
app.ShowDialog(hideUiPanel);
120+
}
121+
122+
private void HideUiButton_Pressed(object sender, EventArgs e)
123+
{
124+
app.Hide();
125+
126+
// Imagine this is our background action behind button
127+
Thread.Sleep(5000);
128+
129+
if (hideUiPanel.HideUiCheckBox.IsChecked)
130+
app.ShowDialog(hideUiPanel);
131+
}
132+
}
133+
}

IAS_HideUI_1/IAS_HideUI_1.csproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.4.7" />
21+
<PackageReference Include="Skyline.DataMiner.Utils.InteractiveAutomationScriptToolkit" Version="9.0.2" />
22+
</ItemGroup>
23+
<ProjectExtensions>
24+
<VisualStudio>
25+
<UserProperties DisLinkedXmlFile="..\IAS_HideUI.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
26+
</VisualStudio>
27+
</ProjectExtensions>
28+
</Project>

SLC-AS-Example_InteractiveAutomationScriptToolkit.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Actions", "Actions", "{7F10
6464
EndProject
6565
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IAS_CheckBoxList_1", "IAS_CheckBoxList_1\IAS_CheckBoxList_1.csproj", "{3B0B0E09-A26C-4F9A-AFDA-A7D7FC4F50EF}"
6666
EndProject
67+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IAS_HideUI", "IAS_HideUI", "{A83E1336-D502-496D-9048-EE6A95231572}"
68+
ProjectSection(SolutionItems) = preProject
69+
IAS_HideUI.xml = IAS_HideUI.xml
70+
EndProjectSection
71+
EndProject
72+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Actions", "Actions", "{13E1A298-3A8E-4140-B2DA-484E4CC0CC6B}"
73+
EndProject
74+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IAS_HideUI_1", "IAS_HideUI_1\IAS_HideUI_1.csproj", "{CE7701AB-8412-489A-96B2-0FCB758E7E93}"
75+
EndProject
6776
Global
6877
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6978
Debug|Any CPU = Debug|Any CPU
@@ -82,6 +91,10 @@ Global
8291
{3B0B0E09-A26C-4F9A-AFDA-A7D7FC4F50EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
8392
{3B0B0E09-A26C-4F9A-AFDA-A7D7FC4F50EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
8493
{3B0B0E09-A26C-4F9A-AFDA-A7D7FC4F50EF}.Release|Any CPU.Build.0 = Release|Any CPU
94+
{CE7701AB-8412-489A-96B2-0FCB758E7E93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95+
{CE7701AB-8412-489A-96B2-0FCB758E7E93}.Debug|Any CPU.Build.0 = Debug|Any CPU
96+
{CE7701AB-8412-489A-96B2-0FCB758E7E93}.Release|Any CPU.ActiveCfg = Release|Any CPU
97+
{CE7701AB-8412-489A-96B2-0FCB758E7E93}.Release|Any CPU.Build.0 = Release|Any CPU
8598
EndGlobalSection
8699
GlobalSection(SolutionProperties) = preSolution
87100
HideSolutionNode = FALSE
@@ -98,6 +111,9 @@ Global
98111
{E1317C39-C65D-4D89-BB72-F5F284341A94} = {A81CCA8A-5280-4798-9442-62C6C68CAD61}
99112
{7F10AEC8-9A16-46AB-A6D6-3CF01E2F2AA3} = {E1317C39-C65D-4D89-BB72-F5F284341A94}
100113
{3B0B0E09-A26C-4F9A-AFDA-A7D7FC4F50EF} = {7F10AEC8-9A16-46AB-A6D6-3CF01E2F2AA3}
114+
{A83E1336-D502-496D-9048-EE6A95231572} = {A81CCA8A-5280-4798-9442-62C6C68CAD61}
115+
{13E1A298-3A8E-4140-B2DA-484E4CC0CC6B} = {A83E1336-D502-496D-9048-EE6A95231572}
116+
{CE7701AB-8412-489A-96B2-0FCB758E7E93} = {13E1A298-3A8E-4140-B2DA-484E4CC0CC6B}
101117
EndGlobalSection
102118
GlobalSection(ExtensibilityGlobals) = postSolution
103119
SolutionGuid = {D10F5189-03D7-4B39-86D5-220E1112B68C}

0 commit comments

Comments
 (0)