Skip to content

Commit 806b220

Browse files
committed
Added the images to the export package
1 parent 68e8706 commit 806b220

File tree

4 files changed

+405
-274
lines changed

4 files changed

+405
-274
lines changed

CompanionFiles/Skyline DataMiner/Documents/Low Code App Editor/Install.xml

+80-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ dd/mm/2021 1.0.0.1 XXX, Skyline Initial version
6464
6565
using System;
6666
using Install_1.DOM;
67+
using Install_1.Images;
6768
using Install_1.LCA;
6869
using Skyline.AppInstaller;
6970
using Skyline.DataMiner.Automation;
@@ -99,6 +100,9 @@ internal class Script
99100
100101
LcaInstaller lcaInstaller = new LcaInstaller(context, installer.Log);
101102
lcaInstaller.InstallDefaultContent();
103+
104+
ImageInstaller imageInstaller = new ImageInstaller(context, installer.Log);
105+
imageInstaller.InstallDefaultContent();
102106
}
103107
catch (Exception e)
104108
{
@@ -152,10 +156,14 @@ namespace Install_1.LCA
152156
Log("Low Code App Installation");
153157
154158
var apps = Directory.GetDirectories(context.AppContentPath + LCA_FOLDERPATH);
159+
Log($"Installing {apps.Length} app(s)");
160+
155161
var existingApps = Directory.GetDirectories(ApplicationsDirectory).Select(dir => Path.GetFileName(dir));
156162
var existingAppsNames = GetAppNames(existingApps);
157-
foreach (var app in apps)
163+
for (int i = 0; i < apps.Length; i++)
158164
{
165+
var app = apps[i];
166+
159167
// Check if the name of the app already exists
160168
var appName = GetAppName(app);
161169
int counter = 0;
@@ -186,6 +194,8 @@ namespace Install_1.LCA
186194
{
187195
CopyFolder(app, Path.Combine(ApplicationsDirectory, Path.GetFileName(app)));
188196
}
197+
198+
Log($"[{i + 1}/{apps.Length}] Installed '{newName}'");
189199
}
190200
}
191201
@@ -340,6 +350,7 @@ namespace Install_1.DOM
340350
public void InstallDefaultContent()
341351
{
342352
Log("Installing DOM items");
353+
343354
foreach (var exportedDomJson in Directory.GetFiles(context.AppContentPath + DOM_FOLDERPATH, "*.json"))
344355
{
345356
Log("Installing " + exportedDomJson);
@@ -592,6 +603,74 @@ namespace Install_1.DOM
592603
{
593604
}
594605
}
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+
}
595674
}]]>
596675
</Value>
597676
<!--<Param type="debug">true</Param>-->

0 commit comments

Comments
 (0)