[prev in list] [next in list] [prev in thread] [next in thread]
List: bzflag-commits
Subject: SF.net SVN: bzflag:[22333] trunk/tools/BZStatCollector
From: JeffM2501 () users ! sourceforge ! net
Date: 2012-01-19 1:20:38
Message-ID: E1RnggA-0006Ac-R4 () sfp-svn-1 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 22333
http://bzflag.svn.sourceforge.net/bzflag/?rev=22333&view=rev
Author: JeffM2501
Date: 2012-01-19 01:20:38 +0000 (Thu, 19 Jan 2012)
Log Message:
-----------
fix sql query issues and handle exceptions
Modified Paths:
--------------
trunk/tools/BZStatCollector/CollectorCLI/CollectorCLI.csproj
trunk/tools/BZStatCollector/CollectorCLI/CollectorCLI.sln
trunk/tools/BZStatCollector/CollectorCLI/Program.cs
trunk/tools/BZStatCollector/DatabaseStore/DBStore.cs
Modified: trunk/tools/BZStatCollector/CollectorCLI/CollectorCLI.csproj
===================================================================
--- trunk/tools/BZStatCollector/CollectorCLI/CollectorCLI.csproj 2012-01-19 00:20:10 \
UTC (rev 22332)
+++ trunk/tools/BZStatCollector/CollectorCLI/CollectorCLI.csproj 2012-01-19 01:20:38 \
UTC (rev 22333) @@ -15,28 +15,29 @@
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <PlatformTarget>x86</PlatformTarget>
+ <PropertyGroup>
+ <StartupObject>CollectorCLI.Program</StartupObject>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
+ <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <PlatformTarget>x86</PlatformTarget>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
- <PropertyGroup>
- <StartupObject>CollectorCLI.Program</StartupObject>
- </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
Modified: trunk/tools/BZStatCollector/CollectorCLI/CollectorCLI.sln
===================================================================
--- trunk/tools/BZStatCollector/CollectorCLI/CollectorCLI.sln 2012-01-19 00:20:10 UTC \
(rev 22332)
+++ trunk/tools/BZStatCollector/CollectorCLI/CollectorCLI.sln 2012-01-19 01:20:38 UTC \
(rev 22333) @@ -17,16 +17,16 @@
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|Any CPU.ActiveCfg = Debug|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|Mixed Platforms.Build.0 = Debug|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|x86.ActiveCfg = Debug|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|x86.Build.0 = Debug|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|Any CPU.ActiveCfg = Release|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|Mixed Platforms.ActiveCfg = \
Release|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|Mixed Platforms.Build.0 = \
Release|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|x86.ActiveCfg = Release|x86
- {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|x86.Build.0 = Release|x86
+ {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any \
CPU + {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|Mixed Platforms.Build.0 = \
Debug|Any CPU + {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Debug|x86.ActiveCfg = \
Debug|Any CPU + {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|Any CPU.ActiveCfg = \
Release|Any CPU + {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|Any CPU.Build.0 = \
Release|Any CPU + {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|Mixed \
Platforms.ActiveCfg = Release|Any CPU \
+ {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|Mixed Platforms.Build.0 = \
Release|Any CPU + {839B06CD-19AA-4F34-8044-EA3A1DFFB2CB}.Release|x86.ActiveCfg = \
Release|Any CPU {7E5EF4D9-CA19-41F3-B50A-A79A0637C437}.Debug|Any CPU.ActiveCfg = \
Debug|Any CPU {7E5EF4D9-CA19-41F3-B50A-A79A0637C437}.Debug|Any CPU.Build.0 = \
Debug|Any CPU {7E5EF4D9-CA19-41F3-B50A-A79A0637C437}.Debug|Mixed Platforms.ActiveCfg \
= Debug|Any CPU
Modified: trunk/tools/BZStatCollector/CollectorCLI/Program.cs
===================================================================
--- trunk/tools/BZStatCollector/CollectorCLI/Program.cs 2012-01-19 00:20:10 UTC (rev \
22332)
+++ trunk/tools/BZStatCollector/CollectorCLI/Program.cs 2012-01-19 01:20:38 UTC (rev \
22333) @@ -33,8 +33,7 @@
}
else
{
- cfg.Delete();
- FileStream fs = cfg.OpenWrite();
+ FileStream fs = cfg.OpenRead();
XmlSerializer xml = new XmlSerializer(typeof(DBStore.Config));
DBStore.Configuration = (DBStore.Config)xml.Deserialize(fs);
fs.Close();
Modified: trunk/tools/BZStatCollector/DatabaseStore/DBStore.cs
===================================================================
--- trunk/tools/BZStatCollector/DatabaseStore/DBStore.cs 2012-01-19 00:20:10 UTC (rev \
22332)
+++ trunk/tools/BZStatCollector/DatabaseStore/DBStore.cs 2012-01-19 01:20:38 UTC (rev \
22333) @@ -34,10 +34,19 @@
"UID=" + Configuration.Username + ";PASSWORD=" + \
Configuration.Password + ";"; }
- MySqlConnection connection = new MySqlConnection(conString);
- connection.Open();
+ try
+ {
+ MySqlConnection connection = new MySqlConnection(conString);
+ connection.Open();
- return connection;
+ return connection;
+ }
+ catch (System.Exception ex)
+ {
+ Console.WriteLine("error connecting to db " + ex.Message);
+ return null;
+ }
+
}
public void StorePlayerData (BZConnect connector)
@@ -48,15 +57,24 @@
foreach (KeyValuePair<int,GameQuery.PlayerInfo> player in \
connector.GameInfo.Players) {
- string query = String.Format("INSERT INTO player_updates \
(PlayerName, ServerName, Team, Score, Timestamp) VALUES (@PLAYER, @SERVER, @TEAM, \
@SCORE, NOW()"); + string query = String.Format("INSERT INTO \
player_updates (PlayerName, ServerName, Team, Score, Timestamp) VALUES (@PLAYER, \
@SERVER, @TEAM, @SCORE, @TIMESTAMP)");
- MySqlCommand command = new MySqlCommand(query, connection);
- command.Parameters.Add(new MySqlParameter("PLAYER", \
player.Value.Callsign));
- command.Parameters.Add(new MySqlParameter("SERVER", connector.Host + \
":" + connector.Port.ToString()));
- command.Parameters.Add(new MySqlParameter("TEAM", \
player.Value.Team.ToString()));
- command.Parameters.Add(new MySqlParameter("SCORE", \
player.Value.Wins.ToString() + ":" + player.Value.Losses.ToString() + ":"+ \
player.Value.TKs.ToString()));
-
- command.ExecuteNonQuery();
+ try
+ {
+ MySqlCommand command = new MySqlCommand(query, connection);
+ command.Parameters.Add(new MySqlParameter("PLAYER", \
player.Value.Callsign)); + command.Parameters.Add(new \
MySqlParameter("SERVER", connector.Host + ":" + connector.Port.ToString())); + \
command.Parameters.Add(new MySqlParameter("TEAM", player.Value.Team.ToString())); + \
command.Parameters.Add(new MySqlParameter("SCORE", player.Value.Wins.ToString() + ":" \
+ player.Value.Losses.ToString() + ":" + player.Value.TKs.ToString())); + \
command.Parameters.Add(new MySqlParameter("TIMESTAMP", DateTime.Now)); + \
command.ExecuteNonQuery(); + }
+ catch (System.Exception ex)
+ {
+ Console.WriteLine("error in StorePlayerData " + ex.Message);
+ Console.WriteLine(query);
+ }
+
}
connection.Close();
@@ -69,16 +87,25 @@
if (connection == null)
return;
- string query = String.Format("INSERT INTO server_updates (ServerName, \
Players, Observers, Timestamp) VALUES (@SERVER, @PLAYERS, @OBSERVERS, \
NOW())");
- MySqlCommand command = new MySqlCommand(query, connection);
+ try
+ {
+ string query = String.Format("INSERT INTO server_updates \
(ServerName, Players, Observers, Timestamp) VALUES (@SERVER, @PLAYERS, @OBSERVERS, \
@TIMESTAMP)"); + MySqlCommand command = new MySqlCommand(query, \
connection);
- command.Parameters.Add(new MySqlParameter("PLAYERS", \
server.NonObservers));
- command.Parameters.Add(new MySqlParameter("SERVER", server.Host + ":" + \
server.Port.ToString()));
- command.Parameters.Add(new MySqlParameter("OBSERVERS", \
server.TotalPlayers - server.NonObservers));
- command.ExecuteNonQuery();
+ command.Parameters.Add(new MySqlParameter("PLAYERS", \
server.NonObservers)); + command.Parameters.Add(new \
MySqlParameter("SERVER", server.Host + ":" + server.Port.ToString())); + \
command.Parameters.Add(new MySqlParameter("OBSERVERS", server.TotalPlayers - \
server.NonObservers)); + command.Parameters.Add(new \
MySqlParameter("TIMESTAMP", DateTime.Now)); + \
command.ExecuteNonQuery();
- connection.Close();
- connection.Dispose();
+ connection.Close();
+ connection.Dispose();
+ }
+ catch (System.Exception ex)
+ {
+ Console.WriteLine("error in StoreServerData " + ex.Message);
+ }
+
}
public void StoreTotalData(int players, int servers)
@@ -87,13 +114,22 @@
if (connection == null)
return;
- string query = String.Format("INSERT INTO server_totals_log (Players, \
Servers, Timestamp) VALUES (@PLAYERS, @SERVERS, NOW())");
- MySqlCommand command = new MySqlCommand(query, connection);
- command.Parameters.Add(new MySqlParameter("PLAYERS", players));
- command.Parameters.Add(new MySqlParameter("SERVERS", servers));
- command.ExecuteNonQuery();
- connection.Close();
- connection.Dispose();
+ try
+ {
+ string query = String.Format("INSERT INTO server_totals (Players, \
Servers, Timestamp) VALUES (@PLAYERS, @SERVERS, @TIMESTAMP)"); + \
MySqlCommand command = new MySqlCommand(query, connection); + \
command.Parameters.Add(new MySqlParameter("PLAYERS", players)); + \
command.Parameters.Add(new MySqlParameter("SERVERS", servers)); + \
command.Parameters.Add(new MySqlParameter("TIMESTAMP", DateTime.Now)); + \
command.ExecuteNonQuery(); + connection.Close();
+ connection.Dispose();
+ }
+ catch (System.Exception ex)
+ {
+ Console.WriteLine("error in StoreServerData " + ex.Message);
+ }
+
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
BZFlag-commits mailing list
BZFlag-commits@lists.SourceForge.net
https://lists.SourceForge.net/lists/listinfo/bzflag-commits
irc: #BZFlag @ irc.freenode.net
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic