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
+1 -1
View File
@@ -105,7 +105,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="etcinitd\swarmops-backend" />
<None Include="etcinitd\etcinitd-swarmops-backend" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+164
View File
@@ -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 <rick.falkvinge@pirateacademy.eu>
#
# 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
:
+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;
+15 -13
View File
@@ -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));
}
}
}
+1 -1
View File
@@ -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.)
+1 -1
View File
@@ -50,7 +50,7 @@ namespace Swarmops.Site.Automation
/// <remarks/>
public GetGeographyData()
{
this.Url = "http://pirate.activizr.com/Automation/GetGeographyData.asmx";
this.Url = "https://pirate.activizr.com/Automation/GetGeographyData.asmx";
}
/// <remarks/>
+1 -1
View File
@@ -121,7 +121,7 @@
<value>No other actions are available until setup is completed.</value>
</data>
<data name="Init_SidebarInfo_Welcome" xml:space="preserve">
<value>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.</value>
<value>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.</value>
<comment>Info box on database setup screen</comment>
</data>
<data name="Init_SidebarTodo_CompleteSetup" xml:space="preserve">
+72 -49
View File
@@ -18,7 +18,7 @@
<link href='https://fonts.googleapis.com/css?family=Arimo:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
<!-- page title -->
<title>Activizr - Initialize Installation</title>
<title>Swarmops - Initialize Installation</title>
<!-- telerik style sheet manager, followed by style sheet -->
<telerik:RadStyleSheetManager id="RadStyleSheetManager" runat="server" />
@@ -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 @@
<div class="center980px">
<div class="currentuserinfo"><div style="background-image:url('/Images/Icons/iconshock-user-16px.png');background-repeat:no-repeat;padding-left:16px;float:left"><asp:Label ID="LabelCurrentUserName" runat="server" /> | </div><div style="background-image:url('/Images/Icons/iconshock-workchair-16px.png');background-repeat:no-repeat;padding-left:17px;float:left"><asp:Label ID="LabelCurrentOrganizationName" runat="server" /> |&nbsp;</div><div style="background-image:url('/Images/Icons/iconshock-gamepad-16px.png');background-repeat:no-repeat;padding-left:20px;float:left"><asp:Label ID="LabelPreferences" runat="server" /> |&nbsp;</div><asp:Image ID="ImageCultureIndicator" runat="server" ImageUrl="~/Images/Flags/uk.png" /></div>
<div class="logoimage"><a href="/"><img style="border:none" src="/Style/Images/activizr-v5-pirateedition-logo.png" alt="Activizr Logo" /></a></div>
<div class="logoimage"><a href="/"><img style="border:none" src="/Style/Images/activizr-v5-pirateedition-logo.png" alt="Swarmops Logo" /></a></div>
<div class="break"></div>
<div class="topmenu">
<div class="searchbox"><asp:TextBox ID="SearchBox" runat="server" /></div>
@@ -469,12 +487,19 @@
<li><a href="#step-3">
<label class="stepNumber">3</label>
<span class="stepDesc">
User Data<br />
<small>Let's create the first user</small>
Populate<br />
<small>Wait while bootstrap data is loaded</small>
</span>
</a></li>
<li><a href="#step-4">
<label class="stepNumber">4</label>
<span class="stepDesc">
User Data<br />
<small>Let's create the first user</small>
</span>
</a></li>
<li><a href="#step-5">
<label class="stepNumber">5</label>
<span class="stepDesc">
Complete<br />
<small>All done. Let's login!</small>
@@ -482,10 +507,10 @@
</a></li>
</ul>
<div id="step-1">
<h2>Welcome to Activizr</h2>
<p>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&nbsp;2.</p>
<h2>Welcome to Swarmops</h2>
<p>Congratulations! Since you're reading this, you have successfully installed the Swarmops packages and set up an Apache virtual server using mod_mono.</p>
<p>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:</p> <asp:Label runat="server" ID="LabelTest" />
<p>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:</p> <asp:Label runat="server" ID="LabelTest" />
<div class="entryLabelsAdmin" style="width:250px">
What is this server's /etc/hostname?<br />
@@ -501,9 +526,9 @@
<div id="step-2">
<div id="DivDatabaseUnwritable">
<h2>Fix File Permissions</h2>
<asp:Image ImageUrl="~/Images/Icons/iconshock-cross-96px.png" ID="FailWriteConfig" runat="server" ImageAlign="Left" /><p>The bad news is that we can't write to the configuration file. This is fairly normal for a new installation. The good news is that you can fix that, so we can continue installing. Please open a shell to the Activizr server and execute the following commands:</p>
<p><strong>cd /opt/activizr/frontend<br/>sudo chown www-data:www-data database.config<br/>sudo chmod o+w database.config</strong></p>
<p>The installation will continue when it detects that these steps have been done.</p>
<asp:Image ImageUrl="~/Images/Icons/iconshock-cross-96px.png" ID="FailWriteConfig" runat="server" ImageAlign="Left" /><p>The bad news is that we can't write to the configuration file. This is fairly normal for a new installation. The good news is that you can fix that, so we can continue installing. Please open a shell to the Swarmops server and execute the following commands:</p>
<p><strong>cd /etc/swarmops<br/>sudo chown www-data:www-data database.config<br/>sudo chmod o+w database.config</strong></p>
<p>The installation will continue when it detects that these steps have been taken.</p>
</div>
<div id="DivDatabaseWritable" style="display:none">
<h2>Connect to database</h2>
@@ -521,57 +546,55 @@
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadDatabase" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadServer" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadUser" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadPassword" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadPassword" TextMode="Password" runat="server" />&nbsp;<br />
</div>
<div class="entryFieldsAdmin" style="width:80px;margin-left:10px">
<strong>Write access</strong><br/>
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteDatabase" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteServer" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteUser" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsWritePassword" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsWritePassword" TextMode="Password" runat="server" />&nbsp;<br />
</div>
<div class="entryFieldsAdmin" style="width:80px;margin-left:10px">
<strong>Admin access</strong><br/>
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminDatabase" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminServer" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminUser" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminPassword" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminPassword" TextMode="Password" runat="server" />&nbsp;<br />
</div>
<div style="display:none"><asp:Button runat="server" ID="ButtonInitDatabase" Text="You should not see this button" OnClick="ButtonInitDatabase_Click"/></div>
</div>
</div>
<div id="step-3">
<div id="DivInitializingDatabase">
<h2>Initializing database</h2>
<div id="DivProgressDatabase"></div>
<p>Please wait while the database is being initialized with schemas and geographic data from the Activizr servers. This is going to take a <strong>significant</strong> amount of time; we're loading tons of geodata onto your new server.</p>
<p><span id="SpanInitProgressMessage">Initializing...</span></p>
</div>
<div id="DivCreateFirstUser" style="display:none">
<h2>Creating the first user</h2>
<p>Your new Activizr server has been loaded with the geographic layout of the countries we're active in, and the first organization - the <em>Sandbox</em> - has been created. We are now going to create your user account, which will become the systems administrator account of this Activizr installation.</p>
<p>(You can add other people to the <em>System Administrator</em> role later.)</p>
<div class="entryLabelsAdmin" style="width:250px">
Your full name<br />
Your email<br />
Your password<br/>
Repeat password
</div>
<div class="entryFieldsAdmin">
<asp:TextBox CssClass="textinput" ID="TextFirstUserName" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextFirstUserMail" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword1" TextMode="Password" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword2" TextMode="Password" runat="server" />&nbsp;<br />
</div>
</div>
<h2>Initializing database</h2>
<div id="DivProgressDatabase"></div>
<p>Please wait while the database is being initialized with schemas and geographic data from the Swarmops servers. This is going to take a <strong>significant</strong> amount of time; we're loading tons of geodata onto your new server.</p>
<p><span id="SpanInitProgressMessage">Initializing...</span></p>
</div>
<div id="step-4" style="display:none">
<div id="step-4">
<h2>Creating the first user</h2>
<p>Your new Swarmops server has been loaded with the geographic layout of the countries we're active in, and the first organization - the <em>Sandbox</em> - has been created. We are now going to create your user account, which will become the systems administrator account of this Swarmops installation.</p>
<p>(You can add other people to the <em>System Administrator</em> role later.)</p>
<div class="entryLabelsAdmin" style="width:250px">
Your full name<br />
Your email<br />
Your password<br/>
Repeat password
</div>
<div class="entryFieldsAdmin">
<asp:TextBox CssClass="textinput" ID="TextFirstUserName" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextFirstUserMail" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword1" TextMode="Password" runat="server" />&nbsp;<br />
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword2" TextMode="Password" runat="server" />&nbsp;<br />
</div>
</div>
<div id="step-5" style="display:none">
<asp:UpdatePanel runat="server" ID="UpdateFinished" UpdateMode="Conditional">
<ContentTemplate>
<h2>All done - ready to login</h2>
<p>Your Activizr installation is ready! Press Finish to log in as your new user and start using it.</p>
<p>Your Swarmops installation is ready! Press Finish to log in as your new user and start using it.</p>
<div style="display:none"><asp:Button runat="server" ID="ButtonLogin" OnClick="ButtonLogin_Click" Text="This button is invisible."/></div>
</ContentTemplate>
<Triggers>
+30 -7
View File
@@ -19,6 +19,7 @@ using Telerik.Web.UI;
using Swarmops.Database;
using Country = Swarmops.Logic.Structure.Country;
using Swarmops.Logic.Financial;
public partial class Pages_v5_Init_Default : System.Web.UI.Page
{
@@ -264,7 +265,10 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
if (!(VerifyHostName(this.TextServerName.Text) && VerifyHostAddress(this.TextServerAddress.Text)))
{
return; // Probable hack attempt - fail silently
if (!System.Diagnostics.Debugger.IsAttached)
{
return; // Probable hack attempt - fail silently
}
}
// Store database credentials
@@ -286,7 +290,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
this.TextCredentialsAdminPassword.Text)));
}
[WebMethod]
[WebMethod(true)]
public static void InitDatabase()
{
// Make sure we're uninitialized
@@ -317,14 +321,14 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
/// <summary>
/// This function copies the schemas and geography data off an existing Activizr installation. Runs in its own thread.
/// This function copies the schemas and geography data off an existing Swarmops installation. Runs in its own thread.
/// </summary>
public static void InitDatabaseThread()
{
// Ignore the session object, that method of sharing data didn't work, but a static variable did.
_initProgress = 1;
_initMessage = "Loading schema from Activizr servers; creating tables and procs...";
_initMessage = "Loading schema from Swarmops servers; creating tables and procs...";
Thread.Sleep(100);
// Get the schema and initialize the database structures. Requires ADMIN access to database.
@@ -332,7 +336,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
Swarmops.Logic.Support.DatabaseMaintenance.FirstInitialization();
_initProgress = 5;
_initMessage = "Getting list of countries from Activizr servers...";
_initMessage = "Getting list of countries from Swarmops servers...";
Thread.Sleep(100);
// Create translation lists
@@ -523,9 +527,21 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
_initProgress = 10 + (int) (countryCount*initStepPerCountry);
}
// Create initial currencies (European)
Currency.Create("EUR", "Euros", "€");
Currency.Create("USD", "US Dollars", "$");
Currency.Create("CAD", "Canadian Dollars", "CA$");
Currency.Create("SEK", "Swedish Krona", string.Empty);
Currency.Create("NOK", "Norwegian Krona", string.Empty);
Currency.Create("DKK", "Danisk Krona", string.Empty);
Currency.Create("ISK", "Icelandic Krona", string.Empty);
Currency.Create("CHF", "Swiss Franc", string.Empty);
Currency.Create("GBP", "Pounds Sterling", "£");
// Create the sandbox
Swarmops.Logic.Structure.Organization.Create(0, "Sandbox", "Sandbox", "Sandbox", "activizr.com", "Act",
Swarmops.Logic.Structure.Organization.Create(0, "Sandbox", "Sandbox", "Sandbox", "swarmops.com", "Ops",
rootGeographyId, true,
true, 0).EnableEconomy(Swarmops.Logic.Financial.Currency.FromCode("EUR"));
@@ -618,6 +634,13 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
[WebMethod(true)]
public static bool VerifyHostNameAndAddress(string name, string address)
{
if (Path.DirectorySeparatorChar == '\\')
{
// Running in development mode on Windows, so accept any response
return true;
}
return VerifyHostName(HttpUtility.UrlDecode(name)) && VerifyHostAddress(HttpUtility.UrlDecode(address));
}
@@ -627,7 +650,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
return SwarmDb.Configuration.TestConfigurationWritable();
}
[WebMethod]
[WebMethod(true)]
public static void CreateFirstUser(string name, string mail, string password)
{
// Make sure that no first person exists already, as a security measure