@@ -40,7 +40,6 @@ private static string ExportPackage(IEngine engine, IEnumerable<App> apps, Expor
40
40
{
41
41
var now = DateTime . Now ;
42
42
43
- var scriptReferences = new Dictionary < string , List < string > > ( ) ;
44
43
var exportPath = Path . Combine ( LowCodeAppEditorExportPath , $ "{ now . ToString ( "yyyy-MM-dd HH-mm-ss" ) } _App_Export.zip") ;
45
44
if ( apps . Count ( ) == 1 )
46
45
{
@@ -98,79 +97,34 @@ private static string ExportPackage(IEngine engine, IEnumerable<App> apps, Expor
98
97
else
99
98
{
100
99
engine . GenerateInformation ( $ "Adding Scripts") ;
101
-
102
- // Add the scripts used in the App
103
- var scripts = AddScriptsToArchive ( zip , app ) ;
104
-
105
- engine . GenerateInformation ( $ "Adding Script dependencies") ;
106
-
107
- // Add script dependencies
108
- var appReferences = AddDependenciesToArchive ( zip , app , scripts ) ;
109
- foreach ( var pair in appReferences )
110
- {
111
- if ( ! scriptReferences . ContainsKey ( pair . Key ) )
112
- {
113
- scriptReferences . Add ( pair . Key , pair . Value ) ;
114
- }
115
- else
116
- {
117
- scriptReferences [ pair . Key ] . AddRange ( pair . Value ) ;
118
- }
119
- }
100
+ AddScriptsToArchive ( zip , app ) ;
120
101
}
121
102
122
103
if ( ! options . ExcludeDom )
123
104
{
124
105
// Add Dom definitions
106
+ engine . GenerateInformation ( $ "Adding DOM modules, for app '{ app . Name } '") ;
125
107
domModuleIds . AddRangeUnique ( app . LatestVersion . GetUsedDomModules ( ) ) ;
108
+ AddDomToArchive ( engine , zip , domModuleIds , options ) ;
126
109
}
127
110
128
111
if ( ! options . ExcludeImages )
129
112
{
130
113
// Add Images to companion files
114
+ engine . GenerateInformation ( $ "Adding Images, for app '{ app . Name } '") ;
131
115
images . AddRangeUnique ( app . LatestVersion . GetUsedImages ( ) ) ;
116
+ AddImagesToArchive ( zip , images ) ;
132
117
}
133
118
134
119
if ( ! options . ExcludeThemes )
135
120
{
136
121
// Add Theme
122
+ engine . GenerateInformation ( $ "Adding Themes, for app '{ app . Name } '") ;
137
123
themes . AddRangeUnique ( app . LatestVersion . GetUsedThemes ( ) ) ;
124
+ AddThemesToArchive ( zip , themes ) ;
138
125
}
139
126
}
140
127
141
- // Add DOM modules
142
- if ( options . ExcludeDom )
143
- {
144
- engine . GenerateInformation ( $ "Skipping DOM modules") ;
145
- }
146
- else
147
- {
148
- engine . GenerateInformation ( $ "Adding DOM modules") ;
149
- AddDomToArchive ( engine , zip , domModuleIds , options ) ;
150
- }
151
-
152
- if ( options . ExcludeImages )
153
- {
154
- engine . GenerateInformation ( $ "Skipping Images") ;
155
- }
156
- else
157
- {
158
- // Add Images
159
- engine . GenerateInformation ( $ "Adding Images") ;
160
- AddImagesToArchive ( zip , images ) ;
161
- }
162
-
163
- if ( options . ExcludeThemes )
164
- {
165
- engine . GenerateInformation ( $ "Skipping Themes") ;
166
- }
167
- else
168
- {
169
- // Add Themes
170
- engine . GenerateInformation ( $ "Adding Themes") ;
171
- AddThemesToArchive ( zip , themes ) ;
172
- }
173
-
174
128
engine . GenerateInformation ( $ "Adding Installer code") ;
175
129
176
130
// Add custom Low Code App Installer Code
@@ -194,13 +148,9 @@ private static string ExportPackage(IEngine engine, IEnumerable<App> apps, Expor
194
148
sb . AppendLine ( $ "Script\\ { Path . GetDirectoryName ( file . FullName ) } ") ;
195
149
}
196
150
197
- // Add Assemblies
198
- foreach ( var pair in scriptReferences )
151
+ foreach ( var dependency in zip . GetEntries ( "AppInstallContent\\ Assemblies" ) . Where ( x => ! x . FullName . EndsWith ( "\\ " ) ) )
199
152
{
200
- foreach ( var reference in pair . Value )
201
- {
202
- sb . AppendLine ( $ "Assembly\\ { Path . GetDirectoryName ( reference ) } for automationscript:{ pair . Key } ") ;
203
- }
153
+ sb . AppendLine ( dependency . FullName ) ;
204
154
}
205
155
206
156
// Add CompanionFiles
@@ -243,50 +193,86 @@ private static void AddAppToArchive(ZipArchive zip, App app, ExportOptions optio
243
193
}
244
194
}
245
195
246
- private static List < string > AddScriptsToArchive ( ZipArchive zip , App app )
196
+ private static void AddScriptsToArchive ( ZipArchive zip , App app )
247
197
{
248
198
var scripts = app . LatestVersion . GetUsedScripts ( ) ;
199
+ var addedFiles = new List < string > ( ) ;
249
200
foreach ( var script in scripts )
250
201
{
251
- var scriptName = $ "Script_{ script } .xml";
252
- var scriptPath = Path . Combine ( ScriptPath , scriptName ) ;
253
- if ( File . Exists ( scriptPath ) )
202
+ AddScriptToArchive ( zip , app , script , addedFiles ) ;
203
+ }
204
+ }
205
+
206
+ private static void AddScriptToArchive ( ZipArchive zip , App app , string script , List < string > addedFiles )
207
+ {
208
+ var scriptName = $ "Script_{ script } .xml";
209
+ var scriptPath = Path . Combine ( ScriptPath , scriptName ) ;
210
+ if ( File . Exists ( scriptPath ) )
211
+ {
212
+ if ( addedFiles . Exists ( x => x == $ "AppInstallContent\\ Scripts\\ { script } \\ Script_{ script } .xml") )
254
213
{
255
- zip . CreateEntryFromFile ( Path . Combine ( ScriptPath , scriptName ) , Path . Combine ( "AppInstallContent" , "Scripts" , script , scriptName ) ) ;
214
+ return ;
256
215
}
216
+
217
+ zip . CreateEntryFromFile ( Path . Combine ( ScriptPath , scriptName ) , Path . Combine ( "AppInstallContent" , "Scripts" , script , scriptName ) ) ;
218
+ addedFiles . Add ( Path . Combine ( "AppInstallContent" , "Scripts" , script , scriptName ) ) ;
219
+ AddDependenciesToArchive ( zip , app , script , addedFiles ) ;
220
+ AddScriptReferencesToArchive ( zip , app , script , addedFiles ) ;
221
+ }
222
+ }
223
+
224
+ private static void AddScriptReferencesToArchive ( ZipArchive zip , App app , string script , List < string > addedFiles )
225
+ {
226
+ var scriptName = $ "Script_{ script } .xml";
227
+ var scriptPath = Path . Combine ( ScriptPath , scriptName ) ;
228
+ if ( ! File . Exists ( scriptPath ) )
229
+ {
230
+ return ;
257
231
}
258
232
259
- return scripts ;
233
+ var scriptFile = File . ReadAllText ( scriptPath ) ;
234
+ XDocument doc = XDocument . Parse ( scriptFile ) ;
235
+ XNamespace ns = "http://www.skyline.be/automation" ;
236
+ var refParams = doc . Descendants ( ns + "Param" ) . Where ( param => ( string ) param . Attribute ( "type" ) == "scriptRef" ) ;
237
+ foreach ( var reference in refParams . Select ( refParam => refParam . Value ) )
238
+ {
239
+ var split = reference . Split ( ':' ) ;
240
+ var referenceScriptName = split [ 0 ] ;
241
+ if ( addedFiles . Exists ( x => x == $ "AppInstallContent\\ Scripts\\ { referenceScriptName } \\ Script_{ referenceScriptName } .xml") )
242
+ {
243
+ continue ;
244
+ }
245
+
246
+ AddScriptToArchive ( zip , app , referenceScriptName , addedFiles ) ;
247
+ }
260
248
}
261
249
262
- private static Dictionary < string , List < string > > AddDependenciesToArchive ( ZipArchive zip , App app , IEnumerable < string > scripts )
250
+ private static void AddDependenciesToArchive ( ZipArchive zip , App app , string script , List < string > addedFiles )
263
251
{
264
- var scriptReferences = new Dictionary < string , List < string > > ( ) ;
265
- foreach ( var script in scripts )
252
+ var scriptName = $ "Script_{ script } .xml";
253
+ var scriptPath = Path . Combine ( ScriptPath , scriptName ) ;
254
+ if ( ! File . Exists ( scriptPath ) )
266
255
{
267
- if ( ! scriptReferences . ContainsKey ( script ) )
268
- scriptReferences . Add ( script , new List < string > ( ) ) ;
269
- var scriptName = $ "Script_{ script } .xml";
270
- var scriptPath = Path . Combine ( ScriptPath , scriptName ) ;
271
- if ( ! File . Exists ( scriptPath ) )
256
+ return ;
257
+ }
258
+
259
+ var scriptFile = File . ReadAllText ( scriptPath ) ;
260
+ XDocument doc = XDocument . Parse ( scriptFile ) ;
261
+ XNamespace ns = "http://www.skyline.be/automation" ;
262
+ var refParams = doc . Descendants ( ns + "Param" ) . Where ( param => ( string ) param . Attribute ( "type" ) == "ref" ) ;
263
+ foreach ( var reference in refParams . Select ( refParam => refParam . Value ) )
264
+ {
265
+ if ( addedFiles . Exists ( x => x == reference . Replace ( @"C:\Skyline DataMiner" , "AppInstallContent\\ Assemblies" ) ) )
272
266
{
273
267
continue ;
274
268
}
275
269
276
- var scriptFile = System . IO . File . ReadAllText ( scriptPath ) ;
277
- XDocument doc = XDocument . Parse ( scriptFile ) ;
278
- XNamespace ns = "http://www.skyline.be/automation" ;
279
- var refParams = doc . Descendants ( ns + "Param" ) . Where ( param => ( string ) param . Attribute ( "type" ) == "ref" ) ;
280
- foreach ( var reference in refParams . Select ( refParam => refParam . Value ) )
270
+ if ( reference . StartsWith ( DllImportPath ) )
281
271
{
282
- if ( reference . StartsWith ( DllImportPath ) )
283
- {
284
- scriptReferences [ script ] . Add ( reference ) ;
285
- zip . CreateEntryFromFile ( reference , reference . Replace ( @"C:\Skyline DataMiner" , "AppInstallContent\\ Assemblies" ) ) ;
286
- }
272
+ zip . CreateEntryFromFile ( reference , reference . Replace ( @"C:\Skyline DataMiner" , "AppInstallContent\\ Assemblies" ) ) ;
273
+ addedFiles . Add ( reference . Replace ( @"C:\Skyline DataMiner" , "AppInstallContent\\ Assemblies" ) ) ;
287
274
}
288
275
}
289
- return scriptReferences ;
290
276
}
291
277
292
278
private static void AddDomToArchive ( IEngine engine , ZipArchive zip , IEnumerable < string > domModuleIds , ExportOptions options )
0 commit comments