Skip to content

Commit c52ee7b

Browse files
committed
Return empty table, instead of an error when no dom instance/module is given in the input arguments. Maybe this could be intentional and then an error is not correct.
1 parent 5006d22 commit c52ee7b

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

SLC-GQIDS-DOM-History_1/SLC-GQIDS-DOM-History_1.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ Ambachtenstraat 33
4545
4646
DATE VERSION AUTHOR COMMENTS
4747
48-
30/05/2024 1.0.0.1 AMA, Skyline Initial version
48+
30/05/2024 1.0.1 AMA, Skyline Initial version
49+
18/06/2024 1.0.2 AMA, Skyline Fixed exceptions when multiple sections or removed sections were present in the history
50+
01/07/2024 1.0.3 AMA, Skyline Return empty table, when no module or instance is given. This could be intentional, for example when no row is selected in a table
4951
****************************************************************************
5052
*/
5153

@@ -72,8 +74,8 @@ public class GetDOMHistory : IGQIDataSource, IGQIOnInit, IGQIInputArguments
7274
private Guid domInstanceId;
7375

7476
#region IGQIInputArguments
75-
private readonly GQIStringArgument domInstanceModuleArgs = new GQIStringArgument("DOM Module") { IsRequired = true };
76-
private readonly GQIStringArgument domInstanceIdArgs = new GQIStringArgument("DOM Instance ID") { IsRequired = true };
77+
private readonly GQIStringArgument domInstanceModuleArgs = new GQIStringArgument("DOM Module") { IsRequired = false, DefaultValue = String.Empty };
78+
private readonly GQIStringArgument domInstanceIdArgs = new GQIStringArgument("DOM Instance ID") { IsRequired = false, DefaultValue = String.Empty };
7779

7880
public GQIArgument[] GetInputArguments()
7981
{
@@ -82,11 +84,20 @@ public GQIArgument[] GetInputArguments()
8284

8385
public OnArgumentsProcessedOutputArgs OnArgumentsProcessed(OnArgumentsProcessedInputArgs args)
8486
{
85-
var domModule = args.GetArgumentValue(domInstanceModuleArgs);
86-
var rawDomInstanceId = args.GetArgumentValue(domInstanceIdArgs);
87-
if (!Guid.TryParse(rawDomInstanceId, out domInstanceId))
87+
if (!args.TryGetArgumentValue(domInstanceModuleArgs, out var domModule) ||
88+
String.IsNullOrEmpty(domModule))
8889
{
89-
throw new ArgumentException("DOM Instance ID, is not a valid System.Guid");
90+
// If no valid DOM Module ID is given return an empty table.
91+
dataProvider = null;
92+
return new OnArgumentsProcessedOutputArgs();
93+
}
94+
95+
if (!args.TryGetArgumentValue(domInstanceIdArgs, out var rawDomInstanceId) ||
96+
!Guid.TryParse(rawDomInstanceId, out domInstanceId))
97+
{
98+
// If no valid DOM Instance ID is given return an empty table.
99+
dataProvider = null;
100+
return new OnArgumentsProcessedOutputArgs();
90101
}
91102

92103
dataProvider = new DataProvider(dms, domModule);
@@ -120,6 +131,14 @@ public GQIColumn[] GetColumns()
120131

121132
public GQIPage GetNextPage(GetNextPageInputArgs args)
122133
{
134+
if (dataProvider == null)
135+
{
136+
return new GQIPage(new GQIRow[0])
137+
{
138+
HasNextPage = false,
139+
};
140+
}
141+
123142
var changes = dataProvider.GetHistoryForInstance(domInstanceId);
124143

125144
var rows = changes.Select(change => new GQIRow(

0 commit comments

Comments
 (0)