Added logger instance to database class, more informative fail messages.

Logs all HTTP requests
This commit is contained in:
RaidMax 2017-11-14 15:36:55 -06:00
parent 3ccd0013b4
commit 89381bcc7d
10 changed files with 79 additions and 54 deletions

View File

@ -365,8 +365,7 @@ copy /Y "$(TargetDir)IW4MAdmin.exe.config" "$(SolutionDir)BUILD"
copy /Y "$(ProjectDir)lib\Kayak.dll" "$(SolutionDir)BUILD\lib" copy /Y "$(ProjectDir)lib\Kayak.dll" "$(SolutionDir)BUILD\lib"
xcopy /Y /I /E "$(ProjectDir)webfront\*" "$(SolutionDir)BUILD\Webfront" xcopy /Y /I /E "$(ProjectDir)webfront\*" "$(SolutionDir)BUILD\Webfront"
xcopy /Y /I /E "$(TagetDir)Config\*" "$(SolutionDir)BUILD\Config" xcopy /Y /I /E "$(SolutionDir)Admin\Config\*" "$(SolutionDir)BUILD\Config"
if $(ConfigurationName) == Release-Nightly powershell.exe -file "$(SolutionDir)DEPLOY\publish_nightly.ps1" 1.5 if $(ConfigurationName) == Release-Nightly powershell.exe -file "$(SolutionDir)DEPLOY\publish_nightly.ps1" 1.5
if $(ConfigurationName) == Release-Stable powershell.exe -file "$(SolutionDir)DEPLOY\publish_stable.ps1" 1.5 if $(ConfigurationName) == Release-Stable powershell.exe -file "$(SolutionDir)DEPLOY\publish_stable.ps1" 1.5

View File

@ -15,7 +15,7 @@ namespace IW4MAdmin
{ {
// it looks like there's a library error in // it looks like there's a library error in
// Kayak.Http.HttpServerTransactionDelegate.OnError // Kayak.Http.HttpServerTransactionDelegate.OnError
if ((uint)e.HResult == 0x80004003) if ((uint)e.HResult == 0x80004003 || (uint)e.InnerException?.HResult == 0x80004003)
return; return;
ApplicationManager.GetInstance().Logger.WriteWarning("Web service has encountered an error - " + e.Message); ApplicationManager.GetInstance().Logger.WriteWarning("Web service has encountered an error - " + e.Message);
@ -39,6 +39,11 @@ namespace IW4MAdmin
{ {
public void OnRequest(HttpRequestHead request, IDataProducer requestBody, IHttpResponseDelegate response, string IP) public void OnRequest(HttpRequestHead request, IDataProducer requestBody, IHttpResponseDelegate response, string IP)
{ {
var logger = ApplicationManager.GetInstance().GetLogger();
logger.WriteInfo($"HTTP request {request.Path}");
logger.WriteInfo($"QueryString: {request.QueryString}");
logger.WriteInfo($"IP: {IP}");
NameValueCollection querySet = new NameValueCollection(); NameValueCollection querySet = new NameValueCollection();
if (request.QueryString != null) if (request.QueryString != null)

View File

@ -44,8 +44,8 @@ namespace IW4MAdmin
TaskStatuses = new List<AsyncStatus>(); TaskStatuses = new List<AsyncStatus>();
MessageTokens = new List<MessageToken>(); MessageTokens = new List<MessageToken>();
ClientDatabase = new ClientsDB("Database/clients.rm"); ClientDatabase = new ClientsDB("Database/clients.rm", Logger);
AliasesDatabase = new AliasesDB("Database/aliases.rm"); AliasesDatabase = new AliasesDB("Database/aliases.rm", Logger);
ClientPenalties = new PenaltyList(); ClientPenalties = new PenaltyList();
} }

Binary file not shown.

View File

@ -75,8 +75,8 @@ Global
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Any CPU.Build.0 = Debug|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86 {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86 {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {DD5DCDA2-51DB-4B1A-922F-5705546E6115}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
@ -99,8 +99,8 @@ Global
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU {4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Any CPU.Build.0 = Debug|Any CPU {4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86 {4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86 {4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {4785AB75-66F3-4391-985D-63A5A049A0FA}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
@ -123,8 +123,8 @@ Global
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Any CPU.Build.0 = Debug|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86 {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86 {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {D51EECEB-438A-47DA-870F-7D7B41BC24D6}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
@ -147,8 +147,8 @@ Global
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Any CPU.Build.0 = Debug|Any CPU {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86 {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86 {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
@ -170,7 +170,7 @@ Global
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86 {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86 {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
@ -188,7 +188,7 @@ Global
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x64.ActiveCfg = Release-Stable|Any CPU {E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x64.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU {E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU {E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
@ -209,8 +209,8 @@ Global
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU {C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.Build.0 = Debug|Any CPU {C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86 {C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86 {C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
@ -232,7 +232,7 @@ Global
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU {1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86 {1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86 {1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
@ -254,7 +254,7 @@ Global
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Stable|Any CPU.ActiveCfg = Debug|Any CPU {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86 {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86 {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU

View File

@ -54,7 +54,7 @@ namespace MessageBoard.Forum
{ {
forumPages = new List<IPage>(); forumPages = new List<IPage>();
activeSessions = new List<Session>(); activeSessions = new List<Session>();
database = new Storage.Database("Database/forum.db"); database = new Storage.Database("Database/forum.db", null);
} }
public void startSession(string sessionID) public void startSession(string sessionID)

View File

@ -7,7 +7,7 @@ namespace MessageBoard.Storage
{ {
class Database : SharedLibrary.Database class Database : SharedLibrary.Database
{ {
public Database(String FN) : base(FN) { } public Database(String FN, SharedLibrary.Interfaces.ILogger logger) : base(FN, logger) { }
public override void Init() public override void Init()
{ {

View File

@ -100,7 +100,7 @@ namespace StatsPlugin
"where", "where",
}; };
public ChatDatabase(string FN) : base(FN) public ChatDatabase(string FN, SharedLibrary.Interfaces.ILogger logger) : base(FN, logger)
{ {
} }

View File

@ -164,7 +164,7 @@ namespace StatsPlugin
public StatTracking(int port) public StatTracking(int port)
{ {
playerStats = new StatsDB("Database/stats_" + port + ".rm"); playerStats = new StatsDB("Database/stats_" + port + ".rm", ManagerInstance.GetLogger());
inactiveMinutes = new int[18]; inactiveMinutes = new int[18];
Kills = new int[18]; Kills = new int[18];
deathStreaks = new int[18]; deathStreaks = new int[18];
@ -205,7 +205,7 @@ namespace StatsPlugin
ManagerInstance.GetMessageTokens().Add(new MessageToken("TOTALKILLS", GetTotalKills)); ManagerInstance.GetMessageTokens().Add(new MessageToken("TOTALKILLS", GetTotalKills));
ManagerInstance.GetMessageTokens().Add(new MessageToken("TOTALPLAYTIME", GetTotalPlaytime)); ManagerInstance.GetMessageTokens().Add(new MessageToken("TOTALPLAYTIME", GetTotalPlaytime));
ChatDB = new ChatDatabase("Database/ChatHistory.rm"); ChatDB = new ChatDatabase("Database/ChatHistory.rm", ManagerInstance.GetLogger());
try try
{ {
@ -484,7 +484,7 @@ namespace StatsPlugin
public class StatsDB : Database public class StatsDB : Database
{ {
public StatsDB(String FN) : base(FN) { } public StatsDB(String FN, SharedLibrary.Interfaces.ILogger logger) : base(FN, logger) { }
public override void Init() public override void Init()
{ {

View File

@ -9,9 +9,12 @@ namespace SharedLibrary
{ {
public abstract class Database public abstract class Database
{ {
public Database(String FN) private Interfaces.ILogger Logger;
public Database(String FN, Interfaces.ILogger logger)
{ {
FileName = FN; FileName = FN;
Logger = logger;
Init(); Init();
} }
@ -58,7 +61,10 @@ namespace SharedLibrary
catch (Exception E) catch (Exception E)
{ {
Console.WriteLine($"Line 58: {E.Message}"); Logger.WriteWarning($"Database Insert failed");
Logger.WriteDebug($"Exception Message: {E.Message}");
Logger.WriteDebug($"SQL command: {insertcmd.CommandText}");
Logger.WriteDebug($"Database File: {FileName}");
return false; return false;
} }
@ -96,7 +102,10 @@ namespace SharedLibrary
catch (Exception E) catch (Exception E)
{ {
Console.WriteLine($"Line 96: {E.Message}"); Logger.WriteWarning($"Database UpdateIncrement failed");
Logger.WriteDebug($"Exception Message: {E.Message}");
Logger.WriteDebug($"SQL command: {updatecmd?.CommandText}");
Logger.WriteDebug($"Database File: {FileName}");
} }
} }
@ -133,7 +142,10 @@ namespace SharedLibrary
catch (Exception E) catch (Exception E)
{ {
Console.WriteLine($"Line 96: {E.Message}"); Logger.WriteWarning($"Database update failed");
Logger.WriteDebug($"Exception Message: {E.Message}");
Logger.WriteDebug($"SQL Query: {updatecmd.CommandText}");
Logger.WriteDebug($"Database File: {FileName}");
return false; return false;
} }
} }
@ -149,25 +161,26 @@ namespace SharedLibrary
int rowsUpdated = 0; int rowsUpdated = 0;
Request = Request.Replace("!'", "").Replace("!", ""); Request = Request.Replace("!'", "").Replace("!", "");
var Con = GetNewConnection(); var Con = GetNewConnection();
SQLiteCommand CMD = null;
try try
{ {
Con.Open(); Con.Open();
SQLiteCommand CMD = new SQLiteCommand(Con) CMD = new SQLiteCommand(Con)
{ {
CommandText = Request CommandText = Request
}; };
rowsUpdated = CMD.ExecuteNonQuery(); rowsUpdated = CMD.ExecuteNonQuery();
Con.Close(); Con.Close();
return rowsUpdated; return rowsUpdated;
} }
catch (Exception E) catch (Exception E)
{ {
// fixme: this needs to have a reference to a logger.. Logger.WriteWarning($"Database command failed");
Console.WriteLine(E.Message); Logger.WriteDebug($"Exception Message: {E.Message}");
Console.WriteLine(E.StackTrace); Logger.WriteDebug($"SQL command: {CMD?.CommandText}");
Console.WriteLine(Request); Logger.WriteDebug($"Database File: {FileName}");
return 0; return 0;
} }
} }
@ -182,7 +195,7 @@ namespace SharedLibrary
var Con = GetNewConnection(); var Con = GetNewConnection();
updatecmd.Parameters.AddWithValue('@' + where.Key, where.Value); updatecmd.Parameters.AddWithValue('@' + where.Key, where.Value);
updatecmd.Connection = Con; updatecmd.Connection = Con;
try try
{ {
@ -193,10 +206,12 @@ namespace SharedLibrary
Con.Close(); Con.Close();
} }
catch (Exception e) catch (Exception E)
{ {
//LOGME Logger.WriteWarning($"Database GetDataTable failed");
Console.WriteLine($"Line 160: {e.Message}"); Logger.WriteDebug($"Exception Message: {E.Message}");
Logger.WriteDebug($"SQL command: {updatecmd.CommandText}");
Logger.WriteDebug($"Database File: {FileName}");
} }
return dt; return dt;
@ -216,10 +231,12 @@ namespace SharedLibrary
Con.Close(); Con.Close();
} }
catch (Exception e) catch (Exception E)
{ {
//LOGME Logger.WriteWarning($"Database GetDataTable failed");
Console.WriteLine($"Line 181: {e.Message}"); Logger.WriteDebug($"Exception Message: {E.Message}");
Logger.WriteDebug($"SQL command: {cmd.CommandText}");
Logger.WriteDebug($"Database File: {FileName}");
} }
return dt; return dt;
@ -229,24 +246,28 @@ namespace SharedLibrary
{ {
DataTable dt = new DataTable(); DataTable dt = new DataTable();
var Con = GetNewConnection(); var Con = GetNewConnection();
SQLiteCommand cmd = null;
try try
{ {
Con.Open(); Con.Open();
SQLiteCommand mycommand = new SQLiteCommand(Con) cmd = new SQLiteCommand(Con)
{ {
CommandText = sql CommandText = sql
}; };
SQLiteDataReader reader = mycommand.ExecuteReader(); SQLiteDataReader reader = cmd.ExecuteReader();
dt.Load(reader); dt.Load(reader);
reader.Close(); reader.Close();
Con.Close(); Con.Close();
} }
catch (Exception e) catch (Exception E)
{ {
Console.WriteLine($"Line 198: {e.Message}"); Logger.WriteWarning($"Database GetDataTable failed");
Logger.WriteDebug($"Exception Message: {E.Message}");
Logger.WriteDebug($"SQL command: {cmd?.CommandText}");
Logger.WriteDebug($"Database File: {FileName}");
return new DataTable(); return new DataTable();
} }
return dt; return dt;
@ -257,7 +278,7 @@ namespace SharedLibrary
public class ClientsDB : Database public class ClientsDB : Database
{ {
public ClientsDB(String FN) : base(FN) { } public ClientsDB(String FN, Interfaces.ILogger logger) : base(FN, logger) { }
public override void Init() public override void Init()
{ {
@ -508,7 +529,7 @@ namespace SharedLibrary
if (Row["TIME"].ToString().Length < 2) //compatibility with my old database if (Row["TIME"].ToString().Length < 2) //compatibility with my old database
Row["TIME"] = DateTime.Now.ToString(); Row["TIME"] = DateTime.Now.ToString();
var BanType = (Penalty.Type)Enum.Parse(typeof(Penalty.Type), Row["TYPE"].ToString()); var BanType = (Penalty.Type)Enum.Parse(typeof(Penalty.Type), Row["TYPE"].ToString());
ClientPenalties.Add(new Penalty(BanType, Row["Reason"].ToString().Trim(), Row["npID"].ToString(), Row["bannedByID"].ToString(), DateTime.Parse(Row["TIME"].ToString()), Row["IP"].ToString(), DateTime.Parse(Row["EXPIRES"].ToString()))); ClientPenalties.Add(new Penalty(BanType, Row["Reason"].ToString().Trim(), Row["npID"].ToString(), Row["bannedByID"].ToString(), DateTime.Parse(Row["TIME"].ToString()), Row["IP"].ToString(), DateTime.Parse(Row["EXPIRES"].ToString())));
} }
@ -608,7 +629,7 @@ namespace SharedLibrary
public class AliasesDB : Database public class AliasesDB : Database
{ {
public AliasesDB(String FN) : base(FN) { } public AliasesDB(String FN, Interfaces.ILogger logger) : base(FN, logger) { }
public override void Init() public override void Init()
{ {