Skip to content

Commit 4da18c1

Browse files
committed
Add project files.
1 parent 96243da commit 4da18c1

14 files changed

+545
-0
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
trim_trailing_whitespace = true
7+
8+
[*.csproj]
9+
indent_size = 2
10+
11+
[*.cs]
12+
dotnet_sort_system_directives_first = true
13+
dotnet_style_predefined_type_for_locals_parameters_members = true
14+
dotnet_style_predefined_type_for_member_access = false

LICENSE

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
SKYLINE LIBRARY LICENSE
2+
3+
1. Applicability
4+
The software in this repository (hereafter the “Software”) is owned by Skyline Communications (hereafter “Skyline”). The terms of this license govern your use of the Software. If you do not agree with the terms of this license, you may not use or exploit the Software in any other manner.
5+
2. Grant of rights
6+
You may use the Software for the development, testing and validation of DataMiner packages and components only.
7+
You may not use this Software in any other manner without obtaining prior written authorization from Skyline.
8+
It is forbidden to create derivative works of the Software.
9+
3. Intellectual property
10+
Skyline owns the intellectual property rights vested in the Software. Your access to the Software, as granted by Skyline, does not imply permission to use or manipulate the Software in violation of this Library License. Skyline reserves the right to pursue legal action against any breach of its intellectual property rights.
11+
4. No warranty, Limitation of liability
12+
Skyline provides the Software ‘as is’, without any warranty of any kind. Within the maximum extent permitted by applicable laws, Skyline disclaims all liability for the Software.
13+
5. Usage Metrics
14+
Skyline reserves the right to collect non-personal metrics related to the usage of the Software. These metrics may include, but are not limited to, the frequency of use and the primary purposes for which the Software is employed (e.g., automation, protocol analysis, visualization, etc.). By using the Software, you agree to allow Skyline to collect and analyze such metrics for the purpose of improving and enhancing the Software.
15+
6. Applicable laws and jurisdiction
16+
This license shall be governed by the laws of Belgium. Any dispute shall be submitted to the exclusive jurisdiction of the competent courts of Gent, division Kortrijk, Belgium
17+

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Skyline.DataMiner.Sdk
2+
3+
## About
4+
5+
TBD
6+
7+
## Projects
8+
9+
* For more information about Skyline.DataMiner.Sdk, see [Sdk/README.md](Sdk/README.md).
10+
11+
### About DataMiner
12+
13+
DataMiner is a transformational platform that provides vendor-independent control and monitoring of devices and services. Out of the box and by design, it addresses key challenges such as security, complexity, multi-cloud, and much more. It has a pronounced open architecture and powerful capabilities enabling users to evolve easily and continuously.
14+
15+
The foundation of DataMiner is its powerful and versatile data acquisition and control layer. With DataMiner, there are no restrictions to what data users can access. Data sources may reside on premises, in the cloud, or in a hybrid setup.
16+
17+
A unique catalog of 7000+ connectors already exists. In addition, you can leverage DataMiner Development Packages to build your own connectors (also known as "protocols" or "drivers").
18+
19+
> **Note**
20+
> See also: [About DataMiner](https://aka.dataminer.services/about-dataminer).
21+
22+
### About Skyline Communications
23+
24+
At Skyline Communications, we deal with world-class solutions that are deployed by leading companies around the globe. Check out [our proven track record](https://aka.dataminer.services/about-skyline) and see how we make our customers' lives easier by empowering them to take their operations to the next level.
25+
26+
<!-- Uncomment below and add more info to provide more information about how to use this package. -->
27+
<!-- ## Getting Started -->

Sdk/LICENSE.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
SKYLINE LIBRARY LICENSE
2+
3+
1. Applicability
4+
The software in this repository (hereafter the “Software”) is owned by Skyline Communications (hereafter “Skyline”). The terms of this license govern your use of the Software. If you do not agree with the terms of this license, you may not use or exploit the Software in any other manner.
5+
2. Grant of rights
6+
You may use the Software for the development, testing and validation of DataMiner packages and components only.
7+
You may not use this Software in any other manner unless you have obtained Skyline’s prior written authorization to do so.
8+
It is forbidden to create derivative works of the Software.
9+
3. Intellectual property
10+
Skyline owns the intellectual property rights vested in the Software. Skyline granting you access to the Software does not entail permission to utilize or otherwise manipulate the Software in contravention to this Library License. Skyline reserves the right to pursue legal action against you in case of breach of its intellectual property rights.
11+
4. No warranty
12+
Skyline provides the Software ‘as is’, without any warranty of any kind.
13+
5. Limitation of liability
14+
Within the maximum possible extent under the applicable laws, Skyline disclaims all liability for the Software.
15+
6. Applicable laws and jurisdiction
16+
This license shall be governed by the laws of Belgium. Any dispute shall be submitted to the exclusive jurisdiction of the competent courts of Gent, division Kortrijk, Belgium
17+

Sdk/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Skyline.DataMiner.Sdk
2+
3+
## About
4+
5+
Testing, please ignore
6+
7+
### About DataMiner
8+
9+
DataMiner is a transformational platform that provides vendor-independent control and monitoring of devices and services. Out of the box and by design, it addresses key challenges such as security, complexity, multi-cloud, and much more. It has a pronounced open architecture and powerful capabilities enabling users to evolve easily and continuously.
10+
11+
The foundation of DataMiner is its powerful and versatile data acquisition and control layer. With DataMiner, there are no restrictions to what data users can access. Data sources may reside on premises, in the cloud, or in a hybrid setup.
12+
13+
A unique catalog of 7000+ connectors already exist. In addition, you can leverage DataMiner Development Packages to build you own connectors (also known as "protocols" or "drivers").
14+
15+
> **Note**
16+
> See also: [About DataMiner](https://aka.dataminer.services/about-dataminer).
17+
18+
### About Skyline Communications
19+
20+
At Skyline Communications, we deal in world-class solutions that are deployed by leading companies around the globe. Check out [our proven track record](https://aka.dataminer.services/about-skyline) and see how we make our customers' lives easier by empowering them to take their operations to the next level.
21+
22+
<!-- Uncomment below and add more info to provide more information about how to use this package. -->
23+
<!-- ## Getting Started -->

Sdk/Sdk.csproj

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.0</TargetFramework>
4+
<ImplicitUsings>disable</ImplicitUsings>
5+
<Nullable>disable</Nullable>
6+
<AssemblyName>Skyline.DataMiner.Sdk</AssemblyName>
7+
<RootNamespace>Skyline.DataMiner.Sdk</RootNamespace>
8+
<Version>0.0.1</Version>
9+
<PackageTags>Skyline;DataMiner</PackageTags>
10+
<PackageProjectUrl>https://skyline.be</PackageProjectUrl>
11+
<PackageReadmeFile>README.md</PackageReadmeFile>
12+
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
13+
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
14+
<PackageIcon>Icon.png</PackageIcon>
15+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
16+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
17+
<Authors>SkylineCommunications</Authors>
18+
<Company>Skyline Communications</Company>
19+
<Description>TBD</Description>
20+
<PackageType>MSBuildSdk</PackageType>
21+
<BuildOutputTargetFolder>Sdk</BuildOutputTargetFolder>
22+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
23+
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
24+
<NoWarn>1701;1702;NU5100</NoWarn>
25+
</PropertyGroup>
26+
27+
<ItemGroup>
28+
<None Include="README.md" Pack="true" PackagePath="" />
29+
<None Include="LICENSE.txt" Pack="true" PackagePath="" />
30+
<None Include="nuget\Icon.png" Pack="true" PackagePath="" />
31+
<None Include="Sdk\Sdk.props" Pack="true" PackagePath="Sdk" />
32+
<None Include="Sdk\Sdk.targets" Pack="true" PackagePath="Sdk" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<PackageReference Include="Microsoft.Build.Tasks.Core" VersionOverride="$(MicrosoftBuildMinimumPackageVersion)" PrivateAssets="all" ExcludeAssets="Runtime" IncludeAssets="compile; build; native; contentfiles; analyzers; buildtransitive" Version="14.3.0" />
37+
<PackageReference Include="Nito.AsyncEx.Tasks" Version="5.1.2" PrivateAssets="all" />
38+
<PackageReference Include="Skyline.DataMiner.CICD.Common" Version="1.0.5-alpha" PrivateAssets="all" />
39+
<PackageReference Include="Skyline.DataMiner.CICD.Parsers.Common" Version="1.0.13-foxtrot" PrivateAssets="all" />
40+
<PackageReference Include="Skyline.DataMiner.CICD.Assemblers.Automation" Version="1.0.15" PrivateAssets="all" />
41+
<PackageReference Include="Skyline.DataMiner.Core.AppPackageCreator" Version="1.0.4" PrivateAssets="all" />
42+
</ItemGroup>
43+
44+
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
45+
<ItemGroup>
46+
<!-- The TargetPath is the path inside the package that the source file will be placed. This is already precomputed in the ReferenceCopyLocalPaths items' DestinationSubPath, so reuse it here. -->
47+
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths)" TargetPath="%(ReferenceCopyLocalPaths.DestinationSubPath)" />
48+
</ItemGroup>
49+
</Target>
50+
51+
<!-- Temporarily for testing locally -->
52+
<Target Name="FixNuGet" AfterTargets="Pack" Condition=" '$(Configuration)' == 'Debug'">
53+
<RemoveDir Directories="C:\Users\MichielOD\.nuget\packages\skyline.dataminer.sdk" />
54+
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(BaseOutputPath)$(Configuration)\$(AssemblyName).$(PackageVersion).nupkg" DestinationFolder="C:\Users\MichielOD\Documents\MyNugets" />
55+
56+
<Message Text="### Did the thing! ###" Importance="High" />
57+
</Target>
58+
59+
</Project>

Sdk/Sdk/Sdk.props

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition=" '$(MicrosoftCommonPropsHasBeenImported)' != 'true' "/>
3+
</Project>

Sdk/Sdk/Sdk.targets

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project>
2+
<!-- Import normal SDK stuff so everything remains the same -->
3+
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition=" '$(CommonTargetsPath)' == '' " />
4+
5+
<!-- Declare which tasks will be used later -->
6+
<UsingTask TaskName="DmappCreation" AssemblyFile="$(MSBuildThisFileDirectory)\netstandard2.0\Skyline.DataMiner.Sdk.dll"/>
7+
8+
<!-- Custom target that will run after the build -->
9+
<Target Name="DmappCreation" AfterTargets="Build" Condition="'$(GenerateDataMinerPackage)' == 'true'">
10+
<DmappCreation
11+
ProjectFile="$(MSBuildProjectFile)"
12+
ProjectType="$(DataMinerType)"
13+
BaseOutputPath="$(BaseOutputPath)"
14+
Version="$(Version)"
15+
MinimumSupportedDmVersion="$(MinimumSupportedDmVersion)"
16+
/>
17+
</Target>
18+
</Project>

Sdk/SubTasks/AutomationScriptStyle.cs

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
namespace Skyline.DataMiner.Sdk.SubTasks
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
using Skyline.AppInstaller;
10+
using Skyline.DataMiner.CICD.Assemblers.Automation;
11+
using Skyline.DataMiner.CICD.Assemblers.Common;
12+
using Skyline.DataMiner.CICD.FileSystem;
13+
using Skyline.DataMiner.CICD.Parsers.Automation.Xml;
14+
using Skyline.DataMiner.CICD.Parsers.Common.VisualStudio.Projects;
15+
16+
using static Skyline.DataMiner.Sdk.DmappCreation;
17+
18+
internal static class AutomationScriptStyle
19+
{
20+
public static async Task<PackageResult> TryCreatePackage(PackageCreationData data, bool createAsTempFile = false)
21+
{
22+
var result = new PackageResult();
23+
24+
try
25+
{
26+
var script = Script.Load(FileSystem.Instance.Path.Combine(data.Project.ProjectDirectory, $"{data.Project.ProjectName}.xml"));
27+
var scriptProjects = new Dictionary<string, Project>
28+
{
29+
// Will always be one
30+
[data.Project.ProjectName] = data.Project,
31+
};
32+
33+
List<Script> allScripts = new List<Script>();
34+
foreach (Project linkedProject in data.LinkedProjects)
35+
{
36+
if (!linkedProject.DataMinerProjectType.IsAutomationScriptStyle())
37+
{
38+
continue;
39+
}
40+
41+
if (!ProjectToItemConverter.TryConvertToScript(linkedProject, out Script linkedScript))
42+
{
43+
continue;
44+
}
45+
46+
allScripts.Add(linkedScript);
47+
}
48+
49+
AutomationScriptBuilder automationScriptBuilder = new AutomationScriptBuilder(script, scriptProjects, allScripts, data.Project.ProjectDirectory);
50+
BuildResultItems buildResultItems = await automationScriptBuilder.BuildAsync();
51+
52+
AppPackageAutomationScript.AppPackageAutomationScriptBuilder appPackageAutomationScriptBuilder;
53+
if (createAsTempFile)
54+
{
55+
// Create temp file
56+
string tempFileName = FileSystem.Instance.Path.GetTempFileName() + ".xml";
57+
FileSystem.Instance.File.WriteAllText(tempFileName, buildResultItems.Document);
58+
59+
appPackageAutomationScriptBuilder = new AppPackageAutomationScript.AppPackageAutomationScriptBuilder(script.Name, data.Version, tempFileName);
60+
}
61+
else
62+
{
63+
appPackageAutomationScriptBuilder = new AppPackageAutomationScript.AppPackageAutomationScriptBuilder(script.Name, data.Version, ConvertToBytes(buildResultItems.Document));
64+
}
65+
66+
foreach (PackageAssemblyReference packageAssemblyReference in buildResultItems.Assemblies)
67+
{
68+
appPackageAutomationScriptBuilder.WithAssembly(packageAssemblyReference.AssemblyPath, packageAssemblyReference.AssemblyPath);
69+
}
70+
71+
result.Script = appPackageAutomationScriptBuilder.Build();
72+
result.IsSuccess = true;
73+
}
74+
catch (Exception e)
75+
{
76+
result.ErrorMessage = $"Unexpected exception during package creation for '{data.Project.ProjectName}': {e}";
77+
result.IsSuccess = false;
78+
}
79+
80+
return result;
81+
}
82+
83+
public class PackageResult
84+
{
85+
public IAppPackageAutomationScript Script { get; set; }
86+
87+
public string ErrorMessage { get; set; }
88+
89+
public bool IsSuccess { get; set; }
90+
}
91+
92+
private static byte[] ConvertToBytes(string @string)
93+
{
94+
// Convert to byte[].
95+
var memoryStream = new MemoryStream();
96+
using (var streamWriter = new StreamWriter(memoryStream, new UTF8Encoding(true)))
97+
{
98+
streamWriter.Write(@string);
99+
}
100+
101+
byte[] content = memoryStream.ToArray();
102+
return content;
103+
}
104+
}
105+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Skyline.DataMiner.Sdk.SubTasks
2+
{
3+
using Skyline.DataMiner.CICD.Parsers.Common.VisualStudio.Projects;
4+
5+
public static class DataMinerProjectTypeHelper
6+
{
7+
public static bool IsAutomationScriptStyle(this DataMinerProjectType? type)
8+
{
9+
if (type == null)
10+
{
11+
return false;
12+
}
13+
14+
return type == DataMinerProjectType.AutomationScript ||
15+
type == DataMinerProjectType.AutomationScriptLibrary ||
16+
type == DataMinerProjectType.UserDefinedApi ||
17+
type == DataMinerProjectType.AdHocDataSource || // Not exactly a script, but uses the same parsing/assembling for now
18+
type == DataMinerProjectType.Package;
19+
}
20+
}
21+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace Skyline.DataMiner.Sdk.SubTasks
2+
{
3+
using Skyline.DataMiner.CICD.FileSystem;
4+
using Skyline.DataMiner.CICD.Parsers.Automation.Xml;
5+
using Skyline.DataMiner.CICD.Parsers.Common.VisualStudio.Projects;
6+
7+
public static class ProjectToItemConverter
8+
{
9+
public static bool TryConvertToScript(Project project, out Script script)
10+
{
11+
script = null;
12+
13+
string directoryName = FileSystem.Instance.Path.GetDirectoryName(project.Path);
14+
string projectName = FileSystem.Instance.Path.GetFileNameWithoutExtension(project.Path);
15+
16+
string xmlFilePath = FileSystem.Instance.Path.Combine(directoryName, $"{projectName}.xml");
17+
18+
if (!FileSystem.Instance.File.Exists(xmlFilePath))
19+
{
20+
return false;
21+
}
22+
23+
script = Script.Load(xmlFilePath);
24+
return true;
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)