generated from pi-ux-ce/dotnet_build
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
<appSettings>
|
||||||
|
<add key="_keycloak" value="keycloak"/>
|
||||||
|
<add key="_posftgresql" value="postgresql"/>
|
||||||
|
<add key="_apigateway" value="api-gateway"/>
|
||||||
|
<add key="_turnaroundservice" value="TurnaroundService.api"/>
|
||||||
|
<add key="_frontend" value="frontend"/>
|
||||||
|
<add key="_reportsworker" value="ReportsWorker.Api"/>
|
||||||
|
<add key="_dashboardsworker" value="DashboardsWorker.Api"/>
|
||||||
|
<add key="_primaveraconnector" value="PrimaveraWorker.Api"/>
|
||||||
|
<add key="_sapworker" value="SapWorker.Api"/>
|
||||||
|
<add key="_nginx" value="nginx"/>
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
||||||
Generated
+181
@@ -0,0 +1,181 @@
|
|||||||
|
namespace PrometheusServiceManager;
|
||||||
|
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||||
|
buttonRestart = new System.Windows.Forms.Button();
|
||||||
|
buttonStop = new System.Windows.Forms.Button();
|
||||||
|
buttonStart = new System.Windows.Forms.Button();
|
||||||
|
KeycloakCheckBox = new System.Windows.Forms.CheckBox();
|
||||||
|
TextDisplay = new System.Windows.Forms.Label();
|
||||||
|
PostgresqlCheckbox = new System.Windows.Forms.CheckBox();
|
||||||
|
VersionLabel = new System.Windows.Forms.Label();
|
||||||
|
label1 = new System.Windows.Forms.Label();
|
||||||
|
label2 = new System.Windows.Forms.Label();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonRestart
|
||||||
|
//
|
||||||
|
buttonRestart.Location = new System.Drawing.Point(220, 184);
|
||||||
|
buttonRestart.Name = "buttonRestart";
|
||||||
|
buttonRestart.Size = new System.Drawing.Size(144, 55);
|
||||||
|
buttonRestart.TabIndex = 0;
|
||||||
|
buttonRestart.Text = "Restart services";
|
||||||
|
buttonRestart.UseVisualStyleBackColor = true;
|
||||||
|
buttonRestart.Click += buttonRestart_Click;
|
||||||
|
//
|
||||||
|
// buttonStop
|
||||||
|
//
|
||||||
|
buttonStop.Location = new System.Drawing.Point(440, 184);
|
||||||
|
buttonStop.Name = "buttonStop";
|
||||||
|
buttonStop.Size = new System.Drawing.Size(118, 55);
|
||||||
|
buttonStop.TabIndex = 1;
|
||||||
|
buttonStop.Text = "Stop services";
|
||||||
|
buttonStop.UseVisualStyleBackColor = true;
|
||||||
|
buttonStop.Click += buttonStop_Click;
|
||||||
|
//
|
||||||
|
// buttonStart
|
||||||
|
//
|
||||||
|
buttonStart.Location = new System.Drawing.Point(644, 184);
|
||||||
|
buttonStart.Name = "buttonStart";
|
||||||
|
buttonStart.Size = new System.Drawing.Size(144, 55);
|
||||||
|
buttonStart.TabIndex = 2;
|
||||||
|
buttonStart.Text = "Start services";
|
||||||
|
buttonStart.UseVisualStyleBackColor = true;
|
||||||
|
buttonStart.Click += buttonStart_Click;
|
||||||
|
//
|
||||||
|
// KeycloakCheckBox
|
||||||
|
//
|
||||||
|
KeycloakCheckBox.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
KeycloakCheckBox.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
KeycloakCheckBox.Location = new System.Drawing.Point(52, 254);
|
||||||
|
KeycloakCheckBox.Name = "KeycloakCheckBox";
|
||||||
|
KeycloakCheckBox.Size = new System.Drawing.Size(182, 25);
|
||||||
|
KeycloakCheckBox.TabIndex = 3;
|
||||||
|
KeycloakCheckBox.Text = "keycloak restart";
|
||||||
|
KeycloakCheckBox.UseVisualStyleBackColor = false;
|
||||||
|
KeycloakCheckBox.CheckedChanged += KeycloakCheckBoxCheckedChanged;
|
||||||
|
//
|
||||||
|
// TextDisplay
|
||||||
|
//
|
||||||
|
TextDisplay.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
TextDisplay.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)0));
|
||||||
|
TextDisplay.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
TextDisplay.Location = new System.Drawing.Point(396, 391);
|
||||||
|
TextDisplay.Name = "TextDisplay";
|
||||||
|
TextDisplay.Size = new System.Drawing.Size(439, 93);
|
||||||
|
TextDisplay.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// PostgresqlCheckbox
|
||||||
|
//
|
||||||
|
PostgresqlCheckbox.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
PostgresqlCheckbox.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
PostgresqlCheckbox.Location = new System.Drawing.Point(52, 314);
|
||||||
|
PostgresqlCheckbox.Name = "PostgresqlCheckbox";
|
||||||
|
PostgresqlCheckbox.Size = new System.Drawing.Size(182, 25);
|
||||||
|
PostgresqlCheckbox.TabIndex = 6;
|
||||||
|
PostgresqlCheckbox.Text = "PostgreSQL restart";
|
||||||
|
PostgresqlCheckbox.UseVisualStyleBackColor = false;
|
||||||
|
PostgresqlCheckbox.CheckedChanged += PostgresqlCheckboxCheckedChanged;
|
||||||
|
//
|
||||||
|
// VersionLabel
|
||||||
|
//
|
||||||
|
VersionLabel.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
VersionLabel.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)0));
|
||||||
|
VersionLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
VersionLabel.Location = new System.Drawing.Point(924, 581);
|
||||||
|
VersionLabel.Name = "VersionLabel";
|
||||||
|
VersionLabel.Size = new System.Drawing.Size(65, 35);
|
||||||
|
VersionLabel.TabIndex = 7;
|
||||||
|
VersionLabel.Text= Program.version;
|
||||||
|
VersionLabel.Update();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
label1.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)0));
|
||||||
|
label1.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
label1.Location = new System.Drawing.Point(287, 272);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new System.Drawing.Size(439, 93);
|
||||||
|
label1.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
label2.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)0));
|
||||||
|
label2.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
|
label2.Location = new System.Drawing.Point(295, 280);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new System.Drawing.Size(439, 93);
|
||||||
|
label2.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
BackgroundImage = ((System.Drawing.Image)resources.GetObject("$this.BackgroundImage"));
|
||||||
|
BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
ClientSize = new System.Drawing.Size(1013, 636);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(VersionLabel);
|
||||||
|
Controls.Add(PostgresqlCheckbox);
|
||||||
|
Controls.Add(TextDisplay);
|
||||||
|
Controls.Add(KeycloakCheckBox);
|
||||||
|
Controls.Add(buttonStart);
|
||||||
|
Controls.Add(buttonStop);
|
||||||
|
Controls.Add(buttonRestart);
|
||||||
|
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||||
|
Icon = ((System.Drawing.Icon)resources.GetObject("$this.Icon"));
|
||||||
|
MinimizeBox = false;
|
||||||
|
Text = "Services manager";
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.Label label2;
|
||||||
|
|
||||||
|
public static System.Windows.Forms.Label VersionLabel;
|
||||||
|
|
||||||
|
private System.Windows.Forms.CheckBox PostgresqlCheckbox;
|
||||||
|
|
||||||
|
public static System.Windows.Forms.Label TextDisplay;
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonRestart;
|
||||||
|
|
||||||
|
public static System.Windows.Forms.CheckBox KeycloakCheckBox;
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonStart;
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonStop;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
namespace PrometheusServiceManager;
|
||||||
|
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
private void buttonStart_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
Program.StartServices();
|
||||||
|
//Console.WriteLine("Button start pressed");
|
||||||
|
}
|
||||||
|
private void buttonRestart_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Program.RestartServices(true);
|
||||||
|
//Console.WriteLine("Button restart pressed");
|
||||||
|
}
|
||||||
|
private void buttonStop_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Program.ShutdownServices(true);
|
||||||
|
//Console.WriteLine("Button stop pressed");
|
||||||
|
}
|
||||||
|
private void KeycloakCheckBoxCheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PostgresqlCheckboxCheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
+21667
File diff suppressed because it is too large
Load Diff
+181
-4
@@ -1,11 +1,188 @@
|
|||||||
namespace dotnet_build;
|
using System.Configuration;
|
||||||
|
using System.Configuration.Internal;
|
||||||
|
//using Microsoft.Extensions.Configuration;
|
||||||
|
namespace PrometheusServiceManager;
|
||||||
|
using System.ServiceProcess;
|
||||||
|
|
||||||
class Program
|
|
||||||
|
// versions
|
||||||
|
// V1 main release to customers system
|
||||||
|
// V1.1 adding the Administrator option at the start
|
||||||
|
// cancelled as the program would crash , to be investigated
|
||||||
|
// V1.2 displaying starting complete 2025/10/15
|
||||||
|
static class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
private static readonly Dictionary<string,string> ServicesList = ConfigurationManager.AppSettings.AllKeys.ToDictionary(key => key, key => ConfigurationManager.AppSettings[key]);
|
||||||
|
public static bool KeycloakHidden = true;
|
||||||
|
public static bool PostgreSqlHidden = true;
|
||||||
|
|
||||||
|
public static readonly string version = "V1.2";
|
||||||
|
|
||||||
|
[STAThread]
|
||||||
|
|
||||||
|
private static void StartService(string serviceName, int timeoutMilliseconds)
|
||||||
{
|
{
|
||||||
Console.WriteLine("hello world");
|
ServiceController service = new ServiceController(serviceName);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
|
||||||
|
|
||||||
|
service.Start();
|
||||||
|
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void StopService(string serviceName, int timeoutMilliseconds)
|
||||||
|
{
|
||||||
|
ServiceController service = new ServiceController(serviceName);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
|
||||||
|
|
||||||
|
service.Stop();
|
||||||
|
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void StartServices()
|
||||||
|
{
|
||||||
|
if(!Form1.KeycloakCheckBox.Checked)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Keycloak unchecked");
|
||||||
|
ServicesList.Remove("_keycloak");
|
||||||
|
Form1.KeycloakCheckBox.Visible = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<string,string> Service in ServicesList)
|
||||||
|
{
|
||||||
|
|
||||||
|
//Console.WriteLine("checked: "+Form1.KeycloakCheckBox.Checked);
|
||||||
|
//write the service name in the log
|
||||||
|
Console.WriteLine("Starting: "+Service.Key);
|
||||||
|
//start the service
|
||||||
|
StartService(Service.Key, 1000);
|
||||||
|
//update the text box
|
||||||
|
Form1.TextDisplay.Text = "Starting: "+Service.Key;
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
//wait 1 second before
|
||||||
|
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||||
|
|
||||||
|
//displaying end of operation
|
||||||
|
Form1.TextDisplay.Text = "Starting complete ! ";
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void ShutdownServices(bool keycloakRestartRequired)
|
||||||
|
{
|
||||||
|
if(!Form1.KeycloakCheckBox.Checked)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Keycloak unchecked");
|
||||||
|
ServicesList.Remove("_keycloak");
|
||||||
|
Form1.KeycloakCheckBox.Visible = false;
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
|
||||||
|
{
|
||||||
|
//write the service name in the log
|
||||||
|
Console.WriteLine("Stopping: "+Service.Key);
|
||||||
|
//start the service
|
||||||
|
StopService(Service.Key, 1000);
|
||||||
|
//update the text box
|
||||||
|
Form1.TextDisplay.Text = "Stopping: "+Service.Key;
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
//wait 1 second before
|
||||||
|
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||||
|
|
||||||
|
//displaying end of operation
|
||||||
|
Form1.TextDisplay.Text = "Stopping complete ! ";
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void RestartServices(bool keycloakRestartRequired)
|
||||||
|
{
|
||||||
|
if(!Form1.KeycloakCheckBox.Checked)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Keycloak unchecked");
|
||||||
|
ServicesList.Remove("_keycloak");
|
||||||
|
Form1.KeycloakCheckBox.Visible = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
//stop section
|
||||||
|
foreach (KeyValuePair<string,string> Service in ServicesList.Reverse())
|
||||||
|
{
|
||||||
|
//write the service name in the log
|
||||||
|
Console.WriteLine("Stopping: "+Service.Key);
|
||||||
|
//stop the service
|
||||||
|
StopService(Service.Key, 1000);
|
||||||
|
//update the text box
|
||||||
|
Form1.TextDisplay.Text = "Stopping: "+Service.Key;
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
//wait 1 second before
|
||||||
|
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||||
|
|
||||||
|
//displaying end of operation
|
||||||
|
Form1.TextDisplay.Text = "Stopping complete ! ";
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Form1.TextDisplay.Text = "Stopping Complete, waiting... ";
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
//wait 3 second before
|
||||||
|
Thread.Sleep(TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
|
//start section
|
||||||
|
foreach (KeyValuePair<string,string> Service in ServicesList)
|
||||||
|
{
|
||||||
|
//write the service name in the log
|
||||||
|
Console.WriteLine("Starting: "+Service.Key);
|
||||||
|
//start the service
|
||||||
|
StartService(Service.Key, 1000);
|
||||||
|
//update the text box
|
||||||
|
Form1.TextDisplay.Text = "Starting: "+Service.Key;
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
//wait 1 second before
|
||||||
|
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||||
|
|
||||||
|
//displaying end of operation
|
||||||
|
Form1.TextDisplay.Text = "Starting complete ! ";
|
||||||
|
Form1.TextDisplay.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
|
||||||
|
if (ServicesList.ContainsKey("_keycloak"))
|
||||||
|
{
|
||||||
|
Program.KeycloakHidden = false;
|
||||||
|
Console.WriteLine("keycloak is there");
|
||||||
|
}
|
||||||
|
if (ServicesList.ContainsKey("_postgresql"))
|
||||||
|
{
|
||||||
|
Program.PostgreSqlHidden = false;
|
||||||
|
Console.WriteLine("postgresql is there");
|
||||||
|
}
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new Form1());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<ApplicationIcon>webclip_webclip-Photoroom.ico</ApplicationIcon>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.7.25380.108" />
|
||||||
|
<PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.0-preview.5.25277.114" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 171 KiB |
Binary file not shown.
Reference in New Issue
Block a user