From e0ed96b1467321a74f470ac244fc1dbba8583fb9 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 28 Dec 2014 20:27:25 +0100 Subject: [PATCH 1/4] Fixed JSON/jQuery/Ajax/UrlRewrite conflict --- Site5/Pages/v5/Admin/EditOrganization.aspx | 4 ++-- Site5/Pages/v5/Comms/SendMassMessage.aspx | 2 +- Site5/Pages/v5/Financial/AttestCosts.aspx | 4 ++-- Site5/Pages/v5/Financial/PayOutMoney.aspx | 4 ++-- .../Pages/v5/Financial/ValidateReceipts.aspx | 4 ++-- Site5/Pages/v5/Init/Default.aspx | 20 +++++++++---------- Site5/Pages/v5/Ledgers/AccountPlan.aspx | 16 +++++++-------- Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs | 4 ++-- .../v5/Ledgers/ResyncExternalAccount.aspx | 6 +++--- Site5/Pages/v5/Ledgers/UploadBankFiles.aspx | 6 +++--- Site5/Pages/v5/Swarm/ListFindPeople.aspx | 4 ++-- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Site5/Pages/v5/Admin/EditOrganization.aspx b/Site5/Pages/v5/Admin/EditOrganization.aspx index 48d057e3..21cc47c8 100644 --- a/Site5/Pages/v5/Admin/EditOrganization.aspx +++ b/Site5/Pages/v5/Admin/EditOrganization.aspx @@ -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", diff --git a/Site5/Pages/v5/Comms/SendMassMessage.aspx b/Site5/Pages/v5/Comms/SendMassMessage.aspx index 62abb38d..a4d686e8 100644 --- a/Site5/Pages/v5/Comms/SendMassMessage.aspx +++ b/Site5/Pages/v5/Comms/SendMassMessage.aspx @@ -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", diff --git a/Site5/Pages/v5/Financial/AttestCosts.aspx b/Site5/Pages/v5/Financial/AttestCosts.aspx index e5ee5e69..b6380a62 100644 --- a/Site5/Pages/v5/Financial/AttestCosts.aspx +++ b/Site5/Pages/v5/Financial/AttestCosts.aspx @@ -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", diff --git a/Site5/Pages/v5/Financial/PayOutMoney.aspx b/Site5/Pages/v5/Financial/PayOutMoney.aspx index 7fcf8f66..06623554 100644 --- a/Site5/Pages/v5/Financial/PayOutMoney.aspx +++ b/Site5/Pages/v5/Financial/PayOutMoney.aspx @@ -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", diff --git a/Site5/Pages/v5/Financial/ValidateReceipts.aspx b/Site5/Pages/v5/Financial/ValidateReceipts.aspx index cfeba567..49392c3f 100644 --- a/Site5/Pages/v5/Financial/ValidateReceipts.aspx +++ b/Site5/Pages/v5/Financial/ValidateReceipts.aspx @@ -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", diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx index 837535e6..8a4e0e8d 100644 --- a/Site5/Pages/v5/Init/Default.aspx +++ b/Site5/Pages/v5/Init/Default.aspx @@ -104,7 +104,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 +129,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", @@ -177,7 +177,7 @@ // also, won't get re-enabled no matter the outcome $.ajax({ type: "POST", - url: "Default.aspx/FirstCredentialsTest", + url: "/Pages/v5/Init/Default.aspx/FirstCredentialsTest", data: "{" + "'readDatabase':'" + $('#<%=this.TextCredentialsReadDatabase.ClientID %>').val() + "',"+ "'readServer':'" + $('#<%=this.TextCredentialsReadServer.ClientID %>').val() + "',"+ @@ -261,7 +261,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,7 +306,7 @@ $.ajax({ type: "POST", - url: "Default.aspx/ResetTestCredentials", + url: "/Pages/v5/Init/Default.aspx/ResetTestCredentials", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", @@ -321,7 +321,7 @@ $.ajax({ type: "POST", - url: "Default.aspx/IsConfigurationFileWritable", + url: "/Pages/v5/Init/Default.aspx/IsConfigurationFileWritable", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", @@ -346,7 +346,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 +381,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 +411,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 +462,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", diff --git a/Site5/Pages/v5/Ledgers/AccountPlan.aspx b/Site5/Pages/v5/Ledgers/AccountPlan.aspx index 63f52257..5c6fd4eb 100644 --- a/Site5/Pages/v5/Ledgers/AccountPlan.aspx +++ b/Site5/Pages/v5/Ledgers/AccountPlan.aspx @@ -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", diff --git a/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs b/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs index b71a7128..ca1bb100 100644 --- a/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs +++ b/Site5/Pages/v5/Ledgers/AccountPlan.aspx.cs @@ -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 { diff --git a/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx b/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx index 3e6fb36b..a114f9f3 100644 --- a/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx +++ b/Site5/Pages/v5/Ledgers/ResyncExternalAccount.aspx @@ -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", diff --git a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx index 0989bcf6..cac30b5b 100644 --- a/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx +++ b/Site5/Pages/v5/Ledgers/UploadBankFiles.aspx @@ -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", diff --git a/Site5/Pages/v5/Swarm/ListFindPeople.aspx b/Site5/Pages/v5/Swarm/ListFindPeople.aspx index 1073394b..86de6b42 100644 --- a/Site5/Pages/v5/Swarm/ListFindPeople.aspx +++ b/Site5/Pages/v5/Swarm/ListFindPeople.aspx @@ -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", From a9dfd57dcdab8953eef4ff534624053cadd14e02 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 28 Dec 2014 23:04:52 +0100 Subject: [PATCH 2/4] Applied CurrencyTextBox to rest of pages --- Site5/Controls/v5/Financial/CurrencyTextBox.ascx.cs | 5 +++++ Site5/Pages/v5/Financial/CreateInboundInvoice.aspx | 9 +++++---- Site5/Pages/v5/Financial/CreateInboundInvoice.aspx.cs | 8 +++----- Site5/Pages/v5/Financial/FileExpenseClaim.aspx | 9 +++++---- Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs | 8 +++----- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Site5/Controls/v5/Financial/CurrencyTextBox.ascx.cs b/Site5/Controls/v5/Financial/CurrencyTextBox.ascx.cs index c9d88ac7..907d65ee 100644 --- a/Site5/Controls/v5/Financial/CurrencyTextBox.ascx.cs +++ b/Site5/Controls/v5/Financial/CurrencyTextBox.ascx.cs @@ -41,5 +41,10 @@ namespace Swarmops.Frontend.Controls.v5.Financial } // TODO: Add other-currency parsing + + public new void Focus() + { + this.Input.Focus(); + } } } \ No newline at end of file diff --git a/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx b/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx index 2865a7a0..70453cbd 100644 --- a/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx +++ b/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx @@ -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" %> @@ -53,7 +54,7 @@ isValid = validateTextField('#<%=this.TextPurpose.ClientID %>', "") && 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(""); - $('#<%=this.TextAmount.ClientID %>').focus(); + $('#<%=CurrencyAmount.ClientID %>_Input').focus(); } } }); @@ -114,7 +115,7 @@
​
- ​
+ ​
​
​
 
diff --git a/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx.cs b/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx.cs index dcaf0a67..e7fbd090 100644 --- a/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx.cs +++ b/Site5/Pages/v5/Financial/CreateInboundInvoice.aspx.cs @@ -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 diff --git a/Site5/Pages/v5/Financial/FileExpenseClaim.aspx b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx index 942bb8a2..2365e1d0 100644 --- a/Site5/Pages/v5/Financial/FileExpenseClaim.aspx +++ b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx @@ -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" %> @@ -50,7 +51,7 @@ isValid = validateTextField('#<%=this.TextPurpose.ClientID %>', "") && 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(""); - $('#<%=this.TextAmount.ClientID %>').focus(); + $('#<%=this.CurrencyAmount.ClientID %>_Input').focus(); } } }); @@ -107,7 +108,7 @@

- ​
+ ​
​
 
"> 
diff --git a/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs index c377d7b0..e52e0954 100644 --- a/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs +++ b/Site5/Pages/v5/Financial/FileExpenseClaim.aspx.cs @@ -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; From ae6b4bf29a35d44a1e0962b8652ed68f247c41f5 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 29 Dec 2014 03:13:12 +0100 Subject: [PATCH 3/4] Added autoconfig on Init + fixed bugs --- Database/Database-Initialization.cs | 23 ++++- Logic/Structure/GeographyUpdate.cs | 2 +- Site5/Pages/v5/Init/Default.aspx | 148 +++++++++++++++++++--------- Site5/Pages/v5/Init/Default.aspx.cs | 80 ++++++++++++++- Site5/Security/Login.aspx.cs | 2 +- 5 files changed, 203 insertions(+), 52 deletions(-) diff --git a/Database/Database-Initialization.cs b/Database/Database-Initialization.cs index f5cac109..19b06ab8 100644 --- a/Database/Database-Initialization.cs +++ b/Database/Database-Initialization.cs @@ -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 diff --git a/Logic/Structure/GeographyUpdate.cs b/Logic/Structure/GeographyUpdate.cs index 96aa8c2a..e920df84 100644 --- a/Logic/Structure/GeographyUpdate.cs +++ b/Logic/Structure/GeographyUpdate.cs @@ -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]; diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx index 8a4e0e8d..46620ebc 100644 --- a/Site5/Pages/v5/Init/Default.aspx +++ b/Site5/Pages/v5/Init/Default.aspx @@ -10,6 +10,7 @@ + @@ -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: "/Pages/v5/Init/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) { @@ -311,7 +352,7 @@ 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(); }); } }); } @@ -328,10 +369,10 @@ 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. @@ -470,8 +511,16 @@ } }); - } + } + function goManualCredentials() { + autoConfigMode = false; + $('#DivDatabaseRootConfig').css('display', 'none'); + $('#DivDatabaseManualConfig').fadeIn('slow'); + setTimeout('$("#<%=this.TextCredentialsReadDatabase.ClientID %>").focus();', 250); + } + + var autoConfigMode = true; @@ -582,8 +631,15 @@
-