diff --git a/Backend/Backend.csproj b/Backend/Backend.csproj index 8f08f6b6..438ebafb 100644 --- a/Backend/Backend.csproj +++ b/Backend/Backend.csproj @@ -105,7 +105,7 @@ - + diff --git a/Backend/etcinitd/etcinitd-swarmops-backend b/Backend/etcinitd/etcinitd-swarmops-backend new file mode 100644 index 00000000..83b290cc --- /dev/null +++ b/Backend/etcinitd/etcinitd-swarmops-backend @@ -0,0 +1,164 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: swarmops-backend +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Swarmops backend +# Description: This file starts and stops the Swarmsops backend. It is installed as part of +# the swarmops-backend package and placed in /etc/init.d for compatibility with +# Debian and Ubuntu servers. +### END INIT INFO + +# Author: Rick Falkvinge +# +# Please remove the "Author" lines above and replace them +# with your own name if you copy and modify this script. + +# Do NOT "set -e" + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/usr/sbin:/usr/bin:/sbin:/bin +DESC="Swarmops Backend" +NAME=Swarmops.Backend.exe +MONO=/usr/bin/mono +RUNDIR=/opt/swarmops/backend +DAEMON=$RUNDIR/$NAME +DAEMON_ARGS="" +PIDFILE=/var/run/$NAME.pid +VARDIR=/var/run/swarmops +SCRIPTNAME=/etc/init.d/$NAME +KILLFILE=$RUNDIR/swarmops-backend-exit.flag +USRID="swarmops" + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $MONO \ + --make-pidfile --chuid $USRID --chdir $RUNDIR --background --te$ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $MONO \ + --make-pidfile --chuid $USRID --chdir $RUNDIR --background -- $$ + || return 2 + # Add code here, if necessary, that waits for the process to be ready + # to handle requests from services started subsequently which depend + # on this one. As a last resort, sleep for some time. +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + PID=$(cat $PIDFILE) + + touch $KILLFILE + for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + if [ ! -d /proc/$PID ]; then + rm -f $PIDFILE + return 0 + fi + sleep 1 + done + + return 2 +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + #reload|force-reload) + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + #log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #log_end_msg $? + #;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: \ No newline at end of file diff --git a/Database/Configuration.cs b/Database/Configuration.cs index be3405a0..35fa53dc 100644 --- a/Database/Configuration.cs +++ b/Database/Configuration.cs @@ -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 diff --git a/Database/Database-Currencies.cs b/Database/Database-Currencies.cs index f077398f..9a8f12df 100644 --- a/Database/Database-Currencies.cs +++ b/Database/Database-Currencies.cs @@ -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; diff --git a/Logic/Financial/Currency.cs b/Logic/Financial/Currency.cs index 375ea5e7..9684d842 100644 --- a/Logic/Financial/Currency.cs +++ b/Logic/Financial/Currency.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Text; using Swarmops.Basic.Types; +using Swarmops.Database; namespace Swarmops.Logic.Financial { @@ -17,26 +18,27 @@ namespace Swarmops.Logic.Financial return new Currency(basic); } - public static Currency FromIdentity (int currencyId) + public static Currency FromIdentity(int currencyId) { - if (currencyId == 1) - { - return FromBasic(new BasicCurrency(1, "SEK", "Swedish Krona", "SEK")); - } - - throw new NotImplementedException("Currency.FromIdentity"); + return FromBasic(SwarmDb.GetDatabaseForReading().GetCurrency(currencyId)); } - public static Currency FromCode (string code) + public static Currency FromIdentityAggressive(int currencyId) + { + return FromBasic(SwarmDb.GetDatabaseForWriting().GetCurrency(currencyId)); // "For writing" is intentional - replication timing issue + } + + public static Currency FromCode(string code) { code = code.ToUpperInvariant(); - if (code == "SEK") - { - return FromIdentity(1); - } + return FromBasic(SwarmDb.GetDatabaseForReading().GetCurrency(code)); + } - throw new NotImplementedException("Currency.FromIdentity"); + public static Currency Create (string code, string name, string sign) + { + return FromIdentityAggressive( + SwarmDb.GetDatabaseForWriting().CreateCurrency(code, name, sign)); } } } diff --git a/Logic/Support/DatabaseMaintenance.cs b/Logic/Support/DatabaseMaintenance.cs index c17b9656..dadbddae 100644 --- a/Logic/Support/DatabaseMaintenance.cs +++ b/Logic/Support/DatabaseMaintenance.cs @@ -38,7 +38,7 @@ namespace Swarmops.Logic.Support using (WebClient client = new WebClient()) { - sql = client.DownloadString("http://packages.activizr.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/schemas/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.) diff --git a/Site5/App_Code/GetGeographyData.cs b/Site5/App_Code/GetGeographyData.cs index 9bd23ba8..8d2e4172 100644 --- a/Site5/App_Code/GetGeographyData.cs +++ b/Site5/App_Code/GetGeographyData.cs @@ -50,7 +50,7 @@ namespace Swarmops.Site.Automation /// public GetGeographyData() { - this.Url = "http://pirate.activizr.com/Automation/GetGeographyData.asmx"; + this.Url = "https://pirate.activizr.com/Automation/GetGeographyData.asmx"; } /// diff --git a/Site5/App_GlobalResources/Pages.Init.resx b/Site5/App_GlobalResources/Pages.Init.resx index bb219415..5f827e83 100644 --- a/Site5/App_GlobalResources/Pages.Init.resx +++ b/Site5/App_GlobalResources/Pages.Init.resx @@ -121,7 +121,7 @@ No other actions are available until setup is completed. - Welcome to Activizr! This is what the interface looks like, but it's not active yet - first, we'll go through some steps to set up your installation. You'll be up and running shortly. + Welcome to Swarmops! This is what the interface looks like, but it's not active yet - first, we'll go through some steps to set up your installation. You'll be up and running shortly. Info box on database setup screen diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx index 34d0cbfe..15f0e5f4 100644 --- a/Site5/Pages/v5/Init/Default.aspx +++ b/Site5/Pages/v5/Init/Default.aspx @@ -18,7 +18,7 @@ - Activizr - Initialize Installation + Swarmops - Initialize Installation @@ -47,11 +47,24 @@ $(document).ready(function () { + + $('#<%=this.TextCredentialsReadDatabase.ClientID %>').focusout(function () { + var dbValue = $('#<%=this.TextCredentialsReadDatabase.ClientID %>').val(); + $('#<%=this.TextCredentialsWriteDatabase.ClientID %>').val(dbValue); + $('#<%=this.TextCredentialsAdminDatabase.ClientID %>').val(dbValue); + }); + + $('#<%=this.TextCredentialsReadServer.ClientID %>').focusout(function () { + var serverValue = $('#<%=this.TextCredentialsReadServer.ClientID %>').val(); + $('#<%=this.TextCredentialsWriteServer.ClientID %>').val(serverValue); + $('#<%=this.TextCredentialsAdminServer.ClientID %>').val(serverValue); + }); + // Initialize Smart Wizard $('#wizard').smartWizard({ transitionEffect: 'fade', keyNavigation: false, - onLeaveStep: leaveAStepCallback, + onLeaveStep: leaveAStepCallback, onFinish: onFinishCallback }); @@ -60,9 +73,9 @@ return validateStep(stepNum); } - function onFinishCallback(obj) { - $('#<%=this.ButtonLogin.ClientID %>').click(); - } + function onFinishCallback(obj) { + $('#<%=this.ButtonLogin.ClientID %>').click(); + } function validateStep(stepNumber) { var isValid = false; @@ -79,7 +92,7 @@ $.ajax({ type: "POST", url: "Default.aspx/VerifyHostNameAndAddress", - data: "{'name': '" + escape(hostName) + "', 'address': '" + escape(hostAddress) + "'}", + data: "{'name': '" + escape(hostName) + "', 'address': '" + escape(hostAddress) + "'}", contentType: "application/json; charset=utf-8", dataType: "json", async: false, // blocks until function returns - race conditions otherwise @@ -155,6 +168,9 @@ } else if (stepNumber == 3) { + isValid = false; // always disallow button press on populate step + } + else if (stepNumber == 4) { isValid = true; // assume true, make false as we go // Check that all four boxes are filled in, and that Password1 and Password2 equal each other. @@ -197,7 +213,7 @@ }); } } - else if (stepNumber == 4) { + else if (stepNumber == 5) { // If we get here, we're always good isValid = true; @@ -274,14 +290,16 @@ contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { + $('#SpanInitProgressMessage').text(msg.d); + if (msg.d == 'Complete.') { - + // We're done. Do nothing, the progress bar updater will do this step. + $('#wizard').smartWizard("goToStep", 4); } else { - // We're not done yet. Keep the progress bar on-screen and keep re-checking. - $('#SpanInitProgressMessage').text(msg.d); + // We're not done yet. Keep the progress bar on-screen and keep re-checking. setTimeout('updateInitProgressMessage();', 500); } } @@ -314,7 +332,7 @@
|
| 
| 
-
Activizr Logo
+
Swarmops Logo
@@ -469,12 +487,19 @@
  • - User Data
    - Let's create the first user + Populate
    + Wait while bootstrap data is loaded
  • + + User Data
    + Let's create the first user +
    +
  • +
  • + Complete
    All done. Let's login! @@ -482,10 +507,10 @@
  • -

    Welcome to Activizr

    -

    Congratulations! Since you're reading this, you have successfully installed the Activizr packages and set up an Apache virtual server using mod_mono with Mono 2.

    +

    Welcome to Swarmops

    +

    Congratulations! Since you're reading this, you have successfully installed the Swarmops packages and set up an Apache virtual server using mod_mono.

    -

    However, before we proceed, we need to make sure that you are indeed the sysadmin of this server, and not a remote bot who just discovered an unfinished Activizr installation. To do that, answer these simple questions:

    +

    However, before we proceed, we need to make sure that you are indeed the sysadmin of this server, and not a remote bot who just discovered an unfinished Swarmops installation. To do that, answer these simple questions:

    -
    -

    Initializing database

    -
    -

    Please wait while the database is being initialized with schemas and geographic data from the Activizr servers. This is going to take a significant amount of time; we're loading tons of geodata onto your new server.

    -

    Initializing...

    -
    - +

    Initializing database

    +
    +

    Please wait while the database is being initialized with schemas and geographic data from the Swarmops servers. This is going to take a significant amount of time; we're loading tons of geodata onto your new server.

    +

    Initializing...

    -