From 50249ede6e568755ae8c7d46c08c925dd4c79d2d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 26 Nov 2021 16:03:06 +0000 Subject: [PATCH] --- .vscode/launch.json | 26 +++++++++++++++++++ .vscode/tasks.json | 42 ++++++++++++++++++++++++++++++ Program.cs | 59 +++++++++++++++++++++++++++++++++++++++++++ appsettings.json | 9 +++++++ ayanova-version.cs | 9 +++++++ ayconfig.cs | 5 ++++ config.json | 1 + raven-launcher.csproj | 17 +++++++++++++ 8 files changed, 168 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 Program.cs create mode 100644 appsettings.json create mode 100644 ayanova-version.cs create mode 100644 ayconfig.cs create mode 100644 config.json create mode 100644 raven-launcher.csproj diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..aa767a0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/net6.0/raven-launcher.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "integratedTerminal", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..c45b54f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/raven-launcher.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/raven-launcher.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/raven-launcher.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..23c325a --- /dev/null +++ b/Program.cs @@ -0,0 +1,59 @@ +global using System.Text.Json; +global using System.Text.Json.Serialization; + +// Prevent from ending if CTL+C is pressed. +Console.TreatControlCAsInput = true; +Console.WriteLine($"AyaNova server launcher {AyaNovaVersion.VersionString}"); + +AyConfig cfg = null; + +var ConfigFileName = @"config.json"; +var json = string.Empty; +bool FirstTime=false; +//Read configuration or create if not exist +if (File.Exists(ConfigFileName)) +{ + json = File.ReadAllText(ConfigFileName); + cfg = JsonSerializer.Deserialize(json); +} +else +{ + cfg = new AyConfig(); + FirstTime=true; +} + +if(FirstTime){ + Console.WriteLine("Configuration file not found; using default values"); +} +Console.WriteLine("Current configuration:"); + +//iterate / prompt for each value + + +//write configuration +cfg = new AyConfig(); +json = JsonSerializer.Serialize(cfg); +File.WriteAllText(ConfigFileName, json); + + + + + + +Console.WriteLine("Press CTL-C keys to shut down AyaNova Server"); +bool Quit = false; +ConsoleKeyInfo cki; +do +{ + cki = Console.ReadKey(false); + + if (cki.Key == ConsoleKey.C && (cki.Modifiers & ConsoleModifiers.Control) != 0) + { + Quit = true; + } + else + { + Console.WriteLine("Press CTL-C keys to shut down AyaNova Server"); + } + //Console.WriteLine(cki.Key.ToString()); +} while (!Quit); \ No newline at end of file diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..bec7bbb --- /dev/null +++ b/appsettings.json @@ -0,0 +1,9 @@ +{ + "AYANOVA_USE_URLS": "http://*:7575", + "AYANOVA_DB_CONNECTION":"Server=localhost;Username=postgres;Password=mypasswordforpostgres;Database=AyaNova;", + "AYANOVA_DEFAULT_TRANSLATION":"en", + "AYANOVA_BACKUP_PG_DUMP_PATH":"postgres\\bin\\", + "AYANOVA_FOLDER_USER_FILES":"%programdata\\ayanova\\userfiles", + "AYANOVA_FOLDER_BACKUP_FILES":"%programdata\\ayanova\\backupfiles", + "AYANOVA_LOG_PATH":"%programdata\\ayanova\\" +} \ No newline at end of file diff --git a/ayanova-version.cs b/ayanova-version.cs new file mode 100644 index 0000000..c50f4ff --- /dev/null +++ b/ayanova-version.cs @@ -0,0 +1,9 @@ + + /// + /// Version strings centrally located for convenience + /// + internal static class AyaNovaVersion + { + public const string VersionString = "8.0.0-alpha.141"; + public const string FullNameAndVersion = "AyaNova server " + VersionString; + }//eoc diff --git a/ayconfig.cs b/ayconfig.cs new file mode 100644 index 0000000..229aafb --- /dev/null +++ b/ayconfig.cs @@ -0,0 +1,5 @@ +public class AyConfig +{ + public bool AllowScheduleConflicts { get; set; } = true; + public string Test { get; set; } = "AyaNova server "; +} \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..e782ef7 --- /dev/null +++ b/config.json @@ -0,0 +1 @@ +{"AllowScheduleConflicts":true,"Test":"AyaNova server "} \ No newline at end of file diff --git a/raven-launcher.csproj b/raven-launcher.csproj new file mode 100644 index 0000000..3b1b256 --- /dev/null +++ b/raven-launcher.csproj @@ -0,0 +1,17 @@ + + + + Exe + net6.0 + raven_launcher + enable + enable + ayanova.ico + ayanova-launcher + + + + Always + + +