This commit is contained in:
Rick Falkvinge
2014-12-29 16:24:54 +01:00
21 changed files with 265 additions and 109 deletions
+20 -3
View File
@@ -8,7 +8,7 @@ namespace Swarmops.Database
{
// These functions are bloody dangerous, mmmkay?
public void ExecuteAdminCommand (string sqlSequence)
public void ExecuteAdminCommand(string sql)
{
// TODO: Verify that we're in admin mode
@@ -16,14 +16,31 @@ namespace Swarmops.Database
{
connection.Open();
DbCommand command = GetDbCommand (sqlSequence, connection);
DbCommand command = GetDbCommand(sql, connection);
command.CommandType = CommandType.Text;
command.ExecuteNonQuery();
}
}
public int ExecuteAdminCommandScalar (string sqlSequence)
public void ExecuteAdminCommands(string[] sqlSequence)
{
// TODO: Verify that we're in admin mode
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
foreach (string sql in sqlSequence)
{
DbCommand command = GetDbCommand (sql, connection);
command.CommandType = CommandType.Text;
command.ExecuteNonQuery();
}
}
}
public int ExecuteAdminCommandScalar(string sqlSequence)
{
// TODO: Verify that we're in admin mode
+1 -1
View File
@@ -159,7 +159,7 @@ namespace Swarmops.Logic.Structure
cityIdsUsedLookup[city.CityId] = false; // force non-use of invalid city
}
if (cityIdsUsedLookup[city.CityId])
if ((cityIdsUsedLookup.ContainsKey(city.CityId) && cityIdsUsedLookup[city.CityId]) || country.PostalCodeLength == 0)
{
int newGeographyId = geographyIdTranslation[city.GeographyId];
@@ -22,6 +22,8 @@ namespace Swarmops.Frontend.Automation
matches = new People();
}
// TODO: Add filter so the people must have active memberships of this org or any org below it (fixes #1)
if (matches.Count > 10)
{
matches.RemoveRange (10, matches.Count - 10);
@@ -41,5 +41,10 @@ namespace Swarmops.Frontend.Controls.v5.Financial
}
// TODO: Add other-currency parsing
public new void Focus()
{
this.Input.Focus();
}
}
}
+2 -2
View File
@@ -26,7 +26,7 @@
$.ajax({
type: "POST",
url: "EditOrganization.aspx/SwitchToggled",
url: "/Pages/v5/Admin/EditOrganization.aspx/SwitchToggled",
data: $.toJSON(jsonData),
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -54,7 +54,7 @@
$.ajax({
type: "POST",
url: "EditOrganization.aspx/GetInitialData",
url: "/Pages/v5/Admin/EditOrganization.aspx/GetInitialData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
+1 -1
View File
@@ -20,7 +20,7 @@
function onGeographyChange(newGeographyId) {
$.ajax({
type: "POST",
url: "SendMassMessage.aspx/GetRecipientCount",
url: "/Pages/v5/Comms/SendMassMessage.aspx/GetRecipientCount",
data: "{'recipientTypeId': '" + $('#<%=this.DropRecipientClasses.ClientID %>').val() + "', 'geographyId':'" + newGeographyId + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
+2 -2
View File
@@ -65,7 +65,7 @@
var thisIcon = this;
$.ajax({
type: "POST",
url: "AttestCosts.aspx/Attest",
url: "/Pages/v5/Financial/AttestCosts.aspx/Attest",
data: "{'identifier': '" + escape($(this).attr("baseid")) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -87,7 +87,7 @@
var thisIcon = this;
$.ajax({
type: "POST",
url: "AttestCosts.aspx/Deattest",
url: "/Pages/v5/Financial/AttestCosts.aspx/Deattest",
data: "{'identifier': '" + escape($(this).attr("baseid")) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -1,6 +1,7 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="CreateInboundInvoice.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.CreateInboundInvoice" %>
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="CurrencyAmount" Src="~/Controls/v5/Financial/CurrencyTextBox.ascx" %>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
@@ -53,7 +54,7 @@
isValid = validateTextField('#<%=this.TextPurpose.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorPurpose" />") && isValid;
var jsonData = {};
jsonData.amount = $('#<%=this.TextAmount.ClientID %>').val();
jsonData.amount = $('#<%=this.CurrencyAmount.ClientID %>_Input').val();
$.ajax({
type: "POST",
@@ -65,9 +66,9 @@
success: function(msg) {
if (msg.d != true) {
isValid = false;
$('#TextAmount').addClass("entryError");
$('#<%=CurrencyAmount.ClientID %>_Input').addClass("entryError");
alertify.error("<asp:Literal runat="server" ID="LiteralErrorAmount" />");
$('#<%=this.TextAmount.ClientID %>').focus();
$('#<%=CurrencyAmount.ClientID %>_Input').focus();
}
}
});
@@ -114,7 +115,7 @@
<asp:HiddenField ID="HiddenTagSetIdentifiers" runat="server"/>
<div class="entryFields">
<asp:TextBox runat="server" ID="TextSupplier" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextAmount" CssClass="alignRight" />&#8203;<br/>
<Swarmops5:CurrencyAmount runat="server" ID="CurrencyAmount" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextPurpose" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextDueDate" />&#8203;<br/>
<Swarmops5:ComboBudgets ID="ComboBudgets" runat="server" />&nbsp;<br/>
@@ -96,7 +96,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
{
// Prime bank details
this.TextAmount.Text = 0.ToString ("N2");
this.CurrencyAmount.Value = 0;
this.TextSupplier.Focus();
this.TextDueDate.Text = DateTime.Today.AddDays (30).ToShortDateString(); // Use current culture
@@ -137,9 +137,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// The data has been validated client-side already. We'll throw unfriendly exceptions if invalid data is passed here.
// People who choose to disable JavaScript and then submit bad input almost deserve to be hurt.
double amount = Double.Parse (this.TextAmount.Text, NumberStyles.Number);
// parses in current culture - intentional
Int64 amountCents = (Int64) (amount*100);
Int64 amountCents = (Int64) (this.CurrencyAmount.Value*100.0);
string description = this.TextPurpose.Text;
@@ -200,7 +198,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
this.TextAccount.Text = String.Empty;
this.TextPurpose.Text = String.Empty;
this.TextReference.Text = String.Empty;
this.TextAmount.Text = 0.ToString ("N2");
this.CurrencyAmount.Value = 0;
this.TextDueDate.Text = DateTime.Today.AddDays (30).ToShortDateString(); // Use current culture
// the easyUI combo fields should reset automatically on form submission unless we explicitly reconstruct
@@ -1,6 +1,7 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="FileExpenseClaim.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Financial.FileExpenseClaim" %>
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="CurrencyAmount" Src="~/Controls/v5/Financial/CurrencyTextBox.ascx" %>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
@@ -50,7 +51,7 @@
isValid = validateTextField('#<%=this.TextPurpose.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorPurpose" />") && isValid;
var jsonData = {};
jsonData.amount = $('#<%=this.TextAmount.ClientID %>').val();
jsonData.amount = $('#<%=this.CurrencyAmount.ClientID %>_Input').val();
$.ajax({
type: "POST",
@@ -62,9 +63,9 @@
success: function (msg) {
if (msg.d != true) {
isValid = false;
$('#TextAmount').addClass("entryError");
$('#<%=this.CurrencyAmount.ClientID %>_Input').addClass("entryError");
alertify.error("<asp:Literal runat="server" ID="LiteralErrorAmount" />");
$('#<%=this.TextAmount.ClientID %>').focus();
$('#<%=this.CurrencyAmount.ClientID %>_Input').focus();
}
}
});
@@ -107,7 +108,7 @@
<h2><asp:Label runat="server" ID="BoxTitle" /></h2>
<asp:HiddenField ID="HiddenTagSetIdentifiers" runat="server"/>
<div class="entryFields">
<asp:TextBox runat="server" ID="TextAmount" CssClass="alignRight" />&#8203;<br/>
<Swarmops5:CurrencyAmount runat="server" ID="CurrencyAmount" />&#8203;<br/>
<asp:TextBox runat="server" ID="TextPurpose" />&#8203;<br/>
<Swarmops5:ComboBudgets ID="ComboBudgets" runat="server" />&nbsp;<br/>
<asp:Repeater ID="RepeaterTagDrop" runat="server"><ItemTemplate><span id="SpanDropTags<%# Eval("TagSetId") %>"><select class="easyui-combotree" url="/Automation/Json-TransactionTagsTree.aspx?TagSetId=<%# Eval("TagSetId") %>" name="DropTags<%# Eval("TagSetId") %>" id="DropTags<%# Eval("TagSetId") %>" animate="true" style="width:300px"></select></span>&nbsp;<br/></ItemTemplate></asp:Repeater>
@@ -104,8 +104,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
this.TextBank.Text = CurrentUser.BankName;
this.TextClearing.Text = CurrentUser.BankClearing;
this.TextAccount.Text = CurrentUser.BankAccount;
this.TextAmount.Text = 0.ToString ("N2");
this.TextAmount.Focus();
this.CurrencyAmount.Value = 0;
this.CurrencyAmount.Focus();
Localize();
}
@@ -144,9 +144,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
// The data has been validated client-side already. We'll throw unfriendly exceptions if invalid data is passed here.
// People who choose to disable JavaScript and then submit bad input almost deserve to be hurt.
double amount = Double.Parse (this.TextAmount.Text, NumberStyles.Number);
// parses in current culture - intentional
Int64 amountCents = (Int64) (amount*100.0);
Int64 amountCents = (Int64) (this.CurrencyAmount.Value*100.0);
string description = this.TextPurpose.Text;
+2 -2
View File
@@ -60,7 +60,7 @@
var thisIcon = this;
$.ajax({
type: "POST",
url: "PayOutMoney.aspx/ConfirmPayout",
url: "/Pages/v5/Financial/PayOutMoney.aspx/ConfirmPayout",
data: "{'protoIdentity': '" + escape($(this).attr("baseid")) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -84,7 +84,7 @@
$(this).attr("src", "/Images/Abstract/ajaxloader-medium.gif");
$.ajax({
type: "POST",
url: "PayOutMoney.aspx/UndoPayout",
url: "/Pages/v5/Financial/PayOutMoney.aspx/UndoPayout",
data: "{'databaseId': '" + $("#IconApproval" + $(thisIcon).attr("baseid").replace(/\|/g, '')).attr("databaseid") + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -65,7 +65,7 @@
var thisIcon = this;
$.ajax({
type: "POST",
url: "ValidateReceipts.aspx/Validate",
url: "/Pages/v5/Financial/ValidateReceipts.aspx/Validate",
data: "{'identifier': '" + escape($(this).attr("baseid")) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -87,7 +87,7 @@
var thisIcon = this;
$.ajax({
type: "POST",
url: "ValidateReceipts.aspx/Devalidate",
url: "/Pages/v5/Financial/ValidateReceipts.aspx/Devalidate",
data: "{'identifier': '" + escape($(this).attr("baseid")) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
+113 -57
View File
@@ -10,6 +10,7 @@
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script language="javascript" type="text/javascript" src="/Scripts/jquery.leanModal.min.js" ></script>
<script language="javascript" type="text/javascript" src="/Scripts/jquery.smartWizard-2.0.min.js"></script>
<script language="javascript" type="text/javascript" src="/Scripts/jquery.json.min.js"></script>
<!-- fonts -->
<link href='https://fonts.googleapis.com/css?family=Permanent+Marker' rel='stylesheet' type='text/css' />
@@ -104,7 +105,7 @@
if (hostName && hostName.length > 0 && hostAddress && hostAddress.length > 0) {
$.ajax({
type: "POST",
url: "Default.aspx/VerifyHostNameAndAddress",
url: "/Pages/v5/Init/Default.aspx/VerifyHostNameAndAddress",
data: "{'name': '" + escape(hostName) + "', 'address': '" + escape(hostAddress) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -129,7 +130,7 @@
if (isValid) { // Validate writability of config file
$.ajax({
type: "POST",
url: "Default.aspx/IsConfigurationFileWritable",
url: "/Pages/v5/Init/Default.aspx/IsConfigurationFileWritable",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -139,8 +140,9 @@
// Yes, config is writable. Hide "unwritable" div, show "writable" div, all is nice
$('#DivDatabaseUnwritable').css('display', 'none');
$('#DivDatabaseWritable').css('display', 'inline');
$('#<%=this.TextCredentialsReadDatabase.ClientID %>').focus();
$('#DivDatabaseRootConfig').css('display', 'inline');
setTimeout('$("#TextMysqlServerHost").focus();', 250);
//$('#<%=this.TextCredentialsReadDatabase.ClientID %>').focus();
} else {
// Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds.
@@ -155,9 +157,17 @@
else if (stepNumber == 2) {
isValid = true; // assume true, make false as we go
textBoxes = ["<%=this.TextCredentialsReadDatabase.ClientID %>", "<%=this.TextCredentialsReadServer.ClientID %>", "<%=this.TextCredentialsReadUser.ClientID %>", "<%=this.TextCredentialsReadPassword.ClientID %>",
"<%=this.TextCredentialsWriteDatabase.ClientID %>", "<%=this.TextCredentialsWriteServer.ClientID %>", "<%=this.TextCredentialsWriteUser.ClientID %>", "<%=this.TextCredentialsWritePassword.ClientID %>",
"<%=this.TextCredentialsAdminDatabase.ClientID %>", "<%=this.TextCredentialsAdminServer.ClientID %>", "<%=this.TextCredentialsAdminUser.ClientID %>", "<%=this.TextCredentialsAdminPassword.ClientID %>"];
textBoxes = [];
if (autoConfigMode) {
textBoxes = ["TextMysqlServerHost", "TextMysqlRootPassword"];
} else {
textBoxes = [
"<%=this.TextCredentialsReadDatabase.ClientID %>", "<%=this.TextCredentialsReadServer.ClientID %>", "<%=this.TextCredentialsReadUser.ClientID %>", "<%=this.TextCredentialsReadPassword.ClientID %>",
"<%=this.TextCredentialsWriteDatabase.ClientID %>", "<%=this.TextCredentialsWriteServer.ClientID %>", "<%=this.TextCredentialsWriteUser.ClientID %>", "<%=this.TextCredentialsWritePassword.ClientID %>",
"<%=this.TextCredentialsAdminDatabase.ClientID %>", "<%=this.TextCredentialsAdminServer.ClientID %>", "<%=this.TextCredentialsAdminUser.ClientID %>", "<%=this.TextCredentialsAdminPassword.ClientID %>"
];
}
for (loop = 0; loop < textBoxes.length; loop++) {
fieldContents = $('#' + textBoxes[loop]).val();
@@ -174,42 +184,73 @@
if (isValid) {
DisableNext(); // block Next during synchro call - it may take a while
// also, won't get re-enabled no matter the outcome
$.ajax({
type: "POST",
url: "Default.aspx/FirstCredentialsTest",
data: "{" +
"'readDatabase':'" + $('#<%=this.TextCredentialsReadDatabase.ClientID %>').val() + "',"+
"'readServer':'" + $('#<%=this.TextCredentialsReadServer.ClientID %>').val() + "',"+
"'readUser':'" + $('#<%=this.TextCredentialsReadUser.ClientID %>').val() + "',"+
"'readPassword':'" + $('#<%=this.TextCredentialsReadPassword.ClientID %>').val() + "',"+
"'writeDatabase':'" + $('#<%=this.TextCredentialsWriteDatabase.ClientID %>').val() + "',"+
"'writeServer':'" + $('#<%=this.TextCredentialsWriteServer.ClientID %>').val() + "',"+
"'writeUser':'" + $('#<%=this.TextCredentialsWriteUser.ClientID %>').val() + "',"+
"'writePassword':'" + $('#<%=this.TextCredentialsWritePassword.ClientID %>').val() + "',"+
"'adminDatabase':'" + $('#<%=this.TextCredentialsAdminDatabase.ClientID %>').val() + "',"+
"'adminServer':'" + $('#<%=this.TextCredentialsAdminServer.ClientID %>').val() + "',"+
"'adminUser':'" + $('#<%=this.TextCredentialsAdminUser.ClientID %>').val() + "',"+
"'adminPassword':'" + $('#<%=this.TextCredentialsAdminPassword.ClientID %>').val() + "',"+
"'serverName':'" + hostName + "'," +
"'ipAddress':'" + hostAddress +"'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false, // blocks until function returns - race conditions otherwise
success: function (msg) {
if (msg.d.AllPermissionsOk != true) {
// also, won't get re-enabled no matter the outcome
// We have a permissions problem. Block further progress and display the problem.
updatePermissionsAnalysisDisplay(msg.d);
$('#DivDatabaseWritable').fadeOut(400, 'swing', function() { $('#DivDatabasePermissionProblem').fadeIn(200); });
setTimeout('recheckDatabasePermissionsAnalysis();', 5000); // 5s until first re-check
isValid = false;
} else {
// re-enable Next only on exit of step 3
var jsonData = {};
jsonData.serverName = hostName;
jsonData.ipAddress = hostAddress;
if (autoConfigMode) {
jsonData.mysqlHostName = $('#TextMysqlServerHost').val();
jsonData.rootPassword = $('#TextMysqlRootPassword').val();
$.ajax({
type: "POST",
url: "/Pages/v5/Init/Default.aspx/CreateDatabaseFromRoot",
data: $.toJSON(jsonData),
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false, // blocks until function returns - race conditions otherwise
success: function (msg) {
if (msg.d != true) {
// Credentials problem.
$('#TextMysqlRootPassword, #TextMysqlServerHost').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
EnableNext();
isValid = false;
} else {
// re-enable Next only on exit of step 3
}
}
}
});
}
});
}
else
{
jsonData.readDatabase = $('#<%=this.TextCredentialsReadDatabase.ClientID %>').val();
jsonData.readServer = $('#<%=this.TextCredentialsReadServer.ClientID %>').val();
jsonData.readUser = $('#<%=this.TextCredentialsReadUser.ClientID %>').val();
jsonData.readPassword = $('#<%=this.TextCredentialsReadPassword.ClientID %>').val();
jsonData.writeDatabase = $('#<%=this.TextCredentialsWriteDatabase.ClientID %>').val();
jsonData.writeServer = $('#<%=this.TextCredentialsWriteServer.ClientID %>').val();
jsonData.writeUser = $('#<%=this.TextCredentialsWriteUser.ClientID %>').val();
jsonData.writePassword = $('#<%=this.TextCredentialsWritePassword.ClientID %>').val();
jsonData.adminDatabase = $('#<%=this.TextCredentialsAdminDatabase.ClientID %>').val();
jsonData.adminServer = $('#<%=this.TextCredentialsAdminServer.ClientID %>').val();
jsonData.adminUser = $('#<%=this.TextCredentialsAdminUser.ClientID %>').val();
jsonData.adminPassword = $('#<%=this.TextCredentialsAdminPassword.ClientID %>').val();
$.ajax({
type: "POST",
url: "/Pages/v5/Init/Default.aspx/FirstCredentialsTest",
data: $.toJSON(jsonData),
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false, // blocks until function returns - race conditions otherwise
success: function(msg) {
if (msg.d.AllPermissionsOk != true) {
// We have a permissions problem. Block further progress and display the problem.
updatePermissionsAnalysisDisplay(msg.d);
$('#DivDatabaseManualConfig').fadeOut(400, 'swing', function() { $('#DivDatabasePermissionProblem').fadeIn(200); });
setTimeout('recheckDatabasePermissionsAnalysis();', 5000); // 5s until first re-check
isValid = false;
} else {
// re-enable Next only on exit of step 3
}
}
});
}
}
if (isValid) {
@@ -261,7 +302,7 @@
if (isValid) {
$.ajax({
type: "POST",
url: "Default.aspx/CreateFirstUser",
url: "/Pages/v5/Init/Default.aspx/CreateFirstUser",
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",
@@ -306,12 +347,12 @@
$.ajax({
type: "POST",
url: "Default.aspx/ResetTestCredentials",
url: "/Pages/v5/Init/Default.aspx/ResetTestCredentials",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$('#DivDatabasePermissionProblem').fadeOut(200, 'swing', function () { $('#DivDatabaseWritable').fadeIn(200); EnableNext(); });
$('#DivDatabasePermissionProblem').fadeOut(200, 'swing', function () { $('#DivDatabaseManualConfig').fadeIn(200); EnableNext(); });
}
});
}
@@ -321,17 +362,17 @@
$.ajax({
type: "POST",
url: "Default.aspx/IsConfigurationFileWritable",
url: "/Pages/v5/Init/Default.aspx/IsConfigurationFileWritable",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d == true) {
// Yes, config is writable. Hide "unwritable" div, show "writable" div, all is nice
// Yes, config is writable. Hide "unwritable" div, show "config" div, all is nice
$('#DivDatabaseUnwritable').css('display', 'none');
$('#DivDatabaseWritable').fadeIn('slow');
setTimeout('$("#<%=this.TextCredentialsReadDatabase.ClientID %>").focus();', 250);
$('#DivDatabaseManualConfig').fadeIn('slow');
setTimeout('$("#TextMysqlServerHost").focus();', 250);
EnableNext();
} else {
// Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds.
@@ -346,7 +387,7 @@
$.ajax({
type: "POST",
url: "Default.aspx/GetInitProgress",
url: "/Pages/v5/Init/Default.aspx/GetInitProgress",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -381,7 +422,7 @@
$.ajax({
type: "POST",
url: "Default.aspx/GetInitProgressMessage",
url: "/Pages/v5/Init/Default.aspx/GetInitProgressMessage",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -411,7 +452,7 @@
$.ajax({
type: "POST",
url: "Default.aspx/RecheckDatabasePermissions",
url: "/Pages/v5/Init/Default.aspx/RecheckDatabasePermissions",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -462,7 +503,7 @@
function beginInitDatabase() {
$.ajax({
type: "POST",
url: "Default.aspx/InitDatabase",
url: "/Pages/v5/Init/Default.aspx/InitDatabase",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -470,16 +511,24 @@
}
});
}
}
function goManualCredentials() {
autoConfigMode = false;
$('#DivDatabaseRootConfig').css('display', 'none');
$('#DivDatabaseManualConfig').fadeIn('slow');
setTimeout('$("#<%=this.TextCredentialsReadDatabase.ClientID %>").focus();', 250);
}
var autoConfigMode = true;
</script>
<!-- Main menu, dynamically constructed -->
<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/Logo-Stock.png" alt="Swarmops Logo" /></a></div>
<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-24px.png" /></div>
<div class="logoimage"><a href="/"><img style="border:none" src="/Images/Logo-Stock.png" alt="Swarmops Logo" /></a></div>
<div class="break"></div>
<div class="topmenu">
<div class="searchbox"><asp:TextBox ID="SearchBox" runat="server" /></div>
@@ -582,8 +631,15 @@
</tr>
</table>
</div>
<div id="DivDatabaseWritable" style="display:none">
<h2>Connect to database</h2>
<div id="DivDatabaseRootConfig" style="display:none">
<h2>Create the database and users</h2>
<p>The Swarmops install sequence can set up the database and users for you, if you provide a root password to the MySQL database server.</p>
<p>(If you don't trust the Swarmops install to do that, that's fine, go to <a href="javascript:goManualCredentials();">manual account credentials</a>.)</p>
<div class="entryLabelsAdmin" style="width:250px">Hostname of MySQL database server<br/>Root password for that MySQL server<br/>&nbsp;</div>
<div class="entryFieldsAdmin"><input type="text" id="TextMysqlServerHost" value="localhost"/>&nbsp;<br/><input type="password" id="TextMysqlRootPassword"/>&nbsp;</div>
</div>
<div id="DivDatabaseManualConfig" style="display:none">
<h2>Connect to existing database</h2>
<p>Before you fill this in, you will need to have created a database on a MySQL server that this web server can access, and set up user accounts that can access it. For security reasons, we <strong>require</strong> having three separate accounts - one for reading (SELECT permissions only), one for writing (SELECT and EXECUTE), and one for admin. All three accounts also need SELECT permissions on the mysql database.</p>
<div class="entryLabelsAdmin" style="width:120px">
+80 -2
View File
@@ -166,10 +166,78 @@ public partial class Pages_v5_Init_Default : Page
{
flagName = cultureStringLower.Substring (3);
}
this.ImageCultureIndicator.ImageUrl = "~/Images/Flags/" + flagName + ".png";
this.ImageCultureIndicator.ImageUrl = "~/Images/Flags/" + flagName + "-24px.png";
}
[WebMethod]
public static bool CreateDatabaseFromRoot (string mysqlHostName, string rootPassword, string serverName, string ipAddress)
{
if (!(VerifyHostName(serverName) && VerifyHostAddress(ipAddress)))
{
if (!Debugger.IsAttached)
{
return true; // Probable hack attempt - fail silently
}
}
try
{
string random = Authentication.CreateRandomPassword(5);
SwarmDb.Credentials rootCredentials = new SwarmDb.Credentials("mysql", new SwarmDb.ServerSet(mysqlHostName), "root", rootPassword);
string readPass = GenerateLongPassword();
string writePass = GenerateLongPassword();
string adminPass = GenerateLongPassword();
string[] initInstructions =
DbCreateScript.Replace ("[random]", random)
.Replace ("[readpass]", readPass)
.Replace ("[writepass]", writePass)
.Replace ("[adminpass]", adminPass).Split ('#');
SwarmDb.GetTestDatabase (rootCredentials).ExecuteAdminCommands (initInstructions);
PermissionsAnalysis permissionsResult = FirstCredentialsTest (
"Swarmops-" + random, mysqlHostName, "Swarmops-R-" + random, readPass,
"Swarmops-" + random, mysqlHostName, "Swarmops-W-" + random, writePass,
"Swarmops-" + random, mysqlHostName, "Swarmops-A-" + random, adminPass,
serverName, ipAddress);
if (!permissionsResult.AllPermissionsOk)
{
throw new InvalidOperationException("waaaaaah");
}
return true;
}
catch (Exception)
{
return false;
}
}
const string DbCreateScript =
"CREATE DATABASE `Swarmops-[random]`#" +
"CREATE USER `Swarmops-R-[random]` IDENTIFIED BY '[readpass]'#" +
"CREATE USER `Swarmops-W-[random]` IDENTIFIED BY '[writepass]'#" +
"CREATE USER `Swarmops-A-[random]` IDENTIFIED BY '[adminpass]'#" +
"GRANT SELECT ON mysql.proc TO `Swarmops-W-[random]`#" +
"GRANT SELECT ON mysql.proc TO `Swarmops-A-[random]`#" +
"USE `Swarmops-[random]`#" +
"GRANT ALL ON `Swarmops-[random]`.* TO `Swarmops-A-[random]`#" +
"GRANT SELECT ON `Swarmops-[random]`.* TO `Swarmops-W-[random]`#" +
"GRANT EXECUTE ON `Swarmops-[random]`.* TO `Swarmops-W-[random]`#" +
"GRANT SELECT ON `Swarmops-[random]`.* TO `Swarmops-R-[random]`#" +
"FLUSH PRIVILEGES";
static private string GenerateLongPassword()
{
return Guid.NewGuid().ToString ("N") + Guid.NewGuid().ToString ("N");
}
[WebMethod]
public static PermissionsAnalysis FirstCredentialsTest
@@ -427,10 +495,11 @@ public partial class Pages_v5_Init_Default : Page
{
// Get the geography layout
_initMessage = "Initializing geography for " + countryCode + "... ";
_initMessage = "Initializing geography for country " + countryCode + "... ";
Thread.Sleep (100);
GeographyUpdate.PrimeCountry (countryCode);
GuidCache.Set ("DbInitProgress", string.Empty);
countryCount++;
@@ -446,6 +515,8 @@ public partial class Pages_v5_Init_Default : Page
Persistence.Key["SwarmopsInstallationId"] = Guid.NewGuid().ToString();
_initMessage = "Initializing currencies...";
// Create initial currencies (European et al)
Currency.Create ("EUR", "Euros", "€");
@@ -459,6 +530,10 @@ public partial class Pages_v5_Init_Default : Page
Currency.Create ("GBP", "Pounds Sterling", "£");
Currency.Create ("BTC", "Bitcoin", "฿");
// Fetch the first set of exchange rates, completing the currency collection
ExchangeRateSnapshot.Create();
// Create the sandbox
Organization.Create (0, "Sandbox", "Sandbox", "Sandbox", "swarmops.com", "Ops",
@@ -645,8 +720,11 @@ public partial class Pages_v5_Init_Default : Page
FormsAuthentication.RedirectFromLoginPage ("1,1", true);
Response.Redirect ("/", true);
}
}
public class PermissionsAnalysis
{
public bool AllPermissionsOk { get; set; }
+8 -8
View File
@@ -85,7 +85,7 @@
$('#TextAccountName').css('background-color', '#FFFFE0');
$.ajax({
type: "POST",
url: "AccountPlan.aspx/SetAccountName",
url: "/Pages/v5/Ledgers/AccountPlan.aspx/SetAccountName",
data: "{'accountId': '" + escape(accountId) + "', 'name':'" + escape(newAccountName) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -124,7 +124,7 @@
$('#TextAccountBudget').css('background-color', '#FFFFE0');
$.ajax({
type: "POST",
url: "AccountPlan.aspx/SetAccountBudget",
url: "/Pages/v5/Ledgers/AccountPlan.aspx/SetAccountBudget",
data: "{'accountId': '" + escape(accountId) + "', 'budget':'" + escape(newAccountBudget) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -168,7 +168,7 @@
$(this).css('background-color', '#FFFFE0');
$.ajax({
type: "POST",
url: "AccountPlan.aspx/SetAccountInitialBalance",
url: "/Pages/v5/Ledgers/AccountPlan.aspx/SetAccountInitialBalance",
data: $.toJSON(jsonData),
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -200,7 +200,7 @@
function addAccount() {
$.ajax({
type: "POST",
url: "AccountPlan.aspx/CreateAccount",
url: "/Pages/v5/Ledgers/AccountPlan.aspx/CreateAccount",
data: "{'accountType': '" + accountType + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -314,7 +314,7 @@
$.ajax({
type: "POST",
url: "AccountPlan.aspx/SetAccountSwitch",
url: "/Pages/v5/Ledgers/AccountPlan.aspx/SetAccountSwitch",
data: callParameters,
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -365,7 +365,7 @@
$.ajax({
type: "POST",
url: "AccountPlan.aspx/GetAccountData",
url: "/Pages/v5/Ledgers/AccountPlan.aspx/GetAccountData",
data: "{'accountId': '" + escape(accountId) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -408,7 +408,7 @@
$('span#<%= DropOwner.ClientID %>_SpanPeople span input.combo-text').css('background-color', '#FFFFE0');
$.ajax({
type: "POST",
url: "AccountPlan.aspx/SetAccountOwner",
url: "/Pages/v5/Ledgers/AccountPlan.aspx/SetAccountOwner",
data: "{'accountId':'" + escape(accountId) + "','newOwnerId':'" + escape(personId) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -455,7 +455,7 @@
$('span#<%= DropParents.ClientID %>_SpanBudgets span input.combo-text').css('background-color', '#FFFFE0');
$.ajax({
type: "POST",
url: "AccountPlan.aspx/SetAccountParent",
url: "/Pages/v5/Ledgers/AccountPlan.aspx/SetAccountParent",
data: "{'accountId':'" + escape(accountId) + "','parentAccountId':'" + escape(parentAccountId) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
+2 -2
View File
@@ -136,8 +136,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
(
"N0");
result.InitialBalance =
(accountTree.GetDeltaCents (new DateTime (1900, 1, 1),
new DateTime (authData.CurrentOrganization.FirstFiscalYear, 1, 1)).ToString ("N2"));
((accountTree.GetDeltaCents (new DateTime (1900, 1, 1),
new DateTime (authData.CurrentOrganization.FirstFiscalYear, 1, 1))/100.0).ToString ("N2"));
}
else
{
@@ -81,7 +81,7 @@
$.ajax({
type: "POST",
url: "ResyncExternalAccount.aspx/InitializeProcessing",
url: "/Pages/v5/Ledgers/ResyncExternalAccount.aspx/InitializeProcessing",
data: "{'guid': '<%= this.UploadFile.GuidString %>', 'accountIdString':'" + $('#<%= this.DropAccounts.ClientID %>').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -97,7 +97,7 @@
$.ajax({
type: "POST",
url: "ResyncExternalAccount.aspx/GetProcessingProgress",
url: "/Pages/v5/Ledgers/ResyncExternalAccount.aspx/GetProcessingProgress",
data: "{'guid': '<%= this.UploadFile.GuidString %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -156,7 +156,7 @@
$.ajax({
type: "POST",
url: "ResyncExternalAccount.aspx/ExecuteResync",
url: "/Pages/v5/Ledgers/ResyncExternalAccount.aspx/ExecuteResync",
data: "{'guid': '<%= this.UploadFile.GuidString %>'}",
async: false,
contentType: "application/json; charset=utf-8",
+3 -3
View File
@@ -29,7 +29,7 @@
$.ajax({
type: "POST",
url: "UploadBankFiles.aspx/GetAccountUploadInstructions",
url: "/Pages/v5/Ledgers/UploadBankFiles.aspx/GetAccountUploadInstructions",
data: "{'guid': '<%= this.UploadFile.GuidString %>', 'accountIdString':'" + $('#<%= this.DropAccounts.ClientID %>').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -54,7 +54,7 @@
$.ajax({
type: "POST",
url: "UploadBankFiles.aspx/InitializeProcessing",
url: "/Pages/v5/Ledgers/UploadBankFiles.aspx/InitializeProcessing",
data: "{'guid': '<%= this.UploadFile.GuidString %>', 'accountIdString':'" + $('#<%= this.DropAccounts.ClientID %>').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -84,7 +84,7 @@
$.ajax({
type: "POST",
url: "UploadBankFiles.aspx/GetReportedImportResults",
url: "/Pages/v5/Ledgers/UploadBankFiles.aspx/GetReportedImportResults",
data: "{'guid': '<%= this.UploadFile.GuidString %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
+2 -2
View File
@@ -96,7 +96,7 @@
var thisIcon = this;
$.ajax({
type: "POST",
url: "PayOutMoney.aspx/ConfirmPayout",
url: "/Pages/v5/SOMEPATH/PayOutMoney.aspx/ConfirmPayout",
data: "{'protoIdentity': '" + escape($(this).attr("baseid")) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -120,7 +120,7 @@
$(this).attr("src", "/Images/Abstract/ajaxloader-medium.gif");
$.ajax({
type: "POST",
url: "PayOutMoney.aspx/UndoPayout",
url: "/Pages/v5/SOMEPATH/PayOutMoney.aspx/UndoPayout",
data: "{'databaseId': '" + $("#IconApproval" + $(thisIcon).attr("baseid").replace(/\|/g, '')).attr("databaseid") + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
+1 -1
View File
@@ -28,7 +28,7 @@ namespace Swarmops.Pages.Security
if (!SwarmDb.Configuration.IsConfigured())
{
Response.Redirect ("/Init/", true);
Response.Redirect ("/Pages/v5/Init/", true);
return;
}