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+ }
0 commit comments