Committing release candidate of init page
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Activizr.Database
|
||||
{
|
||||
partial class PirateDb
|
||||
{
|
||||
// This function is bloody dangerous, mmkay?
|
||||
// These functions are bloody dangerous, mmmkay?
|
||||
|
||||
public void ExecuteAdminCommand(string sqlSequence)
|
||||
{
|
||||
@@ -26,5 +26,28 @@ namespace Activizr.Database
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
public int ExecuteAdminCommandScalar (string sqlSequence)
|
||||
{
|
||||
// TODO: Verify that we're in admin mode
|
||||
|
||||
using (DbConnection connection = GetMySqlDbConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
DbCommand command = GetDbCommand(sqlSequence, connection);
|
||||
command.CommandType = CommandType.Text;
|
||||
|
||||
object result = command.ExecuteScalar();
|
||||
|
||||
if (result == DBNull.Value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Convert.ToInt32(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+17
-4
@@ -111,6 +111,13 @@ namespace Activizr.Logic.Pirates
|
||||
|
||||
protected int ResolveGeography ()
|
||||
{
|
||||
if (base.CountryId == 0)
|
||||
{
|
||||
base.GeographyId = 1;
|
||||
PirateDb.GetDatabaseForWriting().SetPersonGeography(this.Identity, 1);
|
||||
return 1; // root geography, if no country set
|
||||
}
|
||||
|
||||
Structure.Cities cities = Cities.FromPostalCode(this.PostalCode, base.CountryId);
|
||||
City city = null;
|
||||
|
||||
@@ -137,6 +144,7 @@ namespace Activizr.Logic.Pirates
|
||||
}
|
||||
|
||||
base.GeographyId = city.GeographyId;
|
||||
PirateDb.GetDatabaseForWriting().SetPersonGeography(this.Identity, base.GeographyId);
|
||||
return city.GeographyId;
|
||||
}
|
||||
|
||||
@@ -147,7 +155,7 @@ namespace Activizr.Logic.Pirates
|
||||
{
|
||||
if (GeographyId == 0)
|
||||
{
|
||||
PirateDb.GetDatabaseForWriting().SetPersonGeography (this.Identity, ResolveGeography());
|
||||
ResolveGeography();
|
||||
}
|
||||
|
||||
return Geography.FromIdentity(GeographyId);
|
||||
@@ -165,7 +173,7 @@ namespace Activizr.Logic.Pirates
|
||||
{
|
||||
if (base.GeographyId == 0)
|
||||
{
|
||||
PirateDb.GetDatabaseForWriting().SetPersonGeography(this.Identity, ResolveGeography());
|
||||
ResolveGeography();
|
||||
}
|
||||
|
||||
return base.GeographyId;
|
||||
@@ -494,7 +502,12 @@ namespace Activizr.Logic.Pirates
|
||||
string postal, string city, string countryCode, DateTime dateOfBirth,
|
||||
PersonGender gender)
|
||||
{
|
||||
BasicCountry country = PirateDb.GetDatabaseForReading().GetCountry(countryCode);
|
||||
BasicCountry country = null;
|
||||
|
||||
if (countryCode.Length > 0)
|
||||
{
|
||||
country = PirateDb.GetDatabaseForReading().GetCountry(countryCode);
|
||||
}
|
||||
|
||||
// Clean data
|
||||
|
||||
@@ -509,7 +522,7 @@ namespace Activizr.Logic.Pirates
|
||||
postal = postal.Replace(" ", "").Trim();
|
||||
|
||||
int personId = PirateDb.GetDatabaseForWriting().CreatePerson(name, email, phone, street, postal, city,
|
||||
country.Identity, dateOfBirth, gender);
|
||||
country == null? 0: country.Identity, dateOfBirth, gender);
|
||||
|
||||
|
||||
// Resolve the geography
|
||||
|
||||
@@ -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 in about three minutes.</value>
|
||||
<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>
|
||||
<comment>Info box on database setup screen</comment>
|
||||
</data>
|
||||
<data name="Init_SidebarTodo_CompleteSetup" xml:space="preserve">
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.0 KiB |
@@ -40,13 +40,17 @@
|
||||
|
||||
$(document).ready(function () {
|
||||
// Initialize Smart Wizard
|
||||
$('#wizard').smartWizard({ transitionEffect: 'fade', onLeaveStep: leaveAStepCallback });
|
||||
$('#wizard').smartWizard({ transitionEffect: 'fade', onLeaveStep: leaveAStepCallback, onFinish: onFinishCallback });
|
||||
|
||||
function leaveAStepCallback(obj) {
|
||||
var stepNum = obj.attr('rel');
|
||||
return validateStep(stepNum);
|
||||
}
|
||||
|
||||
function onFinishCallback(obj) {
|
||||
$('#<%=this.ButtonLogin.ClientID %>').click();
|
||||
}
|
||||
|
||||
function validateStep(stepNumber) {
|
||||
var isValid = false;
|
||||
var textBoxes;
|
||||
@@ -62,7 +66,7 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "Default.aspx/VerifyHostNameAndAddress",
|
||||
data: "{'name': '" + hostName + "', 'address': '" + hostAddress + "'}", // TODO: injection vulnerability - strip single quotes from input
|
||||
data: "{'name': '" + escape(hostName) + "', 'address': '" + escape(hostAddress) + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
@@ -166,14 +170,12 @@
|
||||
}
|
||||
|
||||
// If all is valid, create the first user.
|
||||
// TODO: this WILL fuck up when somebody enters O'Hara as name, or anything else containing a single quote. Protect against that.
|
||||
// TODO: make this throw server-side if there is already a Person.FromIdentity(1).
|
||||
|
||||
if (isValid) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "Default.aspx/CreateFirstUser",
|
||||
data: "{'name': '" + $('#<%=this.TextFirstUserName.ClientID %>').val() + "', 'mail': '" + $('#<%=this.TextFirstUserMail.ClientID %>').val() + "', 'address': '" + $('#<%=this.TextFirstUserPassword1.ClientID %>').val() + "'}", // TODO: injection vulnerability - strip single quotes from input
|
||||
data: "{'name': '" + escape($('#<%=this.TextFirstUserName.ClientID %>').val()) + "', 'mail': '" + escape($('#<%=this.TextFirstUserMail.ClientID %>').val()) + "', 'password': '" + escape($('#<%=this.TextFirstUserPassword1.ClientID %>').val()) + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
@@ -186,7 +188,6 @@
|
||||
// If we get here, we're always good
|
||||
|
||||
isValid = true;
|
||||
// TODO: Click the magic button that logs the first user in
|
||||
}
|
||||
|
||||
return isValid;
|
||||
@@ -534,50 +535,31 @@
|
||||
<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>
|
||||
<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 users to the Systems Administrator role later.)</p>
|
||||
<p>(You can add other people to the <em>System Administrator</em> role later.)</p>
|
||||
|
||||
<div class="entrylabels">
|
||||
Your name<br />
|
||||
Your email<br />
|
||||
Your password<br/>
|
||||
Repeat password
|
||||
</div>
|
||||
<div class="entryfields">
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserName" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserMail" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword1" TextMode="Password" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword2" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
|
||||
|
||||
<div class="entrylabels" style="width:250px">
|
||||
Your full name<br />
|
||||
Your email<br />
|
||||
Your password<br/>
|
||||
Repeat password
|
||||
</div>
|
||||
<div class="entryfields">
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserName" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserMail" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword1" TextMode="Password" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword2" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="step-4" style="display:none">
|
||||
<asp:UpdatePanel runat="server" ID="UpdateFinished" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<h2>All done - ready to login</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
||||
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
||||
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
|
||||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
||||
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<p>Your Activizr 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>
|
||||
<asp:AsyncPostBackTrigger ControlID="ButtonInitDatabase" EventName="Click"/>
|
||||
|
||||
@@ -3,13 +3,16 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Activizr.Basic.Enums;
|
||||
using Activizr.Basic.Types;
|
||||
using Activizr.Site.Automation;
|
||||
using Telerik.Web.UI;
|
||||
@@ -112,7 +115,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
|
||||
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
|
||||
|
||||
base.OnPreInit(e);
|
||||
base.OnPreInit(e);
|
||||
}
|
||||
|
||||
public event EventHandler LanguageChanged;
|
||||
@@ -197,14 +200,16 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
switch (item.Attributes["Template"])
|
||||
{
|
||||
case "Build#":
|
||||
item.Text = GetBuildIdentity(); // only dynamically constructed atm -- if more, switch on "template" field
|
||||
item.Text = GetBuildIdentity();
|
||||
// only dynamically constructed atm -- if more, switch on "template" field
|
||||
break;
|
||||
case "CloseLedgers":
|
||||
int year = DateTime.Today.Year;
|
||||
item.Text = String.Format(Resources.Menu5.Menu5_Ledgers_CloseBooks, year - 1); // Modified
|
||||
item.Text = String.Format(Resources.Menu5.Menu5_Ledgers_CloseBooks, year - 1); // Modified
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException("No case for dynamic menu item" + item.Attributes["Template"]);
|
||||
throw new InvalidOperationException("No case for dynamic menu item" +
|
||||
item.Attributes["Template"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -218,7 +223,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
enabled |= !String.IsNullOrEmpty(url);
|
||||
}
|
||||
|
||||
item.Enabled = topLevel; // Modified
|
||||
item.Enabled = topLevel; // Modified
|
||||
if (enabled)
|
||||
{
|
||||
anyItemEnabled = true;
|
||||
@@ -253,8 +258,15 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
return _buildIdentity;
|
||||
}
|
||||
|
||||
protected void ButtonInitDatabase_Click (object sender, EventArgs args)
|
||||
protected void ButtonInitDatabase_Click(object sender, EventArgs args)
|
||||
{
|
||||
// Check the host names and addresses again as a security measure - after all, we can be called from outside our intended script
|
||||
|
||||
if (!(VerifyHostName(this.TextServerName.Text) && VerifyHostAddress(this.TextServerAddress.Text)))
|
||||
{
|
||||
return; // Probable hack attempt - fail silently
|
||||
}
|
||||
|
||||
// Store database credentials
|
||||
|
||||
PirateDb.Configuration.Set(
|
||||
@@ -265,21 +277,39 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
this.TextCredentialsReadUser.Text,
|
||||
this.TextCredentialsReadPassword.Text),
|
||||
new PirateDb.Credentials(this.TextCredentialsWriteDatabase.Text,
|
||||
new PirateDb.ServerSet(this.TextCredentialsWriteServer.Text),
|
||||
this.TextCredentialsWriteUser.Text,
|
||||
this.TextCredentialsWritePassword.Text),
|
||||
new PirateDb.ServerSet(this.TextCredentialsWriteServer.Text),
|
||||
this.TextCredentialsWriteUser.Text,
|
||||
this.TextCredentialsWritePassword.Text),
|
||||
new PirateDb.Credentials(this.TextCredentialsAdminDatabase.Text,
|
||||
new PirateDb.ServerSet(this.TextCredentialsAdminServer.Text),
|
||||
this.TextCredentialsAdminUser.Text,
|
||||
this.TextCredentialsAdminPassword.Text)));
|
||||
new PirateDb.ServerSet(this.TextCredentialsAdminServer.Text),
|
||||
this.TextCredentialsAdminUser.Text,
|
||||
this.TextCredentialsAdminPassword.Text)));
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static void InitDatabase()
|
||||
{
|
||||
// Start an async thread that does all the work, then return
|
||||
// Make sure we're uninitialized
|
||||
|
||||
HttpSessionState currentSessionObject = HttpContext.Current.Session;
|
||||
bool organizationOneExists = false;
|
||||
Activizr.Logic.Structure.Organization organizationOne = null;
|
||||
|
||||
try
|
||||
{
|
||||
organizationOne = Activizr.Logic.Structure.Organization.FromIdentity(1);
|
||||
organizationOneExists = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// We expect this to throw
|
||||
}
|
||||
|
||||
if (organizationOneExists || organizationOne != null)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot re-initialize database");
|
||||
}
|
||||
|
||||
// Start an async thread that does all the work, then return
|
||||
|
||||
Thread initThread = new Thread(InitDatabaseThread);
|
||||
initThread.Start();
|
||||
@@ -371,12 +401,14 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
|
||||
// Create the country's root geography
|
||||
|
||||
int countryRootGeographyId = PirateDb.GetDatabaseForWriting().CreateGeography(geography.Name, rootGeographyId);
|
||||
int countryRootGeographyId = PirateDb.GetDatabaseForWriting().CreateGeography(geography.Name,
|
||||
rootGeographyId);
|
||||
geographyIdTranslation[geography.GeographyId] = countryRootGeographyId;
|
||||
PirateDb.GetDatabaseForWriting().SetCountryGeographyId(countryIdTranslation[countryCode],
|
||||
countryRootGeographyId);
|
||||
|
||||
InitDatabaseThreadCreateGeographyChildren(geography.Children, countryRootGeographyId, ref geographyIdTranslation);
|
||||
InitDatabaseThreadCreateGeographyChildren(geography.Children, countryRootGeographyId,
|
||||
ref geographyIdTranslation);
|
||||
|
||||
_initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry/3);
|
||||
_initMessage = "Retrieving cities for " + countryCode + "...";
|
||||
@@ -390,7 +422,8 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
{
|
||||
cities = geoDataFetcher.GetCitiesForCountry(countryCode);
|
||||
}
|
||||
catch (Exception) // This is a SoapHeaderException in VS debugging, but SOMETHING ELSE! in Mono runtime, so make it generic
|
||||
catch (Exception)
|
||||
// This is a SoapHeaderException in VS debugging, but SOMETHING ELSE! in Mono runtime, so make it generic
|
||||
{
|
||||
// This is typically a country that isn't populated with cities yet. Ignore.
|
||||
countryCount++;
|
||||
@@ -416,7 +449,13 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
// Insert cities
|
||||
|
||||
int newCountryId = countryIdTranslation[countryCode];
|
||||
int cityCount = 0;
|
||||
|
||||
int cityIdHighwater = PirateDb.GetDatabaseForAdmin().ExecuteAdminCommandScalar("SELECT Max(CityId) FROM Cities;");
|
||||
|
||||
_initMessage = string.Format("Setting up {0:N0} cities for {1}...", cities.Length, countryCode);
|
||||
|
||||
string sql = "INSERT INTO Cities (CityName, GeographyId, CountryId, Comment) VALUES ";
|
||||
bool insertComma = false;
|
||||
|
||||
foreach (Activizr.Site.Automation.City city in cities)
|
||||
{
|
||||
@@ -428,26 +467,29 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
if (cityIdsUsedLookup[city.CityId])
|
||||
{
|
||||
int newGeographyId = geographyIdTranslation[city.GeographyId];
|
||||
int newCityId = PirateDb.GetDatabaseForWriting().CreateCity(city.Name, newCountryId,
|
||||
newGeographyId);
|
||||
cityIdTranslation[city.CityId] = newCityId;
|
||||
|
||||
if (insertComma)
|
||||
{
|
||||
sql += ",";
|
||||
}
|
||||
|
||||
sql += "('" + city.Name.Replace("'", "\'") + "'," + newGeographyId.ToString() + "," +
|
||||
newCountryId.ToString() + ",'')";
|
||||
insertComma = true;
|
||||
|
||||
cityIdTranslation[city.CityId] = ++cityIdHighwater; // Note that we assume the assigned ID here.
|
||||
}
|
||||
|
||||
if (cityCount % 25 == 0)
|
||||
{
|
||||
_initMessage = String.Format("Setting up cities for {0} ({1}/{2})...", countryCode, cityCount,
|
||||
cities.Count());
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
cityCount++;
|
||||
|
||||
}
|
||||
|
||||
PirateDb.GetDatabaseForAdmin().ExecuteAdminCommand(sql + ";"); // Inserts all cities in one bulk op, to save roundtrips
|
||||
|
||||
// Insert postal codes
|
||||
|
||||
_initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry*5/6);
|
||||
int postalCodeCount = 0;
|
||||
_initMessage = string.Format("Setting up {0:N0} postal codes for {1}...", postalCodes.Length, countryCode);
|
||||
|
||||
StringBuilder sqlBuild = new StringBuilder("INSERT INTO PostalCodes (PostalCode, CityId, CountryId) VALUES ", 65536);
|
||||
insertComma = false;
|
||||
|
||||
foreach (Activizr.Site.Automation.PostalCode postalCode in postalCodes)
|
||||
{
|
||||
@@ -455,23 +497,25 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
{
|
||||
// Remnants of invalid pointers
|
||||
|
||||
postalCodeCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
int newCityId = cityIdTranslation[postalCode.CityId];
|
||||
PirateDb.GetDatabaseForWriting().CreatePostalCode(postalCode.PostalCode, newCityId, newCountryId);
|
||||
|
||||
if (postalCodeCount % 25 == 0)
|
||||
if (insertComma)
|
||||
{
|
||||
_initMessage = String.Format("Setting up postal codes for {0} ({1}/{2})...", countryCode, postalCodeCount,
|
||||
postalCodes.Count());
|
||||
Thread.Sleep(100);
|
||||
sqlBuild.Append(",");
|
||||
}
|
||||
|
||||
postalCodeCount++;
|
||||
sqlBuild.Append("('" + postalCode.PostalCode.Replace("'", "\'") + "'," + newCityId.ToString() + "," +
|
||||
newCountryId.ToString() + ")");
|
||||
insertComma = true;
|
||||
}
|
||||
|
||||
sqlBuild.Append(";");
|
||||
|
||||
PirateDb.GetDatabaseForAdmin().ExecuteAdminCommand(sqlBuild.ToString()); // Inserts all postal codes in one bulk op, to save roundtrips
|
||||
|
||||
countryCount++;
|
||||
|
||||
_initProgress = 10 + (int) (countryCount*initStepPerCountry);
|
||||
@@ -479,7 +523,8 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
|
||||
// Create the sandbox
|
||||
|
||||
Activizr.Logic.Structure.Organization.Create(0, "Sandbox", "Sandbox", "Sandbox", "activizr.com", "Act", rootGeographyId, true,
|
||||
Activizr.Logic.Structure.Organization.Create(0, "Sandbox", "Sandbox", "Sandbox", "activizr.com", "Act",
|
||||
rootGeographyId, true,
|
||||
true, 0);
|
||||
|
||||
_initProgress = 100;
|
||||
@@ -488,7 +533,9 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
Thread.Sleep(1000); // give some time for static var to stick and web interface to react before killing thread
|
||||
}
|
||||
|
||||
private static void InitDatabaseThreadCreateGeographyChildren (Activizr.Site.Automation.Geography[] children, int parentGeographyId, ref Dictionary<int,int> geographyIdTranslation)
|
||||
private static void InitDatabaseThreadCreateGeographyChildren(Activizr.Site.Automation.Geography[] children,
|
||||
int parentGeographyId,
|
||||
ref Dictionary<int, int> geographyIdTranslation)
|
||||
{
|
||||
foreach (Activizr.Site.Automation.Geography geography in children)
|
||||
{
|
||||
@@ -512,7 +559,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
|
||||
try
|
||||
{
|
||||
int progress = (int)HttpContext.Current.Session["PercentInitComplete"];
|
||||
int progress = (int) HttpContext.Current.Session["PercentInitComplete"];
|
||||
|
||||
return progress;
|
||||
}
|
||||
@@ -540,7 +587,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
|
||||
string realHostName;
|
||||
|
||||
using (TextReader reader = new StreamReader("/etc/hostname")) // This will throw in a Windows dev environment
|
||||
using (TextReader reader = new StreamReader("/etc/hostname")) // This will throw in a Windows dev environment
|
||||
{
|
||||
realHostName = reader.ReadLine();
|
||||
}
|
||||
@@ -554,7 +601,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
}
|
||||
|
||||
[WebMethod(true)]
|
||||
public static bool VerifyHostAddress (string input)
|
||||
public static bool VerifyHostAddress(string input)
|
||||
{
|
||||
string localAddress = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"];
|
||||
|
||||
@@ -567,9 +614,9 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
}
|
||||
|
||||
[WebMethod(true)]
|
||||
public static bool VerifyHostNameAndAddress (string name, string address)
|
||||
public static bool VerifyHostNameAndAddress(string name, string address)
|
||||
{
|
||||
return VerifyHostName(name) && VerifyHostAddress(address);
|
||||
return VerifyHostName(HttpUtility.UrlDecode(name)) && VerifyHostAddress(HttpUtility.UrlDecode(address));
|
||||
}
|
||||
|
||||
[WebMethod(true)]
|
||||
@@ -577,4 +624,70 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
{
|
||||
return PirateDb.Configuration.TestConfigurationWritable();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static void CreateFirstUser(string name, string mail, string password)
|
||||
{
|
||||
// Make sure that no first person exists already, as a security measure
|
||||
|
||||
Activizr.Logic.Pirates.Person personOne = null;
|
||||
bool personOneExists = false;
|
||||
|
||||
try
|
||||
{
|
||||
personOne = Activizr.Logic.Pirates.Person.FromIdentity(1);
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
if (personOne.CityName != "Duckville" || personOne.Email != "noreply@example.com")
|
||||
// these values are returned in debug environments when no person is found
|
||||
{
|
||||
personOneExists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
personOne = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
personOneExists = true;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// We expect this to throw.
|
||||
}
|
||||
|
||||
if (personOneExists || personOne != null)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot run initialization processes again when initialized.");
|
||||
}
|
||||
|
||||
Activizr.Logic.Pirates.Person newPerson = Activizr.Logic.Pirates.Person.Create(HttpUtility.UrlDecode(name), HttpUtility.UrlDecode(mail),
|
||||
HttpUtility.UrlDecode(password), string.Empty, string.Empty, string.Empty,
|
||||
string.Empty, string.Empty, DateTime.MinValue, PersonGender.Unknown);
|
||||
|
||||
newPerson.AddMembership(1, DateTime.MaxValue); // Add membership in Sandbox
|
||||
newPerson.AddRole(RoleType.SystemAdmin, 0, 0); // Add role System Admin
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void ButtonLogin_Click(object sender, EventArgs args)
|
||||
{
|
||||
// Check the host names and addresses again as a security measure - after all, we can be called from outside our intended script
|
||||
|
||||
if (!(VerifyHostName(this.TextServerName.Text) && VerifyHostAddress(this.TextServerAddress.Text)))
|
||||
{
|
||||
return; // Probable hack attempt - fail silently
|
||||
}
|
||||
|
||||
Activizr.Logic.Pirates.Person expectedPersonOne = Activizr.Logic.Security.Authentication.Authenticate("1", this.TextFirstUserPassword1.Text);
|
||||
|
||||
if (expectedPersonOne != null)
|
||||
{
|
||||
FormsAuthentication.RedirectFromLoginPage("1,1", true);
|
||||
Response.Redirect("/", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,12 +215,7 @@
|
||||
border: 1px solid #5A5655;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.swMain .buttonDisabled {
|
||||
color:#F8F8F8 !important;
|
||||
background-color: #CCCCCC !important;
|
||||
border: 1px solid #CCCCCC !important;
|
||||
cursor:text;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious {
|
||||
display:block;
|
||||
float:right;
|
||||
@@ -252,6 +247,83 @@
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious {
|
||||
position: relative;
|
||||
color: white;
|
||||
background: #8CC63F;
|
||||
border: 1px solid #8CC63F;
|
||||
z-index: 99;
|
||||
box-shadow: 1px 1px 4px #476EC7;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#B0C8FF', endColorstr='#86A6F0');
|
||||
background: -moz-linear-gradient(top, #B0C8FF, #86A6F0);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#B0C8FF), to(#86A6F0));
|
||||
text-shadow: #476EC7 0px 0px 3px, #476EC7 0px 0px 3px;
|
||||
border-color: #476EC7;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
.swMain .buttonNext, .swMain .buttonFinish {
|
||||
color: #7F5500;
|
||||
background: #EA8511;
|
||||
border: 1px solid #EA8511;
|
||||
box-shadow: 1px 1px 4px #7F5500;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFC145', endColorstr='#F0AB22');
|
||||
background: -moz-linear-gradient(top, #FFC145, #F0AB22);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#FFC145), to(#F0AB22));
|
||||
text-shadow: #FFEDC8 0px 0px 3px, #FFEDC8 0px 0px 3px;
|
||||
border-color: #C78B15;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
|
||||
.swMain .buttonPrevious:hover
|
||||
{
|
||||
top: -2px;
|
||||
left: -2px;
|
||||
box-shadow: 2px 2px 4px #476EC7;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious:active
|
||||
{
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
box-shadow: 0px 0px 4px #476EC7;
|
||||
}
|
||||
|
||||
.swMain .buttonNext:hover, .swMain .buttonFinish:hover
|
||||
{
|
||||
top: -2px;
|
||||
left: -2px;
|
||||
box-shadow: 2px 2px 4px #7F5500;
|
||||
}
|
||||
|
||||
.swMain .buttonNext:active, .swMain .buttonFinish:active
|
||||
{
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
box-shadow: 0px 0px 4px #7F5500;
|
||||
}
|
||||
|
||||
|
||||
.swMain .buttonDisabled {
|
||||
color:#F8F8F8 !important;
|
||||
background-color: #CCCCCC !important;
|
||||
border: 1px solid #CCCCCC !important;
|
||||
background: -ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#CCCCCC', endColorstr='#BBBBBB') !important;
|
||||
background: -moz-linear-gradient(top, #CCCCCC, #BBBBBB) !important;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#CCCCCC), to(#BBBBBB)) !important;
|
||||
cursor:text;
|
||||
top: 0px !important;
|
||||
left: 0px !important;
|
||||
box-shadow: none !important;
|
||||
text-shadow: none !important;
|
||||
}
|
||||
|
||||
|
||||
/* Form Styles */
|
||||
|
||||
.txtBox {
|
||||
|
||||
Reference in New Issue
Block a user