Compare commits
No commits in common. "v1.0.0" and "main" have entirely different histories.
9 changed files with 117 additions and 35 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,6 +2,7 @@
|
|||
bin/
|
||||
obj/
|
||||
publish/
|
||||
*.zip
|
||||
|
||||
# Skripte aus publish/ im Root behalten
|
||||
!install-service.ps1
|
||||
|
|
|
|||
22
Directory.Build.props
Normal file
22
Directory.Build.props
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<SelfContained>true</SelfContained>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<!-- Version aus Git-Tag lesen: git tag v1.2.3 → Version 1.2.3 -->
|
||||
<GitVersion Condition="'$(GitVersion)' == ''">$([System.String]::Copy('1.0.0'))</GitVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="SetVersionFromGit" BeforeTargets="GetAssemblyVersion;Build;Publish">
|
||||
<Exec Command="git describe --tags --abbrev=0 2>nul" ConsoleToMSBuild="true" IgnoreExitCode="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="GitTagRaw" />
|
||||
</Exec>
|
||||
<PropertyGroup>
|
||||
<!-- v1.2.3 → 1.2.3 -->
|
||||
<GitTagClean>$(GitTagRaw.TrimStart('v').Trim())</GitTagClean>
|
||||
<Version Condition="'$(GitTagClean)' != ''">$(GitTagClean)</Version>
|
||||
<AssemblyVersion Condition="'$(GitTagClean)' != ''">$(GitTagClean).0</AssemblyVersion>
|
||||
<FileVersion Condition="'$(GitTagClean)' != ''">$(GitTagClean).0</FileVersion>
|
||||
</PropertyGroup>
|
||||
<Message Text="Build-Version: $(Version)" Importance="high" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
@ -8,9 +8,10 @@
|
|||
<RootNamespace>MailPrint</RootNamespace>
|
||||
<AssemblyName>MailPrint</AssemblyName>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Version>1.0.0</Version>
|
||||
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||
<FileVersion>1.0.0.0</FileVersion>
|
||||
<SelfContained>true</SelfContained>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,34 @@ try
|
|||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
c.SwaggerDoc("v1", new() { Title = "MailPrint API", Version = "v1" }));
|
||||
{
|
||||
c.SwaggerDoc("v1", new() { Title = "MailPrint API", Version = "v1" });
|
||||
|
||||
// XML-Doku aus /// Kommentaren in OpenAPI uebernehmen
|
||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, "MailPrint.xml");
|
||||
if (File.Exists(xmlPath))
|
||||
c.IncludeXmlComments(xmlPath);
|
||||
|
||||
// API-Key-Security im Schema dokumentieren -> generierte Clients
|
||||
// setzen den Header automatisch, Swagger UI hat Authorize-Button
|
||||
var scheme = new Microsoft.OpenApi.Models.OpenApiSecurityScheme
|
||||
{
|
||||
Name = "X-Api-Key",
|
||||
Type = Microsoft.OpenApi.Models.SecuritySchemeType.ApiKey,
|
||||
In = Microsoft.OpenApi.Models.ParameterLocation.Header,
|
||||
Description = "API-Key fuer alle /api/* Endpunkte. Konfiguriert in MailPrintConfig.",
|
||||
Reference = new Microsoft.OpenApi.Models.OpenApiReference
|
||||
{
|
||||
Type = Microsoft.OpenApi.Models.ReferenceType.SecurityScheme,
|
||||
Id = "ApiKey"
|
||||
}
|
||||
};
|
||||
c.AddSecurityDefinition("ApiKey", scheme);
|
||||
c.AddSecurityRequirement(new Microsoft.OpenApi.Models.OpenApiSecurityRequirement
|
||||
{
|
||||
[scheme] = Array.Empty<string>()
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseSwagger();
|
||||
|
|
|
|||
|
|
@ -8,13 +8,14 @@
|
|||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<RootNamespace>MailPrintConfig</RootNamespace>
|
||||
<AssemblyName>MailPrintConfig</AssemblyName>
|
||||
<Version>1.0.0</Version>
|
||||
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||
<FileVersion>1.0.0.0</FileVersion>
|
||||
<SelfContained>true</SelfContained>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -491,6 +491,17 @@ public class MainForm : Form
|
|||
?? Path.Combine(AppContext.BaseDirectory, "appsettings.json");
|
||||
}
|
||||
|
||||
private static bool IsServiceRunning()
|
||||
{
|
||||
try
|
||||
{
|
||||
var svc = System.ServiceProcess.ServiceController.GetServices()
|
||||
.FirstOrDefault(s => s.ServiceName == ServiceName);
|
||||
return svc?.Status == System.ServiceProcess.ServiceControllerStatus.Running;
|
||||
}
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
private void BrowseFolder(int rowIndex)
|
||||
{
|
||||
string? result = null;
|
||||
|
|
@ -714,6 +725,23 @@ public class MainForm : Form
|
|||
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
||||
File.WriteAllText(path, root.ToString(Formatting.Indented));
|
||||
SetStatus($"Gespeichert: {path}", Color.DarkGreen);
|
||||
|
||||
// Dienst-Neustart anbieten wenn Dienst läuft
|
||||
if (IsServiceRunning())
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
"Konfiguration gespeichert.\n\nDienst jetzt neu starten um Änderungen zu übernehmen?",
|
||||
"Dienst neu starten?",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_ = ServiceActionAsync("stop").ContinueWith(async _ =>
|
||||
{
|
||||
await Task.Delay(1500);
|
||||
await ServiceActionAsync("start");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { SetStatus($"Fehler: {ex.Message}", Color.Red); }
|
||||
}
|
||||
|
|
@ -787,8 +815,8 @@ public class MainForm : Form
|
|||
{
|
||||
var publishDir = Path.GetDirectoryName(txtConfigPath.Text) ?? AppContext.BaseDirectory;
|
||||
var exePath = Path.Combine(publishDir, "MailPrint.exe");
|
||||
var installPs = Path.Combine(publishDir, "..", "install-service.ps1");
|
||||
var uninstallPs= Path.Combine(publishDir, "..", "uninstall-service.ps1");
|
||||
var installPs = Path.Combine(publishDir, "install-service.ps1");
|
||||
var uninstallPs = Path.Combine(publishDir, "uninstall-service.ps1");
|
||||
|
||||
// Bestätigung nur bei Install/Deinstall
|
||||
if (action is "install" or "uninstall")
|
||||
|
|
@ -818,12 +846,13 @@ public class MainForm : Form
|
|||
{
|
||||
FileName = "powershell",
|
||||
Arguments = $"-NoProfile -NonInteractive {cmd}",
|
||||
UseShellExecute = true,
|
||||
Verb = "runas",
|
||||
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardError = true
|
||||
};
|
||||
|
||||
using var p = System.Diagnostics.Process.Start(psi)!;
|
||||
string err = await p.StandardError.ReadToEndAsync();
|
||||
await p.WaitForExitAsync();
|
||||
|
||||
if (p.ExitCode == 0)
|
||||
|
|
@ -840,7 +869,7 @@ public class MainForm : Form
|
|||
MessageBox.Show(successMsg, "Erfolgreich", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
SetStatus($"'{action}' fehlgeschlagen (Code {p.ExitCode})", Color.Red);
|
||||
SetStatus($"'{action}' fehlgeschlagen (Code {p.ExitCode}): {err.Trim()}", Color.Red);
|
||||
}
|
||||
catch (Exception ex) { SetStatus($"Fehler: {ex.Message}", Color.Red); }
|
||||
finally { DisableServiceButtons(false); RefreshStartStop(); }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
using MailPrintConfig;
|
||||
|
||||
class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
MailPrintConfig/app.manifest
Normal file
11
MailPrintConfig/app.manifest
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MailPrintConfig.exe"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
17
build.bat
17
build.bat
|
|
@ -1,17 +0,0 @@
|
|||
@echo off
|
||||
setlocal
|
||||
set PROJ=C:\Users\janwu\OneDrive - dimedtec GmbH\Programmierung\MailPrint\MailPrint\MailPrint.csproj
|
||||
dotnet restore "%PROJ%"
|
||||
if errorlevel 1 goto :err
|
||||
dotnet build "%PROJ%" -c Release
|
||||
if errorlevel 1 goto :err
|
||||
dotnet publish "%PROJ%" -c Release -r win-x64 --self-contained false -o "C:\Users\janwu\OneDrive - dimedtec GmbH\Programmierung\MailPrint\publish"
|
||||
if errorlevel 1 goto :err
|
||||
echo.
|
||||
echo === BUILD ERFOLGREICH ===
|
||||
goto :end
|
||||
:err
|
||||
echo.
|
||||
echo === BUILD FEHLGESCHLAGEN ===
|
||||
exit /b 1
|
||||
:end
|
||||
Loading…
Add table
Add a link
Reference in a new issue