Skip to content

Commit

Permalink
Merge pull request #2 from NecatiMeral/nm/comfort-online
Browse files Browse the repository at this point in the history
Nm/comfort online
  • Loading branch information
NecatiMeral authored Feb 28, 2023
2 parents 8c8c38f + f0b0f6c commit abb2eb9
Show file tree
Hide file tree
Showing 45 changed files with 2,669 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# License header
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
# file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.

# C++ Files
[*.{cpp,h,in}]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,4 @@ MigrationBackup/

build/dev/
!build/dev/.gitkeep
dist/
19 changes: 19 additions & 0 deletions build/Get-Cert-Content.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[CmdletBinding()]
param (
[Parameter(Mandatory = $True)]
[string]
$Cert,
[Parameter(Mandatory = $True)]
[string]
$Pass
)

$flag = [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable
$collection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
$collection.Import($Cert, $Pass, $flag)
$pkcs12ContentType = [System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12
$clearBytes = $collection.Export($pkcs12ContentType)
$fileContentEncoded = [System.Convert]::ToBase64String($clearBytes)
$secret = ConvertTo-SecureString -String $fileContentEncoded -AsPlainText –Force

Write-Host $fileContentEncoded
26 changes: 26 additions & 0 deletions build/pack-node.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[CmdletBinding()]
param (
[Parameter(Mandatory = $True)]
[string]
$Project
)

Write-Host "Packing logic-node project at ``${Project}``" -ForegroundColor Blue
$RepositoryRoot = Resolve-Path (Join-Path $PSScriptRoot '../')
$SdkDir = Join-path $PSScriptRoot 'tools/gira'
$DistDir = Resolve-Path (Join-Path $PSScriptRoot '../dist')

Write-Host "Repository: ``${RepositoryRoot}``"
Write-Host "SDK-Tools: ``${SdkDir}``"
Write-Host "Output: ``${DistDir}``"

$NodeToolPath = Join-Path -Path $SdkDir -ChildPath 'LogicNodeTool.exe'

$CreateNodeArgs = @(
'create'
"${Project}"
"${DistDir}"
)

Write-Host "${NodeToolPath} ${CreateNodeArgs}" -ForegroundColor Magenta
. $NodeToolPath $CreateNodeArgs
42 changes: 42 additions & 0 deletions build/sign-node.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[CmdletBinding()]
param (
[Parameter(Mandatory = $True)]
[string]
$ZipFile,
[Parameter(Mandatory = $True)]
[string]
$Cert,
[Parameter(Mandatory = $True)]
[string]
$Pass
)

$Location = Get-Location
Write-Host "Signing logic-node project at ``${ZipFile}``" -ForegroundColor Blue
$RepositoryRoot = Resolve-Path (Join-Path $PSScriptRoot '../')
$ZipFile = Resolve-Path $ZipFile
$Cert = Resolve-Path $Cert
$SdkDir = Join-path $PSScriptRoot 'tools/gira'
$DistDir = Resolve-Path (Join-Path $PSScriptRoot '../dist')

Write-Host "Repository: ``${RepositoryRoot}``"
Write-Host "SDK-Tools: ``${SdkDir}``"
Write-Host "Output: ``${DistDir}``"

$SignToolPath = Join-Path -Path $SdkDir -ChildPath 'SignLogicNodes.exe'

Set-Location $SdkDir

try {
$SignNodeArgs = @(
"${Cert}"
"${Pass}"
"${ZipFile}"
)

Write-Host "${SignToolPath} ${SignNodeArgs}" -ForegroundColor Magenta
. $SignToolPath $SignNodeArgs
}
finally {
Set-Location $Location
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added dist/.gitkeep
Empty file.
Binary file not shown.
56 changes: 52 additions & 4 deletions dotnet/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,64 @@
</PropertyGroup>

<PropertyGroup>
<RootNamespace>Necati_Meral_Yahoo_De</RootNamespace>
<GiraDeveloperId>necati_meral_yahoo_de</GiraDeveloperId>
</PropertyGroup>

<PropertyGroup Label="Project classification">
<IsTestProject Condition="$(MSBuildProjectFullPath.Contains('test')) and ($(MSBuildProjectName.EndsWith('.Tests')) or $(MSBuildProjectName.EndsWith('.TestBase')))">true</IsTestProject>

<IsNodeProject Condition="$(MSBuildProjectFullPath.Contains('.Logic.')) and (!$(MSBuildProjectName.Contains('.Tests')))">true</IsNodeProject>

<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Debug' and $(IsNodeProject) == 'true'">
<Exec Command="pwsh -NoProfile -ExecutionPolicy RemoteSigned -File &quot;$(MSBuildThisFileDirectory)..\build\pack-node.ps1&quot; -Project $(MSBuildProjectDirectory)\$(OutputPath) " />
</Target>

<!-- TODO: Create a more developer and VS friendly approach-->
<!--<PropertyGroup Condition="'$(IsNodeProject)' == 'true'">
<PostBuildEvent>
echo INFO: Creating ZIP archive
echo INFO: INPUT: "$(MSBuildProjectDirectory)\$(OutputPath)bin\Debug\net48"
echo INFO: OUTPUT "$(RepositoryRoot)dist"
echo TEST: "$(TargetDir)"
;"$(MSBuildThisFileDirectory)..\build\tools\gira\LogicNodeTool.exe" create $(MSBuildProjectDirectory)\$(OutputPath) $(RepositoryRoot)dist
;echo INFO: Logic Nodes are not signed yet and can only be used in the simulation in GPA.
;REM "$(SolutionDir)src\LogicNodesSDK\SignLogicNodes.exe" $(SolutionDir)..\..\build\dev\gira-developer-cert.p7b [certificate_password] $(SolutionDir)Zip
</PostBuildEvent>
</PropertyGroup>-->

<ItemGroup Label="Implicit usings">
<Using Include="LogicModule.Nodes.Helpers" />
<Using Include="LogicModule.ObjectModel" />
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<ItemGroup Label="Workaround for missing dependency on implicit usings">
<Using Remove="System.Net.Http" />
</ItemGroup>

<ItemGroup Label="Add Xunit for tests" Condition="'$(IsTestProject)' == 'true'">
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<ItemGroup Label="SDK dependencies">
<Reference Include="LogicModule.Nodes.Helpers">
<HintPath>$(SolutionDir)src\LogicNodesSDK\LogicModule.Nodes.Helpers.dll</HintPath>
</Reference>
<Reference Include="LogicModule.ObjectModel">
<HintPath>$(SolutionDir)src\LogicNodesSDK\LogicModule.ObjectModel.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup Label="Test dependencies" Condition="'$(IsTestProject)' == 'true'">
<Reference Include="LogicModule.Nodes.TestHelper">
<HintPath>$(SolutionDir)src\LogicNodesSDK\LogicModule.Nodes.TestHelper.dll</HintPath>
</Reference>

<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand All @@ -31,9 +76,10 @@
<PackageReference Include="xunit" Version="$(xUnitPackageVersion)" />
<PackageReference Include="xunit.extensibility.execution" Version="$(xUnitExtensibilityExecutionPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
</ItemGroup>

<PropertyGroup>
<PropertyGroup Label="Package versions">

<!-- Microsoft .NET-Framework reference assemblies -->
<MicrosoftNetFramework45PackageVersion>1.0.3</MicrosoftNetFramework45PackageVersion>
Expand All @@ -53,6 +99,8 @@
<!-- xunit.runner.visualstudio https://www.nuget.org/packages/xunit.runner.visualstudio -->
<xUnitRunnerVisualstudioPackageVersion>2.4.1</xUnitRunnerVisualstudioPackageVersion>

<MoqPackageVersion>4.18.4</MoqPackageVersion>

</PropertyGroup>

<ProjectExtensions>
Expand Down
15 changes: 14 additions & 1 deletion dotnet/NecatiMeral.LogicNodes.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B4F57F38-7B5
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1EE7FB73-9DEA-4D45-9CD0-2F4BFE480FF6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NecatiMeral.LogicNodes.Tests", "test\NecatiMeral.LogicNodes.Tests\NecatiMeral.LogicNodes.Tests.csproj", "{8A4DFEEE-CC9F-467E-8903-ED93D272D884}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NecatiMeral.LogicNodes.Tests", "test\NecatiMeral.LogicNodes.Tests\NecatiMeral.LogicNodes.Tests.csproj", "{8A4DFEEE-CC9F-467E-8903-ED93D272D884}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projektmappenelemente", "Projektmappenelemente", "{40954188-75ED-47A1-9E72-5B1B3F7EA544}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
logic-node.props = logic-node.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NecatiMeral.Logic.ComfortOnline", "src\NecatiMeral.Logic.ComfortOnline\NecatiMeral.Logic.ComfortOnline.csproj", "{90731595-1712-4F0C-82C9-56408D26064E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -25,13 +33,18 @@ Global
{8A4DFEEE-CC9F-467E-8903-ED93D272D884}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A4DFEEE-CC9F-467E-8903-ED93D272D884}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A4DFEEE-CC9F-467E-8903-ED93D272D884}.Release|Any CPU.Build.0 = Release|Any CPU
{90731595-1712-4F0C-82C9-56408D26064E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90731595-1712-4F0C-82C9-56408D26064E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90731595-1712-4F0C-82C9-56408D26064E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90731595-1712-4F0C-82C9-56408D26064E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3F1FF768-FD27-46A2-961C-B6EFDF9CB3B3} = {B4F57F38-7B57-4225-9BD4-264ABC47DE33}
{8A4DFEEE-CC9F-467E-8903-ED93D272D884} = {1EE7FB73-9DEA-4D45-9CD0-2F4BFE480FF6}
{90731595-1712-4F0C-82C9-56408D26064E} = {B4F57F38-7B57-4225-9BD4-264ABC47DE33}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {471310B7-D205-4EEC-A063-0A534164AB9A}
Expand Down
14 changes: 14 additions & 0 deletions dotnet/logic-node.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>

<!--<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net45" Version="$(MicrosoftNetFramework45PackageVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>-->

<ItemGroup>
<Using Remove="System.Net.Http"/>
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions dotnet/src/NecatiMeral.Logic.ComfortOnline/ComfortOnlineConsts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Necati_Meral_Yahoo_De.Logic.ComfortOnline;
public static class ComfortOnlineConsts
{
public const string ComfortOnlineBaseAddress = "https://www.comfort-online.com/";

public static class ErrorCodes
{
public const string Ok = "Ok";
public const string InitialRequestFailed = "InitialRequestFailed";
public const string MissingRequestVerificationToken = "MissingRequestVerificationToken";
public const string InvalidCredentials = "InvalidCredentials";
public const string LoginFailed = "LoginFailed";
public const string UnexpectedError = "UnexpectedError: ";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Text.RegularExpressions;

namespace Necati_Meral_Yahoo_De.Logic.ComfortOnline;
public class ComfortOnlinePageParser
{
readonly Regex _spanRegex = new Regex("<span.*?(?:id=\\\"val_([\\d_]*)\\\")>(.*)<\\/span>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
readonly Regex _inputRegex = new Regex("<input.*?(?:id=\\\"slider_([\\d_]*)\\\".*?value=\\\"([^\\\"]+)|value=\\\"([^\\\"]+).*?id=\\\"slider_([\\d_]*)\\\")[^>]*>", RegexOptions.Compiled | RegexOptions.IgnoreCase);

public ComfortOnlinePlantSectionInfo Parse(string body)
{
var info = new ComfortOnlinePlantSectionInfo();

var spanMatches = _spanRegex.Matches(body);
foreach (Match match in spanMatches)
{
if(match.Groups.Count == 3)
{
info[match.Groups[1].Value] = match.Groups[2].Value;
}
}

var inputMatches = _inputRegex.Matches(body);
foreach (Match match in inputMatches)
{
if (match.Groups.Count == 5)
{
if (string.IsNullOrEmpty(match.Groups[1].Value))
{
info[match.Groups[3].Value] = match.Groups[4].Value;
}
else
{
info[match.Groups[1].Value] = match.Groups[2].Value;
}
}
}

return info;
}

public class ComfortOnlinePlantSectionInfo
{
Dictionary<string, string> _dict;

public IReadOnlyDictionary<string, string> Values => _dict;

public string this[string key]
{
get => _dict[key];
set => _dict[key] = value;
}

public ComfortOnlinePlantSectionInfo()
{
_dict = new Dictionary<string, string>();
}
}
}
Loading

0 comments on commit abb2eb9

Please sign in to comment.