42
42
43
43
import Microsoft.Win32
44
44
import System
45
+ import Newtonsoft.Json
46
+ import Newtonsoft.Json.Serialization
45
47
import System.Collections
46
48
import System.Collections.Generic
47
49
import System.Collections.ObjectModel
@@ -50,7 +52,6 @@ import System.Linq
50
52
import System.Reflection
51
53
import System.Text
52
54
import CodeGen.Engine
53
- import CodeGen.Engine
54
55
import CodeGen.RepositoryAPI
55
56
56
57
.array 0
@@ -546,6 +547,7 @@ namespace CodeGen.Engine
546
547
try
547
548
begin
548
549
context.Repository = new Repository()
550
+
549
551
if (context.DeveloperDebugLoggingEnabled)
550
552
begin
551
553
context.CurrentTask.DevDebugLog("Repository opened")
@@ -1015,15 +1017,15 @@ namespace CodeGen.Engine
1015
1017
;;-------------------------------------------------------------------------
1016
1018
;;Do we have Repository structures specified in the task?
1017
1019
1018
- if (!errStatus && (context.CurrentTask.Structures. Count>0 ))
1020
+ if (!errStatus && (( context.CurrentTask.Structures != ^null && context.CurrentTask.Structures. Count > 0) || (context.TaskSet.Structures.Count > 0) ))
1019
1021
begin
1020
1022
if (context.FileDefinition!=^null) then
1021
1023
errStatus = context.CurrentTask.Errorlog("You can't specify both a repository file and repository structures at the same time!")
1022
1024
else if (!String.IsNullOrWhiteSpace(context.CurrentTask.WindowScript)) then
1023
1025
errStatus = context.CurrentTask.Errorlog("You can't specify a window script and repository structures at the same time!")
1024
1026
else if (!String.IsNullOrEmpty(context.CurrentTask.ProformaFile)) then
1025
1027
errStatus = context.CurrentTask.Errorlog("You can't specify a proforma file and repository structures at the same time!")
1026
- else
1028
+ else if (context.CurrentTask.Structures != ^null && context.CurrentTask.Structures.Count>0) then
1027
1029
begin
1028
1030
;;All or specific structures?
1029
1031
if (context.CurrentTask.Structures[0]=="*") then
@@ -1067,16 +1069,62 @@ namespace CodeGen.Engine
1067
1069
endtry
1068
1070
end
1069
1071
end
1070
-
1071
- ;;Default all structures to use the first file assigned
1072
- if (!errStatus)
1072
+ end
1073
+ else if (context.Taskset.Structures.Count > 0)
1074
+ begin
1075
+ ;;All or specific structures?
1076
+ if (context.Taskset.Structures[0]=="*") then
1077
+ begin
1078
+ ;;Process all structures
1079
+ try
1080
+ begin
1081
+ context.Structures = new RpsStructureCollection(RpsLoadMode.Load,context.CurrentTask.UseAlternateFieldNames)
1082
+ if (context.Structures.Count == 0)
1083
+ errStatus = context.CurrentTask.Errorlog("Your repository contains no structures!")
1084
+ end
1085
+ catch (ex, @RpsException)
1086
+ begin
1087
+ errStatus = context.CurrentTask.Errorlog(ex.Message)
1088
+ end
1089
+ endtry
1090
+ end
1091
+ else
1073
1092
begin
1093
+ ;;Process specified structures
1074
1094
data ix, int
1075
- context.StructureFileIndex = new int[context.Structures.Count]
1076
- for ix from 0 thru context.Structures.Count - 1
1077
- context.StructureFileIndex[ix] = 0
1095
+ for ix from 0 thru context.Taskset.Structures.Count-1
1096
+ begin
1097
+ try
1098
+ begin
1099
+ data newStructure, @RpsStructure, new RpsStructure(context.Taskset.Structures[ix],context.CurrentTask.UseAlternateFieldNames)
1100
+ if (!String.IsNullOrWhiteSpace(context.SelectionWindowScript))
1101
+ begin
1102
+ if (!ProcessSelectionWindows(context,newStructure))
1103
+ begin
1104
+ errStatus = context.CurrentTask.Errorlog(String.Format("Failed to resolve selection windows for structure {0}.",newStructure.Name))
1105
+ exitloop
1106
+ end
1107
+ end
1108
+ context.Structures.Add(newStructure)
1109
+ end
1110
+ catch (ex)
1111
+ begin
1112
+ errStatus = context.CurrentTask.Errorlog(ex.Message)
1113
+ end
1114
+ endtry
1115
+ end
1078
1116
end
1079
1117
end
1118
+
1119
+ ;;Default all structures to use the first file assigned
1120
+ if (!errStatus)
1121
+ begin
1122
+ data ix, int
1123
+ context.StructureFileIndex = new int[context.Structures.Count]
1124
+ for ix from 0 thru context.Structures.Count - 1
1125
+ context.StructureFileIndex[ix] = 0
1126
+ end
1127
+
1080
1128
end
1081
1129
1082
1130
;;-------------------------------------------------------------------------
@@ -1235,7 +1283,7 @@ namespace CodeGen.Engine
1235
1283
tmpStr.Alias = tmpStr.Name
1236
1284
1237
1285
;;Now apply specific aliases from the command line
1238
- if (context.CurrentTask.Aliases. Count>0)
1286
+ if (context.CurrentTask.Aliases != ^null && context.CurrentTask.Aliases. Count>0) then
1239
1287
begin
1240
1288
if (!String.IsNullOrWhiteSpace(context.CurrentTask.WindowScript)) then
1241
1289
errStatus = context.CurrentTask.Errorlog("Can't use WindowScript and Aliases properties together!")
@@ -1255,6 +1303,26 @@ namespace CodeGen.Engine
1255
1303
end
1256
1304
end
1257
1305
end
1306
+ else if (context.Taskset.Aliases.Count > 0)
1307
+ begin
1308
+ if (!String.IsNullOrWhiteSpace(context.CurrentTask.WindowScript)) then
1309
+ errStatus = context.CurrentTask.Errorlog("Can't use WindowScript and Aliases properties together!")
1310
+ else if (context.TaskSet.Aliases.Count > context.Structures.Count) then
1311
+ errStatus = context.CurrentTask.Errorlog("More aliases than repository structures!")
1312
+ else
1313
+ begin
1314
+ context.CurrentTask.DebugLog("Applying structure aliases",true,false)
1315
+ data AliasIndex, int
1316
+ for AliasIndex from 0 thru context.TaskSet.Aliases.Count - 1
1317
+ begin
1318
+ if (!String.IsNullOrWhiteSpace(context.TaskSet.Aliases[AliasIndex]))
1319
+ begin
1320
+ context.Structures[AliasIndex].Alias = context.TaskSet.Aliases[AliasIndex].ToUpper()
1321
+ context.CurrentTask.DebugLog(" - Structure " + context.Structures[AliasIndex].Name + " aliased as " + context.Structures[AliasIndex].Alias)
1322
+ end
1323
+ end
1324
+ end
1325
+ end
1258
1326
end
1259
1327
1260
1328
;;-------------------------------------------------------------------------
0 commit comments