Small style fixes

This commit is contained in:
Rick Falkvinge
2014-09-24 00:45:18 +02:00
parent 608dea4cbe
commit 64239f4e30
7 changed files with 84 additions and 6 deletions
+4
View File
@@ -167,6 +167,10 @@ namespace Swarmops.Backend
OutboundComm.CreateNotification(null, NotificationResource.System_Startup);
// Checking for schemata upgrade
DatabaseMaintenance.UpgradeSchemata();
// Check for existence of installation ID. If not, create one. Warning: has privacy implications when communicated.
if (Persistence.Key["SwarmopsInstallationId"] == string.Empty)
+9 -2
View File
@@ -1,5 +1,12 @@
#!/bin/bash
#Update schemata
cd /home/prod/Smallwebs/Activizr-repo/schemas
echo "Checking for updates to schema..."
svn update
cd /home/packager/swarmops
#Update all files, including this one. Runpos will remain same in possible new version
echo "Checking for updates to packaging process..."
svn update
@@ -38,9 +45,9 @@ echo ""
echo "Notifying developers that new build has packaged for test/deployment..."
if [ "$DROPFOLDER" == "internal" ]; then
echo "The packages (swarmops-frontend-internal, swarmops-backend-internal) are available from repositories now, and can be tested at http://dev.swarmops.com/ as usual. Last 3 commits on 'master':" > deploymsg.txt
echo "$(cat ../lastbuild/swarmops/internal/CommitMessage.txt)" > deploymsg.txt
echo "" >> deploymsg.txt
echo "$(cat ../lastbuild/swarmops/internal/CommitMessage.txt)" >> deploymsg.txt
echo "The packages (swarmops-frontend-internal, swarmops-backend-internal) are available from repositories now, and can be tested at http://dev.swarmops.com/ as usual. Last 3 commits on 'master':" >> deploymsg.txt
else
echo "NOTE: this is a $DROPFOLDER package bundle. It will deploy automatically to live systems via apt-get upgrade. Yay, we made another sprint!" > deploymsg.txt
fi
+1 -1
View File
@@ -158,7 +158,7 @@ scripts/update-repos swarmops-$PACKAGENAME-latest.deb
if [ "$2" == "" ]; then
echo "Installing INTERNAL BUILD on swarmops-dev for testing..."
dpkg -i swarmops-$PACKAGENAME-latest.deb
sudo dpkg -i swarmops-$PACKAGENAME-latest.deb
fi
echo "Cleaning up..."
@@ -275,6 +275,26 @@ namespace Swarmops.Logic.App_GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
///
///This is for information only. You do not need to take action..
/// </summary>
internal static string System_DatabaseSchemaUpgraded_Body {
get {
return ResourceManager.GetString("System_DatabaseSchemaUpgraded_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Swarmops database upgraded.
/// </summary>
internal static string System_DatabaseSchemaUpgraded_Subject {
get {
return ResourceManager.GetString("System_DatabaseSchemaUpgraded_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to An unhandled exception was thrown in Swarmops:
///
@@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CashAdvance_Attested_Body" xml:space="preserve">
<value>Your requested cash advance with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been attested by the budget owner. It will now proceed to payout to you.</value>
@@ -206,6 +206,14 @@ Please log on to Swarmops at [SystemUrl] to confirm or reject them.</value>
<data name="Receipts_Filed_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed</value>
</data>
<data name="System_DatabaseSchemaUpgraded_Body" xml:space="preserve">
<value>Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
This is for information only. You do not need to take action.</value>
</data>
<data name="System_DatabaseSchemaUpgraded_Subject" xml:space="preserve">
<value>Swarmops database upgraded</value>
</data>
<data name="System_Exception_Body" xml:space="preserve">
<value>An unhandled exception was thrown in Swarmops:
@@ -89,6 +89,7 @@ namespace Swarmops.Logic.Communications.Transmission
Unknown = 0,
System_Startup,
System_Exception,
System_DatabaseSchemaUpgraded,
CashAdvance_Requested,
CashAdvance_Attested,
CashAdvance_Deattested,
+39 -1
View File
@@ -5,6 +5,9 @@ using System.Net;
using System.Text;
using Swarmops.Logic.Swarm;
using Swarmops.Database;
using System.Globalization;
using Swarmops.Logic.Communications;
using Swarmops.Logic.Communications.Transmission;
namespace Swarmops.Logic.Support
{
@@ -38,7 +41,7 @@ namespace Swarmops.Logic.Support
using (WebClient client = new WebClient())
{
sql = client.DownloadString("http://packages.swarmops.com/schemas/initialize.sql"); // Hardcoded as security measure - don't want to pass arbitrary sql in from web layer
sql = client.DownloadString("http://packages.swarmops.com/schemata/initialize.sql"); // Hardcoded as security measure - don't want to pass arbitrary sql in from web layer
}
string[] sqlCommands = sql.Split('#'); // in the file, the commands are split by a single # sign. (Semicolons are an integral part of storedprocs, so they can't be used.)
@@ -50,5 +53,40 @@ namespace Swarmops.Logic.Support
SwarmDb.GetDatabaseForWriting().SetKeyValue("DbVersion", "1"); // We're at baseline
}
static public void UpgradeSchemata()
{
int currentDbVersion = Int32.Parse(SwarmDb.GetDatabaseForReading().GetKeyValue("DbVersion"));
int expectedDbVersion = SwarmDb.DbVersion;
string sql;
bool upgraded = false;
while (currentDbVersion < expectedDbVersion)
{
currentDbVersion++;
string fileName = String.Format("http://packages.swarmops.com/schemata/upgrade-{0:D4}.sql", currentDbVersion);
using (WebClient client = new WebClient())
{
sql = client.DownloadString(fileName);
}
string[] sqlCommands = sql.Split('#'); // in the file, the commands are split by a single # sign. (Semicolons are an integral part of storedprocs, so they can't be used.)
foreach (string sqlCommand in sqlCommands)
{
SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommand(sqlCommand.Trim());
}
upgraded = true;
SwarmDb.GetDatabaseForWriting().SetKeyValue("DbVersion", currentDbVersion.ToString(CultureInfo.InvariantCulture)); // Increment after each successful run
}
if (upgraded)
{
OutboundComm.CreateNotification(null, NotificationResource.System_DatabaseSchemaUpgraded);
}
}
}
}