From 91361d720e16ea8b14c4ac9cfddc461ef0dad3ee Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 10 Dec 2014 08:31:22 +0100 Subject: [PATCH 01/33] Style bug on EasyUI in-header dropdowns --- Site5/Style/v5-easyui-elements.css | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Site5/Style/v5-easyui-elements.css b/Site5/Style/v5-easyui-elements.css index df0a65d0..710194d7 100644 --- a/Site5/Style/v5-easyui-elements.css +++ b/Site5/Style/v5-easyui-elements.css @@ -38,6 +38,16 @@ .content h2 span span.combo { padding-left: 4px !important; + padding-top: 0; + border: 1px solid #cccccc; + border-radius: 4px; + box-shadow: 0 0 3px 0 #dddddd inset; + cursor: default; +} + +.content h2 span span.combo:hover { + border: 1px solid #aaaaaa; + box-shadow: 0 0 3px 0 #bbbbbb inset; } .content > h2 > span > span.combo > input.combo-text { From d0930db0cd1f6c44da28f08f960742259ef5bdbd Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 13 Dec 2014 14:59:47 +0100 Subject: [PATCH 02/33] Checkpoint commit and dbupgrade 7 --- Database/Schemata/revisions.txt | 2 +- Database/Schemata/upgrade-0007.sql | 15 ++ Site5/Controls/v5/UI/ExternalScripts.ascx.cs | 12 +- .../v5/Admin/Hacks/PopulateCountry1.aspx | 106 +++++++++++ .../v5/Admin/Hacks/PopulateCountry1.aspx.cs | 167 ++++++++++++++++++ .../v5/Admin/Hacks/PopulateCountry2.aspx | 106 +++++++++++ .../v5/Admin/Hacks/PopulateCountry2.aspx.cs | 110 ++++++++++++ Site5/Pages/v5/Comms/SendMassMessage.aspx.cs | 2 + Site5/Pages/v5/Init/Default.aspx.cs | 22 --- 9 files changed, 516 insertions(+), 26 deletions(-) create mode 100644 Database/Schemata/upgrade-0007.sql create mode 100644 Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx create mode 100644 Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs create mode 100644 Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx create mode 100644 Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs diff --git a/Database/Schemata/revisions.txt b/Database/Schemata/revisions.txt index 3730ea6a..2aaf9886 100644 --- a/Database/Schemata/revisions.txt +++ b/Database/Schemata/revisions.txt @@ -4,4 +4,4 @@ 0004 - Added BankProfile tables and stored procs to insert/update. [Rick Falkvinge] 0005 - Changed PostalCodeLength for NO DK to 4; for GH to zero; added Country.Currency. [Rick Falkvinge] 0006 - Added Memberships.LocalNumber and .FamilyNumber; added CurrencyExchangeRate tables/procs. [Rick Falkvinge] - +0007 - NL update; added Lat/Long to PostalCodes and to People, indexed [RF] diff --git a/Database/Schemata/upgrade-0007.sql b/Database/Schemata/upgrade-0007.sql new file mode 100644 index 00000000..1a4c590f --- /dev/null +++ b/Database/Schemata/upgrade-0007.sql @@ -0,0 +1,15 @@ +UPDATE `Countries` SET `CurrencyCode`='EUR', `PostalCodeLength`='6' WHERE `CountryCode`='NL' + +# + +ALTER TABLE `PostalCodes` +CHANGE COLUMN `Lat` `Latitude` DOUBLE NOT NULL DEFAULT 0.0 , +CHANGE COLUMN `Long` `Longitude` DOUBLE NOT NULL DEFAULT 0.0 + +# + +ALTER TABLE `People` +ADD COLUMN `Latitude` DOUBLE NOT NULL DEFAULT 0.0 AFTER `GeographyId`, +ADD COLUMN `Longitude` DOUBLE NOT NULL DEFAULT 0.0 AFTER `Latitude`, +ADD INDEX `Index_Latitude` (`Latitude` ASC), +ADD INDEX `Index_Longitude` (`Longitude` ASC) diff --git a/Site5/Controls/v5/UI/ExternalScripts.ascx.cs b/Site5/Controls/v5/UI/ExternalScripts.ascx.cs index 419db476..39b5e3e6 100644 --- a/Site5/Controls/v5/UI/ExternalScripts.ascx.cs +++ b/Site5/Controls/v5/UI/ExternalScripts.ascx.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.IO; using System.Text; +using System.Web.UI; using Swarmops.Logic.Support; namespace Swarmops.Frontend.Controls.v5.UI @@ -38,9 +39,14 @@ namespace Swarmops.Frontend.Controls.v5.UI string[] controlNames = Controls.Split (','); foreach (string controlName in controlNames) { - scriptRef.AppendFormat ("\r\n", - controlName.Trim().ToLowerInvariant()); + string controlNameLower = controlName.Trim().ToLowerInvariant(); + if (controlNameLower != "unknown") + { + scriptRef.AppendFormat ( + "\r\n", + controlNameLower); + } } this.LiteralReference.Text = scriptRef.ToString(); diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx new file mode 100644 index 00000000..79df27db --- /dev/null +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx @@ -0,0 +1,106 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateCountry1.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateCountry1" %> +<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %> +<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> +<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %> + + + + + + + + + + + + +
+
+ +
+ + +
+
+
+
+
+ +
+ + + + + + diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs new file mode 100644 index 00000000..259f42dc --- /dev/null +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Threading; +using System.Web.Services; +using Swarmops.Basic.Enums; +using Swarmops.Database; +using Swarmops.Logic.Cache; +using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; +using Swarmops.Logic.Support; +using Swarmops.Logic.Swarm; + +namespace Swarmops.Frontend.Pages.v5.Admin.Hacks +{ + public partial class PopulateCountry1 : PageV5Base + { + protected void Page_Load (object sender, EventArgs e) + { + PageTitle = "Populate Country 1 - Geotree"; + PageIcon = "iconshock-battery-drill"; + InfoBoxLiteral = "You've taken a wrong turn if you're even seeing this page. It's for development purposes."; + } + + + private void Localize() + { + } + + + [WebMethod (true)] + public static void InitializeProcessing (string guid) + { + // Start an async thread that does all the work, then return + + + // FORMAT OF FILE + // + // Tab separated fields + // + // [countrycode] [tab] [geo1] .. [geo_n] + // + // example: + // + // NL [Tab] Greater Amsterdam + // NL [Tab] Greater Amsterdam [Tab] Amsterdam + // NL [Tab] Greater Amsterdam [Tab] Amsterdam [Tab] Wallen + // + // To populate all four nodes, only the last line is necessary, but all three lines are valid. + // + // Nodes are not re-populated on repetition. Node names within a country scope are required to + // be unique. + + + if (!PilotInstallationIds.IsPilot (PilotInstallationIds.SwarmopsLive) && !Debugger.IsAttached) + { + throw new UnauthorizedAccessException("This may only run on Swarmops Master"); + } + + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + if ( + !authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Unknown, + AccessType.Write))) + { + throw new UnauthorizedAccessException(); + } + + Thread initThread = new Thread (ProcessUploadThread); + initThread.Start (guid); + } + + private static void ProcessUploadThread (object guidObject) + { + string guid = (string) guidObject; + Documents documents = Documents.RecentFromDescription (guid); + Document uploadedDoc = documents[0]; + string data = string.Empty; + int count = 0; + + using (StreamReader reader = uploadedDoc.GetReader (1252)) + { + data = reader.ReadToEnd(); + } + + string[] lines = data.Split ('\n'); + + Random random = new Random(); + + Dictionary geoNameLookup = new Dictionary(); + + foreach (string lineRaw in lines) + { + count++; + string line = lineRaw.Trim(); + string[] lineParts = line.Split ('\t'); + + if (lineParts.Length < 2) + { + continue; // at least country and one geo required + } + + // set progress + + int percent = (count*99)/lines.Length; + if (percent == 0) + { + percent = 1; + } + GuidCache.Set (guid + "-Progress", percent); + + // process + + string countryCode = lineParts[0].Trim().ToUpperInvariant(); + + int countryGeoId = Geography.RootIdentity; + if (geoNameLookup.ContainsKey (countryCode)) + { + countryGeoId = geoNameLookup[countryCode]; + } + else + { + Country country = Country.FromCode (countryCode); + if (countryGeoId == Geography.RootIdentity) // country not initialized as node + { + countryGeoId = + SwarmDb.GetDatabaseForWriting().CreateGeography (country.Name + " (" + country.Name + ")", + Geography.RootIdentity); // TODO: Locate country + SwarmDb.GetDatabaseForWriting().SetCountryGeographyId (country.Identity, countryGeoId); + geoNameLookup[countryCode] = countryGeoId; + } + + Geographies countryGeographies = Geography.FromIdentity(countryGeoId).GetTree(); + + foreach (Geography geography in countryGeographies) + { + geoNameLookup[countryCode + geography.Name] = geography.Identity; + } + } + + int lastGeoId = countryGeoId; + for (int partIndex = 1; partIndex < lineParts.Length; partIndex++) + { + if (geoNameLookup.ContainsKey (countryCode + lineParts[partIndex])) + { + // geography exists + lastGeoId = geoNameLookup[countryCode + lineParts[partIndex]]; + } + else + { + // geography does not exist yet: create + + int newGeoId = SwarmDb.GetDatabaseForWriting().CreateGeography (lineParts[partIndex], lastGeoId); + geoNameLookup[countryCode + lineParts[partIndex]] = newGeoId; + lastGeoId = newGeoId; + } + + } + + } + + GuidCache.Set (guid + "-Progress", 100); + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx new file mode 100644 index 00000000..43cd962b --- /dev/null +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx @@ -0,0 +1,106 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateCountry2.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateCountry2" %> +<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %> +<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> +<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %> + + + + + + + + + + + + +
+
+ +
+ + +
+
+
+
+
+ +
+ + + + + + diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs new file mode 100644 index 00000000..9f336ef4 --- /dev/null +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs @@ -0,0 +1,110 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Threading; +using System.Web.Services; +using Swarmops.Basic.Enums; +using Swarmops.Logic.Cache; +using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; +using Swarmops.Logic.Support; +using Swarmops.Logic.Swarm; + +namespace Swarmops.Frontend.Pages.v5.Admin.Hacks +{ + public partial class PopulateCountry2 : PageV5Base + { + protected void Page_Load (object sender, EventArgs e) + { + PageTitle = "Populate Country - Postal Codes, Cities"; + PageIcon = "iconshock-battery-drill"; + InfoBoxLiteral = "You've taken a wrong turn if you're even seeing this page. It's for development purposes."; + } + + + private void Localize() + { + } + + + [WebMethod (true)] + public static void InitializeProcessing (string guid) + { + // Start an async thread that does all the work, then return + + if (!PilotInstallationIds.IsPilot(PilotInstallationIds.SwarmopsLive) && !Debugger.IsAttached) + { + throw new UnauthorizedAccessException("This may only run on Swarmops Master"); + } + + + + AuthenticationData authData = GetAuthenticationDataAndCulture(); + + if ( + !authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Unknown, + AccessType.Write))) + { + throw new UnauthorizedAccessException(); + } + + Thread initThread = new Thread (ProcessUploadThread); + initThread.Start (guid); + } + + private static void ProcessUploadThread (object guidObject) + { + string guid = (string) guidObject; + Documents documents = Documents.RecentFromDescription (guid); + Document uploadedDoc = documents[0]; + string data = string.Empty; + int count = 0; + + using (StreamReader reader = uploadedDoc.GetReader (1252)) + { + data = reader.ReadToEnd(); + } + + string[] lines = data.Split ('\n'); + + Random random = new Random(); + + foreach (string lineRaw in lines) + { + count++; + string line = lineRaw.Trim(); + string[] lineParts = line.Split ('\t'); + + if (lineParts.Length < 12) + { + continue; + } + + int percent = (count*99)/lines.Length; + if (percent == 0) + { + percent = 1; + } + GuidCache.Set (guid + "-Progress", percent); + + string name = lineParts[0] + " " + lineParts[1]; + PersonGender gender = lineParts[2] == "male" ? PersonGender.Male : PersonGender.Female; + DateTime dateOfBirth = DateTime.Parse (lineParts[7], new CultureInfo ("en-US"), DateTimeStyles.None); + Country country = Country.FromCode (lineParts[6]); + + + Person newPerson = Person.Create (name, string.Empty, string.Empty, lineParts[8], lineParts[3], + lineParts[4].Replace (" ", ""), lineParts[5], lineParts[6], dateOfBirth, gender); + + newPerson.NationalIdNumber = lineParts[9]; + newPerson.Longitude = lineParts[10]; + newPerson.Latitude = lineParts[11]; + + newPerson.AddMembership (1, DateTime.Today.AddDays (random.Next (365))); + } + + GuidCache.Set (guid + "-Progress", 100); + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Comms/SendMassMessage.aspx.cs b/Site5/Pages/v5/Comms/SendMassMessage.aspx.cs index d7e99365..269f5bd7 100644 --- a/Site5/Pages/v5/Comms/SendMassMessage.aspx.cs +++ b/Site5/Pages/v5/Comms/SendMassMessage.aspx.cs @@ -23,6 +23,8 @@ namespace Swarmops.Frontend.Pages.Comms this.TextMessage.Style[HtmlTextWriterStyle.Width] = "674px"; this.TextMessage.Style["resize"] = "none"; + + EasyUIControlsUsed = EasyUIControl.Tree; } private void Localize() diff --git a/Site5/Pages/v5/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs index 2bcaaf38..f7e988d8 100644 --- a/Site5/Pages/v5/Init/Default.aspx.cs +++ b/Site5/Pages/v5/Init/Default.aspx.cs @@ -170,28 +170,6 @@ public partial class Pages_v5_Init_Default : Page } - private string GetBuildIdentity() - { - // Read build number if not loaded, or set to "Private" if none - - if (_buildIdentity == null) - { - try - { - using (StreamReader reader = File.OpenText (HttpContext.Current.Request.MapPath ("~/BuildIdentity.txt")) - ) - { - _buildIdentity = "Build " + reader.ReadLine(); - } - } - catch (Exception) - { - _buildIdentity = "Private Build"; - } - } - - return _buildIdentity; - } [WebMethod] public static PermissionsAnalysis FirstCredentialsTest From 2646aa8560da8bf4c9e2845cb2397617cc6192aa Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 13 Dec 2014 15:01:32 +0100 Subject: [PATCH 03/33] Dbupgrade 7 fix --- Database/Schemata/upgrade-0007.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Database/Schemata/upgrade-0007.sql b/Database/Schemata/upgrade-0007.sql index 1a4c590f..c3422f3b 100644 --- a/Database/Schemata/upgrade-0007.sql +++ b/Database/Schemata/upgrade-0007.sql @@ -1,4 +1,4 @@ -UPDATE `Countries` SET `CurrencyCode`='EUR', `PostalCodeLength`='6' WHERE `CountryCode`='NL' +UPDATE `Countries` SET `CurrencyCode`='EUR', `PostalCodeLength`='6' WHERE `Code`='NL' # From aefc0bb16f2feecd82cb987221eac3626d29b224 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 13 Dec 2014 16:15:25 +0100 Subject: [PATCH 04/33] Executing dbupgrade 7 --- Database/Configuration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Database/Configuration.cs b/Database/Configuration.cs index 2e9055cb..8aae7d21 100644 --- a/Database/Configuration.cs +++ b/Database/Configuration.cs @@ -14,7 +14,7 @@ namespace Swarmops.Database /// public static int DbVersionExpected { - get { return 6; } + get { return 7; } } From cd1e73d4c6968a80306ba21b6b22d6a02a3104c3 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 13 Dec 2014 21:49:02 +0100 Subject: [PATCH 05/33] Fix for geo lookup: need exact match --- Database/Database-Geographies.cs | 3 +-- Logic/Cache/GeographyCache.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Database/Database-Geographies.cs b/Database/Database-Geographies.cs index 18055d56..723f08f6 100644 --- a/Database/Database-Geographies.cs +++ b/Database/Database-Geographies.cs @@ -284,8 +284,7 @@ namespace Swarmops.Database DbCommand command = GetDbCommand ( - "SELECT " + geographyFieldSequence + " WHERE Name like '" + geographyName.Replace ("'", "''") + - "%'", + "SELECT " + geographyFieldSequence + " WHERE Name ='" + geographyName.Replace ("'", "''") + "'", connection); using (DbDataReader reader = command.ExecuteReader()) diff --git a/Logic/Cache/GeographyCache.cs b/Logic/Cache/GeographyCache.cs index 87023b88..19128a60 100644 --- a/Logic/Cache/GeographyCache.cs +++ b/Logic/Cache/GeographyCache.cs @@ -228,7 +228,7 @@ namespace Swarmops.Logic.Cache Dictionary> hashedGeographies = GetHashedGeographies(); foreach (int entry in hashedGeographies.Keys) { - if (hashedGeographies[entry][0].Name.ToLower().Trim().StartsWith (cmpName)) + if (hashedGeographies[entry][0].Name.ToLower().Trim() == cmpName) return hashedGeographies[entry][0]; } //TODO: This can miss due to that the geography was added after last cache reload From 35ed03695e1b6ddf3c3ed6476743d16d22235885 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 13 Dec 2014 21:49:21 +0100 Subject: [PATCH 06/33] Added flexible postal code lookup --- Logic/Swarm/Person.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Logic/Swarm/Person.cs b/Logic/Swarm/Person.cs index cdfa9947..f36a934b 100644 --- a/Logic/Swarm/Person.cs +++ b/Logic/Swarm/Person.cs @@ -529,7 +529,22 @@ namespace Swarmops.Logic.Swarm Cities cities = Cities.FromPostalCode (PostalCode, base.CountryId); City city = null; - if (cities.Count == 0) + if (cities.Count == 0 && PostalCode.Length > 3) + { + // try shortening the postal code - like NL dataset - and see if we find anything + + for (int shortening = 1; shortening <= 3; shortening++) + { + cities = Cities.FromPostalCode (PostalCode.Substring (0, PostalCode.Length - shortening), + base.CountryId); + if (cities.Count > 0) + { + break; + } + } + } + + if (cities.Count == 0) // still no hit? Move on to getting city by name { try { From ce0d77ced2528efec3f0d005dd0241b91cb79f26 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 13 Dec 2014 22:22:36 +0100 Subject: [PATCH 07/33] Misc geodata provisioning code --- Site5/App_GlobalResources/GeographyNames.resx | 14 +++- .../v5/Admin/Hacks/PopulateCountry1.aspx | 2 +- .../v5/Admin/Hacks/PopulateCountry1.aspx.cs | 10 +-- .../v5/Admin/Hacks/PopulateCountry2.aspx | 2 +- .../v5/Admin/Hacks/PopulateCountry2.aspx.cs | 75 +++++++++++++++---- ...ulateData.aspx => PopulateFakePeople.aspx} | 6 +- ...ata.aspx.cs => PopulateFakePeople.aspx.cs} | 7 +- 7 files changed, 86 insertions(+), 30 deletions(-) rename Site5/Pages/v5/Admin/Hacks/{PopulateData.aspx => PopulateFakePeople.aspx} (93%) rename Site5/Pages/v5/Admin/Hacks/{PopulateData.aspx.cs => PopulateFakePeople.aspx.cs} (95%) diff --git a/Site5/App_GlobalResources/GeographyNames.resx b/Site5/App_GlobalResources/GeographyNames.resx index 16e122a9..78a52db0 100644 --- a/Site5/App_GlobalResources/GeographyNames.resx +++ b/Site5/App_GlobalResources/GeographyNames.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Central Europe + Denmark @@ -126,6 +129,9 @@ Ghana + + Netherlands + Norway @@ -134,7 +140,6 @@ Eastern Europe - (East of southern tip of Sweden, appx) Europe @@ -147,6 +152,12 @@ Nordics (Finland Denmark Norway Sweden Iceland) + + Nothern Europe + + + Southern Europe + East North Central @@ -188,7 +199,6 @@ Western Europe - (West of southern tip of Sweden, appx) World diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx index 79df27db..26401ff9 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx @@ -89,7 +89,7 @@
diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs index 259f42dc..25ded9c3 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs @@ -40,15 +40,15 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks // // Tab separated fields // - // [countrycode] [tab] [geo1] .. [geo_n] + // [countrycode] [tab] [geo1] [tab] [geo2] [tab] .. [tab] [geo_n] // // example: // - // NL [Tab] Greater Amsterdam - // NL [Tab] Greater Amsterdam [Tab] Amsterdam - // NL [Tab] Greater Amsterdam [Tab] Amsterdam [Tab] Wallen + // NL [Tab] Noord-Holland [Tab] Greater Amsterdam + // NL [Tab] Noord-Holland [Tab] Greater Amsterdam [Tab] Amsterdam + // NL [Tab] Noord-Holland [Tab] Greater Amsterdam [Tab] Amsterdam [Tab] Wallen // - // To populate all four nodes, only the last line is necessary, but all three lines are valid. + // To populate all five nodes (including country), only the last line is necessary, but all these lines are valid. // // Nodes are not re-populated on repetition. Node names within a country scope are required to // be unique. diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx index 43cd962b..ee65cd36 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx @@ -89,7 +89,7 @@
diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs index 9f336ef4..d387f78d 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs @@ -1,10 +1,12 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Threading; using System.Web.Services; using Swarmops.Basic.Enums; +using Swarmops.Database; using Swarmops.Logic.Cache; using Swarmops.Logic.Security; using Swarmops.Logic.Structure; @@ -17,7 +19,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks { protected void Page_Load (object sender, EventArgs e) { - PageTitle = "Populate Country - Postal Codes, Cities"; + PageTitle = "Populate Country 2 - Postal Codes, Cities"; PageIcon = "iconshock-battery-drill"; InfoBoxLiteral = "You've taken a wrong turn if you're even seeing this page. It's for development purposes."; } @@ -33,6 +35,22 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks { // Start an async thread that does all the work, then return + + // FORMAT OF FILE + // + // Tab separated fields + // + // [countrycode] [tab] [postalCode] [tab] [cityName] [tab] [geoNodeName] + // + // example: + // + // NL [Tab] 1026 [Tab] Amsterdam-Zuid [Tab] Amsterdam + // + // For countries that don't use postal codes, leave the postal code field empty. + // + // Node names within a country scope are required to be unique. + + if (!PilotInstallationIds.IsPilot(PilotInstallationIds.SwarmopsLive) && !Debugger.IsAttached) { throw new UnauthorizedAccessException("This may only run on Swarmops Master"); @@ -70,38 +88,65 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks Random random = new Random(); + Dictionary postalCodeDupes = new Dictionary(); + foreach (string lineRaw in lines) { count++; string line = lineRaw.Trim(); string[] lineParts = line.Split ('\t'); - if (lineParts.Length < 12) + if (lineParts.Length != 4) { continue; } - int percent = (count*99)/lines.Length; + int percent = (count * 99) / lines.Length; if (percent == 0) { percent = 1; } - GuidCache.Set (guid + "-Progress", percent); - - string name = lineParts[0] + " " + lineParts[1]; - PersonGender gender = lineParts[2] == "male" ? PersonGender.Male : PersonGender.Female; - DateTime dateOfBirth = DateTime.Parse (lineParts[7], new CultureInfo ("en-US"), DateTimeStyles.None); - Country country = Country.FromCode (lineParts[6]); + GuidCache.Set(guid + "-Progress", percent); - Person newPerson = Person.Create (name, string.Empty, string.Empty, lineParts[8], lineParts[3], - lineParts[4].Replace (" ", ""), lineParts[5], lineParts[6], dateOfBirth, gender); + string countryCode = lineParts[0].Trim().ToUpperInvariant(); + string postalCode = lineParts[1].Trim(); + string cityName = lineParts[2].Trim(); + string nodeName = lineParts[3].Trim(); - newPerson.NationalIdNumber = lineParts[9]; - newPerson.Longitude = lineParts[10]; - newPerson.Latitude = lineParts[11]; + // Dupecheck - newPerson.AddMembership (1, DateTime.Today.AddDays (random.Next (365))); + if (postalCodeDupes.ContainsKey (postalCode)) + { + continue; + } + + Geography geography = Geography.FromName (nodeName); // may dupe! + + // First, make sure country exists + + Country country = Country.FromCode (countryCode); + + // Then, check if the city name exists + + City city = null; + + try + { + city = City.FromName (cityName, country.Identity); + } + catch (ArgumentException) + { + city = City.Create (cityName, country.Identity, geography.Identity); + } + + // Last, add the postal code, if there is any + + if (!string.IsNullOrEmpty (postalCode)) + { + SwarmDb.GetDatabaseForWriting().CreatePostalCode (postalCode, city.Identity, country.Identity); + postalCodeDupes[postalCode] = true; + } } GuidCache.Set (guid + "-Progress", 100); diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateData.aspx b/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx similarity index 93% rename from Site5/Pages/v5/Admin/Hacks/PopulateData.aspx rename to Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx index 6aaf4c6f..d007d3fa 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateData.aspx +++ b/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx @@ -1,4 +1,4 @@ -<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateData" %> +<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateFakePeople.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateFakePeople" %> <%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %> <%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> <%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %> @@ -21,7 +21,7 @@ $.ajax({ type: "POST", - url: "PopulateData.aspx/InitializeProcessing", + url: "PopulateFakePeople.aspx/InitializeProcessing", data: "{'guid': '<%= this.UploadFile.GuidString %>'}", contentType: "application/json; charset=utf-8", dataType: "json", @@ -89,7 +89,7 @@
diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateData.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx.cs similarity index 95% rename from Site5/Pages/v5/Admin/Hacks/PopulateData.aspx.cs rename to Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx.cs index e9b4b943..cf32f6e1 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateData.aspx.cs +++ b/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx.cs @@ -1,6 +1,7 @@ using System; using System.Globalization; using System.IO; +using System.Text; using System.Threading; using System.Web.Services; using Swarmops.Basic.Enums; @@ -12,11 +13,11 @@ using Swarmops.Logic.Swarm; namespace Swarmops.Frontend.Pages.v5.Admin.Hacks { - public partial class PopulateData : PageV5Base + public partial class PopulateFakePeople : PageV5Base { protected void Page_Load (object sender, EventArgs e) { - PageTitle = "Populate Data"; + PageTitle = "Populate Data - Fake People"; PageIcon = "iconshock-battery-drill"; InfoBoxLiteral = "You've taken a wrong turn if you're even seeing this page. It's for development purposes."; } @@ -53,7 +54,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks string data = string.Empty; int count = 0; - using (StreamReader reader = uploadedDoc.GetReader (1252)) + using (StreamReader reader = uploadedDoc.GetReader (Encoding.UTF8)) { data = reader.ReadToEnd(); } From ca974934aa7b9aeb4874c87bff794e2cd9ee6d60 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 14 Dec 2014 00:22:38 +0100 Subject: [PATCH 08/33] Temporary Hack --- Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs | 2 +- Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs index 25ded9c3..6aa6c591 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry1.aspx.cs @@ -56,7 +56,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks if (!PilotInstallationIds.IsPilot (PilotInstallationIds.SwarmopsLive) && !Debugger.IsAttached) { - throw new UnauthorizedAccessException("This may only run on Swarmops Master"); + // throw new UnauthorizedAccessException("This may only run on Swarmops Master"); } AuthenticationData authData = GetAuthenticationDataAndCulture(); diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs index d387f78d..11870f21 100644 --- a/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs @@ -53,7 +53,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin.Hacks if (!PilotInstallationIds.IsPilot(PilotInstallationIds.SwarmopsLive) && !Debugger.IsAttached) { - throw new UnauthorizedAccessException("This may only run on Swarmops Master"); + // throw new UnauthorizedAccessException("This may only run on Swarmops Master"); } From 629e9508d4931fa7bde76c93c5e2a914f2fac0b0 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 14 Dec 2014 01:08:07 +0100 Subject: [PATCH 09/33] Security fix. This is how easy they are to miss... --- Site5/Pages/v5/Init/Default.aspx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site5/Pages/v5/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs index f7e988d8..cd05859a 100644 --- a/Site5/Pages/v5/Init/Default.aspx.cs +++ b/Site5/Pages/v5/Init/Default.aspx.cs @@ -518,7 +518,7 @@ public partial class Pages_v5_Init_Default : Page sqlCityBuild.Append (","); } - sqlCityBuild.Append ("('" + city.Name.Replace ("'", "\'") + "'," + newGeographyId + "," + + sqlCityBuild.Append ("('" + city.Name.Replace ("'", "\\'") + "'," + newGeographyId + "," + newCountryId + ",'')"); insertComma = true; From 31d334a76519c9d1c895efa9091f3b1b6d65bfd0 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 14 Dec 2014 01:14:15 +0100 Subject: [PATCH 10/33] Dumbfix --- Site5/Pages/v5/Init/Default.aspx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site5/Pages/v5/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs index cd05859a..96d8f686 100644 --- a/Site5/Pages/v5/Init/Default.aspx.cs +++ b/Site5/Pages/v5/Init/Default.aspx.cs @@ -361,7 +361,7 @@ public partial class Pages_v5_Init_Default : Page DatabaseMaintenance.FirstInitialization(); - _initProgress = 6; + _initProgress = 3; _initMessage = "Applying all post-baseline database schema upgrades..."; DatabaseMaintenance.UpgradeSchemata(); Thread.Sleep (100); From a7195885b4f35fa7bae14ff329c6d72ca12772bd Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 14 Dec 2014 09:11:03 +0100 Subject: [PATCH 11/33] Added Postal Code Length to country provisioning --- Site5/App_Code/GetGeographyData.cs | 9 +++++++++ Site5/Pages/v5/Init/Default.aspx.cs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Site5/App_Code/GetGeographyData.cs b/Site5/App_Code/GetGeographyData.cs index 60d1e8e0..7c38a4b1 100644 --- a/Site5/App_Code/GetGeographyData.cs +++ b/Site5/App_Code/GetGeographyData.cs @@ -473,6 +473,8 @@ namespace Swarmops.Site.Automation private int geographyIdField; + private int postalCodeLengthField; + /// public int CountryId { @@ -480,6 +482,13 @@ namespace Swarmops.Site.Automation set { this.countryIdField = value; } } + /// + public int PostalCodeLength + { + get { return this.postalCodeLengthField; } + set { this.postalCodeLengthField = value; } + } + /// public string Name { diff --git a/Site5/Pages/v5/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs index 96d8f686..a00b1093 100644 --- a/Site5/Pages/v5/Init/Default.aspx.cs +++ b/Site5/Pages/v5/Init/Default.aspx.cs @@ -400,7 +400,7 @@ public partial class Pages_v5_Init_Default : Page countryIdTranslation[country.Code] = SwarmDb.GetDatabaseForWriting().CreateCountry (country.Name, country.Code, country.Culture, - rootGeographyId, 5, + rootGeographyId, country.PostalCodeLength, string.Empty); count++; From 88d27906650531f89a0afcb37b4adfb8855db93d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 19 Dec 2014 11:43:32 +0100 Subject: [PATCH 12/33] Added credentials validation indicator. Fixes #2. --- Site5/Security/Images/iconshock-cross-12px.png | Bin 0 -> 707 bytes .../Security/Images/iconshock-greentick-16px.png | Bin 0 -> 746 bytes Site5/Security/Login.aspx | 9 ++++++++- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 Site5/Security/Images/iconshock-cross-12px.png create mode 100644 Site5/Security/Images/iconshock-greentick-16px.png diff --git a/Site5/Security/Images/iconshock-cross-12px.png b/Site5/Security/Images/iconshock-cross-12px.png new file mode 100644 index 0000000000000000000000000000000000000000..5c9080778d7f9f72512bfb3ed7ba08798fce6021 GIT binary patch literal 707 zcmV;!0zCbRP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyw@ z4-*}#MPeBM00KivL_t(2&s~y1NK;_|fWP;)IiD^`v^iZV9SqbEiP@N2VNjxwikA+0 zDnZZ?g*@yariYX?5WHvyJt=tzL_HMLlpq;_F)1eDVa;OfHFKhGvo~k^I|b!;|M)JS z#2MDt*9R0uY1)e)*v;AIL?)g7Ffl&<%;)ocb-7&l{eA$XzryI~lj_@d8a9vj_D#lc zh`eMHO;t&lv&neegu>yc4|{sNH8nMCZEazQ#bQ`;Etl^$H-C}BVfoUxUFlphi76f@ z_wbOsogMPm)=*q7kF%lSWOjD;J%DVrTJhYx@iO-5v#@6}QgLS|ip_?cPGhoIxU#xR zZbb#fgM-voRgHSw?u!7j)9JJ;X7e@og+j?-Fd!6#^X=_Ol0@;u1gEkLs!CQW#n1V9 z9&~lx1CYDByRW9=aZVBmVw00>mzT2_jUxK{iAEx*O--bhmyuN!v9yFyQR)DU$z<}k zp`Z|Tco;nxB)hDP?~w?nfI$eXHXCNZ2pCN!bX`9MkiA}SKu_t2U=UML5j!(8L{ycs zu`!M{jX-NF>5dMvfRn~X4q~x)0J5fO`^Sp%dfQPe6#W^la1*HEC{Q;YO_G?4xIBl!2cfO z?)AiUAe#dKN-4ON5^vIW93=%XmSx@Akx@|MGmUH~gbWY>U>F9XDE{dNv;VsFVRccZ zIZ2s-2LsI*8g!K7e)By5K+)NqeE#`-IRFe%I{=`*vmO9&3cDD~)x&SPJ$-aw{5^FE zZtDFuMz_|PDFJ}mgZ0r}dmlR`tc;0mG8ix3z7SZJrJ&?k;|W)J<~~D|G?MZXo)E&I z_|6fES=9`&UMb5$!hBC+OftuFk#Gy{MW553*L2#}W2q^LPt4Q3-LuXTBV&2+oC4De zAy`{#5DX}%H#j2;SzU#qlZy_jV(vn5xRHY$DE9kOS&x?(v3JJr2Wf{yY zOv3u)B)$sjK>CddQ+r#RgB$V0kAm8hrSccxnN^76*C1QBkw)n?wQ9K*;rS5#@ZC;& zeKxcXf1zX|Z9?1N+0^~XF$w^zNsN0M)FxO2>3EEO^&}SPEMZuYuq?qm4I?ZDh;Mcf zEgxNgkml95&gJ&L?(-~rM3zvIak;2Zo#I|=PSqeaq7XWn32M0>BcXnJuBVO!$C8F! zRkqClg1=M*IshpCrZY10aq}Sn cvVY#rA1c@G*_%8>`~Uy|07*qoM6N<$f~Ol!od5s; literal 0 HcmV?d00001 diff --git a/Site5/Security/Login.aspx b/Site5/Security/Login.aspx index 3a9597c3..c4890c07 100644 --- a/Site5/Security/Login.aspx +++ b/Site5/Security/Login.aspx @@ -56,6 +56,7 @@ function onInputCredentials() { clearTimeout(manualCredentialsTestTrigger); + $('#TextLogin, #TextPass').css('background-image', 'none'); manualCredentialsTestTrigger = setTimeout(function() { testManualCredentials(); @@ -71,6 +72,10 @@ jsonData.credentials2FA = $('#Text2FA').val(); jsonData.logonUriEncoded = bitIdUri; + if (jsonData.credentialsLogin.length == 0 || jsonData.credentialsPass.length == 0) { + return; // empty pass or login + } + $.ajax({ type: "POST", url: "Login.aspx/TestCredentials", @@ -80,8 +85,10 @@ success: function(msg) { if (msg.d) { // alert(""); // Modal on Chrome, so need a shaded div instead + $('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-greentick-16px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); } else { - // do nothing + // inform user of bad credentials by means of a red cross on _both_ boxes + $('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); } }, error: function(msg) { From 20e063acfb5f831192877fbab5f2ce90005cdbde Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 20 Dec 2014 18:14:02 +0100 Subject: [PATCH 13/33] Persist org ID across sessions --- Basic/Enums/ObjectOptionalDataType.cs | 7 +- ...ansmission.NotificationPayload.Designer.cs | 105 ++++++++++++++++-- ...ions.Transmission.NotificationPayload.resx | 51 +++++++-- Logic/Swarm/Person.cs | 6 + Site5/Pages/v5/Init/Default.aspx | 2 +- .../Security/SetCurrentOrganization.aspx.cs | 2 + Site5/Security/Login.aspx | 14 ++- Site5/Security/Login.aspx.cs | 27 ++++- Site5/Style/style-v5.css | 6 + 9 files changed, 184 insertions(+), 36 deletions(-) diff --git a/Basic/Enums/ObjectOptionalDataType.cs b/Basic/Enums/ObjectOptionalDataType.cs index c50ab4d9..6ddc00ce 100644 --- a/Basic/Enums/ObjectOptionalDataType.cs +++ b/Basic/Enums/ObjectOptionalDataType.cs @@ -284,6 +284,11 @@ namespace Swarmops.Basic.Enums /// /// For a person, the BitId address they use to login /// - BitIdLoginAddress + BitIdLoginAddress, + + /// + /// For a person, the last logged-on organization id. Used to go back there on new login. + /// + LastLoginOrganizationId } } \ No newline at end of file diff --git a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs index 27546213..b18cd4c8 100644 --- a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs +++ b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs @@ -111,7 +111,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to [OrganizationName] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat]. + /// Looks up a localized string similar to [[OrganizationName]] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat]. /// internal static string CashAdvance_PaidOut_Subject { get { @@ -131,7 +131,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to (ACTION ITEM) [OrganizationName] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed. + /// Looks up a localized string similar to [[OrganizationName] - ACTION ITEM] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed. /// internal static string CashAdvance_Requested_Subject { get { @@ -149,7 +149,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to [OrganizationName] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat]. + /// Looks up a localized string similar to [[OrganizationName]] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat]. /// internal static string ExpenseClaim_Attested_Subject { get { @@ -169,7 +169,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to (ACTION ITEM) [OrganizationName] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed. + /// Looks up a localized string similar to [[OrganizationName] - ACTION ITEM] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed. /// internal static string ExpenseClaim_Created_Subject { get { @@ -189,7 +189,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to [OrganizationName] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat]. + /// Looks up a localized string similar to [[OrganizationName]] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat]. /// internal static string ExpenseClaim_Deattested_Subject { get { @@ -207,7 +207,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to [OrganizationName] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat]. + /// Looks up a localized string similar to [[OrganizationName]] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat]. /// internal static string ExpenseClaim_Denied_Subject { get { @@ -227,7 +227,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to [OrganizationName] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat]. + /// Looks up a localized string similar to [[OrganizationName]] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat]. /// internal static string ExpenseClaim_Devalidated_Subject { get { @@ -247,7 +247,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to [OrganizationName] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat]. + /// Looks up a localized string similar to [[OrganizationName]] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat]. /// internal static string ExpenseClaim_PaidOut_Subject { get { @@ -267,7 +267,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to [OrganizationName] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat]. + /// Looks up a localized string similar to [[OrganizationName]] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat]. /// internal static string ExpenseClaim_Validated_Subject { get { @@ -287,7 +287,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to (ACTION ITEM) [OrganizationName] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed. + /// Looks up a localized string similar to [[OrganizationName] - ACTION ITEM] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed. /// internal static string InboundInvoice_Created_Subject { get { @@ -295,6 +295,89 @@ namespace Swarmops.Logic.App_GlobalResources { } } + /// + /// Looks up a localized string similar to A new [Regular] was manually added to [OrganizationName] within an area of yours.. + /// + internal static string Membership_New_Added_Body { + get { + return ResourceManager.GetString("Membership_New_Added_Body", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode] (manual). + /// + internal static string Membership_New_Added_Subject { + get { + return ResourceManager.GetString("Membership_New_Added_Subject", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A new [Regular] has signed up for [OrganizationName] within an area of yours.. + /// + internal static string Membership_New_Selfsignup_Body { + get { + return ResourceManager.GetString("Membership_New_Selfsignup_Body", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode]. + /// + internal static string Membership_New_Selfsignup_Subject { + get { + return ResourceManager.GetString("Membership_New_Selfsignup_Subject", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [[OrganizationName]] [Regularship] renewed: [PersonName], [PersonGeography] [CountryCode] (manual). + /// + internal static string Membership_Renewed_Manual_Subject { + get { + return ResourceManager.GetString("Membership_Renewed_Manual_Subject", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Your message has been queued for delivery and the recipients have been resolved. Your mail will be sent to, or be attempted to sent to, [RecipientCount] people in [Geography] in [OrganizationName].. + /// + internal static string OutboundComm_Resolved_Body { + get { + return ResourceManager.GetString("OutboundComm_Resolved_Body", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [[OrganizationName]] Comm recipients determined for [GeographyName]: [RecipientCount]. + /// + internal static string OutboundComm_Resolved_Subject { + get { + return ResourceManager.GetString("OutboundComm_Resolved_Subject", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Your message to [GeographyName] has been sent to all scheduled recipients. Of the [RecipientCount] planned recipients, [RecipientsSuccess] succeeded from Swarmops' horizon. (These can fail later for a number of reasons, from broken computers to hospitalized recipients.) + /// + ///Time spent transmitting: [TransmissionTime].. + /// + internal static string OutboundComm_Sent_Body { + get { + return ResourceManager.GetString("OutboundComm_Sent_Body", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [[OrganizationName]] Comms transmitted: [GeographyName]. + /// + internal static string OutboundComm_Sent_Subject { + get { + return ResourceManager.GetString("OutboundComm_Sent_Subject", resourceCulture); + } + } + /// /// Looks up a localized string similar to Receipts have been filed that need validation for their financial processes to continue. /// @@ -307,7 +390,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to (ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed. + /// Looks up a localized string similar to [[OrganizationName] - ACTION ITEM] Receipts Filed - Validation Needed. /// internal static string Receipts_Filed_Subject { get { diff --git a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx index 81c75ad5..2a89b118 100644 --- a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx +++ b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx @@ -137,7 +137,7 @@ Expect more communication from the budget owner to follow on the matter. This means you should see the amount on your account shortly. - [OrganizationName] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat] + [[OrganizationName]] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat] [ConcernedPersonName] has requested a cash advance of [CurrencyCode] [BudgetAmountFloat] for the purpose of [RequestPurpose]. This money is part of your budget, [BudgetName]. @@ -146,14 +146,14 @@ Please log on to Swarmops at [SystemUrl] to attest or deny. This is sent to the budget owner(s) only. - (ACTION ITEM) [OrganizationName] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed + [[OrganizationName] - ACTION ITEM] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been attested by the budget owner. It will be paid out to you when the receipts are confirmed valid. This is sent to the claimer. - [OrganizationName] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat] + [[OrganizationName]] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat] [ConcernedPersonName] has created an expense claim against the budget of [BudgetName] for the amount of [CurrencyCode] [BudgetAmountFloat]. The claim concerns [RequestPurpose]. You will need to attest this expense claim. @@ -162,7 +162,7 @@ Please log on to Swarmops at [SystemUrl] to attest or deny. This is sent to the budget owner(s)only. - (ACTION ITEM) [OrganizationName] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed + [[OrganizationName] - ACTION ITEM] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed ACTION ITEM should be translated. @@ -172,14 +172,14 @@ Expect more communication from the budget owner to follow on the matter. This is sent to the claimer. - [OrganizationName] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat] + [[OrganizationName]] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat] Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat] concerning [RequestPurpose] has been denied. Expect more communications to follow on what you need to do to file a proper expense claim. This is sent to the claimer. - [OrganizationName] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat] + [[OrganizationName]] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat] The receipts for your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], have been DE-validated by the financial record keepers of the organization. This usually indicates some sort of problem with the documentation of your expense claim. @@ -187,7 +187,7 @@ Expect more communication from the budget owner to follow on the matter. Expect more communication to follow on the matter. If you don't hear from record keepers in short time on this matter, do follow up with them. - [OrganizationName] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat] + [[OrganizationName]] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat] Your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], has been marked as paid out by the organization's accountants. @@ -195,7 +195,7 @@ Expect more communication to follow on the matter. If you don't hear from record This means you should see the amount on your account shortly. - [OrganizationName] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat] + [[OrganizationName]] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat] The receipts for your expense claim with [OrganizationName] for [CurrencyCode] [BudgetAmountFloat], concerning [RequestPurpose], have been validated by people responsible for keeping the records in order. @@ -204,7 +204,7 @@ The claim will be paid out to you when the amount has also been attested by the This is sent to the claimer. - [OrganizationName] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat] + [[OrganizationName]] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat] An invoice from [Supplier], concerning [Description], has been filed against your budget of [BudgetName] for the amount of [CurrencyCode] [BudgetAmountFloat]. You must attest this invoice before it proceeds to payout. @@ -212,7 +212,36 @@ The claim will be paid out to you when the amount has also been attested by the Please log on to Swarmops at [SystemUrl] to attest or deny. - (ACTION ITEM) [OrganizationName] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed + [[OrganizationName] - ACTION ITEM] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed + + + A new [Regular] was manually added to [OrganizationName] within an area of yours. + + + [[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode] (manual) + + + A new [Regular] has signed up for [OrganizationName] within an area of yours. + + + [[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode] + + + [[OrganizationName]] [Regularship] renewed: [PersonName], [PersonGeography] [CountryCode] (manual) + + + Your message has been queued for delivery and the recipients have been resolved. Your mail will be sent to, or be attempted to sent to, [RecipientCount] people in [Geography] in [OrganizationName]. + + + [[OrganizationName]] Comm recipients determined for [GeographyName]: [RecipientCount] + + + Your message to [GeographyName] has been sent to all scheduled recipients. Of the [RecipientCount] planned recipients, [RecipientsSuccess] succeeded from Swarmops' horizon. (These can fail later for a number of reasons, from broken computers to hospitalized recipients.) + +Time spent transmitting: [TransmissionTime]. + + + [[OrganizationName]] Comms transmitted: [GeographyName] Receipts have been filed that need validation for their financial processes to continue. @@ -220,7 +249,7 @@ Please log on to Swarmops at [SystemUrl] to attest or deny. Please log on to Swarmops at [SystemUrl] to confirm or reject them. - (ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed + [[OrganizationName] - ACTION ITEM] Receipts Filed - Validation Needed Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion]. diff --git a/Logic/Swarm/Person.cs b/Logic/Swarm/Person.cs index f36a934b..df2a9bd5 100644 --- a/Logic/Swarm/Person.cs +++ b/Logic/Swarm/Person.cs @@ -430,6 +430,12 @@ namespace Swarmops.Logic.Swarm } } + public int LastLogonOrganizationId + { + get { return OptionalData.GetOptionalDataInt (ObjectOptionalDataType.LastLoginOrganizationId); } + set { OptionalData.SetOptionalDataInt (ObjectOptionalDataType.LastLoginOrganizationId, value); } + } + public string PortraitPhotographer { get { return OptionalData.GetOptionalDataString (ObjectOptionalDataType.PortraitPhotographer); } diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx index c9f9e31a..837535e6 100644 --- a/Site5/Pages/v5/Init/Default.aspx +++ b/Site5/Pages/v5/Init/Default.aspx @@ -486,7 +486,7 @@
-

+
diff --git a/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs b/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs index 52911dcc..dccd0aa7 100644 --- a/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs +++ b/Site5/Pages/v5/Security/SetCurrentOrganization.aspx.cs @@ -48,6 +48,8 @@ namespace Swarmops.Frontend.Pages.v5.Security suggestedOrganization.Identity.ToString (CultureInfo.InvariantCulture) + ",," + logonFlags; + CurrentUser.LastLogonOrganizationId = suggestedOrganization.Identity; + if (!string.IsNullOrEmpty (returnUrlString)) { FormsAuthentication.SetAuthCookie (userIdentityString, true); diff --git a/Site5/Security/Login.aspx b/Site5/Security/Login.aspx index c4890c07..08dbccf1 100644 --- a/Site5/Security/Login.aspx +++ b/Site5/Security/Login.aspx @@ -83,13 +83,15 @@ contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { - if (msg.d) { - // alert(""); // Modal on Chrome, so need a shaded div instead + if (msg.d == "Success") { + // Good credentials. TODO: Add manual 2FA challenge if applicable. $('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-greentick-16px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); - } else { - // inform user of bad credentials by means of a red cross on _both_ boxes - $('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); - } + } else if (msg.d == "Fail") { + // inform user of bad credentials by means of a red cross on _both_ boxes + $('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); + } else { + // wut? + } }, error: function(msg) { // retry after a second diff --git a/Site5/Security/Login.aspx.cs b/Site5/Security/Login.aspx.cs index 660ba560..1cd811d1 100644 --- a/Site5/Security/Login.aspx.cs +++ b/Site5/Security/Login.aspx.cs @@ -12,6 +12,7 @@ using Resources; using Swarmops.Database; using Swarmops.Logic.Cache; using Swarmops.Logic.Security; +using Swarmops.Logic.Structure; using Swarmops.Logic.Support; using Swarmops.Logic.Swarm; @@ -234,7 +235,7 @@ namespace Swarmops.Pages.Security [WebMethod] // ReSharper disable once InconsistentNaming - public static bool TestCredentials (string credentialsLogin, string credentialsPass, string credentials2FA, + public static string TestCredentials (string credentialsLogin, string credentialsPass, string credentials2FA, string logonUriEncoded) { if (!string.IsNullOrEmpty (credentialsLogin.Trim()) && !string.IsNullOrEmpty (credentialsPass.Trim())) @@ -248,17 +249,32 @@ namespace Swarmops.Pages.Security // TODO: Determine last logged-on organization. Right now, log on to Sandbox. + int lastOrgId = authenticatedPerson.LastLogonOrganizationId; + + if (lastOrgId == 0) + { + lastOrgId = Organization.SandboxIdentity; + } + + if (!authenticatedPerson.MemberOfWithInherited (lastOrgId)) + { + // If the person doesn't have access to the last organization (anymore), log on to Sandbox + + lastOrgId = 1; + } + GuidCache.Set (logonUri + "-LoggedOn", - authenticatedPerson.Identity.ToString (CultureInfo.InvariantCulture) + ",1,,AuthPlain"); - return true; + authenticatedPerson.Identity.ToString (CultureInfo.InvariantCulture) + "," + lastOrgId.ToString(CultureInfo.InvariantCulture) + ",,AuthPlain"); + + return "Success"; // Prepare here for "2FARequired" return code } catch (UnauthorizedAccessException) { - return false; + return "Fail"; } } - return false; + return "Fail"; } @@ -281,7 +297,6 @@ namespace Swarmops.Pages.Security this.LiteralCredentialsUser.Text = Resources.Pages.Security.Login_Username; this.LiteralCredentialsPass.Text = Resources.Pages.Security.Login_Password; this.LiteralCredentials2FA.Text = Resources.Pages.Security.Login_GoogleAuthenticatorCode; - this.LiteralLoginSuccess.Text = Resources.Pages.Security.Login_LoggingIn; } diff --git a/Site5/Style/style-v5.css b/Site5/Style/style-v5.css index 30fa9d6b..d11aa10d 100644 --- a/Site5/Style/style-v5.css +++ b/Site5/Style/style-v5.css @@ -358,6 +358,12 @@ div.loginbox background-color: #E4ECFF; } + +input.InputManualCredentials { + border: solid 1px #A2BEFF; + padding: 2px; +} + span.loginalphabetasign { font-size: 24px; From c5afbf7470cb803a9e345db738d86bcc103d8602 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 21 Dec 2014 03:20:25 +0100 Subject: [PATCH 14/33] Testing path rewrite in App_BeginReq --- Site5/Global.asax | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Site5/Global.asax b/Site5/Global.asax index c1fed010..8ccfdcac 100644 --- a/Site5/Global.asax +++ b/Site5/Global.asax @@ -1,4 +1,5 @@ <%@ Application Language="C#" %> +<%@ Import Namespace="System.IO" %>