Committing work

This commit is contained in:
Rick Falkvinge
2013-07-10 14:18:27 +00:00
parent 628e213114
commit 7c25e6ce01
10 changed files with 311 additions and 76 deletions
+6 -3
View File
@@ -95,7 +95,8 @@ namespace Swarmops.Database
{
XmlSerializer serializer = new XmlSerializer(typeof(Configuration));
using (TextWriter writeFileStream = new StreamWriter(GetConfigurationFileName()))
string fileName = GetConfigurationFileName();
using (TextWriter writeFileStream = new StreamWriter(fileName))
{
serializer.Serialize(writeFileStream, configuration);
}
@@ -118,14 +119,16 @@ namespace Swarmops.Database
return "/etc/swarmops/database.config";
}
else if (HttpContext.Current != null)
else if (System.Diagnostics.Debugger.IsAttached)
{
// Dev web process
// Dev web process. This will throw if we're not in a HttpContext and trying to debug something else.
return HttpContext.Current.Server.MapPath ("~/database.config");
}
else
{
throw new NotImplementedException("Invalid state");
// Dev console process
return "database.config"; // Each dev needs to set the working directory to the Console directory when debugging
+20
View File
@@ -109,6 +109,26 @@ namespace Swarmops.Database
#region Creation and manipulation - stored procedures
public int CreateCurrency(string code, string name, string sign)
{
DateTime now = DateTime.Now;
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("CreateCurrency", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "code", code.ToUpperInvariant());
AddParameterWithName(command, "name", name);
AddParameterWithName(command, "sign", sign);
return Convert.ToInt32(command.ExecuteScalar());
}
}
public int SetCurrencyExchangeRate (DateTime date, int currencyId, double eur100)
{
DateTime now = DateTime.Now;