From c214be937c6ea8e6ba0df028081b0c920ebce9a0 Mon Sep 17 00:00:00 2001 From: "SnapixLP | Tim G." Date: Mon, 19 May 2025 09:16:34 +0200 Subject: [PATCH] Initial Commit --- .gitignore | 352 +++++++++++++++++++++ DX86/.gitignore | 352 +++++++++++++++++++++ DX86/DX86.cs | 384 +++++++++++++++++++++++ DX86/DX86.csproj | 14 + DX86/Modules/InputBox.cs | 63 ++++ DX86/Modules/ItemSelector.cs | 158 ++++++++++ DX86/Modules/MessageBox.cs | 55 ++++ DX86/Modules/MessageSender.cs | 95 ++++++ DX86/Program.cs | 11 + DX86/TcpServer.cs | 107 +++++++ DX86/UdpServer.cs | 71 +++++ Library/.gitignore | 352 +++++++++++++++++++++ Library/Connection.cs | 5 + Library/Library.csproj | 9 + Library/Server.cs | 6 + Library/Worker.cs | 6 + Library/WorkerState.cs | 8 + ManagementClient/.gitignore | 352 +++++++++++++++++++++ ManagementClient/App.xaml | 9 + ManagementClient/App.xaml.cs | 12 + ManagementClient/AssemblyInfo.cs | 10 + ManagementClient/MainWindow.xaml | 12 + ManagementClient/MainWindow.xaml.cs | 23 ++ ManagementClient/ManagementClient.csproj | 15 + Mitarbeiter-Verwaltung.sln | 40 +++ Server/.gitignore | 352 +++++++++++++++++++++ Server/BackendServer.cs | 54 ++++ Server/CommandManager.cs | 44 +++ Server/Commands/ICommand.cs | 10 + Server/MySQL.cs | 242 ++++++++++++++ Server/Program.cs | 34 ++ Server/Server.csproj | 20 ++ StempelClient/.gitignore | 352 +++++++++++++++++++++ StempelClient/App.xaml | 9 + StempelClient/App.xaml.cs | 12 + StempelClient/AssemblyInfo.cs | 10 + StempelClient/MainWindow.xaml | 12 + StempelClient/MainWindow.xaml.cs | 23 ++ StempelClient/StempelClient.csproj | 15 + 39 files changed, 3710 insertions(+) create mode 100644 .gitignore create mode 100644 DX86/.gitignore create mode 100644 DX86/DX86.cs create mode 100644 DX86/DX86.csproj create mode 100644 DX86/Modules/InputBox.cs create mode 100644 DX86/Modules/ItemSelector.cs create mode 100644 DX86/Modules/MessageBox.cs create mode 100644 DX86/Modules/MessageSender.cs create mode 100644 DX86/Program.cs create mode 100644 DX86/TcpServer.cs create mode 100644 DX86/UdpServer.cs create mode 100644 Library/.gitignore create mode 100644 Library/Connection.cs create mode 100644 Library/Library.csproj create mode 100644 Library/Server.cs create mode 100644 Library/Worker.cs create mode 100644 Library/WorkerState.cs create mode 100644 ManagementClient/.gitignore create mode 100644 ManagementClient/App.xaml create mode 100644 ManagementClient/App.xaml.cs create mode 100644 ManagementClient/AssemblyInfo.cs create mode 100644 ManagementClient/MainWindow.xaml create mode 100644 ManagementClient/MainWindow.xaml.cs create mode 100644 ManagementClient/ManagementClient.csproj create mode 100644 Mitarbeiter-Verwaltung.sln create mode 100644 Server/.gitignore create mode 100644 Server/BackendServer.cs create mode 100644 Server/CommandManager.cs create mode 100644 Server/Commands/ICommand.cs create mode 100644 Server/MySQL.cs create mode 100644 Server/Program.cs create mode 100644 Server/Server.csproj create mode 100644 StempelClient/.gitignore create mode 100644 StempelClient/App.xaml create mode 100644 StempelClient/App.xaml.cs create mode 100644 StempelClient/AssemblyInfo.cs create mode 100644 StempelClient/MainWindow.xaml create mode 100644 StempelClient/MainWindow.xaml.cs create mode 100644 StempelClient/StempelClient.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..156463b --- /dev/null +++ b/.gitignore @@ -0,0 +1,352 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +.vscode/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +/.dotnet +/.packages +/.tools/vswhere/2.5.2 +/.tools/native/iltools + +### OSX ### + +.DS_Store +.AppleDouble +.LSOverride + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Exceptions to the exclusions +!src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/*.rsp +!src/Microsoft.DotNet.Wpf/src/WpfGfx/tools/csp/**/*.rsp + diff --git a/DX86/.gitignore b/DX86/.gitignore new file mode 100644 index 0000000..156463b --- /dev/null +++ b/DX86/.gitignore @@ -0,0 +1,352 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +.vscode/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +/.dotnet +/.packages +/.tools/vswhere/2.5.2 +/.tools/native/iltools + +### OSX ### + +.DS_Store +.AppleDouble +.LSOverride + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Exceptions to the exclusions +!src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/*.rsp +!src/Microsoft.DotNet.Wpf/src/WpfGfx/tools/csp/**/*.rsp + diff --git a/DX86/DX86.cs b/DX86/DX86.cs new file mode 100644 index 0000000..e1bf356 --- /dev/null +++ b/DX86/DX86.cs @@ -0,0 +1,384 @@ +using DX86.Modules; + +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; + +namespace DX86 +{ + /// + /// Represents the type of server, either TCP or UDP. + /// + public enum ServerType + { + TCP, + UDP + } + + /// + /// The main class for the DX86 server. This class manages the TCP and UDP server functionality, including accepting client connections, receiving messages, and handling client disconnections. + /// + public class DX86 + { + private MessageSender ms; + private TcpListener tcpServer; + private UdpClient udpServer; + private List tcpClients = new List(); + private readonly object clientListLock = new object(); + private ServerType serverType; + + public event Action ClientConnected; + public event Action MessageReceived; + public event Action ClientDisconnected; + + public event Action UdpClientConnected; + public event Action UdpMessageReceived; + public event Action UdpClientDisconnected; + + public DX86(MessageSender ms, ServerType type) + { + this.ms = ms; + this.serverType = type; + ms.Log("[DX86] DX86 initialized for " + type.ToString() + " server."); + } + + public void StartServer(string ipAddress, int port) + { + if (serverType == ServerType.TCP) + { + tcpServer = new TcpListener(IPAddress.Parse(ipAddress), port); + tcpServer.Start(); + ms.Log($"[DX86] TCP server started on {ipAddress}:{port}"); + AcceptTcpClientsAsync(); + } + else if (serverType == ServerType.UDP) + { + udpServer = new UdpClient(port); + ms.Log($"[DX86] UDP server started on {ipAddress}:{port}"); + ReceiveUdpMessagesAsync(); + } + } + + private async Task ReceiveUdpMessagesAsync() + { + while (true) + { + try + { + var receivedResult = await udpServer.ReceiveAsync(); + string message = Encoding.UTF8.GetString(receivedResult.Buffer); + //ms.Log($"[DX86] Received UDP message from {receivedResult.RemoteEndPoint}: {message}"); + + // Trigger the event + UdpMessageReceived?.Invoke(receivedResult.RemoteEndPoint, message); + } + catch (Exception ex) + { + ms.Error("[DX86] Error receiving UDP message: " + ex.Message); + // Optionally handle specific exceptions or rethrow + } + } + } + + public void StopServer() + { + if (serverType == ServerType.TCP) + { + tcpServer.Stop(); + lock (clientListLock) + { + foreach (var client in tcpClients) + { + client.Close(); + } + tcpClients.Clear(); + } + ms.Log("[DX86] TCP server stopped."); + } + else if (serverType == ServerType.UDP) + { + udpServer.Close(); + ms.Log("[DX86] UDP server stopped."); + } + } + + private async Task AcceptTcpClientsAsync() + { + while (true) + { + var client = await tcpServer.AcceptTcpClientAsync(); + lock (clientListLock) + { + tcpClients.Add(client); + } + ClientConnected?.Invoke(client); + ms.Log("[DX86] Client connected."); + HandleTcpClientAsync(client); + } + } + + private async Task HandleTcpClientAsync(TcpClient client) + { + var stream = client.GetStream(); + byte[] buffer = new byte[1024]; + int numBytesRead; + try + { + while ((numBytesRead = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0) + { + string receivedMessage = Encoding.UTF8.GetString(buffer, 0, numBytesRead); + MessageReceived?.Invoke(client, receivedMessage); + //ms.Log($"[DX86] Message from client: {receivedMessage}"); + BroadcastMessage(receivedMessage, client); + } + } + catch (Exception ex) + { + ms.Error("[DX86] Error handling client: " + ex.Message); + } + finally + { + lock (clientListLock) + { + tcpClients.Remove(client); + } + client.Close(); + ClientDisconnected?.Invoke(client); + ms.Log("[DX86] Client disconnected."); + } + } + + public async Task SendMessageAsync(TcpClient client, string message) + { + try + { + var stream = client.GetStream(); + var buffer = Encoding.UTF8.GetBytes(message); + stream.WriteAsync(buffer, 0, buffer.Length); + } + catch (Exception ex) + { + ms.Error($"[DX86] DX86 Failed to send message to {client.Client.RemoteEndPoint}: {ex.Message}"); + } + } + + public async Task SendUdpMessageAsync(string message, string ipAddress, int port) + { + try + { + var udpClient = new UdpClient(); + var buffer = Encoding.UTF8.GetBytes(message); + await udpClient.SendAsync(buffer, buffer.Length, new IPEndPoint(IPAddress.Parse(ipAddress), port)); + udpClient.Close(); + ms.Log($"[DX86] Sent UDP message to {ipAddress}:{port}"); + } + catch (Exception ex) + { + ms.Error("[DX86] Error sending UDP message: " + ex.Message); + } + } + + public void BroadcastMessage(string message, TcpClient sender) + { + lock (clientListLock) + { + foreach (var client in tcpClients) + { + if (client != sender && client.Connected) + { + try + { + var buffer = Encoding.UTF8.GetBytes(message); + client.GetStream().WriteAsync(buffer, 0, buffer.Length); + } + catch (Exception ex) + { + ms.Error($"[DX86] Failed to send message to {client.Client.RemoteEndPoint}: {ex.Message}"); + } + } + } + } + } + + + public static string GetVersion() + { + return "0.243.554.3 - BETA"; + } + + } +} + +/* +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; + +namespace DX86 +{ + public class DX86 + { + private MessageSender ms; + private TcpListener server; + private List clients = new List(); + + public event Action ClientConnected; + public event Action MessageReceived; + public event Action ClientDisconnected; + + public DX86(MessageSender ms) + { + this.ms = ms; + ms.Log("[DX86] DX86 initialized!"); + } + + public void StartServer(string ipAddress, int port) + { + server = new TcpListener(IPAddress.Parse(ipAddress), port); + server.Start(); + ms.Log($"[DX86] DX86 started on {ipAddress}:{port}"); + AcceptClientsAsync(); + } + + public void StopServer() + { + server.Stop(); // Stop the TcpListener. + + foreach (var client in clients) + { + if (client.Connected) + { + client.Close(); // Disconnect each client. + } + } + clients.Clear(); // Clear the list of clients. + ms.Log("[DX86] DX86 stopped."); + } + + private async Task AcceptClientsAsync() + { + while (true) + { + var client = await server.AcceptTcpClientAsync(); + clients.Add(client); + ClientConnected?.Invoke(client); + ms.Log("[DX86] DX86 Client connected."); + HandleClientAsync(client); + } + } + + private async Task HandleClientAsync(TcpClient client) + { + var stream = client.GetStream(); + var buffer = new byte[1024]; + + try + { + while (true) + { + var byteCount = await stream.ReadAsync(buffer, 0, buffer.Length); + if (byteCount == 0) break; + var message = Encoding.UTF8.GetString(buffer, 0, byteCount); + MessageReceived?.Invoke(client, message); + BroadcastMessage(message, client); + } + } + catch (Exception ex) + { + ms.Error("[DX86] DX86: " + ex.Message); + } + finally + { + clients.Remove(client); + client.Close(); + ClientDisconnected?.Invoke(client); + ms.Log("[DX86] DX86 Client disconnected."); + } + } + + public async Task SendMessageAsync(TcpClient client, string message) + { + try + { + var stream = client.GetStream(); + var buffer = Encoding.UTF8.GetBytes(message); + stream.WriteAsync(buffer, 0, buffer.Length); + } + catch (Exception ex) + { + ms.Error($"[DX86] DX86 Failed to send message to {client.Client.RemoteEndPoint}: {ex.Message}"); + } + } + + private void BroadcastMessage(string message, TcpClient sender) + { + foreach (var client in clients) + { + if (client != sender) + { + try + { + var stream = client.GetStream(); + var buffer = Encoding.UTF8.GetBytes(message); + stream.WriteAsync(buffer, 0, buffer.Length); + } + catch (Exception ex) + { + ms.Error($"[DX86] DX86 Failed to send message to {client.Client.RemoteEndPoint}: {ex.Message}"); + } + } + } + } + } +} + +*/ + +/* +namespace DX86; + +public class DX86 +{ + private MessageSender ms; + + private List clientList; + + public DX86(MessageSender ms) + { + ms.Log("[DX86] Initializing DX86..."); + this.ms = ms; + this.clientList = new List(); + ms.Log("[DX86] DX86 initialized!"); + } + + public void CreateClient() + { + clientList.Add(new Client()); + } + + public int GetClientCount() + { + return clientList.Count; + } + + public Client? GetClient(int id) + { + try + { + return clientList[id]; + } + catch (Exception e) + { + ms.Error("[DX86] Error getting client: " + e.Message); + return null; + } + + } +} +*/ \ No newline at end of file diff --git a/DX86/DX86.csproj b/DX86/DX86.csproj new file mode 100644 index 0000000..a3b8e66 --- /dev/null +++ b/DX86/DX86.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/DX86/Modules/InputBox.cs b/DX86/Modules/InputBox.cs new file mode 100644 index 0000000..a814115 --- /dev/null +++ b/DX86/Modules/InputBox.cs @@ -0,0 +1,63 @@ +namespace DX86.Modules; + +public class InputBox +{ + private MessageSender ms; + + public InputBox(MessageSender ms) + { + this.ms = ms; + ms.Log("[InputBox] InputBox initialized."); + } + + public string ShowAsync(string title, List lines) + { + ms.SaveOnly(true); + Console.Clear(); + string message = ""; + + List longestLine = new List(); + int lineNumber = 0; + + foreach (var line in lines) + { + longestLine.Add(line.Length); + lineNumber++; + } + + longestLine.Add(title.Length + 4); + + int minLength = 50; + + int maxLength = longestLine.Max(); + + if (maxLength < minLength) + { + maxLength = minLength; + } + + string titleBar = new string('-', maxLength); + + Console.WriteLine("+ {0} +", titleBar); + Console.WriteLine("| » {0}{1} |", title, new string(' ', (maxLength - title.Length) - 4)); + Console.WriteLine("+ {0} +", titleBar); + + for (int i = 0; i < lines.Count; i++) + { + Console.WriteLine("| {0}{1} |", lines[i], new string(' ', maxLength - longestLine[i])); + } + + Console.WriteLine("+ {0} +", titleBar); + Console.WriteLine("| {0} |", new string(' ', maxLength)); + Console.WriteLine("+ {0} +", titleBar); + + Console.SetCursorPosition(2, 4+lines.Count); + + string output = Console.ReadLine(); + + ms.SaveOnly(false); + ms.SendHistory(); + + return output; + } +} \ No newline at end of file diff --git a/DX86/Modules/ItemSelector.cs b/DX86/Modules/ItemSelector.cs new file mode 100644 index 0000000..09475f2 --- /dev/null +++ b/DX86/Modules/ItemSelector.cs @@ -0,0 +1,158 @@ +namespace DX86.Modules; +/* + * Copyright 2024 SnapixLP + */ +public class ItemSelector +{ + private MessageSender ms; + public ItemSelector(MessageSender ms) + { + this.ms = ms; + ms.Log("[ItemSelector] ItemSelector initialized"); + } + + private string listTitle = ""; + + public void SetTitle(string title) + { + listTitle = title; + } + public string SelectItemFromList(string[] items) + { + bool noerror = true; + while (noerror) + { + try + { + Console.Clear(); + ms.SaveOnly(true); + int cursorPosition = 1; + int listPosition = 1; + bool running = true; + + while (running) + { + GenerateList(listTitle, items, cursorPosition, listPosition); + ConsoleKeyInfo keyInfo = Console.ReadKey(true); + + switch (keyInfo.Key) + { + case ConsoleKey.UpArrow: + cursorPosition -= 1; + break; + case ConsoleKey.DownArrow: + cursorPosition += 1; + break; + case ConsoleKey.W: + listPosition -= 1; + break; + case ConsoleKey.S: + listPosition += 1; + break; + case ConsoleKey.Enter: + running = false; + break; + case ConsoleKey.F1: + MessageBox mbox = new MessageBox(ms); + mbox.ShowAsync("Help", [ + "Use the Arrow keys to select the items from the list.", + "Press enter to select the items from the list.", + "Press F1 to see this message.", + ]); + break; + } + + if (cursorPosition > items.Length) + { + cursorPosition = 1; + listPosition = 1; + } + + if (cursorPosition < 1) + { + cursorPosition = items.Length; + listPosition = items.Length - 4; + } + + if (listPosition > 1 && cursorPosition - listPosition == 0) + { + listPosition -= 1; + } + if (listPosition < items.Length - 4 && cursorPosition - listPosition == 4) + { + listPosition += 1; + } + + Console.Clear(); + + } + ms.SaveOnly(false); + Console.Clear(); + ms.SendHistory(); + noerror = false; + return items[cursorPosition - 1]; + + } + catch (Exception e) + { + MessageBox messageBox = new MessageBox(ms); + ms.Error("[ItemSelector] [SelectItemFromList()] An Error Occured"); + ms.Error(e.Message); + messageBox.ShowAsync("An error Occured | ItemSelector.cs at SelectItemFromList()", [e.Message, "", "Please try again..."]); + } + } + + return ""; + } + + public static void GenerateList(string title, string[] items, int cursorPostion, int listPosition) + { + //Console.WriteLine($"{cursorPostion}, {listPosition}, {items.Length}, {cursorPostion - listPosition}, {listPosition < items.Length - 4}");; + + + string outMessage = ""; + + string headBar = ""; + for (int i = 1; i <= title.Length; i++) + headBar += "="; + + string titleSpace = ""; + if (headBar.Length - (items[cursorPostion - 1].Length + 14) < 0) + { + // make int from negative to positive + int adjustedLength = Math.Abs(headBar.Length - (items[cursorPostion - 1].Length + 14)); + for (int i = 1; i <= adjustedLength; i++) + { + headBar += "="; + titleSpace += " "; + } + } + + string spaces = ""; + for (int i = 1; i <= headBar.Length - (items[cursorPostion - 1].Length + 14); i++) + spaces += " "; + + outMessage += $"[ {headBar} ]\n"; + outMessage += ($"[ {title}{titleSpace} ]\n"); + outMessage += ($"[ Current Item: {items[cursorPostion-1]} [{cursorPostion}/{items.Length}]{spaces} ]\n"); + outMessage += ($"[ Press \"F1\" for help ]\n"); + outMessage += "\n"; + Console.WriteLine(outMessage); + int b = listPosition - 2; + for (int i = listPosition - 1; i < items.Length && i <= b + 5; i++) + { + if(i == cursorPostion - 1) + { + Console.ForegroundColor = ConsoleColor.DarkGreen; + Console.WriteLine("[" + listPosition + "] " + items[i]); + Console.ResetColor(); + listPosition++; + } + else + { + Console.WriteLine("[" + listPosition + "] " + items[i]); + listPosition++; + } + } + } +} \ No newline at end of file diff --git a/DX86/Modules/MessageBox.cs b/DX86/Modules/MessageBox.cs new file mode 100644 index 0000000..a295ead --- /dev/null +++ b/DX86/Modules/MessageBox.cs @@ -0,0 +1,55 @@ +namespace DX86.Modules; +/* + * Copyright 2024 SnapixLP + */ +public class MessageBox +{ + private MessageSender ms; + + public MessageBox(MessageSender ms) + { + this.ms = ms; + ms.Log("[MessageBox] MessageBox initialized"); + } + + public async Task ShowAsync(string title, List lines) + { + ms.SaveOnly(true); + Console.Clear(); + string message = ""; + + List longestLine = new List(); + int lineNumber = 0; + + foreach (var line in lines) + { + longestLine.Add(line.Length); + lineNumber++; + } + + longestLine.Add(title.Length + 4); + + int maxLength = longestLine.Max(); + + string titleBar = new string('-', maxLength); + + Console.WriteLine("+ {0} +", titleBar); + Console.WriteLine("| » {0}{1} |", title, new string(' ', (maxLength - title.Length) - 4)); + Console.WriteLine("+ {0} +", titleBar); + + for (int i = 0; i < lines.Count; i++) + { + Console.WriteLine("| {0}{1} |", lines[i], new string(' ', maxLength - longestLine[i])); + } + + Console.WriteLine("+ {0} +", titleBar); + + Console.Write(" »» Press any key to continue..."); + Console.ReadKey(); + ms.SaveOnly(false); + ms.SendHistory(); + + return "OK"; + } + +} \ No newline at end of file diff --git a/DX86/Modules/MessageSender.cs b/DX86/Modules/MessageSender.cs new file mode 100644 index 0000000..ee7ea42 --- /dev/null +++ b/DX86/Modules/MessageSender.cs @@ -0,0 +1,95 @@ +namespace DX86.Modules; +/* + * Copyright 2024 SnapixLP + */ +public class MessageSender +{ + private string[] messageHistory = {}; + private bool saveOnly = false; + + private string logfile; + + public MessageSender(string logfile) + { + this.logfile = logfile; + if (!File.Exists(logfile)) + { + File.Create(logfile).Close(); + Log("[MessageSender] Log file created."); + } + Log("[MessageSender] Starting Logoutput to " + logfile); + Log("[MessageSender] MessageSender initialized."); + } + + private async Task WriteToFileAsync(string message) + { + try + { + using (StreamWriter writer = new StreamWriter(logfile, true)) + { + await writer.WriteLineAsync(message); + } + } + catch (Exception ex) + { + Error($"Failed to write to log file: {ex.Message}"); + } + } + + + public async void Log(string message) + { + Console.ForegroundColor = ConsoleColor.Gray; + this.Send($"[{DateTime.Now}] [INFO ] {message}"); + } + public async void Warn(string message) + { + Console.ForegroundColor = ConsoleColor.Yellow; + this.Send($"[{DateTime.Now}] [WARN ] {message}"); + Console.ForegroundColor = ConsoleColor.Gray; + } + public async void Error(string message) + { + Console.ForegroundColor = ConsoleColor.Red; + this.Send($"[{DateTime.Now}] [ERROR] {message}"); + Console.ForegroundColor = ConsoleColor.Gray; + } + + private async void Send(string message) + { + WriteToFileAsync(message); + if (!saveOnly) + { + Console.WriteLine(message); + } + + messageHistory = messageHistory.Concat(new[] { message }).ToArray(); + if (messageHistory.Length > 50) + { + messageHistory = messageHistory.Skip(1).ToArray(); + } + } + + public async void SendHistory() + { + + int i = 0; + foreach (var s in messageHistory) + { + if (s.Contains("[INFO ]")) + Console.ForegroundColor = ConsoleColor.Gray; + if (s.Contains("[WARN ]")) + Console.ForegroundColor = ConsoleColor.Yellow; + if (s.Contains("[ERROR]")) + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"{s}"); + Console.ForegroundColor = ConsoleColor.Gray; + } + } + + public void SaveOnly(bool newValue) + { + saveOnly = newValue; + } + +} \ No newline at end of file diff --git a/DX86/Program.cs b/DX86/Program.cs new file mode 100644 index 0000000..cebc42e --- /dev/null +++ b/DX86/Program.cs @@ -0,0 +1,11 @@ +namespace DX86; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("Welcome to DX86!"); + Console.WriteLine("Please do not run this program as itself."); + Console.WriteLine("DX86 is only a dependency for other programs."); + } +} \ No newline at end of file diff --git a/DX86/TcpServer.cs b/DX86/TcpServer.cs new file mode 100644 index 0000000..7704cc3 --- /dev/null +++ b/DX86/TcpServer.cs @@ -0,0 +1,107 @@ +using System.Net; +using System.Net.Sockets; +using DX86.Modules; + +namespace DX86; +using System.Net.Sockets; + +public abstract class TcpServer +{ + private string address; + private int port; + protected MessageSender ms; + private DX86 dx86; + public List optionsList; + + + public TcpServer(string address, int port, MessageSender ms) + { + ms.Log("[DX86] Setting up server."); + this.address = address; + this.port = port; + this.ms = ms; + optionsList = new List(); + this.dx86 = new DX86(ms, ServerType.TCP); + optionsList.Add("cancel"); + ms.Log("[DX86] Server Setup Complete."); + _ = RunServer(); + } + + + private async Task RunServer() + { + ms.Log("[DX86] Starting server."); + // Subscribe to events + dx86.ClientConnected += ClientConnectEvent; + dx86.MessageReceived += MessageReceivedEvent; + dx86.ClientDisconnected += ClientDisconnectEvent; + + // Start the server + dx86.StartServer(address, port); + ms.Log("[DX86] Server started."); + + // Keep the server running indefinitely + await Task.Delay(Timeout.Infinite); + } + + public void StopServer() + { + ms.Log("[DX86] Got Signal to Stop Server."); + dx86.StopServer(); + ms.Log("[DX86] Server stopped."); + } + + public string GetAddress() + { + return address; + } + + public int GetPort() + { + return port; + } + + public void SendMessageAsync(TcpClient client, string message) + { + dx86.SendMessageAsync(client, message); + } + + public void BroadcastMessageAsync(TcpClient sender, string message) + { + dx86.BroadcastMessage(message, sender); + } + + public IPEndPoint GetClientEndPoint(TcpClient client) + { + if (client == null) + { + return null; + } + + if (!client.Connected) + { + return null; + } + + // Get the remote endpoint, cast it to IPEndPoint + IPEndPoint remoteEndPoint = client.Client.RemoteEndPoint as IPEndPoint; + + if (remoteEndPoint != null) + { + // Return the IP address and port + return remoteEndPoint; + } + + return null; + } + + + public abstract string ToggleOption(string option, string value); + public abstract List> ConfigureOptions(string option); + // Define your event handlers + protected abstract void ClientConnectEvent(TcpClient client); + + protected abstract void MessageReceivedEvent(TcpClient client, string message); + + protected abstract void ClientDisconnectEvent(TcpClient client); +} \ No newline at end of file diff --git a/DX86/UdpServer.cs b/DX86/UdpServer.cs new file mode 100644 index 0000000..8ebdec8 --- /dev/null +++ b/DX86/UdpServer.cs @@ -0,0 +1,71 @@ +using System.Net.Sockets; +using DX86.Modules; + +namespace DX86; +using System.Net.Sockets; + +public abstract class UdpServer +{ + private string address; + private int port; + protected MessageSender ms; + private DX86 dx86; + + + public UdpServer(string address, int port, MessageSender ms) + { + ms.Log("[DX86] Setting up server."); + this.address = address; + this.port = port; + this.ms = ms; + this.dx86 = new DX86(ms, ServerType.UDP); + ms.Log("[DX86] Server Setup Complete."); + _ = RunServer(); + } + + + private async Task RunServer() + { + ms.Log("[DX86] Starting server."); + // Subscribe to events + dx86.ClientConnected += ClientConnectEvent; + dx86.MessageReceived += MessageReceivedEvent; + dx86.ClientDisconnected += ClientDisconnectEvent; + + // Start the server + dx86.StartServer(address, port); + ms.Log("[DX86] Server started."); + + // Keep the server running indefinitely + await Task.Delay(Timeout.Infinite); + } + + public void StopServer() + { + ms.Log("[DX86] Got Signal to Stop Server."); + dx86.StopServer(); + ms.Log("[DX86] Server stopped."); + } + + public string GetAddress() + { + return address; + } + + public int GetPort() + { + return port; + } + + public void SendMessageAsync(TcpClient client, string message) + { + dx86.SendMessageAsync(client, message); + } + + // Define your event handlers + protected abstract void ClientConnectEvent(TcpClient client); + + protected abstract void MessageReceivedEvent(TcpClient client, string message); + + protected abstract void ClientDisconnectEvent(TcpClient client); +} \ No newline at end of file diff --git a/Library/.gitignore b/Library/.gitignore new file mode 100644 index 0000000..156463b --- /dev/null +++ b/Library/.gitignore @@ -0,0 +1,352 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +.vscode/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +/.dotnet +/.packages +/.tools/vswhere/2.5.2 +/.tools/native/iltools + +### OSX ### + +.DS_Store +.AppleDouble +.LSOverride + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Exceptions to the exclusions +!src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/*.rsp +!src/Microsoft.DotNet.Wpf/src/WpfGfx/tools/csp/**/*.rsp + diff --git a/Library/Connection.cs b/Library/Connection.cs new file mode 100644 index 0000000..509e448 --- /dev/null +++ b/Library/Connection.cs @@ -0,0 +1,5 @@ +namespace Library; + +public class Connection +{ +} \ No newline at end of file diff --git a/Library/Library.csproj b/Library/Library.csproj new file mode 100644 index 0000000..3a63532 --- /dev/null +++ b/Library/Library.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/Library/Server.cs b/Library/Server.cs new file mode 100644 index 0000000..a18349b --- /dev/null +++ b/Library/Server.cs @@ -0,0 +1,6 @@ +namespace Library; + +public class Server +{ + +} \ No newline at end of file diff --git a/Library/Worker.cs b/Library/Worker.cs new file mode 100644 index 0000000..c58516a --- /dev/null +++ b/Library/Worker.cs @@ -0,0 +1,6 @@ +namespace Library; + +public class Worker +{ + +} \ No newline at end of file diff --git a/Library/WorkerState.cs b/Library/WorkerState.cs new file mode 100644 index 0000000..21c7f3b --- /dev/null +++ b/Library/WorkerState.cs @@ -0,0 +1,8 @@ +namespace Library; + +public enum WorkerState +{ + WORKING, + BREAK, + AWAY, +} \ No newline at end of file diff --git a/ManagementClient/.gitignore b/ManagementClient/.gitignore new file mode 100644 index 0000000..156463b --- /dev/null +++ b/ManagementClient/.gitignore @@ -0,0 +1,352 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +.vscode/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +/.dotnet +/.packages +/.tools/vswhere/2.5.2 +/.tools/native/iltools + +### OSX ### + +.DS_Store +.AppleDouble +.LSOverride + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Exceptions to the exclusions +!src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/*.rsp +!src/Microsoft.DotNet.Wpf/src/WpfGfx/tools/csp/**/*.rsp + diff --git a/ManagementClient/App.xaml b/ManagementClient/App.xaml new file mode 100644 index 0000000..c6cc29f --- /dev/null +++ b/ManagementClient/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/ManagementClient/App.xaml.cs b/ManagementClient/App.xaml.cs new file mode 100644 index 0000000..f9984af --- /dev/null +++ b/ManagementClient/App.xaml.cs @@ -0,0 +1,12 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace ManagementClient; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : Application +{ +} \ No newline at end of file diff --git a/ManagementClient/AssemblyInfo.cs b/ManagementClient/AssemblyInfo.cs new file mode 100644 index 0000000..4a05c7d --- /dev/null +++ b/ManagementClient/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/ManagementClient/MainWindow.xaml b/ManagementClient/MainWindow.xaml new file mode 100644 index 0000000..8dda31e --- /dev/null +++ b/ManagementClient/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/ManagementClient/MainWindow.xaml.cs b/ManagementClient/MainWindow.xaml.cs new file mode 100644 index 0000000..67f454e --- /dev/null +++ b/ManagementClient/MainWindow.xaml.cs @@ -0,0 +1,23 @@ +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace ManagementClient; + +/// +/// Interaction logic for MainWindow.xaml +/// +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/ManagementClient/ManagementClient.csproj b/ManagementClient/ManagementClient.csproj new file mode 100644 index 0000000..4d75920 --- /dev/null +++ b/ManagementClient/ManagementClient.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net8.0-windows + enable + enable + true + + + + + + + diff --git a/Mitarbeiter-Verwaltung.sln b/Mitarbeiter-Verwaltung.sln new file mode 100644 index 0000000..841ed70 --- /dev/null +++ b/Mitarbeiter-Verwaltung.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "Library\Library.csproj", "{DFFEBB62-43F0-42B5-AB05-5E9EF7EFA386}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagementClient", "ManagementClient\ManagementClient.csproj", "{B170987C-55AA-42E6-8D77-A496D67D2C47}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StempelClient", "StempelClient\StempelClient.csproj", "{4D1140E0-E45C-4EB5-9CD8-B2115B3EEE5B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{1F338FF7-7CD0-4565-B5C4-D84F77A6FDA8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DX86", "DX86\DX86.csproj", "{62C2A1CE-C82A-4588-9CE5-42E8108D8B78}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DFFEBB62-43F0-42B5-AB05-5E9EF7EFA386}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFFEBB62-43F0-42B5-AB05-5E9EF7EFA386}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFFEBB62-43F0-42B5-AB05-5E9EF7EFA386}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFFEBB62-43F0-42B5-AB05-5E9EF7EFA386}.Release|Any CPU.Build.0 = Release|Any CPU + {B170987C-55AA-42E6-8D77-A496D67D2C47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B170987C-55AA-42E6-8D77-A496D67D2C47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B170987C-55AA-42E6-8D77-A496D67D2C47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B170987C-55AA-42E6-8D77-A496D67D2C47}.Release|Any CPU.Build.0 = Release|Any CPU + {4D1140E0-E45C-4EB5-9CD8-B2115B3EEE5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D1140E0-E45C-4EB5-9CD8-B2115B3EEE5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D1140E0-E45C-4EB5-9CD8-B2115B3EEE5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D1140E0-E45C-4EB5-9CD8-B2115B3EEE5B}.Release|Any CPU.Build.0 = Release|Any CPU + {1F338FF7-7CD0-4565-B5C4-D84F77A6FDA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F338FF7-7CD0-4565-B5C4-D84F77A6FDA8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F338FF7-7CD0-4565-B5C4-D84F77A6FDA8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F338FF7-7CD0-4565-B5C4-D84F77A6FDA8}.Release|Any CPU.Build.0 = Release|Any CPU + {62C2A1CE-C82A-4588-9CE5-42E8108D8B78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {62C2A1CE-C82A-4588-9CE5-42E8108D8B78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {62C2A1CE-C82A-4588-9CE5-42E8108D8B78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {62C2A1CE-C82A-4588-9CE5-42E8108D8B78}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Server/.gitignore b/Server/.gitignore new file mode 100644 index 0000000..156463b --- /dev/null +++ b/Server/.gitignore @@ -0,0 +1,352 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +.vscode/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +/.dotnet +/.packages +/.tools/vswhere/2.5.2 +/.tools/native/iltools + +### OSX ### + +.DS_Store +.AppleDouble +.LSOverride + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Exceptions to the exclusions +!src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/*.rsp +!src/Microsoft.DotNet.Wpf/src/WpfGfx/tools/csp/**/*.rsp + diff --git a/Server/BackendServer.cs b/Server/BackendServer.cs new file mode 100644 index 0000000..1930583 --- /dev/null +++ b/Server/BackendServer.cs @@ -0,0 +1,54 @@ +using System.Net.Sockets; +using DX86.Modules; + +namespace Server; + +public class BackendServer : DX86.TcpServer +{ + CommandManager _CommandManager; + public BackendServer(string address, int port, MessageSender ms) : base(address, port, ms) + { + ms.Log("[BACKENDSERVER] Setting up server."); + _CommandManager = new CommandManager(); + ms.Log("[BACKENDSERVER] Server Setup Complete."); + } + + public override string ToggleOption(string option, string value) + { + throw new NotImplementedException(); + } + + public override List> ConfigureOptions(string option) + { + throw new NotImplementedException(); + } + + protected override void ClientConnectEvent(TcpClient client) + { + ms.Log("[BACKENDSERVER] Client connected: " + client.Client.RemoteEndPoint); + } + + protected override void MessageReceivedEvent(TcpClient client, string message) + { + ms.Log("[BACKENDSERVER] Message received from client: " + message); + if (message.StartsWith(".")) + { + handleCommand(cmd: message, client: client); + + } + } + + protected override void ClientDisconnectEvent(TcpClient client) + { + throw new NotImplementedException(); + } + + private void handleCommand(string cmd, TcpClient client) + { + string[] args = cmd.Split(' '); + string command = args[0].Substring(1); // Remove the leading dot + string[] commandArgs = args.Skip(1).ToArray(); // Get the arguments after the command + + + } +} \ No newline at end of file diff --git a/Server/CommandManager.cs b/Server/CommandManager.cs new file mode 100644 index 0000000..82c2be8 --- /dev/null +++ b/Server/CommandManager.cs @@ -0,0 +1,44 @@ +using System.Reflection; +using Server.Commands; + +namespace Server; + +public class CommandManager +{ + private readonly Dictionary _commands = new(); + + public CommandManager() + { + LoadCommands(); + } + + private void LoadCommands() + { + // Get all types implementing ICommand + var commandTypes = Assembly.GetExecutingAssembly() + .GetTypes() + .Where(t => typeof(ICommand).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract); + + foreach (var type in commandTypes) + { + // Create an instance of the command + if (Activator.CreateInstance(type) is ICommand command) + { + // Use the Executor property as the key + _commands[command.Executor] = command; + } + } + } + + public void ExecuteCommand(string executor, params string[] args) + { + if (_commands.TryGetValue(executor, out var command)) + { + command.Exec(args); + } + else + { + Console.WriteLine($"Command '{executor}' not found."); + } + } +} \ No newline at end of file diff --git a/Server/Commands/ICommand.cs b/Server/Commands/ICommand.cs new file mode 100644 index 0000000..6532034 --- /dev/null +++ b/Server/Commands/ICommand.cs @@ -0,0 +1,10 @@ +using System.Net.Sockets; +using DX86; + +namespace Server.Commands; + +public interface ICommand +{ + string Executor { get; } + public void Exec(string[] args, TcpClient? client = null, TcpServer? clientSocket = null); +} \ No newline at end of file diff --git a/Server/MySQL.cs b/Server/MySQL.cs new file mode 100644 index 0000000..148b216 --- /dev/null +++ b/Server/MySQL.cs @@ -0,0 +1,242 @@ +using System; +using System.Collections.Generic; +using System.Data; +using DX86.Modules; +using MySql.Data.MySqlClient; +using Newtonsoft.Json; + +namespace Server +{ + public class MySQL + { + private MySqlConnection _connection; + private MessageSender ms; + + public MySQL(string username, string password, string server, string database, MessageSender ms) + { + this.ms = ms; + ms.Log("[MySQL] Initializing connection..."); + string connectionString = $"Server={server};Database={database};User ID={username};Password={password};"; + _connection = new MySqlConnection(connectionString); + ms.Log("[MySQL] Connection to database..."); + + try + { + _connection.Open(); + ms.Log("[MySQL] Connection established."); + } + catch (Exception ex) + { + ms.Error("[MySQL] Connection failed: " + ex.Message); + ms.Error("[MySQL] Please check your connection settings."); + ms.Error("[MySQL] Make sure the MySQL server is running and accessible."); + ms.Error("[MySQL] A MySQL Connection is necessary to run this application."); + ms.Error("[MySQL] Exiting..."); + Environment.Exit(1); + } + } + + private string JsonResponse(object data, bool error = false) + { + return JsonConvert.SerializeObject(new { error, data }); + } + + private string GetType(object value) + { + return value switch + { + int => "i", + float or double => "d", + string => "s", + _ => "b" + }; + } + + public string Insert(string table, Dictionary data) + { + string columns = string.Join(", ", data.Keys); + string placeholders = string.Join(", ", new string[data.Count].Select(_ => "?")); + + string sql = $"INSERT INTO `{table}` ({columns}) VALUES ({placeholders})"; + using var cmd = new MySqlCommand(sql, _connection); + + string types = ""; + foreach (var value in data.Values) + { + types += GetType(value); + cmd.Parameters.AddWithValue(null, value); + } + + try + { + cmd.ExecuteNonQuery(); + long insertId = cmd.LastInsertedId; + return JsonResponse(new { insert_id = insertId }); + } + catch (Exception ex) + { + return JsonResponse($"Execute failed: {ex.Message}", true); + } + } + + public string Get(string table, Dictionary parameters = null, int? limit = null, int? offset = null) + { + string sql = $"SELECT * FROM `{table}`"; + string types = ""; + var values = new List(); + + if (parameters != null && parameters.Count > 0) + { + var conditions = new List(); + foreach (var param in parameters) + { + conditions.Add($"`{param.Key}` = ?"); + types += GetType(param.Value); + values.Add(param.Value); + } + sql += " WHERE " + string.Join(" AND ", conditions); + } + + if (limit.HasValue) + { + sql += " LIMIT ?"; + types += "i"; + values.Add(limit.Value); + if (offset.HasValue) + { + sql += " OFFSET ?"; + types += "i"; + values.Add(offset.Value); + } + } + + using var cmd = new MySqlCommand(sql, _connection); + for (int i = 0; i < values.Count; i++) + { + cmd.Parameters.AddWithValue(null, values[i]); + } + + try + { + using var reader = cmd.ExecuteReader(); + var data = new List>(); + while (reader.Read()) + { + var row = new Dictionary(); + for (int i = 0; i < reader.FieldCount; i++) + { + row[reader.GetName(i)] = reader.GetValue(i); + } + data.Add(row); + } + return JsonResponse(data); + } + catch (Exception ex) + { + return JsonResponse($"Execute failed: {ex.Message}", true); + } + } + + public string Update(string table, Dictionary data, Dictionary where) + { + var setClauses = new List(); + var whereClauses = new List(); + string types = ""; + var values = new List(); + + foreach (var item in data) + { + setClauses.Add($"`{item.Key}` = ?"); + types += GetType(item.Value); + values.Add(item.Value); + } + + foreach (var condition in where) + { + whereClauses.Add($"`{condition.Key}` = ?"); + types += GetType(condition.Value); + values.Add(condition.Value); + } + + string sql = $"UPDATE `{table}` SET {string.Join(", ", setClauses)} WHERE {string.Join(" AND ", whereClauses)}"; + using var cmd = new MySqlCommand(sql, _connection); + for (int i = 0; i < values.Count; i++) + { + cmd.Parameters.AddWithValue(null, values[i]); + } + + try + { + int affectedRows = cmd.ExecuteNonQuery(); + return JsonResponse(new { affected_rows = affectedRows }); + } + catch (Exception ex) + { + return JsonResponse($"Execute failed: {ex.Message}", true); + } + } + + public string Delete(string table, Dictionary where) + { + var whereClauses = new List(); + string types = ""; + var values = new List(); + + foreach (var condition in where) + { + whereClauses.Add($"`{condition.Key}` = ?"); + types += GetType(condition.Value); + values.Add(condition.Value); + } + + string sql = $"DELETE FROM `{table}` WHERE {string.Join(" AND ", whereClauses)}"; + using var cmd = new MySqlCommand(sql, _connection); + for (int i = 0; i < values.Count; i++) + { + cmd.Parameters.AddWithValue(null, values[i]); + } + + try + { + int affectedRows = cmd.ExecuteNonQuery(); + return JsonResponse(new { affected_rows = affectedRows }); + } + catch (Exception ex) + { + return JsonResponse($"Execute failed: {ex.Message}", true); + } + } + + public string Query(string sql, string types = null, List values = null) + { + using var cmd = new MySqlCommand(sql, _connection); + if (types != null && values != null) + { + for (int i = 0; i < values.Count; i++) + { + cmd.Parameters.AddWithValue(null, values[i]); + } + } + + try + { + using var reader = cmd.ExecuteReader(); + var data = new List>(); + while (reader.Read()) + { + var row = new Dictionary(); + for (int i = 0; i < reader.FieldCount; i++) + { + row[reader.GetName(i)] = reader.GetValue(i); + } + data.Add(row); + } + return JsonResponse(data); + } + catch (Exception ex) + { + return JsonResponse($"Query failed: {ex.Message}", true); + } + } + } +} \ No newline at end of file diff --git a/Server/Program.cs b/Server/Program.cs new file mode 100644 index 0000000..eadb753 --- /dev/null +++ b/Server/Program.cs @@ -0,0 +1,34 @@ +using DX86.Modules; +using Library; + +namespace Server; + +class Program +{ + public static MessageSender messageSender; + public static MessageBox messageBox; + public static InputBox inputBox; + public static ItemSelector itemSelector; + public static MySQL mySql; + + static void Main(string[] args) + { + Console.WriteLine("Initializing server..."); + // Initialize the server components + messageSender = new MessageSender("log.txt"); + messageBox = new MessageBox(messageSender); + inputBox = new InputBox(messageSender); + itemSelector = new ItemSelector(messageSender); + + // Connect to the database + //mySql = new MySQL("username", "password", "localhost", "database", messageSender); + + // Start the server + + messageBox.ShowAsync("Server started", ["LOL","Laurenz Stinkt xd"]); + string name = inputBox.ShowAsync("Test", ["type your name "]); + + messageBox.ShowAsync("Welcome", ["Hello " + name]); + + } +} \ No newline at end of file diff --git a/Server/Server.csproj b/Server/Server.csproj new file mode 100644 index 0000000..88b21cf --- /dev/null +++ b/Server/Server.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + + + diff --git a/StempelClient/.gitignore b/StempelClient/.gitignore new file mode 100644 index 0000000..156463b --- /dev/null +++ b/StempelClient/.gitignore @@ -0,0 +1,352 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +.vscode/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +/.dotnet +/.packages +/.tools/vswhere/2.5.2 +/.tools/native/iltools + +### OSX ### + +.DS_Store +.AppleDouble +.LSOverride + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Exceptions to the exclusions +!src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/*.rsp +!src/Microsoft.DotNet.Wpf/src/WpfGfx/tools/csp/**/*.rsp + diff --git a/StempelClient/App.xaml b/StempelClient/App.xaml new file mode 100644 index 0000000..49b85a0 --- /dev/null +++ b/StempelClient/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/StempelClient/App.xaml.cs b/StempelClient/App.xaml.cs new file mode 100644 index 0000000..00644c4 --- /dev/null +++ b/StempelClient/App.xaml.cs @@ -0,0 +1,12 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace StempelClient; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : Application +{ +} \ No newline at end of file diff --git a/StempelClient/AssemblyInfo.cs b/StempelClient/AssemblyInfo.cs new file mode 100644 index 0000000..4a05c7d --- /dev/null +++ b/StempelClient/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/StempelClient/MainWindow.xaml b/StempelClient/MainWindow.xaml new file mode 100644 index 0000000..7a05d8b --- /dev/null +++ b/StempelClient/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/StempelClient/MainWindow.xaml.cs b/StempelClient/MainWindow.xaml.cs new file mode 100644 index 0000000..6939a90 --- /dev/null +++ b/StempelClient/MainWindow.xaml.cs @@ -0,0 +1,23 @@ +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace StempelClient; + +/// +/// Interaction logic for MainWindow.xaml +/// +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/StempelClient/StempelClient.csproj b/StempelClient/StempelClient.csproj new file mode 100644 index 0000000..4d75920 --- /dev/null +++ b/StempelClient/StempelClient.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net8.0-windows + enable + enable + true + + + + + + +