version 2.2 stable

This commit is contained in:
RaidMax 2018-10-12 21:28:22 -05:00
parent 65cf3566db
commit 305817d00c
6 changed files with 28 additions and 7 deletions

View File

@ -10,6 +10,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Collections.Generic; using System.Collections.Generic;
using SharedLibraryCore.Localization; using SharedLibraryCore.Localization;
using IW4MAdmin.Application.Migration;
namespace IW4MAdmin.Application namespace IW4MAdmin.Application
{ {
@ -42,6 +43,9 @@ namespace IW4MAdmin.Application
Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey); Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey);
CheckDirectories(); CheckDirectories();
// do any needed migrations
// todo: move out
ConfigurationMigration.MoveConfigFolder10518(null);
ServerManager = ApplicationManager.GetInstance(); ServerManager = ApplicationManager.GetInstance();
Localization.Configure.Initialize(ServerManager.GetApplicationSettings().Configuration()?.CustomLocale); Localization.Configure.Initialize(ServerManager.GetApplicationSettings().Configuration()?.CustomLocale);

View File

@ -53,9 +53,6 @@ namespace IW4MAdmin.Application
private ApplicationManager() private ApplicationManager()
{ {
// do any needed migrations
// todo: move out
ConfigurationMigration.MoveConfigFolder10518(Logger);
_servers = new List<Server>(); _servers = new List<Server>();
Commands = new List<Command>(); Commands = new List<Command>();
TaskStatuses = new List<AsyncStatus>(); TaskStatuses = new List<AsyncStatus>();

View File

@ -30,7 +30,7 @@ namespace IW4MAdmin.Application.Migration
if (!Directory.Exists(configDirectory)) if (!Directory.Exists(configDirectory))
{ {
log.WriteDebug($"Creating directory for configs {configDirectory}"); log?.WriteDebug($"Creating directory for configs {configDirectory}");
Directory.CreateDirectory(configDirectory); Directory.CreateDirectory(configDirectory);
} }
@ -40,7 +40,7 @@ namespace IW4MAdmin.Application.Migration
foreach (var configFile in configurationFiles) foreach (var configFile in configurationFiles)
{ {
log.WriteDebug($"Moving config file {configFile}"); log?.WriteDebug($"Moving config file {configFile}");
string destinationPath = Path.Join("Configuration", configFile); string destinationPath = Path.Join("Configuration", configFile);
if (!File.Exists(destinationPath)) if (!File.Exists(destinationPath))
{ {
@ -51,7 +51,7 @@ namespace IW4MAdmin.Application.Migration
if (!File.Exists(Path.Join("Database", "Database.db")) && if (!File.Exists(Path.Join("Database", "Database.db")) &&
File.Exists("Database.db")) File.Exists("Database.db"))
{ {
log.WriteDebug("Moving database file"); log?.WriteDebug("Moving database file");
File.Move("Database.db", Path.Join("Database", "Database.db")); File.Move("Database.db", Path.Join("Database", "Database.db"));
} }
} }

View File

@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
_customcallbacks.gsc = _customcallbacks.gsc _customcallbacks.gsc = _customcallbacks.gsc
README.md = README.md README.md = README.md
RunPublishPre.cmd = RunPublishPre.cmd RunPublishPre.cmd = RunPublishPre.cmd
RunPublishRelease.cmd = RunPublishRelease.cmd
version.txt = version.txt version.txt = version.txt
EndProjectSection EndProjectSection
EndProject EndProject

View File

@ -18,7 +18,9 @@ namespace Tests
{ {
File.WriteAllText("test_mp.log", "test_log_file"); File.WriteAllText("test_mp.log", "test_log_file");
Manager = Program.ServerManager; IW4MAdmin.Application.Localization.Configure.Initialize("en-US");
Manager = ApplicationManager.GetInstance();
var config = new ApplicationConfiguration var config = new ApplicationConfiguration
{ {
@ -43,6 +45,7 @@ namespace Tests
Manager.ConfigHandler.Set(config); Manager.ConfigHandler.Set(config);
Manager.Init().Wait(); Manager.Init().Wait();
Task.Run(() => Manager.Start()); Task.Run(() => Manager.Start());
} }

View File

@ -188,6 +188,22 @@ namespace Tests
resetEvent.Wait(5000); resetEvent.Wait(5000);
} }
[Fact]
public void PrintCommands()
{
var sb = new StringBuilder();
sb.AppendLine("|Name |Alias|Description |Requires Target|Syntax |Required Level|");
sb.AppendLine("|--------------| -----| --------------------------------------------------------| -----------------| -------------| ----------------|");
foreach (var command in Manager.GetCommands().OrderByDescending(c => c.Permission).ThenBy(c => c.Name))
{
sb.AppendLine($"|{command.Name}|{command.Alias}|{command.Description}|{command.RequiresTarget}|{command.Syntax.Substring(8).EscapeMarkdown()}|{command.Permission}|");
}
Assert.True(false, sb.ToString());
}
} }
} }