Skip to content

Commit 8b2980d

Browse files
2 parents 17b1685 + eeab98d commit 8b2980d

File tree

11 files changed

+143
-22
lines changed

11 files changed

+143
-22
lines changed

CancelService_1/CancelService_1.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ namespace CancelService_1
6262
/// </summary>
6363
public class Script
6464
{
65+
private static string[] primaryKeysCurrentServices = new string[0];
66+
private static Element nevionVideoIPathElement;
67+
6568
/// <summary>
6669
/// The script entry point.
6770
/// </summary>
@@ -77,7 +80,17 @@ public static void Run(IEngine engine)
7780
return;
7881
}
7982

83+
nevionVideoIPathElement = engine.FindElementsByProtocol("Nevion Video iPath", "Production").FirstOrDefault();
84+
if (nevionVideoIPathElement == null)
85+
{
86+
engine.ExitFail("Nevion Video iPath element not found!");
87+
return;
88+
}
89+
90+
primaryKeysCurrentServices = nevionVideoIPathElement.GetTablePrimaryKeys(1500); // Used to check if new connection entries has been added after the ConnectServices.
91+
8092
CancelCurrentServices(engine, serviceIds);
93+
VerifyCancelService(engine, serviceIds);
8194
}
8295
catch (Exception e)
8396
{
@@ -122,5 +135,22 @@ private static bool TryGetIdsFromInput(string input, out List<string> ids)
122135
return false;
123136
}
124137
}
138+
139+
private static void VerifyCancelService(IEngine engine, List<string> serviceIds)
140+
{
141+
int retries = 0;
142+
bool allEntriesFound = false;
143+
int tableEntriesExcludingCurrentDestination = primaryKeysCurrentServices.Length - serviceIds.Count;
144+
while (!allEntriesFound && retries < 100)
145+
{
146+
engine.Sleep(60);
147+
148+
var allPrimaryKeys = nevionVideoIPathElement.GetTablePrimaryKeys(1500);
149+
150+
allEntriesFound = allPrimaryKeys.Length == tableEntriesExcludingCurrentDestination;
151+
152+
retries++;
153+
}
154+
}
125155
}
126156
}

CancelService_1/CancelService_1.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<Version>13.0.3</Version>
5454
</PackageReference>
5555
<PackageReference Include="Skyline.DataMiner.Dev.Automation">
56-
<Version>10.3.6</Version>
56+
<Version>10.3.9</Version>
5757
</PackageReference>
5858
<PackageReference Include="StyleCop.Analyzers">
5959
<Version>1.1.118</Version>
@@ -64,7 +64,7 @@
6464
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6565
<ProjectExtensions>
6666
<VisualStudio>
67-
<UserProperties DisLinkedXmlFile="..\CancelService.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
67+
<UserProperties DisLinkId="1" DisProjectType="automationScriptProject" DisLinkedXmlFile="..\CancelService.xml" />
6868
</VisualStudio>
6969
</ProjectExtensions>
7070
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

ConnectServices_1/ConnectServices_1.cs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,30 @@ namespace ConnectServices_1
5353
{
5454
using System;
5555
using System.Collections.Generic;
56+
using System.Configuration;
5657
using System.Linq;
58+
using System.Threading;
5759
using Newtonsoft.Json;
5860
using Skyline.DataMiner.Automation;
61+
using Skyline.DataMiner.Core.DataMinerSystem.Automation;
62+
using Skyline.DataMiner.Core.DataMinerSystem.Common;
5963

6064
/// <summary>
6165
/// Represents a DataMiner Automation script.
6266
/// </summary>
6367
public class Script
6468
{
69+
private static string[] primaryKeysCurrentServices = new string[0];
70+
private static Element nevionVideoIPathElement;
71+
6572
/// <summary>
6673
/// The script entry point.
6774
/// </summary>
6875
/// <param name="engine">Link with SLAutomation process.</param>
6976
public static void Run(IEngine engine)
7077
{
78+
engine.SetFlag(RunTimeFlags.NoKeyCaching);
79+
7180
try
7281
{
7382
var sourceDescriptorLabelInputParameter = engine.GetScriptParam("SourceName").Value;
@@ -123,7 +132,17 @@ public static void Run(IEngine engine)
123132
return;
124133
}
125134

135+
nevionVideoIPathElement = engine.FindElementsByProtocol("Nevion Video iPath", "Production").FirstOrDefault();
136+
if (nevionVideoIPathElement == null)
137+
{
138+
engine.ExitFail("Nevion Video iPath element not found!");
139+
return;
140+
}
141+
142+
primaryKeysCurrentServices = nevionVideoIPathElement.GetTablePrimaryKeys(1500); // Used to check if new connection entries has been added after the ConnectServices.
143+
126144
ConnectServices(engine, sourceName, destinationNames, profileName);
145+
VerifyConnectService(engine, destinationNames);
127146
}
128147
catch (Exception e)
129148
{
@@ -133,13 +152,6 @@ public static void Run(IEngine engine)
133152

134153
private static void ConnectServices(IEngine engine, string sourceName, List<string> destinationNames, string profile)
135154
{
136-
var nevionVideoIPathElement = engine.FindElementsByProtocol("Nevion Video iPath", "Production").FirstOrDefault();
137-
if (nevionVideoIPathElement == null)
138-
{
139-
engine.ExitFail("Nevion Video iPath element not found!");
140-
return;
141-
}
142-
143155
if (!nevionVideoIPathElement.IsActive)
144156
{
145157
engine.ExitFail("Nevion Video iPath element not active!");
@@ -168,5 +180,22 @@ private static bool TryGetInputValue(string input, out List<string> labels)
168180
return false;
169181
}
170182
}
183+
184+
private static void VerifyConnectService(IEngine engine, List<string> destinationNames)
185+
{
186+
int retries = 0;
187+
bool allEntriesFound = false;
188+
int tableEntryCountIncludingNewEntries = primaryKeysCurrentServices.Length + destinationNames.Count;
189+
while (!allEntriesFound && retries < 100)
190+
{
191+
engine.Sleep(50);
192+
193+
var allPrimaryKeys = nevionVideoIPathElement.GetTablePrimaryKeys(1500);
194+
195+
allEntriesFound = allPrimaryKeys.Length == tableEntryCountIncludingNewEntries;
196+
197+
retries++;
198+
}
199+
}
171200
}
172201
}

ConnectServices_1/ConnectServices_1.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@
5252
<PackageReference Include="Newtonsoft.Json">
5353
<Version>13.0.3</Version>
5454
</PackageReference>
55+
<PackageReference Include="Skyline.DataMiner.Core.DataMinerSystem.Automation">
56+
<Version>1.1.0.5</Version>
57+
</PackageReference>
5558
<PackageReference Include="Skyline.DataMiner.Dev.Automation">
56-
<Version>10.3.6</Version>
59+
<Version>10.3.9</Version>
5760
</PackageReference>
5861
<PackageReference Include="StyleCop.Analyzers">
5962
<Version>1.1.118</Version>
@@ -64,7 +67,7 @@
6467
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6568
<ProjectExtensions>
6669
<VisualStudio>
67-
<UserProperties DisLinkedXmlFile="..\ConnectServices.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
70+
<UserProperties DisLinkId="1" DisProjectType="automationScriptProject" DisLinkedXmlFile="..\ConnectServices.xml" />
6871
</VisualStudio>
6972
</ProjectExtensions>
7073
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

DisconnectServices_1/DisconnectServices_1.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,17 @@ namespace DisconnectServices_1
6464
/// </summary>
6565
public class Script
6666
{
67+
private static string[] primaryKeysCurrentServices = new string[0];
68+
private static Element nevionVideoIPathElement;
69+
6770
/// <summary>
6871
/// The script entry point.
6972
/// </summary>
7073
/// <param name="engine">Link with SLAutomation process.</param>
7174
public static void Run(IEngine engine)
7275
{
76+
engine.SetFlag(RunTimeFlags.NoKeyCaching);
77+
7378
try
7479
{
7580
var destinationIdsParameter = engine.GetScriptParam("DestinationIds").Value;
@@ -79,7 +84,17 @@ public static void Run(IEngine engine)
7984
return;
8085
}
8186

87+
nevionVideoIPathElement = engine.FindElementsByProtocol("Nevion Video iPath", "Production").FirstOrDefault();
88+
if (nevionVideoIPathElement == null)
89+
{
90+
engine.ExitFail("Nevion Video iPath element not found!");
91+
return;
92+
}
93+
94+
primaryKeysCurrentServices = nevionVideoIPathElement.GetTablePrimaryKeys(1500); // Used to check if new connection entries has been added after the ConnectServices.
95+
8296
DisconnectDestinations(engine, destinationIds);
97+
VerifyDisconnectService(engine, destinationIds);
8398
}
8499
catch (Exception e)
85100
{
@@ -139,5 +154,22 @@ private static bool TryGetIdsFromInput(string input, out List<string> ids)
139154
return false;
140155
}
141156
}
157+
158+
private static void VerifyDisconnectService(IEngine engine, List<string> destinationNames)
159+
{
160+
int retries = 0;
161+
bool allEntriesFound = false;
162+
int tableEntriesExcludingCurrentDestination = primaryKeysCurrentServices.Length - destinationNames.Count;
163+
while (!allEntriesFound && retries < 100)
164+
{
165+
engine.Sleep(60);
166+
167+
var allPrimaryKeys = nevionVideoIPathElement.GetTablePrimaryKeys(1500);
168+
169+
allEntriesFound = allPrimaryKeys.Length == tableEntriesExcludingCurrentDestination;
170+
171+
retries++;
172+
}
173+
}
142174
}
143175
}

DisconnectServices_1/DisconnectServices_1.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<Version>1.1.0.5</Version>
6060
</PackageReference>
6161
<PackageReference Include="Skyline.DataMiner.Dev.Automation">
62-
<Version>10.3.6</Version>
62+
<Version>10.3.9</Version>
6363
</PackageReference>
6464
<PackageReference Include="StyleCop.Analyzers">
6565
<Version>1.1.118</Version>
@@ -70,7 +70,7 @@
7070
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7171
<ProjectExtensions>
7272
<VisualStudio>
73-
<UserProperties DisLinkedXmlFile="..\DisconnectServices.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
73+
<UserProperties DisLinkId="1" DisProjectType="automationScriptProject" DisLinkedXmlFile="..\DisconnectServices.xml" />
7474
</VisualStudio>
7575
</ProjectExtensions>
7676
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

GQI_NevionVideoIPath_GetDestinations_1/GQI_NevionVideoIPath_GetDestinations_1.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</ItemGroup>
5151
<ItemGroup>
5252
<PackageReference Include="Skyline.DataMiner.Dev.Automation">
53-
<Version>10.3.6</Version>
53+
<Version>10.3.9</Version>
5454
</PackageReference>
5555
<PackageReference Include="StyleCop.Analyzers">
5656
<Version>1.1.118</Version>
@@ -61,7 +61,7 @@
6161
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6262
<ProjectExtensions>
6363
<VisualStudio>
64-
<UserProperties DisLinkedXmlFile="..\GQI_NevionVideoIPath_GetDestinations.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
64+
<UserProperties DisLinkId="1" DisProjectType="automationScriptProject" DisLinkedXmlFile="..\GQI_NevionVideoIPath_GetDestinations.xml" />
6565
</VisualStudio>
6666
</ProjectExtensions>
6767
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

GQI_NevionVideoIPath_GetSources_1/GQI_NevionVideoIPath_GetSources_1.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</ItemGroup>
5151
<ItemGroup>
5252
<PackageReference Include="Skyline.DataMiner.Dev.Automation">
53-
<Version>10.3.6</Version>
53+
<Version>10.3.9</Version>
5454
</PackageReference>
5555
<PackageReference Include="StyleCop.Analyzers">
5656
<Version>1.1.118</Version>
@@ -61,7 +61,7 @@
6161
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6262
<ProjectExtensions>
6363
<VisualStudio>
64-
<UserProperties DisLinkedXmlFile="..\GQI_NevionVideoIPath_GetSources.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
64+
<UserProperties DisLinkId="1" DisProjectType="automationScriptProject" DisLinkedXmlFile="..\GQI_NevionVideoIPath_GetSources.xml" />
6565
</VisualStudio>
6666
</ProjectExtensions>
6767
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

GQI_NevionVideoIPath_GetTags/GQI_NevionVideoIPath_GetTags.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</ItemGroup>
5151
<ItemGroup>
5252
<PackageReference Include="Skyline.DataMiner.Dev.Automation">
53-
<Version>10.3.6</Version>
53+
<Version>10.3.9</Version>
5454
</PackageReference>
5555
<PackageReference Include="StyleCop.Analyzers">
5656
<Version>1.1.118</Version>
@@ -61,7 +61,7 @@
6161
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6262
<ProjectExtensions>
6363
<VisualStudio>
64-
<UserProperties DisLinkedXmlFile="..\GQI_NevionVideoIPath_GetTags.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
64+
<UserProperties DisLinkId="1" DisProjectType="automationScriptProject" DisLinkedXmlFile="..\GQI_NevionVideoIPath_GetTags.xml" />
6565
</VisualStudio>
6666
</ProjectExtensions>
6767
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

ScheduleServices_1/ScheduleDialog.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class ScheduleDialog : Dialog
3939
private readonly Element nevionVideoIPathElement;
4040

4141
private List<string> destinationNames;
42+
private string[] primaryKeysCurrentServices = new string[0];
4243

4344
public ScheduleDialog(IEngine engine) : base(engine)
4445
{
@@ -57,10 +58,16 @@ public ScheduleDialog(IEngine engine) : base(engine)
5758
return;
5859
}
5960

61+
primaryKeysCurrentServices = nevionVideoIPathElement.GetTablePrimaryKeys(1500); // Used to check if new connection entries has been added after the ConnectServices.
62+
6063
startRadioButtonList.Changed += (s, o) => HandleStartOptionChanged();
6164
endRadioButtonList.Changed += (s, o) => HandleEndOptionChanged();
6265

63-
ConnectButton.Pressed += (s, o) => TriggerConnectOnElement();
66+
ConnectButton.Pressed += (s, o) =>
67+
{
68+
TriggerConnectOnElement();
69+
VerifyConnectService(); // Temproary untill real time updates are fully supported in the apps.
70+
};
6471

6572
GenerateUI();
6673
}
@@ -195,6 +202,23 @@ public void TriggerConnectOnElement()
195202
nevionVideoIPathElement.SetParameter(2309, visioString);
196203
}
197204

205+
private void VerifyConnectService()
206+
{
207+
int retries = 0;
208+
bool allEntriesFound = false;
209+
int tableEntryCountIncludingNewEntries = primaryKeysCurrentServices.Length + DestinationNames.Count;
210+
while (!allEntriesFound && retries < 100)
211+
{
212+
Engine.Sleep(50);
213+
214+
var allPrimaryKeys = nevionVideoIPathElement.GetTablePrimaryKeys(1500);
215+
216+
allEntriesFound = allPrimaryKeys.Length == tableEntryCountIncludingNewEntries;
217+
218+
retries++;
219+
}
220+
}
221+
198222
private void HandleStartOptionChanged()
199223
{
200224
var startSelection = startRadioButtonList.Selected;

0 commit comments

Comments
 (0)