@@ -64,6 +64,7 @@ dd/mm/2021 1.0.0.1 XXX, Skyline Initial version
64
64
65
65
using System;
66
66
using Install_1.DOM;
67
+ using Install_1.Images;
67
68
using Install_1.LCA;
68
69
using Skyline.AppInstaller;
69
70
using Skyline.DataMiner.Automation;
@@ -99,6 +100,9 @@ internal class Script
99
100
100
101
LcaInstaller lcaInstaller = new LcaInstaller(context, installer.Log);
101
102
lcaInstaller.InstallDefaultContent();
103
+
104
+ ImageInstaller imageInstaller = new ImageInstaller(context, installer.Log);
105
+ imageInstaller.InstallDefaultContent();
102
106
}
103
107
catch (Exception e)
104
108
{
@@ -152,10 +156,14 @@ namespace Install_1.LCA
152
156
Log("Low Code App Installation");
153
157
154
158
var apps = Directory.GetDirectories(context.AppContentPath + LCA_FOLDERPATH);
159
+ Log($"Installing {apps.Length} app(s)");
160
+
155
161
var existingApps = Directory.GetDirectories(ApplicationsDirectory).Select(dir => Path.GetFileName(dir));
156
162
var existingAppsNames = GetAppNames(existingApps);
157
- foreach (var app in apps)
163
+ for (int i = 0; i < apps.Length; i++ )
158
164
{
165
+ var app = apps[i];
166
+
159
167
// Check if the name of the app already exists
160
168
var appName = GetAppName(app);
161
169
int counter = 0;
@@ -186,6 +194,8 @@ namespace Install_1.LCA
186
194
{
187
195
CopyFolder(app, Path.Combine(ApplicationsDirectory, Path.GetFileName(app)));
188
196
}
197
+
198
+ Log($"[{i + 1}/{apps.Length}] Installed '{newName}'");
189
199
}
190
200
}
191
201
@@ -340,6 +350,7 @@ namespace Install_1.DOM
340
350
public void InstallDefaultContent()
341
351
{
342
352
Log("Installing DOM items");
353
+
343
354
foreach (var exportedDomJson in Directory.GetFiles(context.AppContentPath + DOM_FOLDERPATH, "*.json"))
344
355
{
345
356
Log("Installing " + exportedDomJson);
@@ -592,6 +603,74 @@ namespace Install_1.DOM
592
603
{
593
604
}
594
605
}
606
+ }
607
+
608
+ //---------------------------------
609
+ // Images\ImageInstaller.cs
610
+ //---------------------------------
611
+ namespace Install_1.Images
612
+ {
613
+ using System;
614
+ using System.Collections.Generic;
615
+ using System.IO;
616
+ using System.Linq;
617
+
618
+ using Newtonsoft.Json.Linq;
619
+
620
+ using Skyline.DataMiner.Net.AppPackages;
621
+
622
+ public class ImageInstaller
623
+ {
624
+ private const string Images_FOLDERPATH = @"CompanionFiles\Images";
625
+ private const string Images_Directory = @"C:\Skyline DataMiner\Dashboards\_IMAGES";
626
+
627
+ private readonly AppInstallContext context;
628
+ private readonly Action<string> logMethod;
629
+
630
+ public ImageInstaller(AppInstallContext context, Action<string> logMethod)
631
+ {
632
+ // Null checks still required / valid input data check
633
+ this.context = context;
634
+ this.logMethod = logMethod;
635
+ }
636
+
637
+ // Summary:
638
+ // Installs all provided images
639
+ // in the AppContent of the package on the DMS.
640
+ public void InstallDefaultContent()
641
+ {
642
+ Log("Low Code App Images Installation");
643
+
644
+ // Check if images folder exists
645
+ if (!Directory.Exists(Images_Directory))
646
+ {
647
+ Log("C:\\Skyline DataMiner\\Dashboards\\_IMAGES directory does not exists, creating it.");
648
+ Directory.CreateDirectory(Images_Directory);
649
+ }
650
+
651
+ var images = Directory.GetFiles(context.AppContentPath + Images_FOLDERPATH);
652
+ Log($"Installing {images.Length} image(s).");
653
+ for(int i = 0; i < images.Length; i++)
654
+ {
655
+ var image = images[i];
656
+ File.Copy(image, Path.Combine(Images_Directory, Path.GetFileName(image)));
657
+ Log($"[{i + 1}/{images.Length}] Installed {Path.GetFileName(image)}");
658
+ }
659
+ }
660
+
661
+ // Summary:
662
+ // Logs the provided message into the logfile "C:\Skyline DataMiner\Logging\SLAppPackageInstaller.txt".
663
+ // The message will also be shown during installation with the DataMiner Application
664
+ // Package Installer from the Skyline TaskBar Utility.
665
+ //
666
+ // Parameters:
667
+ // message:
668
+ // A message you want to log or show during installation.
669
+ public void Log(string message)
670
+ {
671
+ logMethod(message);
672
+ }
673
+ }
595
674
}]]>
596
675
</Value >
597
676
<!-- <Param type="debug">true</Param>-->
0 commit comments