From d350791acccc65068b0d8e2ae7f20b4b511a0c91 Mon Sep 17 00:00:00 2001 From: HuskyTeufel Date: Fri, 25 Mar 2022 15:47:46 +0100 Subject: [PATCH] Key von Syncfusion wird aus der Dongle nun gelesen --- BerichtGen/FrmOptions.cs | 5 ++- BerichtGen/makeGraphic.cs | 4 +- Dongle/Dongle.csproj | 60 ++++++++++++++++++++++++++++++ Dongle/Properties/AssemblyInfo.cs | 36 ++++++++++++++++++ {SanSystem => SanShared}/Dongle.cs | 50 ++++++++++++------------- SanShared/SanShared.csproj | 13 +++++++ SanSystem/FrmSelectNewSan.cs | 3 +- SanSystem/Program.cs | 2 + SanSystem/SanSystem.csproj | 13 ------- SanSystem/frmMain.cs | 1 - 10 files changed, 145 insertions(+), 42 deletions(-) create mode 100644 Dongle/Dongle.csproj create mode 100644 Dongle/Properties/AssemblyInfo.cs rename {SanSystem => SanShared}/Dongle.cs (78%) diff --git a/BerichtGen/FrmOptions.cs b/BerichtGen/FrmOptions.cs index d458c09..2e8388c 100644 --- a/BerichtGen/FrmOptions.cs +++ b/BerichtGen/FrmOptions.cs @@ -45,7 +45,10 @@ namespace BerichtGen { InitializeComponent(); - Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NDE3ODkzQDMxMzgyZTM0MmUzMFU4Zi9HelJVSzVxQXVLdlp6NTRuOXhwR1JtdzgybVBsdGNDeGZwdkhwNGM9"); + Dongle dongle = new Dongle(60); + Trace.WriteLine("FrmOptions: " + dongle.SyncfusionKey); + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(dongle.SyncfusionKey); + dongle.CleanDongle(); this.firma = firma; diff --git a/BerichtGen/makeGraphic.cs b/BerichtGen/makeGraphic.cs index 6ef6699..dcdff26 100644 --- a/BerichtGen/makeGraphic.cs +++ b/BerichtGen/makeGraphic.cs @@ -97,7 +97,9 @@ namespace BerichtGen /// public static bool GetGraphics(List struktures,string destinationPath) { - Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NDE3ODkzQDMxMzgyZTM0MmUzMFU4Zi9HelJVSzVxQXVLdlp6NTRuOXhwR1JtdzgybVBsdGNDeGZwdkhwNGM9"); + Dongle dongle = new Dongle(60); + Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(dongle.SyncfusionKey); + dongle.CleanDongle(); ChartControl tempChart = getGraph(struktures, "Temperatur"); if (tempChart == null) return false; diff --git a/Dongle/Dongle.csproj b/Dongle/Dongle.csproj new file mode 100644 index 0000000..1873849 --- /dev/null +++ b/Dongle/Dongle.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {3362303F-994B-412B-B50D-7C701D5751D6} + Library + Properties + Dongle + Dongle + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + False + ..\3rdPackage\WibuCmNET.dll + + + False + ..\3rdPackage\wupi.net.dll + + + False + ..\3rdPackage\WupiEngineNet.dll + + + + + + + + \ No newline at end of file diff --git a/Dongle/Properties/AssemblyInfo.cs b/Dongle/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f4ce5dc --- /dev/null +++ b/Dongle/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("Dongle")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Dongle")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("3362303f-994b-412b-b50d-7c701d5751d6")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// indem Sie "*" wie unten gezeigt eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SanSystem/Dongle.cs b/SanShared/Dongle.cs similarity index 78% rename from SanSystem/Dongle.cs rename to SanShared/Dongle.cs index a17e3b4..30bfa7f 100644 --- a/SanSystem/Dongle.cs +++ b/SanShared/Dongle.cs @@ -1,23 +1,19 @@ -using CodeMeter; -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using CodeMeter; -/* - * - * - * 4e 6a 41 77 4e 6a 51 7a 51 44 4d 78 4d 7a 6b 79 5a 54 4d 30 4d 6d 55 7a 4d 47 35 4c 61 32 55 7a 51 31 46 30 52 33 64 46 5a 45 68 35 56 57 74 47 61 7a 5a 30 61 48 70 55 57 69 39 58 64 6b 78 4a 54 32 78 43 62 6b 74 58 52 58 46 57 63 30 5a 73 64 7a 41 39 - */ -namespace SanSystem +namespace SanShared { - class Dongle: IDisposable + //4e 6a 41 77 4e 6a 51 7a 51 44 4d 78 4d 7a 6b 79 5a 54 4d 30 4d 6d 55 7a 4d 47 35 4c 61 32 55 7a 51 31 46 30 52 33 64 46 5a 45 68 35 56 57 74 47 61 7a 5a 30 61 48 70 55 57 69 39 58 64 6b 78 4a 54 32 78 43 62 6b 74 58 52 58 46 57 63 30 5a 73 64 7a 41 39 + public class Dongle : IDisposable { uint FirmCode; uint ProductCode; - public string SyncfusionKey =""; + public string SyncfusionKey = ""; Api cmApi; CmCredential cmCred; @@ -36,7 +32,7 @@ namespace SanSystem this.ProductCode = 1; #endif - + cmApi = new Api(); cmCred = new CmCredential(); cmAcc = new CmAccess2(); @@ -49,15 +45,15 @@ namespace SanSystem hcmse = cmApi.CmAccess2(CmAccessOption.Local, cmAcc); - if(hcmse == null) + if (hcmse == null) { ErrorCodes2 code = cmApi.CmGetLastErrorCode2(); string output = string.Format("{0}", code); - + } if (!CheckDongleVorhanden()) - Trace.WriteLine("Dongle nicht vorhanden"); + throw new Exception("Dongle not connected"); cmBoxInfo = new CmBoxInfo(); @@ -70,27 +66,32 @@ namespace SanSystem CmEntryData[] pCmBoxEntry = (CmEntryData[])cmApi.CmGetInfo(hcmse, CmGetInfoOption.EntryData); - for(int i = 0; i < pCmBoxEntry.Length; i++) + for (int i = 0; i < pCmBoxEntry.Length; i++) { - switch(pCmBoxEntry[i].Ctrl & 0x0ffff) + switch (pCmBoxEntry[i].Ctrl & 0x0ffff) { case (uint)CodeMeter.GlobalEntryOption.ProtectedData: - //var s = pCmBoxEntry[i].Data; - SyncfusionKey = Encoding.ASCII.GetString(pCmBoxEntry[i].Data); - //var len = pCmBoxEntry[i].DataLen; - //var stringer = Encoding.ASCII.GetString(s); - //Debugger.Break(); + // Transfer to transformed byte + uint length = pCmBoxEntry[i].DataLen; + byte[] datas = new byte[length]; + for(uint f = 0; f < length; f++) + { + datas[f] = pCmBoxEntry[i].Data[f]; + } + + + SyncfusionKey = Encoding.ASCII.GetString(datas); break; } } - + foreach (CmBoxEntry2 boxes in tmpBoxContent) { if (boxes.ProductCode == this.ProductCode) { this.BoxContent = boxes; } - + } } ~Dongle() @@ -161,6 +162,5 @@ namespace SanSystem CleanDongle(); } } - - } + diff --git a/SanShared/SanShared.csproj b/SanShared/SanShared.csproj index eb24725..a6a5944 100644 --- a/SanShared/SanShared.csproj +++ b/SanShared/SanShared.csproj @@ -41,6 +41,18 @@ + + False + ..\3rdPackage\WibuCmNET.dll + + + False + ..\3rdPackage\wupi.net.dll + + + False + ..\3rdPackage\WupiEngineNet.dll + @@ -55,6 +67,7 @@ + diff --git a/SanSystem/FrmSelectNewSan.cs b/SanSystem/FrmSelectNewSan.cs index 459c2ef..dd848cb 100644 --- a/SanSystem/FrmSelectNewSan.cs +++ b/SanSystem/FrmSelectNewSan.cs @@ -1,4 +1,5 @@ -using System; +using SanShared; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; diff --git a/SanSystem/Program.cs b/SanSystem/Program.cs index fe6267f..c2de1c8 100644 --- a/SanSystem/Program.cs +++ b/SanSystem/Program.cs @@ -1,4 +1,5 @@ #define LAPTOP +using SanShared; using System; using System.Collections.Generic; using System.Linq; @@ -6,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; + namespace SanSystem { static class Program diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index ff6ccb6..ec49594 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -104,22 +104,9 @@ - - False - ..\3rdPackage\WibuCmNET.dll - - - False - ..\3rdPackage\wupi.net.dll - - - False - ..\3rdPackage\WupiEngineNet.dll - - diff --git a/SanSystem/frmMain.cs b/SanSystem/frmMain.cs index 8623f53..a80d72d 100644 --- a/SanSystem/frmMain.cs +++ b/SanSystem/frmMain.cs @@ -15,7 +15,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using WupiEngine; namespace SanSystem {