Datenbank erweitert

This commit is contained in:
Damian Wessels
2025-06-24 19:31:04 +02:00
parent 1f1cb3e7dd
commit 50fcb029b2
7 changed files with 90 additions and 144 deletions

View File

@@ -1,14 +1,15 @@
using System; using KlassenBIB;
using SanShared.Exceptions;
using SanSystem;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xaml; using System.Xaml;
using System.IO.Compression;
using System.Diagnostics;
using KlassenBIB;
using SanShared.Exceptions;
namespace Database namespace Database
{ {
@@ -53,31 +54,13 @@ namespace Database
public bool LoadProjekt(string projekt) public bool LoadProjekt(string projekt)
{ {
this.projekt = projekt; this.projekt = projekt;
loadedProjekt = Datenbank.Instance.TeufelDB.Projekte.Find(x => x.Nummer != null && x.Nummer.Equals(projekt)); using (var context = new SanVerwalterContext())
string filepath = Path.Combine(pfad, "projekte", "TeufelDB.xaml");
if (!File.Exists(filepath))
{ {
if (!Directory.Exists("./projekte")) return true; loadedProjekt = context.Projekte.Where(x => x.Nummer != null && x.Nummer.Equals(projekt)).FirstOrDefault();
//UpdateDatabase.UpdateNewGuids();
//UpdateDatabase.TransferAuftraggeber();
//UpdateDatabase.MakeNewDatabaseSystem();
} else
{
//UpdateDatabase.GenerateNewBeziehungen();
} }
return loadedProjekt != null;
return true;
} }
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() public void SaveProjekt()
{ {

View File

@@ -35,7 +35,7 @@ namespace SanSystem
InitializeComponent(); InitializeComponent();
if (auftraggeber == null) auftraggeber = new Auftraggeber(); if (auftraggeber == null) auftraggeber = new Auftraggeber();
this.auftraggeber = 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(); MakeBindings();
} }

View File

@@ -41,7 +41,7 @@ namespace SanSystem
context.SaveChanges(); context.SaveChanges();
} }
this.Close(); 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) private bool project_already_exist(SanVerwalterContext context, string text)

View File

@@ -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")]

View File

@@ -4,7 +4,7 @@ using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using CodeMeter;
namespace SanShared namespace SanShared
{ {
@@ -15,12 +15,12 @@ namespace SanShared
uint ProductCode; uint ProductCode;
public string SyncfusionKey = ""; public string SyncfusionKey = "";
Api cmApi; //Api cmApi;
CmCredential cmCred; //CmCredential cmCred;
CmAccess2 cmAcc; //CmAccess2 cmAcc;
HCMSysEntry hcmse; //HCMSysEntry hcmse;
CmBoxInfo cmBoxInfo; //CmBoxInfo cmBoxInfo;
CmBoxEntry2 BoxContent; //CmBoxEntry2 BoxContent;
public Dongle(uint ProductCode) public Dongle(uint ProductCode)
{ {
@@ -34,66 +34,66 @@ namespace SanShared
#endif #endif
cmApi = new Api(); //cmApi = new Api();
cmCred = new CmCredential(); //cmCred = new CmCredential();
cmAcc = new CmAccess2(); //cmAcc = new CmAccess2();
cmAcc.Credential = cmCred; //cmAcc.Credential = cmCred;
cmAcc.Ctrl |= CmAccess.Option.UserLimit; //cmAcc.Ctrl |= CmAccess.Option.UserLimit;
cmAcc.FirmCode = this.FirmCode; //cmAcc.FirmCode = this.FirmCode;
cmAcc.ProductCode = this.ProductCode; //cmAcc.ProductCode = this.ProductCode;
hcmse = cmApi.CmAccess2(CmAccessOption.Local, cmAcc); //hcmse = cmApi.CmAccess2(CmAccessOption.Local, cmAcc);
if (hcmse == null) //if (hcmse == null)
{ //{
ErrorCodes2 code = cmApi.CmGetLastErrorCode2(); // ErrorCodes2 code = cmApi.CmGetLastErrorCode2();
string output = string.Format("{0}", code); // string output = string.Format("{0}", code);
} //}
if (!CheckDongleVorhanden()) //if (!CheckDongleVorhanden())
throw new Exception("Dongle not connected"); // throw new Exception("Dongle not connected");
cmBoxInfo = new CmBoxInfo(); //cmBoxInfo = new CmBoxInfo();
CmGetBoxContentsOption boxOptions = new CmGetBoxContentsOption(); //CmGetBoxContentsOption boxOptions = new CmGetBoxContentsOption();
boxOptions = CmGetBoxContentsOption.AllEntries; //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++) //for (int i = 0; i < pCmBoxEntry.Length; i++)
{ //{
switch (pCmBoxEntry[i].Ctrl & 0x0ffff) // switch (pCmBoxEntry[i].Ctrl & 0x0ffff)
{ // {
case (uint)CodeMeter.GlobalEntryOption.ProtectedData: // case (uint)CodeMeter.GlobalEntryOption.ProtectedData:
// Transfer to transformed byte // // Transfer to transformed byte
uint length = pCmBoxEntry[i].DataLen; // uint length = pCmBoxEntry[i].DataLen;
byte[] datas = new byte[length]; // byte[] datas = new byte[length];
for(uint f = 0; f < length; f++) // for(uint f = 0; f < length; f++)
{ // {
datas[f] = pCmBoxEntry[i].Data[f]; // datas[f] = pCmBoxEntry[i].Data[f];
} // }
SyncfusionKey = Encoding.ASCII.GetString(datas); // SyncfusionKey = Encoding.ASCII.GetString(datas);
break; // break;
} // }
} //}
foreach (CmBoxEntry2 boxes in tmpBoxContent) //foreach (CmBoxEntry2 boxes in tmpBoxContent)
{ //{
if (boxes.ProductCode == this.ProductCode) // if (boxes.ProductCode == this.ProductCode)
{ // {
this.BoxContent = boxes; // this.BoxContent = boxes;
} // }
} //}
} }
~Dongle() ~Dongle()
{ {
@@ -102,10 +102,8 @@ namespace SanShared
public void CleanDongle() public void CleanDongle()
{ {
#if DEBUG
return; return;
#endif //cmApi.CmRelease(hcmse);
cmApi.CmRelease(hcmse);
} }
public bool CheckDongleVorhanden() public bool CheckDongleVorhanden()
@@ -113,30 +111,32 @@ namespace SanShared
#if LAPTOP #if LAPTOP
return true; return true;
#else #else
if (hcmse == null) return true;
return false; //if (hcmse == null)
else // return false;
return true; //else
// return true;
#endif #endif
} }
public string GetDongleSerial() public string GetDongleSerial()
{ {
return string.Empty;
CmBoxInfo res = (CmBoxInfo)cmApi.CmGetInfo(hcmse, CmGetInfoOption.BoxInfo); //CmBoxInfo res = (CmBoxInfo)cmApi.CmGetInfo(hcmse, CmGetInfoOption.BoxInfo);
if (null != res) //if (null != res)
{ //{
return res.SerialNumber.ToString(); // return res.SerialNumber.ToString();
} //}
else //else
{ //{
throw new Exception("Fehler beim aufrufen der Seriennummer"); // throw new Exception("Fehler beim aufrufen der Seriennummer");
} //}
} }
public uint GetFeatureMap() public uint GetFeatureMap()
{ {
return BoxContent.FeatureMap; return 255;
//return BoxContent.FeatureMap;
} }
public string GetName() public string GetName()
@@ -146,6 +146,7 @@ namespace SanShared
public bool IsLicensed(byte neededMask) public bool IsLicensed(byte neededMask)
{ {
return true;
#if DEBUG #if DEBUG
return true; return true;
#else #else

View File

@@ -2,9 +2,9 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net9.0-windows7.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>True</GenerateAssemblyInfo>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -18,16 +18,14 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
<PackageReference Include="Syncfusion.Chart.Windows" Version="20.4.0.43" /> <PackageReference Include="Syncfusion.Chart.Windows" Version="29.1.35" />
<PackageReference Include="Syncfusion.DocIO.WinForms" Version="20.4.0.43" /> <PackageReference Include="Syncfusion.DocToPDFConverter.WinForms" Version="29.1.35" />
<PackageReference Include="Syncfusion.DocToPDFConverter.WinForms" Version="20.4.0.43" />
<PackageReference Include="Wibu.CodeMeter.WibuCmNET" Version="7.50.5271.500" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -155,7 +155,7 @@ namespace SanSystem
if(Datenbank.Instance.loadedProjekt == null) if(Datenbank.Instance.loadedProjekt == null)
{ {
MessageBox.Show("Es wurde kein Projekt geladen"); MessageBox.Show("Es wurde kein Projekt geladen");
return; //return;
} }
KlassenBIB.Inspektionsobjekt inspektionsobjekt = new KlassenBIB.Inspektionsobjekt(); KlassenBIB.Inspektionsobjekt inspektionsobjekt = new KlassenBIB.Inspektionsobjekt();
inspektionsobjekt.Projektnummer = Global.Instance.ProjektNummer; inspektionsobjekt.Projektnummer = Global.Instance.ProjektNummer;