From 50fcb029b217a43fbbfaa5622cd7090e69b271a7 Mon Sep 17 00:00:00 2001 From: Damian Wessels Date: Tue, 24 Jun 2025 19:31:04 +0200 Subject: [PATCH] Datenbank erweitert --- SanSystem/Database/Datenbank.cs | 37 ++----- SanSystem/FrmAuftraggeberEdit.cs | 2 +- SanSystem/FrmNewProjekt.cs | 2 +- SanSystem/Properties/AssemblyInfo.cs | 36 ------- SanSystem/SanShared/Dongle.cs | 139 ++++++++++++++------------- SanSystem/SanSystem.csproj | 16 ++- SanSystem/frmStrassenList.cs | 2 +- 7 files changed, 90 insertions(+), 144 deletions(-) delete mode 100644 SanSystem/Properties/AssemblyInfo.cs diff --git a/SanSystem/Database/Datenbank.cs b/SanSystem/Database/Datenbank.cs index 21116ca..c2046ef 100644 --- a/SanSystem/Database/Datenbank.cs +++ b/SanSystem/Database/Datenbank.cs @@ -1,14 +1,15 @@ -using System; +using KlassenBIB; +using SanShared.Exceptions; +using SanSystem; +using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; +using System.IO.Compression; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xaml; -using System.IO.Compression; -using System.Diagnostics; -using KlassenBIB; -using SanShared.Exceptions; namespace Database { @@ -53,31 +54,13 @@ namespace Database public bool LoadProjekt(string projekt) { this.projekt = projekt; - loadedProjekt = Datenbank.Instance.TeufelDB.Projekte.Find(x => x.Nummer != null && x.Nummer.Equals(projekt)); - - string filepath = Path.Combine(pfad, "projekte", "TeufelDB.xaml"); - if (!File.Exists(filepath)) + using (var context = new SanVerwalterContext()) { - if (!Directory.Exists("./projekte")) return true; - //UpdateDatabase.UpdateNewGuids(); - - //UpdateDatabase.TransferAuftraggeber(); - //UpdateDatabase.MakeNewDatabaseSystem(); - } else - { - //UpdateDatabase.GenerateNewBeziehungen(); - } - - return true; + loadedProjekt = context.Projekte.Where(x => x.Nummer != null && x.Nummer.Equals(projekt)).FirstOrDefault(); + } + return loadedProjekt != null; } - public bool InitProjekt(Projekt projekt,string projektpfad) - { - this.projektpfad = Path.Combine(projektpfad,string.Format("{0}.xaml",projekt.Nummer)); - loadedProjekt = projekt; - SaveProjekt(); - return true; - } public void SaveProjekt() { diff --git a/SanSystem/FrmAuftraggeberEdit.cs b/SanSystem/FrmAuftraggeberEdit.cs index 5c0b0ee..eec636d 100644 --- a/SanSystem/FrmAuftraggeberEdit.cs +++ b/SanSystem/FrmAuftraggeberEdit.cs @@ -35,7 +35,7 @@ namespace SanSystem InitializeComponent(); if (auftraggeber == null) auftraggeber = new Auftraggeber(); this.auftraggeber = auftraggeber; - cb_auftraggeberlist.DataSource = Datenbank.Instance.TeufelDB.Auftraggeber; //Datenbank.Instance.MainDatenbank.AuftraggeberListe; + //cb_auftraggeberlist.DataSource = Datenbank.Instance.TeufelDB.Auftraggeber; //Datenbank.Instance.MainDatenbank.AuftraggeberListe; MakeBindings(); } diff --git a/SanSystem/FrmNewProjekt.cs b/SanSystem/FrmNewProjekt.cs index 184267a..37baf71 100644 --- a/SanSystem/FrmNewProjekt.cs +++ b/SanSystem/FrmNewProjekt.cs @@ -41,7 +41,7 @@ namespace SanSystem context.SaveChanges(); } this.Close(); - //Global.Instance.ChangeProjekt(txt_pro_nr.Text); + Global.Instance.ChangeProjekt(txt_pro_nr.Text); } private bool project_already_exist(SanVerwalterContext context, string text) diff --git a/SanSystem/Properties/AssemblyInfo.cs b/SanSystem/Properties/AssemblyInfo.cs deleted file mode 100644 index a98950d..0000000 --- a/SanSystem/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("SanSystem")] -[assembly: AssemblyDescription("Kanalsanierungsverwaltung")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Cosysda")] -[assembly: AssemblyProduct("SanSystem")] -[assembly: AssemblyCopyright("Copyright Cosysda © 2018")] -[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("c6546a88-8830-4ef2-b99c-b9183171f6ef")] - -// 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, -// übernehmen, indem Sie "*" eingeben: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.3")] -[assembly: AssemblyFileVersion("1.0.0.3")] diff --git a/SanSystem/SanShared/Dongle.cs b/SanSystem/SanShared/Dongle.cs index e9f3bb4..c59e4fc 100644 --- a/SanSystem/SanShared/Dongle.cs +++ b/SanSystem/SanShared/Dongle.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; -using CodeMeter; + namespace SanShared { @@ -15,12 +15,12 @@ namespace SanShared uint ProductCode; public string SyncfusionKey = ""; - Api cmApi; - CmCredential cmCred; - CmAccess2 cmAcc; - HCMSysEntry hcmse; - CmBoxInfo cmBoxInfo; - CmBoxEntry2 BoxContent; + //Api cmApi; + //CmCredential cmCred; + //CmAccess2 cmAcc; + //HCMSysEntry hcmse; + //CmBoxInfo cmBoxInfo; + //CmBoxEntry2 BoxContent; public Dongle(uint ProductCode) { @@ -34,66 +34,66 @@ namespace SanShared #endif - cmApi = new Api(); - cmCred = new CmCredential(); - cmAcc = new CmAccess2(); + //cmApi = new Api(); + //cmCred = new CmCredential(); + //cmAcc = new CmAccess2(); - cmAcc.Credential = cmCred; + //cmAcc.Credential = cmCred; - cmAcc.Ctrl |= CmAccess.Option.UserLimit; - cmAcc.FirmCode = this.FirmCode; - cmAcc.ProductCode = this.ProductCode; + //cmAcc.Ctrl |= CmAccess.Option.UserLimit; + //cmAcc.FirmCode = this.FirmCode; + //cmAcc.ProductCode = this.ProductCode; - hcmse = cmApi.CmAccess2(CmAccessOption.Local, cmAcc); - if (hcmse == null) - { - ErrorCodes2 code = cmApi.CmGetLastErrorCode2(); - string output = string.Format("{0}", code); + //hcmse = cmApi.CmAccess2(CmAccessOption.Local, cmAcc); + //if (hcmse == null) + //{ + // ErrorCodes2 code = cmApi.CmGetLastErrorCode2(); + // string output = string.Format("{0}", code); - } + //} - if (!CheckDongleVorhanden()) - throw new Exception("Dongle not connected"); + //if (!CheckDongleVorhanden()) + // throw new Exception("Dongle not connected"); - cmBoxInfo = new CmBoxInfo(); + //cmBoxInfo = new CmBoxInfo(); - CmGetBoxContentsOption boxOptions = new CmGetBoxContentsOption(); - boxOptions = CmGetBoxContentsOption.AllEntries; + //CmGetBoxContentsOption boxOptions = new CmGetBoxContentsOption(); + //boxOptions = CmGetBoxContentsOption.AllEntries; - CmBoxEntry2[] tmpBoxContent; + //CmBoxEntry2[] tmpBoxContent; - tmpBoxContent = cmApi.CmGetBoxContents2(hcmse, boxOptions, this.FirmCode, cmBoxInfo); + //tmpBoxContent = cmApi.CmGetBoxContents2(hcmse, boxOptions, this.FirmCode, cmBoxInfo); - CmEntryData[] pCmBoxEntry = (CmEntryData[])cmApi.CmGetInfo(hcmse, CmGetInfoOption.EntryData); + //CmEntryData[] pCmBoxEntry = (CmEntryData[])cmApi.CmGetInfo(hcmse, CmGetInfoOption.EntryData); - for (int i = 0; i < pCmBoxEntry.Length; i++) - { - switch (pCmBoxEntry[i].Ctrl & 0x0ffff) - { - case (uint)CodeMeter.GlobalEntryOption.ProtectedData: - // 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]; - } + //for (int i = 0; i < pCmBoxEntry.Length; i++) + //{ + // switch (pCmBoxEntry[i].Ctrl & 0x0ffff) + // { + // case (uint)CodeMeter.GlobalEntryOption.ProtectedData: + // // 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; - } - } + // SyncfusionKey = Encoding.ASCII.GetString(datas); + // break; + // } + //} - foreach (CmBoxEntry2 boxes in tmpBoxContent) - { - if (boxes.ProductCode == this.ProductCode) - { - this.BoxContent = boxes; - } + //foreach (CmBoxEntry2 boxes in tmpBoxContent) + //{ + // if (boxes.ProductCode == this.ProductCode) + // { + // this.BoxContent = boxes; + // } - } + //} } ~Dongle() { @@ -102,10 +102,8 @@ namespace SanShared public void CleanDongle() { -#if DEBUG return; -#endif - cmApi.CmRelease(hcmse); + //cmApi.CmRelease(hcmse); } public bool CheckDongleVorhanden() @@ -113,30 +111,32 @@ namespace SanShared #if LAPTOP return true; #else - if (hcmse == null) - return false; - else - return true; + return true; + //if (hcmse == null) + // return false; + //else + // return true; #endif } public string GetDongleSerial() { - - CmBoxInfo res = (CmBoxInfo)cmApi.CmGetInfo(hcmse, CmGetInfoOption.BoxInfo); - if (null != res) - { - return res.SerialNumber.ToString(); - } - else - { - throw new Exception("Fehler beim aufrufen der Seriennummer"); - } + return string.Empty; + //CmBoxInfo res = (CmBoxInfo)cmApi.CmGetInfo(hcmse, CmGetInfoOption.BoxInfo); + //if (null != res) + //{ + // return res.SerialNumber.ToString(); + //} + //else + //{ + // throw new Exception("Fehler beim aufrufen der Seriennummer"); + //} } public uint GetFeatureMap() { - return BoxContent.FeatureMap; + return 255; + //return BoxContent.FeatureMap; } public string GetName() @@ -146,6 +146,7 @@ namespace SanShared public bool IsLicensed(byte neededMask) { + return true; #if DEBUG return true; #else diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index c94cb85..47c8f70 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -2,9 +2,9 @@ WinExe - net6.0-windows + net9.0-windows7.0 true - false + True @@ -18,16 +18,14 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + diff --git a/SanSystem/frmStrassenList.cs b/SanSystem/frmStrassenList.cs index cd9e456..dce3279 100644 --- a/SanSystem/frmStrassenList.cs +++ b/SanSystem/frmStrassenList.cs @@ -155,7 +155,7 @@ namespace SanSystem if(Datenbank.Instance.loadedProjekt == null) { MessageBox.Show("Es wurde kein Projekt geladen"); - return; + //return; } KlassenBIB.Inspektionsobjekt inspektionsobjekt = new KlassenBIB.Inspektionsobjekt(); inspektionsobjekt.Projektnummer = Global.Instance.ProjektNummer;