Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
BlazorExplorer net6
Browse files Browse the repository at this point in the history
Simplified version for further work
  • Loading branch information
aorzelskiGH committed Sep 21, 2023
1 parent 798845e commit cf3f670
Show file tree
Hide file tree
Showing 28 changed files with 232 additions and 188 deletions.
2 changes: 1 addition & 1 deletion src/AasxIntegrationBaseGdi/AasxIntegrationBaseGdi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<!-- force NuGet / Build to put required.dll and more to bin folder -->
<!-- Drawback: puts all other *.dll as well :-( -->
Expand Down
12 changes: 6 additions & 6 deletions src/AasxIntegrationBaseWpf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
//// [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
//(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
// oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
//(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
// designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
//(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
// oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
//(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
// designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
)]


Expand Down
5 changes: 3 additions & 2 deletions src/AasxOpenidClient/AasxOpenidClient.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!--
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<UseWPF>true</UseWPF> -->
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<ItemGroup>
Expand Down
31 changes: 24 additions & 7 deletions src/AasxOpenidClient/OpenIDCLient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
// using System.Windows.Forms;

/*
Copyright (c) 2020 see https://github.com/IdentityServer/IdentityServer4
Expand All @@ -38,6 +38,7 @@ static public bool AcceptAllCertifications(

public class UiLambdaSet
{
/*
public delegate DialogResult ShowMessageDelegate(
string content, string text, string caption, MessageBoxButtons buttons = 0);
public ShowMessageDelegate MesssageBox;
Expand All @@ -50,6 +51,7 @@ public static DialogResult MesssageBoxShow(
return lambdaSet.MesssageBox(content, text, caption, buttons);
return System.Windows.Forms.MessageBox.Show(content + text, caption, buttons);
}
*/
}

public static string authServer = "https://localhost:50001";
Expand Down Expand Up @@ -112,6 +114,7 @@ public static async Task Run(string tag, string value, UiLambdaSet uiLambda = nu
"\nConinue?";

// Displays the MessageBox.
/*
var result = UiLambdaSet.MesssageBoxShow(
uiLambda, message, "", caption, MessageBoxButtons.YesNo);
if (result != System.Windows.Forms.DialogResult.Yes)
Expand All @@ -122,6 +125,7 @@ public static async Task Run(string tag, string value, UiLambdaSet uiLambda = nu
UiLambdaSet.MesssageBoxShow(uiLambda, "", "Access Aasx Server at " + dataServer,
"Data Server", MessageBoxButtons.OK);
*/

var handler = new HttpClientHandler();
handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
Expand All @@ -147,8 +151,10 @@ public static async Task Run(string tag, string value, UiLambdaSet uiLambda = nu

while (operation != "")
{
/*
UiLambdaSet.MesssageBoxShow(uiLambda, "", "operation: " + operation + value + "\ntoken: " + token,
"Operation", MessageBoxButtons.OK);
*/

switch (operation)
{
Expand All @@ -174,8 +180,10 @@ public static async Task Run(string tag, string value, UiLambdaSet uiLambda = nu
StringSplitOptions.RemoveEmptyEntries);
Console.WriteLine("Redirect to:" + splitResult[0]);
authServer = splitResult[0];
/*
UiLambdaSet.MesssageBoxShow(
uiLambda, authServer, "", "Redirect to", MessageBoxButtons.OK);
*/
lastOperation = operation;
operation = "authenticate";
continue;
Expand All @@ -190,9 +198,11 @@ public static async Task Run(string tag, string value, UiLambdaSet uiLambda = nu
switch (operation)
{
case "/server/listaas/":
/*
UiLambdaSet.MesssageBoxShow(uiLambda,
"", "SelectFromListFlyoutItem missing", "SelectFromListFlyoutItem missing",
MessageBoxButtons.OK);
*/
value = "0";
operation = "/server/getaasx2/";
break;
Expand Down Expand Up @@ -247,9 +257,10 @@ public static async Task Run(string tag, string value, UiLambdaSet uiLambda = nu
client.SetBearerToken(token);

response.Show();
/*
UiLambdaSet.MesssageBoxShow(uiLambda, response.AccessToken, "",
"Access Token", MessageBoxButtons.OK);

*/
operation = lastOperation;
lastOperation = "";
}
Expand All @@ -261,8 +272,10 @@ public static async Task Run(string tag, string value, UiLambdaSet uiLambda = nu
}
break;
case "error":
/*
UiLambdaSet.MesssageBoxShow(uiLambda, "", $"Can not perform: {lastOperation}",
"Error", MessageBoxButtons.OK);
*/
operation = "";
break;
}
Expand All @@ -280,7 +293,7 @@ public static async Task<TokenResponse> RequestTokenAsync(
var disco = await client.GetDiscoveryDocumentAsync(authServer);
if (disco.IsError) throw new Exception(disco.Error);

UiLambdaSet.MesssageBoxShow(uiLambda, disco.Raw, "", "Discovery JSON", MessageBoxButtons.OK);
// UiLambdaSet.MesssageBoxShow(uiLambda, disco.Raw, "", "Discovery JSON", MessageBoxButtons.OK);

List<string> rootCertSubject = new List<string>();
dynamic discoObject = null;
Expand All @@ -301,7 +314,7 @@ public static async Task<TokenResponse> RequestTokenAsync(
Console.ResetColor();
Console.WriteLine(clientToken + "\n");

UiLambdaSet.MesssageBoxShow(uiLambda, clientToken, "", "Client Token", MessageBoxButtons.OK);
// UiLambdaSet.MesssageBoxShow(uiLambda, clientToken, "", "Client Token", MessageBoxButtons.OK);

var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
{
Expand Down Expand Up @@ -376,12 +389,13 @@ private static string CreateClientToken(SigningCredentials credential, string cl

if (credential == null)
{
/*
var res = UiLambdaSet.MesssageBoxShow(uiLambda, "",
"Select certificate chain from certificate store? \n" +
"(otherwise use file Andreas_Orzelski_Chain.pfx)",
"Select certificate chain", MessageBoxButtons.YesNo);

if (res == DialogResult.No)
*/
if (false /*res == DialogResult.No*/)
{
certFileName = "Andreas_Orzelski_Chain.pfx";
password = "i40";
Expand Down Expand Up @@ -416,10 +430,13 @@ private static string CreateClientToken(SigningCredentials credential, string cl
if (rootCertFound)
fcollection = fcollection2;

/*
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.SingleSelection);
*/
X509Certificate2Collection scollection = new X509Certificate2Collection(fcollection);
if (scollection.Count != 0)
{
certificate = scollection[0];
Expand Down Expand Up @@ -477,7 +494,7 @@ private static string CreateClientToken(SigningCredentials credential, string cl
Convert.ToBase64String(certificate.RawData, Base64FormattingOptions.InsertLineBreaks));
builder.AppendLine("-----END CERTIFICATE-----");

UiLambdaSet.MesssageBoxShow(uiLambda, builder.ToString(), "", "Client Certificate", MessageBoxButtons.OK);
// UiLambdaSet.MesssageBoxShow(uiLambda, builder.ToString(), "", "Client Certificate", MessageBoxButtons.OK);

credential = new X509SigningCredentials(certificate);
// oz end
Expand Down
3 changes: 3 additions & 0 deletions src/AasxOpenidClient/OpenIDClientInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,13 @@ private string CreateClientToken(SigningCredentials credential, string clientId,
if (rootCertFound)
fcollection = fcollection2;

/*
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.SingleSelection);
*/
X509Certificate2Collection scollection = new X509Certificate2Collection(fcollection);
if (scollection.Count != 0)
{
certificate = scollection[0];
Expand Down
12 changes: 6 additions & 6 deletions src/AasxPackageExplorer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
//(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
// oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
//(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
// designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
//(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
// oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
//(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
// designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
)]


Expand Down
8 changes: 3 additions & 5 deletions src/AasxPackageLogic/AasxPackageLogic.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<!-- <UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF> -->
</PropertyGroup>
<PropertyGroup>
<!-- Used to access the XML summary for Options.cs -->
Expand Down Expand Up @@ -43,12 +43,10 @@
<ProjectReference Include="..\AasxAmlImExport\AasxAmlImExport.csproj" />
<ProjectReference Include="..\AasxBammRdfImExport\AasxBammRdfImExport.csproj" />
<ProjectReference Include="..\AasxFileServerRestLibrary\AasxFileServerRestLibrary.csproj" />
<ProjectReference Include="..\AasxIntegrationBaseWpf\AasxIntegrationBaseWpf.csproj" />
<ProjectReference Include="..\AasxIntegrationBase\AasxIntegrationBase.csproj" />
<ProjectReference Include="..\AasxOpenidClient\AasxOpenidClient.csproj" />
<ProjectReference Include="..\AasxPredefinedConcepts\AasxPredefinedConcepts.csproj" />
<ProjectReference Include="..\AasxSchemaExport\AasxSchemaExport.csproj" />
<ProjectReference Include="..\AasxSignature\AasxSignature.csproj" />
<ProjectReference Include="..\AnyUi\AnyUi.csproj" />
<ProjectReference Include="..\jsoncanonicalizer\jsoncanonicalizer.csproj" />
<ProjectReference Include="..\SSIExtension\SSIExtension.csproj" />
Expand Down
8 changes: 8 additions & 0 deletions src/AasxPackageLogic/AasxScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public override async Task<object> Invoke(IScriptContext context, object[] args)
// invoke action
// https://stackoverflow.com/questions/39438441/
Task<int> x = null;
/*
if (Application.Current != null)
{
// WPF case
Expand All @@ -228,6 +229,7 @@ public override async Task<object> Invoke(IScriptContext context, object[] args)
Log.Singleton.Silent("" + x);
}
else
*/
{
// Blazor case
await _script?.Remote?.Tool(args);
Expand Down Expand Up @@ -269,14 +271,17 @@ public override object Invoke(IScriptContext context, object[] args)
Console.WriteLine($"Execute Select " + string.Join(",", args));

// which application
/*
if (Application.Current == null)
{
Log.Singleton.Error("For script execution, Application.Current for Blazor is not available.");
}
*/

// invoke action
// https://stackoverflow.com/questions/39438441/
Aas.IReferable x = null;
/*
if (Application.Current != null)
{
// WPF case
Expand All @@ -288,6 +293,7 @@ public override object Invoke(IScriptContext context, object[] args)
Log.Singleton.Silent("" + x.IdShort);
}
else
*/
{
// Blazor?? case
x = _script.Remote?.Select(args);
Expand Down Expand Up @@ -337,6 +343,7 @@ public async override Task<object> Invoke(IScriptContext context, object[] args)
// invoke action
// https://stackoverflow.com/questions/39438441/
bool x = false;
/*
if (Application.Current != null)
{
// WPF case
Expand All @@ -347,6 +354,7 @@ public async override Task<object> Invoke(IScriptContext context, object[] args)
Log.Singleton.Silent("" + x);
}
else
*/
{
// Blazor case
x = await _script.Remote?.Location(args);
Expand Down
4 changes: 2 additions & 2 deletions src/AasxPackageLogic/AdminShellEvents/AasEventCompressor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ This source code may use other Open Source software components (see LICENSE.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Annotations;
using static System.Windows.Forms.AxHost;
// using System.Windows.Annotations;
// using static System.Windows.Forms.AxHost;
using Aas = AasCore.Aas3_0;

namespace AasxIntegrationBase.AdminShellEvents
Expand Down
4 changes: 2 additions & 2 deletions src/AasxPackageLogic/DispEditHelperEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ This source code may use other Open Source software components (see LICENSE.txt)
using System.Linq;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Windows.Documents;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
// using System.Windows.Documents;
// using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
using Aas = AasCore.Aas3_0;

namespace AasxPackageLogic
Expand Down
8 changes: 7 additions & 1 deletion src/AasxPackageLogic/MainWindowHeadless.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
using AasxPackageLogic.PackageCentral;
using AasxPredefinedConcepts;
using AasxPredefinedConcepts.Convert;
using AasxSignature;
// using AasxSignature;
using AdminShellNS;
using AnyUi;
using Extensions;
Expand Down Expand Up @@ -230,25 +230,31 @@ public async Task CommandBinding_GeneralDispatchHeadless(
}

// do
/*
PackageHelper.SignAll(
sourceFn, certFn,
invokeMessage: (ticket.InvokeMessage == null)
? StandardInvokeMessageDelegate : ticket.InvokeMessage);
*/
}

if (cmd == "validatecertificate")
{
// arguments
/*
if (!(ticket["Source"] is string sourceFn))
{
LogErrorToTicket(ticket, "Validate: source package filename invalid.");
return;
}
*/

// do
/*
PackageHelper.Validate(sourceFn,
invokeMessage: (ticket.InvokeMessage == null)
? StandardInvokeMessageDelegate : ticket.InvokeMessage);
*/
}

if (cmd == "encrypt")
Expand Down
Loading

0 comments on commit cf3f670

Please sign in to comment.