diff --git a/Basic/Basic.csproj b/Basic/Basic.csproj index 2fc1464c..96e78554 100644 --- a/Basic/Basic.csproj +++ b/Basic/Basic.csproj @@ -72,7 +72,8 @@ - + + @@ -97,8 +98,8 @@ - - + + @@ -147,7 +148,7 @@ - + @@ -156,7 +157,7 @@ Code - + True True @@ -171,9 +172,8 @@ - + - @@ -191,4 +191,4 @@ - + \ No newline at end of file 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/Basic/Types/GeographyWithPeople.cs b/Basic/Types/GeographyWithPeople.cs deleted file mode 100644 index dcf8aa5c..00000000 --- a/Basic/Types/GeographyWithPeople.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace Swarmops.Basic.Types -{ - [Serializable] - public class BasicGeographyWithPeople - { - public int ActivistCount; - public int GeographyID; - public string GeograpyName; - public string LeadContent; - public int MemberCount; - public int OrgId = 0; - public string OrgName; - public int ParentGeographyId; - public int ParentOrgId; - public string SecondsContent; - } -} \ No newline at end of file diff --git a/Basic/Types/BasicCity.cs b/Basic/Types/Structure/BasicCity.cs similarity index 79% rename from Basic/Types/BasicCity.cs rename to Basic/Types/Structure/BasicCity.cs index f7113294..05bddc33 100644 --- a/Basic/Types/BasicCity.cs +++ b/Basic/Types/Structure/BasicCity.cs @@ -1,42 +1,42 @@ -using System; -using Swarmops.Basic.Interfaces; - -namespace Swarmops.Basic.Types -{ - [Serializable] - public class BasicCity : IHasIdentity - { - public BasicCity (int cityId, string name, int countryId, int geographyId) - { - CityId = cityId; - Name = name; - CountryId = countryId; - GeographyId = geographyId; - } - - public BasicCity (BasicCity original) - : this (original.CityId, original.Name, original.CountryId, original.GeographyId) - { - } - - [Obsolete ("Do not call this ctor directly. It exists to enable serialization.", true)] - public BasicCity() - { - // this ctor should never be called from code - } - - public int CityId { get; private set; } - public string Name { get; protected set; } - public int CountryId { get; protected set; } - public int GeographyId { get; protected set; } - - #region IHasIdentity Members - - public int Identity - { - get { return CityId; } - } - - #endregion - } +using System; +using Swarmops.Basic.Interfaces; + +namespace Swarmops.Basic.Types.Structure +{ + [Serializable] + public class BasicCity : IHasIdentity + { + public BasicCity (int cityId, string name, int countryId, int geographyId) + { + this.CityId = cityId; + this.Name = name; + this.CountryId = countryId; + this.GeographyId = geographyId; + } + + public BasicCity (BasicCity original) + : this (original.CityId, original.Name, original.CountryId, original.GeographyId) + { + } + + [Obsolete ("Do not call this ctor directly. It exists to enable serialization.", true)] + public BasicCity() + { + // this ctor should never be called from code + } + + public int CityId { get; private set; } + public string Name { get; protected set; } + public int CountryId { get; protected set; } + public int GeographyId { get; protected set; } + + #region IHasIdentity Members + + public int Identity + { + get { return this.CityId; } + } + + #endregion + } } \ No newline at end of file diff --git a/Basic/Types/BasicCountry.cs b/Basic/Types/Structure/BasicCountry.cs similarity index 65% rename from Basic/Types/BasicCountry.cs rename to Basic/Types/Structure/BasicCountry.cs index 1a913533..b43a115e 100644 --- a/Basic/Types/BasicCountry.cs +++ b/Basic/Types/Structure/BasicCountry.cs @@ -1,69 +1,71 @@ -using System; -using Swarmops.Basic.Interfaces; - -namespace Swarmops.Basic.Types -{ - [Serializable] - public class BasicCountry : IHasIdentity - { - public BasicCountry (int countryId, string name, string code) - { - CountryId = countryId; - Name = name; - Code = code; - } - - public BasicCountry (int countryId, string name, string code, string defaultCulture, string currencyCode, - int geographyId, int postalCodeLength) - : this (countryId, name, code) - { - Culture = defaultCulture; - CurrencyCode = currencyCode; - GeographyId = geographyId; - PostalCodeLength = postalCodeLength; - } - - public BasicCountry (BasicCountry original) - : this ( - original.CountryId, original.Name, original.Code, original.Culture, original.CurrencyCode, - original.GeographyId, original.PostalCodeLength) - { - } - - [Obsolete ("Do not call this function directly. It exists to enable serialization.", true)] - public BasicCountry() - { - // this does not initialize the Basic Country, but exists to enable serialization. - } - - public int CountryId { get; private set; } - public string Name { get; protected set; } - public string Code { get; protected set; } - public string Culture { get; protected set; } - public string CurrencyCode { get; protected set; } - public int GeographyId { get; protected set; } - public int PostalCodeLength { get; protected set; } - - public int CurrencyId - { - get - { - if (Code == "SE") - { - return 1; - } - - throw new NotImplementedException ("BasicCountry.CurrencyId"); - } - } - - #region IHasIdentity Members - - public int Identity - { - get { return CountryId; } - } - - #endregion - } +using System; +using Swarmops.Basic.Interfaces; + +namespace Swarmops.Basic.Types.Structure +{ + [Serializable] + public class BasicCountry : IHasIdentity + { + public BasicCountry (int countryId, string name, string code) + { + this.CountryId = countryId; + this.Name = name; + this.Code = code; + } + + public BasicCountry (int countryId, string name, string code, string defaultCulture, string currencyCode, + int geographyId, int postalCodeLength, string postalCodeFormat) + : this (countryId, name, code) + { + this.Culture = defaultCulture; + this.CurrencyCode = currencyCode; + this.GeographyId = geographyId; + this.PostalCodeLength = postalCodeLength; + this.PostalCodeFormat = postalCodeFormat; + } + + public BasicCountry (BasicCountry original) + : this ( + original.CountryId, original.Name, original.Code, original.Culture, original.CurrencyCode, + original.GeographyId, original.PostalCodeLength, original.PostalCodeFormat) + { + } + + [Obsolete ("Do not call this function directly. It exists to enable serialization.", true)] + public BasicCountry() + { + // this does not initialize the Basic Country, but exists to enable serialization. + } + + public int CountryId { get; private set; } + public string Name { get; protected set; } + public string Code { get; protected set; } + public string Culture { get; protected set; } // may be overridden at geography level (multilinguality etc.) + public string CurrencyCode { get; protected set; } + public int GeographyId { get; protected set; } + public int PostalCodeLength { get; protected set; } + public string PostalCodeFormat { get; protected set; } + + public int CurrencyId + { + get + { + if (this.Code == "SE") + { + return 1; + } + + throw new NotImplementedException ("BasicCountry.CurrencyId"); + } + } + + #region IHasIdentity Members + + public int Identity + { + get { return this.CountryId; } + } + + #endregion + } } \ No newline at end of file diff --git a/Basic/Types/BasicGeography.cs b/Basic/Types/Structure/BasicGeography.cs similarity index 85% rename from Basic/Types/BasicGeography.cs rename to Basic/Types/Structure/BasicGeography.cs index 65047d25..abc238d6 100644 --- a/Basic/Types/BasicGeography.cs +++ b/Basic/Types/Structure/BasicGeography.cs @@ -1,65 +1,65 @@ -using System; -using Swarmops.Basic.Interfaces; - -namespace Swarmops.Basic.Types -{ - /// - /// A geographical node. - /// - [Serializable] - public class BasicGeography : IHasIdentity - { - public BasicGeography (int geographyId, int parentGeographyId, string name) - : this (geographyId, parentGeographyId, name, 0) - { - } - - public BasicGeography (int geographyId, int parentGeographyId, string name, int generation) - { - GeographyId = geographyId; - ParentGeographyId = parentGeographyId; - Name = name; - Generation = generation; - } - - public BasicGeography (BasicGeography original) - : this (original.GeographyId, original.ParentGeographyId, original.Name, original.Generation) - { - } - - [Obsolete ("Do not use this ctor. It is provided to enable serializability.", true)] - public BasicGeography() - { - // provided for serializability - does not initialize fields - } - - /// - /// The database id of this geography. - /// - public int GeographyId { get; private set; } - - /// - /// The database id of the parent geography, for linking in a tree structure. - /// - public int ParentGeographyId { get; protected set; } - - /// - /// The friendly name of the node (city, county, region, etc). - /// - public string Name { get; protected set; } - - /// - /// The generation of this node. Used in tree-style listings. - /// - public int Generation { get; protected set; } - - #region IHasIdentity Members - - public int Identity - { - get { return GeographyId; } - } - - #endregion - } +using System; +using Swarmops.Basic.Interfaces; + +namespace Swarmops.Basic.Types.Structure +{ + /// + /// A geographical node. + /// + [Serializable] + public class BasicGeography : IHasIdentity + { + public BasicGeography (int geographyId, int parentGeographyId, string name) + : this (geographyId, parentGeographyId, name, 0) + { + } + + public BasicGeography (int geographyId, int parentGeographyId, string name, int generation) + { + this.GeographyId = geographyId; + this.ParentGeographyId = parentGeographyId; + this.Name = name; + this.Generation = generation; + } + + public BasicGeography (BasicGeography original) + : this (original.GeographyId, original.ParentGeographyId, original.Name, original.Generation) + { + } + + [Obsolete ("Do not use this ctor. It is provided to enable serializability.", true)] + public BasicGeography() + { + // provided for serializability - does not initialize fields + } + + /// + /// The database id of this geography. + /// + public int GeographyId { get; private set; } + + /// + /// The database id of the parent geography, for linking in a tree structure. + /// + public int ParentGeographyId { get; protected set; } + + /// + /// The friendly name of the node (city, county, region, etc). + /// + public string Name { get; protected set; } + + /// + /// The generation of this node. Used in tree-style listings. + /// + public int Generation { get; protected set; } + + #region IHasIdentity Members + + public int Identity + { + get { return this.GeographyId; } + } + + #endregion + } } \ No newline at end of file diff --git a/Basic/Types/BasicGeographyDesignation.cs b/Basic/Types/Structure/BasicGeographyDesignation.cs similarity index 76% rename from Basic/Types/BasicGeographyDesignation.cs rename to Basic/Types/Structure/BasicGeographyDesignation.cs index acfe42ef..d5e59964 100644 --- a/Basic/Types/BasicGeographyDesignation.cs +++ b/Basic/Types/Structure/BasicGeographyDesignation.cs @@ -1,27 +1,27 @@ -using Swarmops.Basic.Enums; - -namespace Swarmops.Basic.Types -{ - public class BasicGeographyDesignation - { - public BasicGeographyDesignation (int geographyId, int countryId, - string designation, GeographyLevel geoLevelId) - { - GeographyId = geographyId; - CountryId = countryId; - Designation = designation; - GeographyLevel = geoLevelId; - } - - public BasicGeographyDesignation (BasicGeographyDesignation original) : - this (original.GeographyId, original.CountryId, original.Designation, original.GeographyLevel) - { - // empty copy ctor - } - - public int GeographyId { get; private set; } - public int CountryId { get; private set; } - public string Designation { get; private set; } - public GeographyLevel GeographyLevel { get; private set; } - } +using Swarmops.Basic.Enums; + +namespace Swarmops.Basic.Types.Structure +{ + public class BasicGeographyDesignation + { + public BasicGeographyDesignation (int geographyId, int countryId, + string designation, GeographyLevel geoLevelId) + { + this.GeographyId = geographyId; + this.CountryId = countryId; + this.Designation = designation; + this.GeographyLevel = geoLevelId; + } + + public BasicGeographyDesignation (BasicGeographyDesignation original) : + this (original.GeographyId, original.CountryId, original.Designation, original.GeographyLevel) + { + // empty copy ctor + } + + public int GeographyId { get; private set; } + public int CountryId { get; private set; } + public string Designation { get; private set; } + public GeographyLevel GeographyLevel { get; private set; } + } } \ No newline at end of file diff --git a/Basic/Types/Structure/BasicGeographyUpdate.cs b/Basic/Types/Structure/BasicGeographyUpdate.cs new file mode 100644 index 00000000..3ce04f0a --- /dev/null +++ b/Basic/Types/Structure/BasicGeographyUpdate.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using Swarmops.Basic.Interfaces; + +namespace Swarmops.Basic.Types.Structure +{ + [Serializable] + public class BasicGeographyUpdate: IHasIdentity + { + [Obsolete ("Do not call this ctor directly. It is intended for serialization.", true)] + public BasicGeographyUpdate() + { + + } + + public BasicGeographyUpdate (int geographyUpdateId, string updateType, string updateSource, string guid, + string countryCode, string changeDataXml, DateTime createdDateTime, DateTime effectiveDateTime, + bool processed) + { + this.GeographyUpdateId = geographyUpdateId; + this.UpdateType = updateType; + this.UpdateSource = updateSource; + this.Guid = guid; + this.CountryCode = countryCode; + this.ChangeDataXml = changeDataXml; + this.CreatedDateTime = createdDateTime; + this.EffectiveDateTime = effectiveDateTime; + this.Processed = processed; + } + + public BasicGeographyUpdate (BasicGeographyUpdate original) + : this ( + original.GeographyUpdateId, original.UpdateType, original.UpdateSource, original.Guid, + original.CountryCode, original.ChangeDataXml, original.CreatedDateTime, original.EffectiveDateTime, + original.Processed) + { + // copy ctor - empty + } + + + public int GeographyUpdateId { get; private set; } + public string UpdateType { get; private set; } + public string UpdateSource { get; private set; } + public string Guid { get; private set; } + public string CountryCode { get; private set; } + public string ChangeDataXml { get; private set; } + public DateTime CreatedDateTime { get; private set; } + public DateTime EffectiveDateTime { get; private set; } + public bool Processed { get; protected set; } + + public int Identity { get { return GeographyUpdateId; } } + } +} diff --git a/Basic/Types/BasicOrganization.cs b/Basic/Types/Structure/BasicOrganization.cs similarity index 78% rename from Basic/Types/BasicOrganization.cs rename to Basic/Types/Structure/BasicOrganization.cs index 47f18c86..b89a7801 100644 --- a/Basic/Types/BasicOrganization.cs +++ b/Basic/Types/Structure/BasicOrganization.cs @@ -1,93 +1,93 @@ -using Swarmops.Basic.Interfaces; - -namespace Swarmops.Basic.Types -{ - public class BasicOrganization : IHasIdentity - { - private string nameShort; - - #region IHasIdentity Members - - public int Identity - { - get { return OrganizationId; } - } - - #endregion - - public BasicOrganization() - { - } - - public BasicOrganization (int organizationId, string name, string nameInternational) - { - OrganizationId = organizationId; - Name = name; - NameInternational = nameInternational; - } - - public BasicOrganization (int organizationId, int parentOrganizationId, string name, string nameInternational) : - this (organizationId, name, nameInternational) - { - ParentOrganizationId = parentOrganizationId; - } - - - public BasicOrganization (int organizationId, int parentOrganizationId, string name, string nameInternational, - string nameShort, string domain, string mailPrefix, int anchorGeographyId, - bool acceptsMembers, bool autoAssignNewMembers, - int defaultCountryId) - : this (organizationId, parentOrganizationId, name, nameInternational) - { - this.nameShort = nameShort; - Domain = domain; - MailPrefix = mailPrefix; - AnchorGeographyId = anchorGeographyId; - AcceptsMembers = acceptsMembers; - AutoAssignNewMembers = autoAssignNewMembers; - DefaultCountryId = defaultCountryId; - } - - public BasicOrganization (BasicOrganization original) - : this ( - original.Identity, original.ParentOrganizationId, original.Name, original.NameInternational, - original.NameShort, original.Domain, original.MailPrefix, original.AnchorGeographyId, - original.AcceptsMembers, original.AutoAssignNewMembers, original.DefaultCountryId) - { - } - - public int DefaultCountryId { get; protected set; } - - public string Name { get; protected set; } - - public string NameInternational { get; protected set; } - - public string NameShort - { - get - { - if (this.nameShort.Length > 0) - { - return this.nameShort; - } - - return Name; - } - set { this.nameShort = value; } - } - - public string Domain { get; protected set; } - - public string MailPrefix { get; protected set; } - - public int AnchorGeographyId { get; protected set; } - - public bool AcceptsMembers { get; protected set; } - - public int OrganizationId { get; protected set; } - - public int ParentOrganizationId { get; protected set; } - - public bool AutoAssignNewMembers { get; protected set; } - } +using Swarmops.Basic.Interfaces; + +namespace Swarmops.Basic.Types.Structure +{ + public class BasicOrganization : IHasIdentity + { + private string nameShort; + + #region IHasIdentity Members + + public int Identity + { + get { return this.OrganizationId; } + } + + #endregion + + public BasicOrganization() + { + } + + public BasicOrganization (int organizationId, string name, string nameInternational) + { + this.OrganizationId = organizationId; + this.Name = name; + this.NameInternational = nameInternational; + } + + public BasicOrganization (int organizationId, int parentOrganizationId, string name, string nameInternational) : + this (organizationId, name, nameInternational) + { + this.ParentOrganizationId = parentOrganizationId; + } + + + public BasicOrganization (int organizationId, int parentOrganizationId, string name, string nameInternational, + string nameShort, string domain, string mailPrefix, int anchorGeographyId, + bool acceptsMembers, bool autoAssignNewMembers, + int defaultCountryId) + : this (organizationId, parentOrganizationId, name, nameInternational) + { + this.nameShort = nameShort; + this.Domain = domain; + this.MailPrefix = mailPrefix; + this.AnchorGeographyId = anchorGeographyId; + this.AcceptsMembers = acceptsMembers; + this.AutoAssignNewMembers = autoAssignNewMembers; + this.DefaultCountryId = defaultCountryId; + } + + public BasicOrganization (BasicOrganization original) + : this ( + original.Identity, original.ParentOrganizationId, original.Name, original.NameInternational, + original.NameShort, original.Domain, original.MailPrefix, original.AnchorGeographyId, + original.AcceptsMembers, original.AutoAssignNewMembers, original.DefaultCountryId) + { + } + + public int DefaultCountryId { get; protected set; } + + public string Name { get; protected set; } + + public string NameInternational { get; protected set; } + + public string NameShort + { + get + { + if (this.nameShort.Length > 0) + { + return this.nameShort; + } + + return this.Name; + } + set { this.nameShort = value; } + } + + public string Domain { get; protected set; } + + public string MailPrefix { get; protected set; } + + public int AnchorGeographyId { get; protected set; } + + public bool AcceptsMembers { get; protected set; } + + public int OrganizationId { get; protected set; } + + public int ParentOrganizationId { get; protected set; } + + public bool AutoAssignNewMembers { get; protected set; } + } } \ No newline at end of file diff --git a/Basic/Types/BasicPostalCode.cs b/Basic/Types/Structure/BasicPostalCode.cs similarity index 78% rename from Basic/Types/BasicPostalCode.cs rename to Basic/Types/Structure/BasicPostalCode.cs index b058db06..6110a33c 100644 --- a/Basic/Types/BasicPostalCode.cs +++ b/Basic/Types/Structure/BasicPostalCode.cs @@ -1,32 +1,32 @@ -using System; - -namespace Swarmops.Basic.Types -{ - [Serializable] - public class BasicPostalCode - { - public BasicPostalCode (int postalCodeId, string postalCode, int cityId, int countryId) - { - PostalCodeId = postalCodeId; - PostalCode = postalCode.Replace (" ", ""); - CityId = cityId; - CountryId = countryId; - } - - public BasicPostalCode (BasicPostalCode original) - : this (original.PostalCodeId, original.PostalCode, original.CityId, original.CountryId) - { - } - - [Obsolete ("Do not call this ctor directly. It exists to enable serialization.", true)] - public BasicPostalCode() - { - // this should never be called from code - } - - public int PostalCodeId { get; private set; } - public string PostalCode { get; private set; } // any whitespace removed - public int CityId { get; protected set; } - public int CountryId { get; protected set; } - } +using System; + +namespace Swarmops.Basic.Types.Structure +{ + [Serializable] + public class BasicPostalCode + { + public BasicPostalCode (int postalCodeId, string postalCode, int cityId, int countryId) + { + this.PostalCodeId = postalCodeId; + this.PostalCode = postalCode.Replace (" ", ""); + this.CityId = cityId; + this.CountryId = countryId; + } + + public BasicPostalCode (BasicPostalCode original) + : this (original.PostalCodeId, original.PostalCode, original.CityId, original.CountryId) + { + } + + [Obsolete ("Do not call this ctor directly. It exists to enable serialization.", true)] + public BasicPostalCode() + { + // this should never be called from code + } + + public int PostalCodeId { get; private set; } + public string PostalCode { get; private set; } // any whitespace removed + public int CityId { get; protected set; } + public int CountryId { get; protected set; } + } } \ No newline at end of file diff --git a/Database/Configuration.cs b/Database/Configuration.cs index 2e9055cb..820ce141 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 8; } } diff --git a/Database/Database-ConnectionsCommands.cs b/Database/Database-ConnectionsCommands.cs index 5529260f..93c0f94c 100644 --- a/Database/Database-ConnectionsCommands.cs +++ b/Database/Database-ConnectionsCommands.cs @@ -234,10 +234,10 @@ namespace Swarmops.Database string[] forbiddenArray = { "\\", "--", ";", "/*", "*/", "select ", "drop ", "update ", "delete ", "insert ", - "=" + "=", "`" }; - string output = input.Replace ("'", "''"); // the typical case + string output = input.Replace ("'", "\\'"); // the typical case string inputLower = input.ToLowerInvariant(); foreach (string forbidden in forbiddenArray) { diff --git a/Database/Database-Countries.cs b/Database/Database-Countries.cs index bb135f41..74a4df18 100644 --- a/Database/Database-Countries.cs +++ b/Database/Database-Countries.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Data; using System.Data.Common; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; namespace Swarmops.Database { @@ -11,7 +12,7 @@ namespace Swarmops.Database #region Field reading code private const string countryFieldSequence = " CountryId,Name,Code,Culture,CurrencyCode," + // 0-4 - "GeographyId,PostalCodeLength FROM Countries "; // 5-6 + "GeographyId,PostalCodeLength,PostalCodeFormat FROM Countries "; // 5-7 private static BasicCountry ReadCountryFromDataReader (DbDataReader reader) @@ -23,8 +24,9 @@ namespace Swarmops.Database string currencyCode = reader.GetString (4); int geographyId = reader.GetInt32 (5); int postalCodeLength = reader.GetInt32 (6); + string postalCodeFormat = reader.GetString (7); - return new BasicCountry (countryId, name, code, culture, currencyCode, geographyId, postalCodeLength); + return new BasicCountry (countryId, name, code, culture, currencyCode, geographyId, postalCodeLength, postalCodeFormat); } #endregion diff --git a/Database/Database-Geographies.cs b/Database/Database-Geographies.cs index 18055d56..f10f78c3 100644 --- a/Database/Database-Geographies.cs +++ b/Database/Database-Geographies.cs @@ -4,6 +4,7 @@ using System.Data; using System.Data.Common; using Swarmops.Basic.Enums; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; namespace Swarmops.Database { @@ -284,8 +285,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/Database/Database-GeographyUpdates.cs b/Database/Database-GeographyUpdates.cs new file mode 100644 index 00000000..ffd91782 --- /dev/null +++ b/Database/Database-GeographyUpdates.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using System.Globalization; +using Swarmops.Basic.Enums; +using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; + +namespace Swarmops.Database +{ + public partial class SwarmDb + { + #region Field reading code + + private const string geographyUpdateFieldSequence = + " GeographyUpdates.GeographyUpdateId, GeographyUpdates.GeographyUpdateTypeId, " + // 0-1 + "GeographyUpdates.GeographyUpdateSourceId, GeographyUpdates.Guid, GeographyUpdates.CountryCode, " + // 2-4 + "GeographyUpdates.ChangeDataXml, GeographyUpdates.CreatedDateTime, " + // 5-6 + "GeographyUpdates.EffectiveDateTime,GeographyUpdates.Processed, " + // 7-8 + "GeographyUpdateTypes.Name AS GeographyUpdateType, " + // 9 + "GeographyUpdateSources.Name AS GeographyUpdateSource " + // 10 + "FROM GeographyUpdates " + + "JOIN GeographyUpdateTypes ON (GeographyUpdateTypes.GeographyUpdateTypeId=GeographyUpdates.GeographyUpdateTypeId) " + + "JOIN GeographyUpdateSources ON (GeographyUpdateSources.GeographyUpdateSourceId=GeographyUpdates.GeographyUpdateSourceId) "; + + private static BasicGeographyUpdate ReadGeographyUpdateFromDataReader (DbDataReader reader) + { + int geographyUpdateId = reader.GetInt32 (0); + // Fields# 1 and 2 are indexes into other tables, contents of which joined in #9 and #10 instead + string guid = reader.GetString (3); + string countryCode = reader.GetString (4); + string changeDataXml = reader.GetString (5); + DateTime createdDateTime = reader.GetDateTime (6); + DateTime effectiveDateTime = reader.GetDateTime (7); + bool processed = reader.GetBoolean (8); + string updateType = reader.GetString (9); + string updateSource = reader.GetString (10); + + return new BasicGeographyUpdate (geographyUpdateId, updateType, updateSource, guid, countryCode, + changeDataXml, createdDateTime, effectiveDateTime, processed); + } + + #endregion + + + public BasicGeographyUpdate GetGeographyUpdate(int identity) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand( + "SELECT " + geographyUpdateFieldSequence + " WHERE GeographyUpdateId=" + identity.ToString(CultureInfo.InvariantCulture), connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + if (reader.Read()) + { + return ReadGeographyUpdateFromDataReader(reader); + } + + throw new ArgumentException ("No such GeographyUpdate: " + + identity.ToString (CultureInfo.InvariantCulture)); + } + } + } + + + + + public BasicGeographyUpdate[] GetAllGeographyUpdates() + { + List result = new List(); + + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand ( + "SELECT " + geographyUpdateFieldSequence + " ORDER BY CreatedDateTime", connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + while (reader.Read()) + { + result.Add (ReadGeographyUpdateFromDataReader (reader)); + } + + return result.ToArray(); + } + } + } + + + public BasicGeographyUpdate[] GetGeographyUpdatesSince(DateTime since) + { + List result = new List(); + + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand( + "SELECT " + geographyUpdateFieldSequence + " WHERE CreatedDateTime >= @sinceDateTime", connection); + AddParameterWithName(command, "@sinceDateTime", since); + + using (DbDataReader reader = command.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(ReadGeographyUpdateFromDataReader(reader)); + } + + return result.ToArray(); + } + } + } + + + public BasicGeographyUpdate[] GetUnprocessedGeographyUpdates() + { + List result = new List(); + + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand( + "SELECT " + geographyUpdateFieldSequence + " WHERE EffectiveDateTime >= @dateTimeNow AND Processed=0", connection); + AddParameterWithName(command, "@dateTimeNow", DateTime.UtcNow); + + using (DbDataReader reader = command.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(ReadGeographyUpdateFromDataReader(reader)); + } + + return result.ToArray(); + } + } + } + + + public bool ExistGeographyUpdateWithGuid(string guid) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand( + "SELECT Guid FROM GeographyUpdates WHERE Guid = @testGuid", connection); + AddParameterWithName(command, "@testGuid", guid); + + using (DbDataReader reader = command.ExecuteReader()) + { + if (reader.Read()) + { + return true; + } + + return false; + } + } + } + + + public int CreateGeographyUpdate (string updateType, string updateSource, string guid, string countryCode, string changeDataXml, DateTime createdDateTime, DateTime effectiveDateTime) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand ("CreateGeographyUpdate", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "geographyUpdateType", updateType); + AddParameterWithName(command, "geographyUpdateSource", updateSource); + AddParameterWithName(command, "guid", guid); + AddParameterWithName(command, "countryCode", countryCode); + AddParameterWithName(command, "changeDataXml", changeDataXml); + AddParameterWithName(command, "createdDateTime", createdDateTime); + AddParameterWithName(command, "effectiveDateTime", effectiveDateTime); + + return Convert.ToInt32 (command.ExecuteScalar()); + } + } + + public void SetGeographyUpdateProcessed (int geographyUpdateId) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetGeographyUpdateProcessed", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "geographyUpdateId", geographyUpdateId); + command.ExecuteNonQuery(); + } + } + } +} \ No newline at end of file diff --git a/Database/Database-Newsletters.cs b/Database/Database-Newsletters.cs index b94c6861..67508707 100644 --- a/Database/Database-Newsletters.cs +++ b/Database/Database-Newsletters.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Data; using System.Data.Common; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; namespace Swarmops.Database { diff --git a/Database/Database-Organizations.cs b/Database/Database-Organizations.cs index 2f6ac50c..2f7ab832 100644 --- a/Database/Database-Organizations.cs +++ b/Database/Database-Organizations.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Data; using System.Data.Common; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; namespace Swarmops.Database { diff --git a/Database/Database-People.cs b/Database/Database-People.cs index 7faec35e..175ddedb 100644 --- a/Database/Database-People.cs +++ b/Database/Database-People.cs @@ -5,6 +5,7 @@ using System.Data.Common; using System.Diagnostics; using Swarmops.Basic.Enums; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; namespace Swarmops.Database { diff --git a/Database/Database-PostalCodes.cs b/Database/Database-PostalCodes.cs index 42f692a4..e4e47cef 100644 --- a/Database/Database-PostalCodes.cs +++ b/Database/Database-PostalCodes.cs @@ -3,6 +3,7 @@ using System.Data.Common; using Swarmops.Basic.Types; // This is the first part of Database to fully use MySql. +using Swarmops.Basic.Types.Structure; namespace Swarmops.Database { diff --git a/Database/Database-PostalCodesCities.cs b/Database/Database-PostalCodesCities.cs index fbb44852..245ea436 100644 --- a/Database/Database-PostalCodesCities.cs +++ b/Database/Database-PostalCodesCities.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Data; using System.Data.Common; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; namespace Swarmops.Database { diff --git a/Database/Database.csproj b/Database/Database.csproj index 6f7bdccd..577ba67d 100644 --- a/Database/Database.csproj +++ b/Database/Database.csproj @@ -58,6 +58,7 @@ + @@ -142,4 +143,4 @@ - + \ No newline at end of file diff --git a/Database/Schemata/revisions.txt b/Database/Schemata/revisions.txt index 3730ea6a..b0a3ef81 100644 --- a/Database/Schemata/revisions.txt +++ b/Database/Schemata/revisions.txt @@ -4,4 +4,5 @@ 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] +0008 - GeographyUpdate updates ahead of deploying: added country, Guid [RF] diff --git a/Database/Schemata/upgrade-0007.sql b/Database/Schemata/upgrade-0007.sql new file mode 100644 index 00000000..c3422f3b --- /dev/null +++ b/Database/Schemata/upgrade-0007.sql @@ -0,0 +1,15 @@ +UPDATE `Countries` SET `CurrencyCode`='EUR', `PostalCodeLength`='6' WHERE `Code`='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/Database/Schemata/upgrade-0008.sql b/Database/Schemata/upgrade-0008.sql new file mode 100644 index 00000000..42813807 --- /dev/null +++ b/Database/Schemata/upgrade-0008.sql @@ -0,0 +1,78 @@ +ALTER TABLE `GeographyUpdates` +ADD COLUMN `GeographyUpdateSourceId` INT(11) NOT NULL AFTER `GeographyUpdateTypeId`, +ADD COLUMN `CountryCode` VARCHAR(8) NOT NULL AFTER `EffectiveDateTime`, +ADD COLUMN `Guid` VARCHAR(40) NOT NULL AFTER `GeographyUpdateSourceId`, +ADD INDEX `indexGuid` (`Guid` ASC) + + +# + + +CREATE TABLE `GeographyUpdateSources` ( + `GeographyUpdateSourceId` INT NOT NULL AUTO_INCREMENT, + `Name` VARCHAR(128) NOT NULL, + PRIMARY KEY (`GeographyUpdateSourceId`), + INDEX `indexName` (`Name` ASC)) + + +# + + +ALTER TABLE `GeographyUpdateTypes` +ADD INDEX `indexName` (`Name` ASC) + + +# + + +ALTER TABLE `Countries` +ADD COLUMN `PostalCodeFormat` VARCHAR(32) NOT NULL DEFAULT '' AFTER `PostalCodeLength` + + +# + + +DROP PROCEDURE `CreateGeographyUpdate` + + +# + + +CREATE PROCEDURE `CreateGeographyUpdate`( + geographyUpdateType VARCHAR(128), + geographyUpdateSource VARCHAR(128), + guid VARCHAR(40), + countryCode VARCHAR(8), + changeDataXml TEXT, + createdDateTime DATETIME, + effectiveDateTime DATETIME +) +BEGIN + + DECLARE geographyUpdateTypeId INTEGER; + DECLARE geographyUpdateSourceId INTEGER; + + IF ((SELECT COUNT(*) FROM GeographyUpdateTypes WHERE GeographyUpdateTypes.Name=geographyUpdateType) = 0) + THEN + INSERT INTO GeographyUpdateTypes (Name) VALUES (geographyUpdateType); + SELECT LAST_INSERT_ID() INTO geographyUpdateTypeId; + ELSE + SELECT GeographyUpdateTypes.GeographyUpdateTypeId INTO geographyUpdateTypeId FROM GeographyUpdateTypes + WHERE GeographyUpdateTypes.Name=geographyUpdateType; + END IF; + + IF ((SELECT COUNT(*) FROM GeographyUpdateSources WHERE GeographyUpdateSources.Name=geographyUpdateSource) = 0) + THEN + INSERT INTO GeographyUpdateSources (Name) VALUES (geographyUpdateSource); + SELECT LAST_INSERT_ID() INTO geographyUpdateSourceId; + ELSE + SELECT GeographyUpdateSources.GeographyUpdateSourceId INTO geographyUpdateSourceId FROM GeographyUpdateSources + WHERE GeographyUpdateSources.Name=geographyUpdateSource; + END IF; + + INSERT INTO GeographyUpdates (GeographyUpdateTypeId,GeographyUpdateSourceId,Guid,CreatedDateTime,EffectiveDateTime,CountryCode,ChangeDataXml,Processed) + VALUES (geographyUpdateTypeId,geographyUpdateSourceId,guid,createdDateTime,effectiveDateTime,countryCode,changeDataXml,0); + + SELECT LAST_INSERT_ID() As Identity; + +END 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/Site5/App_Code/GetGeographyData.cs b/Logic/Automation/GetGeographyData.cs similarity index 97% rename from Site5/App_Code/GetGeographyData.cs rename to Logic/Automation/GetGeographyData.cs index 60d1e8e0..46b2184c 100644 --- a/Site5/App_Code/GetGeographyData.cs +++ b/Logic/Automation/GetGeographyData.cs @@ -1,881 +1,890 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.296 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Web.Services; -using System.Web.Services.Protocols; -using System.Xml.Serialization; - -// -// This source code was auto-generated by wsdl, Version=4.0.30319.1. -// - - -namespace Swarmops.Site.Automation -{ - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [WebServiceBinding(Name = "GetGeographyDataSoap", Namespace = "http://swarmops.com/")] - [XmlInclude(typeof (BasicGeography))] - [XmlInclude(typeof (BasicPostalCode))] - [XmlInclude(typeof (BasicCity))] - [XmlInclude(typeof (BasicCountry))] - public partial class GetGeographyData : System.Web.Services.Protocols.SoapHttpClientProtocol - { - - private System.Threading.SendOrPostCallback GetCountriesOperationCompleted; - - private System.Threading.SendOrPostCallback GetCountriesInUseOperationCompleted; - - private System.Threading.SendOrPostCallback GetCitiesForCountryOperationCompleted; - - private System.Threading.SendOrPostCallback GetPostalCodesForCountryOperationCompleted; - - private System.Threading.SendOrPostCallback GetGeographyOperationCompleted; - - private System.Threading.SendOrPostCallback GetGeographyForCountryOperationCompleted; - - /// - public GetGeographyData() - { - this.Url = "http://live.swarmops.com/Automation/GetGeographyData.asmx"; - } - - /// - public event GetCountriesCompletedEventHandler GetCountriesCompleted; - - /// - public event GetCountriesInUseCompletedEventHandler GetCountriesInUseCompleted; - - /// - public event GetCitiesForCountryCompletedEventHandler GetCitiesForCountryCompleted; - - /// - public event GetPostalCodesForCountryCompletedEventHandler GetPostalCodesForCountryCompleted; - - /// - public event GetGeographyCompletedEventHandler GetGeographyCompleted; - - /// - public event GetGeographyForCountryCompletedEventHandler GetGeographyForCountryCompleted; - - /// - [SoapDocumentMethod("http://swarmops.com/GetCountries", - RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", - Use = System.Web.Services.Description.SoapBindingUse.Literal, - ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public Country[] GetCountries() - { - object[] results = this.Invoke("GetCountries", new object[0]); - return ((Country[]) (results[0])); - } - - /// - public System.IAsyncResult BeginGetCountries(System.AsyncCallback callback, object asyncState) - { - return this.BeginInvoke("GetCountries", new object[0], callback, asyncState); - } - - /// - public Country[] EndGetCountries(System.IAsyncResult asyncResult) - { - object[] results = this.EndInvoke(asyncResult); - return ((Country[]) (results[0])); - } - - /// - public void GetCountriesAsync() - { - this.GetCountriesAsync(null); - } - - /// - public void GetCountriesAsync(object userState) - { - if ((this.GetCountriesOperationCompleted == null)) - { - this.GetCountriesOperationCompleted = - new System.Threading.SendOrPostCallback(this.OnGetCountriesOperationCompleted); - } - this.InvokeAsync("GetCountries", new object[0], this.GetCountriesOperationCompleted, userState); - } - - private void OnGetCountriesOperationCompleted(object arg) - { - if ((this.GetCountriesCompleted != null)) - { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = - ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); - this.GetCountriesCompleted(this, - new GetCountriesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, - invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// - [SoapDocumentMethod("http://swarmops.com/GetCountriesInUse", - RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", - Use = System.Web.Services.Description.SoapBindingUse.Literal, - ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public Country[] GetCountriesInUse() - { - object[] results = this.Invoke("GetCountriesInUse", new object[0]); - return ((Country[]) (results[0])); - } - - /// - public System.IAsyncResult BeginGetCountriesInUse(System.AsyncCallback callback, object asyncState) - { - return this.BeginInvoke("GetCountriesInUse", new object[0], callback, asyncState); - } - - /// - public Country[] EndGetCountriesInUse(System.IAsyncResult asyncResult) - { - object[] results = this.EndInvoke(asyncResult); - return ((Country[]) (results[0])); - } - - /// - public void GetCountriesInUseAsync() - { - this.GetCountriesInUseAsync(null); - } - - /// - public void GetCountriesInUseAsync(object userState) - { - if ((this.GetCountriesInUseOperationCompleted == null)) - { - this.GetCountriesInUseOperationCompleted = - new System.Threading.SendOrPostCallback(this.OnGetCountriesInUseOperationCompleted); - } - this.InvokeAsync("GetCountriesInUse", new object[0], this.GetCountriesInUseOperationCompleted, userState); - } - - private void OnGetCountriesInUseOperationCompleted(object arg) - { - if ((this.GetCountriesInUseCompleted != null)) - { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = - ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); - this.GetCountriesInUseCompleted(this, - new GetCountriesInUseCompletedEventArgs(invokeArgs.Results, - invokeArgs.Error, - invokeArgs.Cancelled, - invokeArgs.UserState)); - } - } - - /// - [SoapDocumentMethod("http://swarmops.com/GetCitiesForCountry", - RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", - Use = System.Web.Services.Description.SoapBindingUse.Literal, - ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public City[] GetCitiesForCountry(string countryCode) - { - object[] results = this.Invoke("GetCitiesForCountry", new object[] - { - countryCode - }); - return ((City[]) (results[0])); - } - - /// - public System.IAsyncResult BeginGetCitiesForCountry(string countryCode, System.AsyncCallback callback, - object asyncState) - { - return this.BeginInvoke("GetCitiesForCountry", new object[] - { - countryCode - }, callback, asyncState); - } - - /// - public City[] EndGetCitiesForCountry(System.IAsyncResult asyncResult) - { - object[] results = this.EndInvoke(asyncResult); - return ((City[]) (results[0])); - } - - /// - public void GetCitiesForCountryAsync(string countryCode) - { - this.GetCitiesForCountryAsync(countryCode, null); - } - - /// - public void GetCitiesForCountryAsync(string countryCode, object userState) - { - if ((this.GetCitiesForCountryOperationCompleted == null)) - { - this.GetCitiesForCountryOperationCompleted = - new System.Threading.SendOrPostCallback(this.OnGetCitiesForCountryOperationCompleted); - } - this.InvokeAsync("GetCitiesForCountry", new object[] - { - countryCode - }, this.GetCitiesForCountryOperationCompleted, userState); - } - - private void OnGetCitiesForCountryOperationCompleted(object arg) - { - if ((this.GetCitiesForCountryCompleted != null)) - { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = - ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); - this.GetCitiesForCountryCompleted(this, - new GetCitiesForCountryCompletedEventArgs(invokeArgs.Results, - invokeArgs.Error, - invokeArgs.Cancelled, - invokeArgs.UserState)); - } - } - - /// - [SoapDocumentMethod("http://swarmops.com/GetPostalCodesForCountry", - RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", - Use = System.Web.Services.Description.SoapBindingUse.Literal, - ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public PostalCode[] GetPostalCodesForCountry(string countryCode) - { - object[] results = this.Invoke("GetPostalCodesForCountry", new object[] - { - countryCode - }); - return ((PostalCode[]) (results[0])); - } - - /// - public System.IAsyncResult BeginGetPostalCodesForCountry(string countryCode, System.AsyncCallback callback, - object asyncState) - { - return this.BeginInvoke("GetPostalCodesForCountry", new object[] - { - countryCode - }, callback, asyncState); - } - - /// - public PostalCode[] EndGetPostalCodesForCountry(System.IAsyncResult asyncResult) - { - object[] results = this.EndInvoke(asyncResult); - return ((PostalCode[]) (results[0])); - } - - /// - public void GetPostalCodesForCountryAsync(string countryCode) - { - this.GetPostalCodesForCountryAsync(countryCode, null); - } - - /// - public void GetPostalCodesForCountryAsync(string countryCode, object userState) - { - if ((this.GetPostalCodesForCountryOperationCompleted == null)) - { - this.GetPostalCodesForCountryOperationCompleted = - new System.Threading.SendOrPostCallback(this.OnGetPostalCodesForCountryOperationCompleted); - } - this.InvokeAsync("GetPostalCodesForCountry", new object[] - { - countryCode - }, this.GetPostalCodesForCountryOperationCompleted, - userState); - } - - private void OnGetPostalCodesForCountryOperationCompleted(object arg) - { - if ((this.GetPostalCodesForCountryCompleted != null)) - { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = - ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); - this.GetPostalCodesForCountryCompleted(this, - new GetPostalCodesForCountryCompletedEventArgs( - invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, - invokeArgs.UserState)); - } - } - - /// - [SoapDocumentMethod("http://swarmops.com/GetGeography", - RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", - Use = System.Web.Services.Description.SoapBindingUse.Literal, - ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public Geography GetGeography(int nodeId) - { - object[] results = this.Invoke("GetGeography", new object[] - { - nodeId - }); - return ((Geography) (results[0])); - } - - /// - public System.IAsyncResult BeginGetGeography(int nodeId, System.AsyncCallback callback, object asyncState) - { - return this.BeginInvoke("GetGeography", new object[] - { - nodeId - }, callback, asyncState); - } - - /// - public Geography EndGetGeography(System.IAsyncResult asyncResult) - { - object[] results = this.EndInvoke(asyncResult); - return ((Geography) (results[0])); - } - - /// - public void GetGeographyAsync(int nodeId) - { - this.GetGeographyAsync(nodeId, null); - } - - /// - public void GetGeographyAsync(int nodeId, object userState) - { - if ((this.GetGeographyOperationCompleted == null)) - { - this.GetGeographyOperationCompleted = - new System.Threading.SendOrPostCallback(this.OnGetGeographyOperationCompleted); - } - this.InvokeAsync("GetGeography", new object[] - { - nodeId - }, this.GetGeographyOperationCompleted, userState); - } - - private void OnGetGeographyOperationCompleted(object arg) - { - if ((this.GetGeographyCompleted != null)) - { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = - ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); - this.GetGeographyCompleted(this, - new GetGeographyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, - invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// - [SoapDocumentMethod("http://swarmops.com/GetGeographyForCountry", - RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", - Use = System.Web.Services.Description.SoapBindingUse.Literal, - ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public Geography GetGeographyForCountry(string countryCode) - { - object[] results = this.Invoke("GetGeographyForCountry", new object[] - { - countryCode - }); - return ((Geography) (results[0])); - } - - /// - public System.IAsyncResult BeginGetGeographyForCountry(string countryCode, System.AsyncCallback callback, - object asyncState) - { - return this.BeginInvoke("GetGeographyForCountry", new object[] - { - countryCode - }, callback, asyncState); - } - - /// - public Geography EndGetGeographyForCountry(System.IAsyncResult asyncResult) - { - object[] results = this.EndInvoke(asyncResult); - return ((Geography) (results[0])); - } - - /// - public void GetGeographyForCountryAsync(string countryCode) - { - this.GetGeographyForCountryAsync(countryCode, null); - } - - /// - public void GetGeographyForCountryAsync(string countryCode, object userState) - { - if ((this.GetGeographyForCountryOperationCompleted == null)) - { - this.GetGeographyForCountryOperationCompleted = - new System.Threading.SendOrPostCallback(this.OnGetGeographyForCountryOperationCompleted); - } - this.InvokeAsync("GetGeographyForCountry", new object[] - { - countryCode - }, this.GetGeographyForCountryOperationCompleted, userState); - } - - private void OnGetGeographyForCountryOperationCompleted(object arg) - { - if ((this.GetGeographyForCountryCompleted != null)) - { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = - ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); - this.GetGeographyForCountryCompleted(this, - new GetGeographyForCountryCompletedEventArgs(invokeArgs.Results, - invokeArgs.Error, - invokeArgs.Cancelled, - invokeArgs.UserState)); - } - } - - /// - public new void CancelAsync(object userState) - { - base.CancelAsync(userState); - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [Serializable()] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [XmlType(Namespace = "http://swarmops.com/")] - public partial class Country : BasicCountry - { - } - - /// - [XmlInclude(typeof (Country))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [Serializable()] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [XmlType(Namespace = "http://swarmops.com/")] - public partial class BasicCountry - { - - private int countryIdField; - - private string nameField; - - private string codeField; - - private string cultureField; - - private int geographyIdField; - - /// - public int CountryId - { - get { return this.countryIdField; } - set { this.countryIdField = value; } - } - - /// - public string Name - { - get { return this.nameField; } - set { this.nameField = value; } - } - - /// - public string Code - { - get { return this.codeField; } - set { this.codeField = value; } - } - - /// - public string Culture - { - get { return this.cultureField; } - set { this.cultureField = value; } - } - - /// - public int GeographyId - { - get { return this.geographyIdField; } - set { this.geographyIdField = value; } - } - } - - /// - [XmlInclude(typeof (Geography))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [Serializable()] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [XmlType(Namespace = "http://swarmops.com/")] - public partial class BasicGeography - { - - private int geographyIdField; - - private int parentGeographyIdField; - - private string nameField; - - private int generationField; - - /// - public int GeographyId - { - get { return this.geographyIdField; } - set { this.geographyIdField = value; } - } - - /// - public int ParentGeographyId - { - get { return this.parentGeographyIdField; } - set { this.parentGeographyIdField = value; } - } - - /// - public string Name - { - get { return this.nameField; } - set { this.nameField = value; } - } - - /// - public int Generation - { - get { return this.generationField; } - set { this.generationField = value; } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [Serializable()] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [XmlType(Namespace = "http://swarmops.com/")] - public partial class Geography : BasicGeography - { - - private Geography[] childrenField; - - /// - public Geography[] Children - { - get { return this.childrenField; } - set { this.childrenField = value; } - } - } - - /// - [XmlInclude(typeof (PostalCode))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [Serializable()] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [XmlType(Namespace = "http://swarmops.com/")] - public partial class BasicPostalCode - { - - private int postalCodeIdField; - - private string postalCodeField; - - private int cityIdField; - - private int countryIdField; - - /// - public int PostalCodeId - { - get { return this.postalCodeIdField; } - set { this.postalCodeIdField = value; } - } - - /// - public string PostalCode - { - get { return this.postalCodeField; } - set { this.postalCodeField = value; } - } - - /// - public int CityId - { - get { return this.cityIdField; } - set { this.cityIdField = value; } - } - - /// - public int CountryId - { - get { return this.countryIdField; } - set { this.countryIdField = value; } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [Serializable()] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [XmlType(Namespace = "http://swarmops.com/")] - public partial class PostalCode : BasicPostalCode - { - } - - /// - [XmlInclude(typeof (City))] - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [Serializable()] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [XmlType(Namespace = "http://swarmops.com/")] - public partial class BasicCity - { - - private int cityIdField; - - private string nameField; - - private int countryIdField; - - private int geographyIdField; - - /// - public int CityId - { - get { return this.cityIdField; } - set { this.cityIdField = value; } - } - - /// - public string Name - { - get { return this.nameField; } - set { this.nameField = value; } - } - - /// - public int CountryId - { - get { return this.countryIdField; } - set { this.countryIdField = value; } - } - - /// - public int GeographyId - { - get { return this.geographyIdField; } - set { this.geographyIdField = value; } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [Serializable()] - [DebuggerStepThrough()] - [DesignerCategory("code")] - [XmlType(Namespace = "http://swarmops.com/")] - public partial class City : BasicCity - { - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - public delegate void GetCountriesCompletedEventHandler(object sender, GetCountriesCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [DebuggerStepThrough()] - [DesignerCategory("code")] - public partial class GetCountriesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs - { - - private object[] results; - - internal GetCountriesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, - object userState) : - base(exception, cancelled, userState) - { - this.results = results; - } - - /// - public Country[] Result - { - get - { - this.RaiseExceptionIfNecessary(); - return ((Country[]) (this.results[0])); - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - public delegate void GetCountriesInUseCompletedEventHandler(object sender, GetCountriesInUseCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [DebuggerStepThrough()] - [DesignerCategory("code")] - public partial class GetCountriesInUseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs - { - - private object[] results; - - internal GetCountriesInUseCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, - object userState) : - base(exception, cancelled, userState) - { - this.results = results; - } - - /// - public Country[] Result - { - get - { - this.RaiseExceptionIfNecessary(); - return ((Country[]) (this.results[0])); - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - public delegate void GetCitiesForCountryCompletedEventHandler(object sender, GetCitiesForCountryCompletedEventArgs e - ); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [DebuggerStepThrough()] - [DesignerCategory("code")] - public partial class GetCitiesForCountryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs - { - - private object[] results; - - internal GetCitiesForCountryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, - object userState) : - base(exception, cancelled, userState) - { - this.results = results; - } - - /// - public City[] Result - { - get - { - this.RaiseExceptionIfNecessary(); - return ((City[]) (this.results[0])); - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - public delegate void GetPostalCodesForCountryCompletedEventHandler( - object sender, GetPostalCodesForCountryCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [DebuggerStepThrough()] - [DesignerCategory("code")] - public partial class GetPostalCodesForCountryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs - { - - private object[] results; - - internal GetPostalCodesForCountryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, - object userState) : - base(exception, cancelled, userState) - { - this.results = results; - } - - /// - public PostalCode[] Result - { - get - { - this.RaiseExceptionIfNecessary(); - return ((PostalCode[]) (this.results[0])); - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - public delegate void GetGeographyCompletedEventHandler(object sender, GetGeographyCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [DebuggerStepThrough()] - [DesignerCategory("code")] - public partial class GetGeographyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs - { - - private object[] results; - - internal GetGeographyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, - object userState) : - base(exception, cancelled, userState) - { - this.results = results; - } - - /// - public Geography Result - { - get - { - this.RaiseExceptionIfNecessary(); - return ((Geography) (this.results[0])); - } - } - } - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - public delegate void GetGeographyForCountryCompletedEventHandler( - object sender, GetGeographyForCountryCompletedEventArgs e); - - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] - [DebuggerStepThrough()] - [DesignerCategory("code")] - public partial class GetGeographyForCountryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs - { - - private object[] results; - - internal GetGeographyForCountryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, - object userState) : - base(exception, cancelled, userState) - { - this.results = results; - } - - /// - public Geography Result - { - get - { - this.RaiseExceptionIfNecessary(); - return ((Geography) (this.results[0])); - } - } - } - +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.296 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Web.Services; +using System.Web.Services.Protocols; +using System.Xml.Serialization; + +// +// This source code was auto-generated by wsdl, Version=4.0.30319.1. +// + + +namespace Swarmops.Logic.Automation +{ + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [WebServiceBinding(Name = "GetGeographyDataSoap", Namespace = "http://swarmops.com/")] + [XmlInclude(typeof (BasicGeography))] + [XmlInclude(typeof (BasicPostalCode))] + [XmlInclude(typeof (BasicCity))] + [XmlInclude(typeof (BasicCountry))] + public partial class GetGeographyData : System.Web.Services.Protocols.SoapHttpClientProtocol + { + + private System.Threading.SendOrPostCallback GetCountriesOperationCompleted; + + private System.Threading.SendOrPostCallback GetCountriesInUseOperationCompleted; + + private System.Threading.SendOrPostCallback GetCitiesForCountryOperationCompleted; + + private System.Threading.SendOrPostCallback GetPostalCodesForCountryOperationCompleted; + + private System.Threading.SendOrPostCallback GetGeographyOperationCompleted; + + private System.Threading.SendOrPostCallback GetGeographyForCountryOperationCompleted; + + /// + public GetGeographyData() + { + this.Url = "http://live.swarmops.com/Automation/GetGeographyData.asmx"; + } + + /// + public event GetCountriesCompletedEventHandler GetCountriesCompleted; + + /// + public event GetCountriesInUseCompletedEventHandler GetCountriesInUseCompleted; + + /// + public event GetCitiesForCountryCompletedEventHandler GetCitiesForCountryCompleted; + + /// + public event GetPostalCodesForCountryCompletedEventHandler GetPostalCodesForCountryCompleted; + + /// + public event GetGeographyCompletedEventHandler GetGeographyCompleted; + + /// + public event GetGeographyForCountryCompletedEventHandler GetGeographyForCountryCompleted; + + /// + [SoapDocumentMethod("http://swarmops.com/GetCountries", + RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", + Use = System.Web.Services.Description.SoapBindingUse.Literal, + ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public Country[] GetCountries() + { + object[] results = this.Invoke("GetCountries", new object[0]); + return ((Country[]) (results[0])); + } + + /// + public System.IAsyncResult BeginGetCountries(System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("GetCountries", new object[0], callback, asyncState); + } + + /// + public Country[] EndGetCountries(System.IAsyncResult asyncResult) + { + object[] results = this.EndInvoke(asyncResult); + return ((Country[]) (results[0])); + } + + /// + public void GetCountriesAsync() + { + this.GetCountriesAsync(null); + } + + /// + public void GetCountriesAsync(object userState) + { + if ((this.GetCountriesOperationCompleted == null)) + { + this.GetCountriesOperationCompleted = + new System.Threading.SendOrPostCallback(this.OnGetCountriesOperationCompleted); + } + this.InvokeAsync("GetCountries", new object[0], this.GetCountriesOperationCompleted, userState); + } + + private void OnGetCountriesOperationCompleted(object arg) + { + if ((this.GetCountriesCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = + ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); + this.GetCountriesCompleted(this, + new GetCountriesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, + invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [SoapDocumentMethod("http://swarmops.com/GetCountriesInUse", + RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", + Use = System.Web.Services.Description.SoapBindingUse.Literal, + ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public Country[] GetCountriesInUse() + { + object[] results = this.Invoke("GetCountriesInUse", new object[0]); + return ((Country[]) (results[0])); + } + + /// + public System.IAsyncResult BeginGetCountriesInUse(System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("GetCountriesInUse", new object[0], callback, asyncState); + } + + /// + public Country[] EndGetCountriesInUse(System.IAsyncResult asyncResult) + { + object[] results = this.EndInvoke(asyncResult); + return ((Country[]) (results[0])); + } + + /// + public void GetCountriesInUseAsync() + { + this.GetCountriesInUseAsync(null); + } + + /// + public void GetCountriesInUseAsync(object userState) + { + if ((this.GetCountriesInUseOperationCompleted == null)) + { + this.GetCountriesInUseOperationCompleted = + new System.Threading.SendOrPostCallback(this.OnGetCountriesInUseOperationCompleted); + } + this.InvokeAsync("GetCountriesInUse", new object[0], this.GetCountriesInUseOperationCompleted, userState); + } + + private void OnGetCountriesInUseOperationCompleted(object arg) + { + if ((this.GetCountriesInUseCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = + ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); + this.GetCountriesInUseCompleted(this, + new GetCountriesInUseCompletedEventArgs(invokeArgs.Results, + invokeArgs.Error, + invokeArgs.Cancelled, + invokeArgs.UserState)); + } + } + + /// + [SoapDocumentMethod("http://swarmops.com/GetCitiesForCountry", + RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", + Use = System.Web.Services.Description.SoapBindingUse.Literal, + ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public City[] GetCitiesForCountry(string countryCode) + { + object[] results = this.Invoke("GetCitiesForCountry", new object[] + { + countryCode + }); + return ((City[]) (results[0])); + } + + /// + public System.IAsyncResult BeginGetCitiesForCountry(string countryCode, System.AsyncCallback callback, + object asyncState) + { + return this.BeginInvoke("GetCitiesForCountry", new object[] + { + countryCode + }, callback, asyncState); + } + + /// + public City[] EndGetCitiesForCountry(System.IAsyncResult asyncResult) + { + object[] results = this.EndInvoke(asyncResult); + return ((City[]) (results[0])); + } + + /// + public void GetCitiesForCountryAsync(string countryCode) + { + this.GetCitiesForCountryAsync(countryCode, null); + } + + /// + public void GetCitiesForCountryAsync(string countryCode, object userState) + { + if ((this.GetCitiesForCountryOperationCompleted == null)) + { + this.GetCitiesForCountryOperationCompleted = + new System.Threading.SendOrPostCallback(this.OnGetCitiesForCountryOperationCompleted); + } + this.InvokeAsync("GetCitiesForCountry", new object[] + { + countryCode + }, this.GetCitiesForCountryOperationCompleted, userState); + } + + private void OnGetCitiesForCountryOperationCompleted(object arg) + { + if ((this.GetCitiesForCountryCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = + ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); + this.GetCitiesForCountryCompleted(this, + new GetCitiesForCountryCompletedEventArgs(invokeArgs.Results, + invokeArgs.Error, + invokeArgs.Cancelled, + invokeArgs.UserState)); + } + } + + /// + [SoapDocumentMethod("http://swarmops.com/GetPostalCodesForCountry", + RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", + Use = System.Web.Services.Description.SoapBindingUse.Literal, + ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public PostalCode[] GetPostalCodesForCountry(string countryCode) + { + object[] results = this.Invoke("GetPostalCodesForCountry", new object[] + { + countryCode + }); + return ((PostalCode[]) (results[0])); + } + + /// + public System.IAsyncResult BeginGetPostalCodesForCountry(string countryCode, System.AsyncCallback callback, + object asyncState) + { + return this.BeginInvoke("GetPostalCodesForCountry", new object[] + { + countryCode + }, callback, asyncState); + } + + /// + public PostalCode[] EndGetPostalCodesForCountry(System.IAsyncResult asyncResult) + { + object[] results = this.EndInvoke(asyncResult); + return ((PostalCode[]) (results[0])); + } + + /// + public void GetPostalCodesForCountryAsync(string countryCode) + { + this.GetPostalCodesForCountryAsync(countryCode, null); + } + + /// + public void GetPostalCodesForCountryAsync(string countryCode, object userState) + { + if ((this.GetPostalCodesForCountryOperationCompleted == null)) + { + this.GetPostalCodesForCountryOperationCompleted = + new System.Threading.SendOrPostCallback(this.OnGetPostalCodesForCountryOperationCompleted); + } + this.InvokeAsync("GetPostalCodesForCountry", new object[] + { + countryCode + }, this.GetPostalCodesForCountryOperationCompleted, + userState); + } + + private void OnGetPostalCodesForCountryOperationCompleted(object arg) + { + if ((this.GetPostalCodesForCountryCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = + ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); + this.GetPostalCodesForCountryCompleted(this, + new GetPostalCodesForCountryCompletedEventArgs( + invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, + invokeArgs.UserState)); + } + } + + /// + [SoapDocumentMethod("http://swarmops.com/GetGeography", + RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", + Use = System.Web.Services.Description.SoapBindingUse.Literal, + ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public Geography GetGeography(int nodeId) + { + object[] results = this.Invoke("GetGeography", new object[] + { + nodeId + }); + return ((Geography) (results[0])); + } + + /// + public System.IAsyncResult BeginGetGeography(int nodeId, System.AsyncCallback callback, object asyncState) + { + return this.BeginInvoke("GetGeography", new object[] + { + nodeId + }, callback, asyncState); + } + + /// + public Geography EndGetGeography(System.IAsyncResult asyncResult) + { + object[] results = this.EndInvoke(asyncResult); + return ((Geography) (results[0])); + } + + /// + public void GetGeographyAsync(int nodeId) + { + this.GetGeographyAsync(nodeId, null); + } + + /// + public void GetGeographyAsync(int nodeId, object userState) + { + if ((this.GetGeographyOperationCompleted == null)) + { + this.GetGeographyOperationCompleted = + new System.Threading.SendOrPostCallback(this.OnGetGeographyOperationCompleted); + } + this.InvokeAsync("GetGeography", new object[] + { + nodeId + }, this.GetGeographyOperationCompleted, userState); + } + + private void OnGetGeographyOperationCompleted(object arg) + { + if ((this.GetGeographyCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = + ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); + this.GetGeographyCompleted(this, + new GetGeographyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, + invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [SoapDocumentMethod("http://swarmops.com/GetGeographyForCountry", + RequestNamespace = "http://swarmops.com/", ResponseNamespace = "http://swarmops.com/", + Use = System.Web.Services.Description.SoapBindingUse.Literal, + ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public Geography GetGeographyForCountry(string countryCode) + { + object[] results = this.Invoke("GetGeographyForCountry", new object[] + { + countryCode + }); + return ((Geography) (results[0])); + } + + /// + public System.IAsyncResult BeginGetGeographyForCountry(string countryCode, System.AsyncCallback callback, + object asyncState) + { + return this.BeginInvoke("GetGeographyForCountry", new object[] + { + countryCode + }, callback, asyncState); + } + + /// + public Geography EndGetGeographyForCountry(System.IAsyncResult asyncResult) + { + object[] results = this.EndInvoke(asyncResult); + return ((Geography) (results[0])); + } + + /// + public void GetGeographyForCountryAsync(string countryCode) + { + this.GetGeographyForCountryAsync(countryCode, null); + } + + /// + public void GetGeographyForCountryAsync(string countryCode, object userState) + { + if ((this.GetGeographyForCountryOperationCompleted == null)) + { + this.GetGeographyForCountryOperationCompleted = + new System.Threading.SendOrPostCallback(this.OnGetGeographyForCountryOperationCompleted); + } + this.InvokeAsync("GetGeographyForCountry", new object[] + { + countryCode + }, this.GetGeographyForCountryOperationCompleted, userState); + } + + private void OnGetGeographyForCountryOperationCompleted(object arg) + { + if ((this.GetGeographyForCountryCompleted != null)) + { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = + ((System.Web.Services.Protocols.InvokeCompletedEventArgs) (arg)); + this.GetGeographyForCountryCompleted(this, + new GetGeographyForCountryCompletedEventArgs(invokeArgs.Results, + invokeArgs.Error, + invokeArgs.Cancelled, + invokeArgs.UserState)); + } + } + + /// + public new void CancelAsync(object userState) + { + base.CancelAsync(userState); + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [Serializable()] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [XmlType(Namespace = "http://swarmops.com/")] + public partial class Country : BasicCountry + { + } + + /// + [XmlInclude(typeof (Country))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [Serializable()] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [XmlType(Namespace = "http://swarmops.com/")] + public partial class BasicCountry + { + + private int countryIdField; + + private string nameField; + + private string codeField; + + private string cultureField; + + private int geographyIdField; + + private int postalCodeLengthField; + + /// + public int CountryId + { + get { return this.countryIdField; } + set { this.countryIdField = value; } + } + + /// + public int PostalCodeLength + { + get { return this.postalCodeLengthField; } + set { this.postalCodeLengthField = value; } + } + + /// + public string Name + { + get { return this.nameField; } + set { this.nameField = value; } + } + + /// + public string Code + { + get { return this.codeField; } + set { this.codeField = value; } + } + + /// + public string Culture + { + get { return this.cultureField; } + set { this.cultureField = value; } + } + + /// + public int GeographyId + { + get { return this.geographyIdField; } + set { this.geographyIdField = value; } + } + } + + /// + [XmlInclude(typeof (Geography))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [Serializable()] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [XmlType(Namespace = "http://swarmops.com/")] + public partial class BasicGeography + { + + private int geographyIdField; + + private int parentGeographyIdField; + + private string nameField; + + private int generationField; + + /// + public int GeographyId + { + get { return this.geographyIdField; } + set { this.geographyIdField = value; } + } + + /// + public int ParentGeographyId + { + get { return this.parentGeographyIdField; } + set { this.parentGeographyIdField = value; } + } + + /// + public string Name + { + get { return this.nameField; } + set { this.nameField = value; } + } + + /// + public int Generation + { + get { return this.generationField; } + set { this.generationField = value; } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [Serializable()] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [XmlType(Namespace = "http://swarmops.com/")] + public partial class Geography : BasicGeography + { + + private Geography[] childrenField; + + /// + public Geography[] Children + { + get { return this.childrenField; } + set { this.childrenField = value; } + } + } + + /// + [XmlInclude(typeof (PostalCode))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [Serializable()] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [XmlType(Namespace = "http://swarmops.com/")] + public partial class BasicPostalCode + { + + private int postalCodeIdField; + + private string postalCodeField; + + private int cityIdField; + + private int countryIdField; + + /// + public int PostalCodeId + { + get { return this.postalCodeIdField; } + set { this.postalCodeIdField = value; } + } + + /// + public string PostalCode + { + get { return this.postalCodeField; } + set { this.postalCodeField = value; } + } + + /// + public int CityId + { + get { return this.cityIdField; } + set { this.cityIdField = value; } + } + + /// + public int CountryId + { + get { return this.countryIdField; } + set { this.countryIdField = value; } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [Serializable()] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [XmlType(Namespace = "http://swarmops.com/")] + public partial class PostalCode : BasicPostalCode + { + } + + /// + [XmlInclude(typeof (City))] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [Serializable()] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [XmlType(Namespace = "http://swarmops.com/")] + public partial class BasicCity + { + + private int cityIdField; + + private string nameField; + + private int countryIdField; + + private int geographyIdField; + + /// + public int CityId + { + get { return this.cityIdField; } + set { this.cityIdField = value; } + } + + /// + public string Name + { + get { return this.nameField; } + set { this.nameField = value; } + } + + /// + public int CountryId + { + get { return this.countryIdField; } + set { this.countryIdField = value; } + } + + /// + public int GeographyId + { + get { return this.geographyIdField; } + set { this.geographyIdField = value; } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [Serializable()] + [DebuggerStepThrough()] + [DesignerCategory("code")] + [XmlType(Namespace = "http://swarmops.com/")] + public partial class City : BasicCity + { + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + public delegate void GetCountriesCompletedEventHandler(object sender, GetCountriesCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [DebuggerStepThrough()] + [DesignerCategory("code")] + public partial class GetCountriesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + + private object[] results; + + internal GetCountriesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, + object userState) : + base(exception, cancelled, userState) + { + this.results = results; + } + + /// + public Country[] Result + { + get + { + this.RaiseExceptionIfNecessary(); + return ((Country[]) (this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + public delegate void GetCountriesInUseCompletedEventHandler(object sender, GetCountriesInUseCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [DebuggerStepThrough()] + [DesignerCategory("code")] + public partial class GetCountriesInUseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + + private object[] results; + + internal GetCountriesInUseCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, + object userState) : + base(exception, cancelled, userState) + { + this.results = results; + } + + /// + public Country[] Result + { + get + { + this.RaiseExceptionIfNecessary(); + return ((Country[]) (this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + public delegate void GetCitiesForCountryCompletedEventHandler(object sender, GetCitiesForCountryCompletedEventArgs e + ); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [DebuggerStepThrough()] + [DesignerCategory("code")] + public partial class GetCitiesForCountryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + + private object[] results; + + internal GetCitiesForCountryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, + object userState) : + base(exception, cancelled, userState) + { + this.results = results; + } + + /// + public City[] Result + { + get + { + this.RaiseExceptionIfNecessary(); + return ((City[]) (this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + public delegate void GetPostalCodesForCountryCompletedEventHandler( + object sender, GetPostalCodesForCountryCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [DebuggerStepThrough()] + [DesignerCategory("code")] + public partial class GetPostalCodesForCountryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + + private object[] results; + + internal GetPostalCodesForCountryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, + object userState) : + base(exception, cancelled, userState) + { + this.results = results; + } + + /// + public PostalCode[] Result + { + get + { + this.RaiseExceptionIfNecessary(); + return ((PostalCode[]) (this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + public delegate void GetGeographyCompletedEventHandler(object sender, GetGeographyCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [DebuggerStepThrough()] + [DesignerCategory("code")] + public partial class GetGeographyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + + private object[] results; + + internal GetGeographyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, + object userState) : + base(exception, cancelled, userState) + { + this.results = results; + } + + /// + public Geography Result + { + get + { + this.RaiseExceptionIfNecessary(); + return ((Geography) (this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + public delegate void GetGeographyForCountryCompletedEventHandler( + object sender, GetGeographyForCountryCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] + [DebuggerStepThrough()] + [DesignerCategory("code")] + public partial class GetGeographyForCountryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs + { + + private object[] results; + + internal GetGeographyForCountryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, + object userState) : + base(exception, cancelled, userState) + { + this.results = results; + } + + /// + public Geography Result + { + get + { + this.RaiseExceptionIfNecessary(); + return ((Geography) (this.results[0])); + } + } + } + } \ No newline at end of file diff --git a/Logic/Cache/GeographyCache.cs b/Logic/Cache/GeographyCache.cs index 87023b88..90668de1 100644 --- a/Logic/Cache/GeographyCache.cs +++ b/Logic/Cache/GeographyCache.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Structure; @@ -228,7 +229,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 diff --git a/Logic/Cache/OrganizationCache.cs b/Logic/Cache/OrganizationCache.cs index 10f047e8..7693075c 100644 --- a/Logic/Cache/OrganizationCache.cs +++ b/Logic/Cache/OrganizationCache.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Structure; diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index f63d8617..3ec05bf3 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -67,6 +67,7 @@ + @@ -100,6 +101,9 @@ True Logic.Communications.Transmission.MailPayload.resx + + Component + @@ -236,6 +240,8 @@ + + diff --git a/Logic/Security/Authorization.cs b/Logic/Security/Authorization.cs index f2e2fdc1..4bf1dc6c 100644 --- a/Logic/Security/Authorization.cs +++ b/Logic/Security/Authorization.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Swarmops.Basic.Enums; using Swarmops.Basic.Types; using Swarmops.Basic.Types.Security; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Cache; using Swarmops.Logic.Structure; diff --git a/Logic/Structure/Cities.cs b/Logic/Structure/Cities.cs index 7fbfd9c6..2fd43f27 100644 --- a/Logic/Structure/Cities.cs +++ b/Logic/Structure/Cities.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; namespace Swarmops.Logic.Structure diff --git a/Logic/Structure/City.cs b/Logic/Structure/City.cs index ac7fcdd5..4219e65f 100644 --- a/Logic/Structure/City.cs +++ b/Logic/Structure/City.cs @@ -1,5 +1,6 @@ using System; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; namespace Swarmops.Logic.Structure diff --git a/Logic/Structure/Countries.cs b/Logic/Structure/Countries.cs index 17bcfcd4..7027d758 100644 --- a/Logic/Structure/Countries.cs +++ b/Logic/Structure/Countries.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; namespace Swarmops.Logic.Structure diff --git a/Logic/Structure/Country.cs b/Logic/Structure/Country.cs index e0ce6bbc..2d0e5d20 100644 --- a/Logic/Structure/Country.cs +++ b/Logic/Structure/Country.cs @@ -1,5 +1,6 @@ using System; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Financial; diff --git a/Logic/Structure/Geographies.cs b/Logic/Structure/Geographies.cs index 9bea7c8b..60455b42 100644 --- a/Logic/Structure/Geographies.cs +++ b/Logic/Structure/Geographies.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Swarmops.Basic.Enums; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Cache; using Swarmops.Logic.Support; diff --git a/Logic/Structure/Geography.cs b/Logic/Structure/Geography.cs index 2055a9ce..08cc895e 100644 --- a/Logic/Structure/Geography.cs +++ b/Logic/Structure/Geography.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using Swarmops.Basic.Enums; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Cache; using Swarmops.Logic.Interfaces; diff --git a/Logic/Structure/GeographyUpdate.cs b/Logic/Structure/GeographyUpdate.cs new file mode 100644 index 00000000..96aa8c2a --- /dev/null +++ b/Logic/Structure/GeographyUpdate.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Swarmops.Basic.Types.Structure; +using Swarmops.Database; +using Swarmops.Logic.Automation; +using Swarmops.Logic.Cache; +using MasterGeography = Swarmops.Logic.Automation.Geography; +using MasterCity = Swarmops.Logic.Automation.City; +using MasterPostalCode = Swarmops.Logic.Automation.PostalCode; +using GeographyDataLoader = Swarmops.Logic.Automation.GetGeographyData; + +namespace Swarmops.Logic.Structure +{ + [Serializable] + public class GeographyUpdate : BasicGeographyUpdate + { + [Obsolete("Do not call this ctor directly. It is intended for serialization use only.", true)] + public GeographyUpdate() + { + + } + + private GeographyUpdate (BasicGeographyUpdate basic) + : base (basic) + { + // private ctor + } + + public static GeographyUpdate FromBasic(BasicGeographyUpdate basic) + { + return new GeographyUpdate(basic); + } + + public Country Country + { + get + { + if (string.IsNullOrEmpty (base.CountryCode)) + { + return null; + } + + return Country.FromCode (base.CountryCode); + } + } + + public static GeographyUpdate Create (string updateType, string updateSource, string guid, string countryCode, string changeDataXml, DateTime effectiveDateTime) + { + int identity = SwarmDb.GetDatabaseForWriting() + .CreateGeographyUpdate (updateType, updateSource, guid, countryCode, changeDataXml, DateTime.UtcNow, + effectiveDateTime); + return FromBasic (SwarmDb.GetDatabaseForWriting().GetGeographyUpdate (identity)); // "ForWriting" intentional to avoid db replication race conditions + } + + public new bool Processed + { + get { return base.Processed; } + set + { + if (value != base.Processed && value) + { + SwarmDb.GetDatabaseForWriting().SetGeographyUpdateProcessed (this.Identity); + base.Processed = true; + } + } + } + + public void Run() + { + // Run this geography update and apply it to the database. + + if (DateTime.UtcNow < EffectiveDateTime) + { + // we shouldn't process this yet - return unprocessed + return; // DESIGN: throw exception instead? + } + + switch (UpdateType) + { + case "PrimeCountry": + PrimeCountry (CountryCode); // static fn so needs to pass country code + + break; + case "SetPostalCodeData": + break; + case "SetCountryPosition": + break; + default: + throw new NotImplementedException("Unimplemented geography update type: " + UpdateType); + } + + Processed = true; + } + + public static void PrimeCountry (string countryCode) + { + Country country = Country.FromCode (countryCode); + if (country.GeographyId != Geography.RootIdentity) + { + // already initialized + return; + } + + GeographyDataLoader geoDataLoader = new GeographyDataLoader(); + + MasterGeography geography = geoDataLoader.GetGeographyForCountry(countryCode); + MasterCity[] cities = geoDataLoader.GetCitiesForCountry(countryCode); + MasterPostalCode[] postalCodes = geoDataLoader.GetPostalCodesForCountry(countryCode); + + // ID Translation lists + + Dictionary geographyIdTranslation = new Dictionary(); + Dictionary cityIdTranslation = new Dictionary(); + Dictionary cityIdsUsedLookup = new Dictionary(); + + // Create the country's root geography + + int countryRootGeographyId = SwarmDb.GetDatabaseForWriting().CreateGeography(geography.Name, + Geography.RootIdentity); + geographyIdTranslation[geography.GeographyId] = countryRootGeographyId; + SwarmDb.GetDatabaseForWriting().SetCountryGeographyId(country.Identity, + countryRootGeographyId); + + int count = 0; + int total = InitDatabaseThreadCountGeographyChildren(geography.Children); + + InitDatabaseThreadCreateGeographyChildren(geography.Children, countryRootGeographyId, + ref geographyIdTranslation, ref count, total); + + // Find which cities are actually used + + foreach (MasterPostalCode postalCode in postalCodes) + { + cityIdsUsedLookup[postalCode.CityId] = true; + } + + GuidCache.Set ("DbInitProgress", "(finalizing)"); + + // Insert cities + + int newCountryId = country.Identity; + + int cityIdHighwater = + SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommandScalar("SELECT Max(CityId) FROM Cities;"); + + StringBuilder sqlCityBuild = + new StringBuilder("INSERT INTO Cities (CityName, GeographyId, CountryId, Comment) VALUES ", 65536); + bool insertComma = false; + + foreach (MasterCity city in cities) + { + if (!geographyIdTranslation.ContainsKey(city.GeographyId)) + { + cityIdsUsedLookup[city.CityId] = false; // force non-use of invalid city + } + + if (cityIdsUsedLookup[city.CityId]) + { + int newGeographyId = geographyIdTranslation[city.GeographyId]; + + if (insertComma) + { + sqlCityBuild.Append(","); + } + + sqlCityBuild.Append("('" + city.Name.Replace("'", "\\'") + "'," + newGeographyId + "," + + newCountryId + ",'')"); + insertComma = true; + + cityIdTranslation[city.CityId] = ++cityIdHighwater; // Note that we assume the assigned ID here. + } + } + + sqlCityBuild.Append(";"); + + SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommand(sqlCityBuild.ToString()); + // Inserts all cities in one bulk op, to save roundtrips + + // Insert postal codes, if any + + if (postalCodes.Length > 0) + { + StringBuilder sqlBuild = + new StringBuilder ("INSERT INTO PostalCodes (PostalCode, CityId, CountryId) VALUES ", 65536); + insertComma = false; + + foreach (MasterPostalCode postalCode in postalCodes) + { + if (cityIdsUsedLookup[postalCode.CityId] == false) + { + // Remnants of invalid pointers + + continue; + } + + int newCityId = cityIdTranslation[postalCode.CityId]; + + if (insertComma) + { + sqlBuild.Append (","); + } + + sqlBuild.Append ("('" + postalCode.PostalCode.Replace ("'", "\\'") + "'," + newCityId + "," + + newCountryId + ")"); + insertComma = true; + } + + sqlBuild.Append (";"); + + // Insert all postal codes in one bulk op, to save roundtrips + SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommand(sqlBuild.ToString()); + } + } + + + private static int InitDatabaseThreadCountGeographyChildren(MasterGeography[] children) + { + int count = 0; + + foreach (MasterGeography child in children) + { + count++; + count += InitDatabaseThreadCountGeographyChildren(child.Children); + } + + return count; + } + + + + private static void InitDatabaseThreadCreateGeographyChildren(MasterGeography[] children, + int parentGeographyId, + ref Dictionary geographyIdTranslation, ref int count, int total) + { + count++; + + foreach (MasterGeography geography in children) + { + int newGeographyId = SwarmDb.GetDatabaseForWriting().CreateGeography(geography.Name, parentGeographyId); + geographyIdTranslation[geography.GeographyId] = newGeographyId; + + InitDatabaseThreadCreateGeographyChildren(geography.Children, newGeographyId, ref geographyIdTranslation, + ref count, total); + } + + if (total != 0) + { + GuidCache.Set("DbInitProgress", String.Format ("({0}%)", count * 100 / total)); + // shouldn't be here but wtf + } + } + + } +} diff --git a/Logic/Structure/GeographyUpdates.cs b/Logic/Structure/GeographyUpdates.cs new file mode 100644 index 00000000..d0d45439 --- /dev/null +++ b/Logic/Structure/GeographyUpdates.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Swarmops.Basic.Types.Structure; +using Swarmops.Database; +using Swarmops.Logic.Support; + +namespace Swarmops.Logic.Structure +{ + public class GeographyUpdates:PluralBase + { + static public GeographyUpdates GetUnprocessed() + { + return FromArray (SwarmDb.GetDatabaseForReading().GetUnprocessedGeographyUpdates()); + } + + static public GeographyUpdates GetCreatedSince (DateTime dateTimeSince) + { + return FromArray (SwarmDb.GetDatabaseForReading().GetGeographyUpdatesSince (dateTimeSince)); + } + } +} diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs index f79387db..ba847cbf 100644 --- a/Logic/Structure/Organization.cs +++ b/Logic/Structure/Organization.cs @@ -6,6 +6,7 @@ using System.Text; using System.Text.RegularExpressions; using Swarmops.Basic.Enums; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Cache; using Swarmops.Logic.Communications; diff --git a/Logic/Structure/Organizations.cs b/Logic/Structure/Organizations.cs index 254e2add..9b1cb484 100644 --- a/Logic/Structure/Organizations.cs +++ b/Logic/Structure/Organizations.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Cache; using Swarmops.Logic.Support; diff --git a/Logic/Structure/PostalCode.cs b/Logic/Structure/PostalCode.cs index 32c2ced0..0aade8fc 100644 --- a/Logic/Structure/PostalCode.cs +++ b/Logic/Structure/PostalCode.cs @@ -1,5 +1,6 @@ using System; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; namespace Swarmops.Logic.Structure { diff --git a/Logic/Structure/PostalCodes.cs b/Logic/Structure/PostalCodes.cs index e15d6dfe..533cadfa 100644 --- a/Logic/Structure/PostalCodes.cs +++ b/Logic/Structure/PostalCodes.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; namespace Swarmops.Logic.Structure diff --git a/Logic/Support/SingularFactory.cs b/Logic/Support/SingularFactory.cs index 2559d653..cfe66552 100644 --- a/Logic/Support/SingularFactory.cs +++ b/Logic/Support/SingularFactory.cs @@ -1,4 +1,7 @@ using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; using Swarmops.Basic.Interfaces; using Swarmops.Basic.Types; using Swarmops.Basic.Types.Communications; @@ -12,130 +15,53 @@ using Swarmops.Logic.Swarm; namespace Swarmops.Logic.Support { /// - /// This class supports the PluralBase foundation. Mirroring FromBasic() here is the - /// price we pay to get FromArray(), FromSingle(), LogicalOr() etc in all the plural - /// classes. + /// This class supports the PluralBase foundation. /// internal class SingularFactory { public static object FromBasic (IHasIdentity basic) { - string argumentType = basic.GetType().ToString(); + // ASSUMPTION: We're assuming that the type to be created exists in the "Logic" assembly, and that we can bind permanently in a lookup - switch (argumentType) + MethodInfo basicConverterMethod = null; + Type basicType = basic.GetType(); + + if (_converterLookup.ContainsKey (basicType)) { - // ----- Is there any way to make self-writing code here through replication or similar, so - // ----- that every case doesn't need to be listed? - - - // ------------ COMMUNICATION CLASSES ------------ - - case "Swarmops.Basic.Types.BasicCommunicationTurnaround": - return CommunicationTurnaround.FromBasic ((BasicCommunicationTurnaround) basic); - - case "Swarmops.Basic.Types.Communications.BasicOutboundComm": - return OutboundComm.FromBasic ((BasicOutboundComm) basic); - - case "Swarmops.Basic.Types.Communications.BasicOutboundCommRecipient": - return OutboundCommRecipient.FromBasic ((BasicOutboundCommRecipient) basic); - - - // ----------- FINANCIAL CLASSES ---------- - - case "Swarmops.Basic.Types.BasicExpenseClaim": - return ExpenseClaim.FromBasic ((BasicExpenseClaim) basic); - - case "Swarmops.Basic.Types.Financial.BasicCashAdvance": - return CashAdvance.FromBasic ((BasicCashAdvance) basic); - - case "Swarmops.Basic.Types.BasicInboundInvoice": - return InboundInvoice.FromBasic ((BasicInboundInvoice) basic); - - case "Swarmops.Basic.Types.Financial.BasicFinancialAccount": - return FinancialAccount.FromBasic ((BasicFinancialAccount) basic); - - case "Swarmops.Basic.Types.Financial.BasicFinancialTransaction": - return FinancialTransaction.FromBasic ((BasicFinancialTransaction) basic); - - case "Swarmops.Basic.Types.BasicFinancialValidation": - return FinancialValidation.FromBasic ((BasicFinancialValidation) basic); - - case "Swarmops.Basic.Types.BasicOutboundInvoice": - return OutboundInvoice.FromBasic ((BasicOutboundInvoice) basic); - - case "Swarmops.Basic.Types.BasicOutboundInvoiceItem": - return OutboundInvoiceItem.FromBasic ((BasicOutboundInvoiceItem) basic); - - case "Swarmops.Basic.Types.BasicPayment": - return Payment.FromBasic ((BasicPayment) basic); - - case "Swarmops.Basic.Types.BasicPaymentGroup": - return PaymentGroup.FromBasic ((BasicPaymentGroup) basic); - - case "Swarmops.Basic.Types.BasicPayout": - return Payout.FromBasic ((BasicPayout) basic); - - case "Swarmops.Basic.Types.BasicPayrollAdjustment": - return PayrollAdjustment.FromBasic ((BasicPayrollAdjustment) basic); - - case "Swarmops.Basic.Types.BasicPayrollItem": - return PayrollItem.FromBasic ((BasicPayrollItem) basic); - - case "Swarmops.Basic.Types.BasicSalary": - return Salary.FromBasic ((BasicSalary) basic); - - case "Swarmops.Basic.Types.BasicCurrency": - return Currency.FromBasic ((BasicCurrency) basic); - - case "Swarmops.Basic.Types.Financial.BasicFinancialTransactionTagSet": - return FinancialTransactionTagSet.FromBasic ((BasicFinancialTransactionTagSet) basic); - - case "Swarmops.Basic.Types.Financial.BasicFinancialTransactionTagType": - return FinancialTransactionTagType.FromBasic ((BasicFinancialTransactionTagType) basic); - - // ------------ GOVERNANCE CLASSES ------------ - - case "Swarmops.Basic.Types.BasicBallot": - return Ballot.FromBasic ((BasicBallot) basic); - - case "Swarmops.Basic.Types.BasicMeetingElectionCandidate": - return MeetingElectionCandidate.FromBasic ((BasicInternalPollCandidate) basic); - - case "Swarmops.Basic.Types.BasicMeetingElection": - return MeetingElection.FromBasic ((BasicInternalPoll) basic); - - case "Swarmops.Basic.Types.BasicMeetingElectionVote": - return MeetingElectionVote.FromBasic ((BasicInternalPollVote) basic); - - case "Swarmops.Basic.Types.Governance.BasicMotion": - return Motion.FromBasic ((BasicMotion) basic); - - case "Swarmops.Basic.Types.Governance.BasicMotionAmendment": - return MotionAmendment.FromBasic ((BasicMotionAmendment) basic); - - - // ------------ PARLEY/ACTIVISM CLASSES ------------ - - case "Swarmops.Basic.Types.BasicExternalActivity": - return ExternalActivity.FromBasic ((BasicExternalActivity) basic); - - case "Swarmops.Basic.Types.BasicParley": - return Parley.FromBasic ((BasicParley) basic); - - case "Swarmops.Basic.Types.BasicParleyAttendee": - return ParleyAttendee.FromBasic ((BasicParleyAttendee) basic); - - case "Swarmops.Basic.Types.BasicParleyOption": - return ParleyOption.FromBasic ((BasicParleyOption) basic); - - case "Swarmops.Basic.Types.BasicPerson": - return Person.FromBasic ((BasicPerson) basic); - - // ------------------ FAIL ---------------- - - default: - throw new NotImplementedException ("Unimplemented argument type in SingularFactory: " + argumentType); + basicConverterMethod = _converterLookup[basicType]; } + else + { + + Assembly logicAssembly = typeof (SingularFactory).Assembly; + Assembly basicAssembly = typeof (BasicPerson).Assembly; + + System.Type[] logicTypes = + logicAssembly.GetTypes().Where (type => type.IsSubclassOf (basicType)).ToArray(); + + if (logicTypes.Length > 1) + { + throw new InvalidOperationException ("More than one type in Swarmops.Logic derives from " + + basicType.ToString()); + } + if (logicTypes.Length == 0) + { + throw new InvalidOperationException ( + "Unable to find higher-order class in Swarmops.Logic for base type " + basicType.ToString()); + } + + Type logicType = logicTypes[0]; + + basicConverterMethod = logicType.GetMethod ("FromBasic", BindingFlags.Static | BindingFlags.Public); + _converterLookup[basicType] = basicConverterMethod; + } + + object result = basicConverterMethod.Invoke(null, new object[] {basic}); + + return result; + } + + static private Dictionary _converterLookup = new Dictionary(); } } \ No newline at end of file diff --git a/Logic/Swarm/People.cs b/Logic/Swarm/People.cs index 09d8498c..793d8294 100644 --- a/Logic/Swarm/People.cs +++ b/Logic/Swarm/People.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Swarmops.Basic.Enums; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Logic.Security; using Swarmops.Logic.Structure; diff --git a/Logic/Swarm/Person.cs b/Logic/Swarm/Person.cs index cdfa9947..ee0b1b7f 100644 --- a/Logic/Swarm/Person.cs +++ b/Logic/Swarm/Person.cs @@ -7,6 +7,7 @@ using System.Text.RegularExpressions; using Swarmops.Basic.Enums; using Swarmops.Basic.Interfaces; using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Structure; using Swarmops.Database; using Swarmops.Database.Attributes; using Swarmops.Logic.Communications; @@ -430,6 +431,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); } @@ -529,7 +536,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 { diff --git a/README.md b/README.md index ebe2e090..c63d5388 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ If you're daring enough to install a pilot of Swarmops, you're most welcome to d > `wget http://packages.swarmops.com/swarmops-packages.gpg.key` > `apt-key add swarmops-packages.gpg.key` -Then, edit /etc/apt/sources.list to include this line, probably at the bottom: -> `deb http://packages.swarmops.com/ squeeze contrib` +Then, add the Swarmops repository to your list of software sources: +> `echo deb http://packages.swarmops.com/ squeeze contrib > /etc/apt/sources.list.d/swarmops.list` Then run > `apt-get update` 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/Controls/v5/Base/MainMenu.ascx.cs b/Site5/Controls/v5/Base/MainMenu.ascx.cs index 019d3d4d..7b78c7a3 100644 --- a/Site5/Controls/v5/Base/MainMenu.ascx.cs +++ b/Site5/Controls/v5/Base/MainMenu.ascx.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Web.UI; using System.Xml.Serialization; @@ -51,6 +52,12 @@ namespace Swarmops.Controls.Base { output.Write ("
  • ", menuItem.Type); string localizedText = "RESOURCE NOT FOUND"; + string prettyNavUrl = menuItem.NavigateUrl ?? string.Empty; + + if (!Debugger.IsAttached) + { + prettyNavUrl = prettyNavUrl.Replace ("/Pages/v5/", "/").Replace (".aspx", ""); + } if (!String.IsNullOrEmpty (menuItem.ResourceKey)) { @@ -83,7 +90,7 @@ namespace Swarmops.Controls.Base case MenuItemType.Link: output.Write ( "{2}", - menuItem.ImageUrl, menuItem.NavigateUrl, localizedText, iconSize); + menuItem.ImageUrl, prettyNavUrl, localizedText, iconSize); break; case MenuItemType.Disabled: case MenuItemType.BuildNumber: 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/Global.asax b/Site5/Global.asax index c1fed010..34f6b932 100644 --- a/Site5/Global.asax +++ b/Site5/Global.asax @@ -1,4 +1,5 @@ <%@ Application Language="C#" %> +<%@ Import Namespace="System.IO" %> + + + + + + + + +
    +
    + +
    + + +
    +
    +
    +
    +
    + +
    + + + + + + 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..11870f21 --- /dev/null +++ b/Site5/Pages/v5/Admin/Hacks/PopulateCountry2.aspx.cs @@ -0,0 +1,155 @@ +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 PopulateCountry2 : PageV5Base + { + protected void Page_Load (object sender, EventArgs e) + { + 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."; + } + + + 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] [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"); + } + + + + 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 postalCodeDupes = new Dictionary(); + + foreach (string lineRaw in lines) + { + count++; + string line = lineRaw.Trim(); + string[] lineParts = line.Split ('\t'); + + if (lineParts.Length != 4) + { + continue; + } + + int percent = (count * 99) / lines.Length; + if (percent == 0) + { + percent = 1; + } + GuidCache.Set(guid + "-Progress", percent); + + + string countryCode = lineParts[0].Trim().ToUpperInvariant(); + string postalCode = lineParts[1].Trim(); + string cityName = lineParts[2].Trim(); + string nodeName = lineParts[3].Trim(); + + // Dupecheck + + 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); + } + } +} \ No newline at end of file diff --git a/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx b/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx new file mode 100644 index 00000000..d007d3fa --- /dev/null +++ b/Site5/Pages/v5/Admin/Hacks/PopulateFakePeople.aspx @@ -0,0 +1,106 @@ +<%@ 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" %> + + + + + + + + + + + + +
    +
    + +
    + + +
    +
    +
    +
    +
    + +
    + + + + + + 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(); } 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 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/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs index 2bcaaf38..f903fcb5 100644 --- a/Site5/Pages/v5/Init/Default.aspx.cs +++ b/Site5/Pages/v5/Init/Default.aspx.cs @@ -13,20 +13,20 @@ using System.Web.UI; using Resources; using Swarmops.Basic.Enums; using Swarmops.Database; +using Swarmops.Logic.Cache; using Swarmops.Logic.Financial; using Swarmops.Logic.Security; using Swarmops.Logic.Structure; using Swarmops.Logic.Support; using Swarmops.Logic.Swarm; -using Swarmops.Site.Automation; -using City = Swarmops.Site.Automation.City; -using Country = Swarmops.Site.Automation.Country; -using Geography = Swarmops.Site.Automation.Geography; -using PostalCode = Swarmops.Site.Automation.PostalCode; +using Swarmops.Logic.Automation; +using City = Swarmops.Logic.Automation.City; +using Country = Swarmops.Logic.Automation.Country; +using Geography = Swarmops.Logic.Automation.Geography; +using PostalCode = Swarmops.Logic.Automation.PostalCode; public partial class Pages_v5_Init_Default : Page { - private static string _buildIdentity; private static SwarmDb.Credentials _testReadCredentials; private static SwarmDb.Credentials _testWriteCredentials; private static SwarmDb.Credentials _testAdminCredentials; @@ -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 @@ -383,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); @@ -394,10 +372,7 @@ public partial class Pages_v5_Init_Default : Page // Create translation lists - Dictionary geographyIdTranslation = new Dictionary(); - Dictionary cityIdTranslation = new Dictionary(); Dictionary countryIdTranslation = new Dictionary(); - Dictionary cityIdsUsedLookup = new Dictionary(); // Initialize the root geography (which becomes #1 if everything works) @@ -422,7 +397,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++; @@ -452,142 +427,10 @@ public partial class Pages_v5_Init_Default : Page { // Get the geography layout - _initMessage = "Retrieving geography for " + countryCode + "..."; + _initMessage = "Initializing geography for " + countryCode + "... "; Thread.Sleep (100); - Geography geography = geoDataFetcher.GetGeographyForCountry (countryCode); - - _initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry/6); - _initMessage = "Setting up geography for " + countryCode + "..."; - Thread.Sleep (100); - - // Create the country's root geography - - int countryRootGeographyId = SwarmDb.GetDatabaseForWriting().CreateGeography (geography.Name, - rootGeographyId); - geographyIdTranslation[geography.GeographyId] = countryRootGeographyId; - SwarmDb.GetDatabaseForWriting().SetCountryGeographyId (countryIdTranslation[countryCode], - countryRootGeographyId); - - count = 0; - total = InitDatabaseThreadCountGeographyChildren (geography.Children); - - InitDatabaseThreadCreateGeographyChildren (geography.Children, countryRootGeographyId, - ref geographyIdTranslation, countryCode, ref count, total); - - _initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry/3); - _initMessage = "Retrieving cities for " + countryCode + "..."; - Thread.Sleep (100); - - // Get the postal codes and cities - - City[] cities = null; - - try - { - cities = geoDataFetcher.GetCitiesForCountry (countryCode); - } - catch (Exception) - // This is a SoapHeaderException in VS debugging, but SOMETHING ELSE! in Mono runtime, so make it generic - { - // This is typically a country that isn't populated with cities yet. Ignore. - countryCount++; - continue; - } - - - _initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry/2); - _initMessage = "Retrieving postal codes for " + countryCode + "..."; - Thread.Sleep (100); - - PostalCode[] postalCodes = geoDataFetcher.GetPostalCodesForCountry (countryCode); - - // Find which cities are actually used - - foreach (PostalCode postalCode in postalCodes) - { - cityIdsUsedLookup[postalCode.CityId] = true; - } - - _initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry*2/3); - - // Insert cities - - int newCountryId = countryIdTranslation[countryCode]; - - int cityIdHighwater = - SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommandScalar ("SELECT Max(CityId) FROM Cities;"); - - _initMessage = string.Format ("Setting up {0:N0} cities for {1}...", cities.Length, countryCode); - - StringBuilder sqlCityBuild = - new StringBuilder ("INSERT INTO Cities (CityName, GeographyId, CountryId, Comment) VALUES ", 65536); - bool insertComma = false; - - foreach (City city in cities) - { - if (!geographyIdTranslation.ContainsKey (city.GeographyId)) - { - cityIdsUsedLookup[city.CityId] = false; // force non-use of invalid city - } - - if (cityIdsUsedLookup[city.CityId]) - { - int newGeographyId = geographyIdTranslation[city.GeographyId]; - - if (insertComma) - { - sqlCityBuild.Append (","); - } - - sqlCityBuild.Append ("('" + city.Name.Replace ("'", "\'") + "'," + newGeographyId + "," + - newCountryId + ",'')"); - insertComma = true; - - cityIdTranslation[city.CityId] = ++cityIdHighwater; // Note that we assume the assigned ID here. - } - } - - sqlCityBuild.Append (";"); - - SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommand (sqlCityBuild.ToString()); - // Inserts all cities in one bulk op, to save roundtrips - - // Insert postal codes - - _initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry*5/6); - _initMessage = string.Format ("Setting up {0:N0} postal codes for {1}...", postalCodes.Length, - countryCode); - - StringBuilder sqlBuild = - new StringBuilder ("INSERT INTO PostalCodes (PostalCode, CityId, CountryId) VALUES ", 65536); - insertComma = false; - - foreach (PostalCode postalCode in postalCodes) - { - if (cityIdsUsedLookup[postalCode.CityId] == false) - { - // Remnants of invalid pointers - - continue; - } - - int newCityId = cityIdTranslation[postalCode.CityId]; - - if (insertComma) - { - sqlBuild.Append (","); - } - - sqlBuild.Append ("('" + postalCode.PostalCode.Replace ("'", "\'") + "'," + newCityId + "," + - newCountryId + ")"); - insertComma = true; - } - - sqlBuild.Append (";"); - - SwarmDb.GetDatabaseForAdmin().ExecuteAdminCommand (sqlBuild.ToString()); - // Inserts all postal codes in one bulk op, to save roundtrips + GeographyUpdate.PrimeCountry (countryCode); countryCount++; @@ -597,12 +440,13 @@ public partial class Pages_v5_Init_Default : Page // Set Geography at baseline (TODO: Ask for what baseline we got) Persistence.Key["LastGeographyUpdateId"] = "0"; + Persistence.Key["LastGeographyUpdate"] = "1900-01-01"; // Set an installation ID Persistence.Key["SwarmopsInstallationId"] = Guid.NewGuid().ToString(); - // Create initial currencies (European) + // Create initial currencies (European et al) Currency.Create ("EUR", "Euros", "€"); Currency.Create ("USD", "US Dollars", "$"); @@ -634,42 +478,6 @@ public partial class Pages_v5_Init_Default : Page Thread.Sleep (1000); // give some time for static var to stick and web interface to react before killing thread } - private static int InitDatabaseThreadCountGeographyChildren (Geography[] children) - { - int count = 0; - - foreach (Geography child in children) - { - count++; - count += InitDatabaseThreadCountGeographyChildren (child.Children); - } - - return count; - } - - private static void InitDatabaseThreadCreateGeographyChildren (Geography[] children, - int parentGeographyId, - ref Dictionary geographyIdTranslation, string countryCode, ref int count, int total) - { - count++; - - foreach (Geography geography in children) - { - int newGeographyId = SwarmDb.GetDatabaseForWriting().CreateGeography (geography.Name, parentGeographyId); - geographyIdTranslation[geography.GeographyId] = newGeographyId; - - InitDatabaseThreadCreateGeographyChildren (geography.Children, newGeographyId, ref geographyIdTranslation, - countryCode, ref count, total); - } - - if (total != 0) - { - _initMessage = String.Format ("Setting up geography for {0}... ({1}%)", countryCode, count*100/total); - // shouldn't be here but wtf - } - Thread.Sleep (50); - } - [WebMethod] public static int GetInitProgress() @@ -692,7 +500,7 @@ public partial class Pages_v5_Init_Default : Page [WebMethod] public static string GetInitProgressMessage() { - return _initMessage; + return _initMessage + GuidCache.Get ("DbInitProgress"); } [WebMethod] 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/FinalizeLogin.aspx.cs b/Site5/Security/FinalizeLogin.aspx.cs index 6530774a..2cab37ac 100644 --- a/Site5/Security/FinalizeLogin.aspx.cs +++ b/Site5/Security/FinalizeLogin.aspx.cs @@ -14,12 +14,13 @@ namespace Swarmops.Security if (string.IsNullOrEmpty (identity)) { - Response.Redirect ("Login.aspx"); + Response.Redirect ("Login"); } else { GuidCache.Delete (nonce + "-Identity"); - FormsAuthentication.RedirectFromLoginPage (identity, true); + FormsAuthentication.SetAuthCookie (identity, true); + Response.Redirect ("/"); } } } diff --git a/Site5/Security/Images/iconshock-cross-12px.png b/Site5/Security/Images/iconshock-cross-12px.png new file mode 100644 index 00000000..5c908077 Binary files /dev/null and b/Site5/Security/Images/iconshock-cross-12px.png differ diff --git a/Site5/Security/Images/iconshock-greentick-16px.png b/Site5/Security/Images/iconshock-greentick-16px.png new file mode 100644 index 00000000..673f61b0 Binary files /dev/null and b/Site5/Security/Images/iconshock-greentick-16px.png differ diff --git a/Site5/Security/Login.aspx b/Site5/Security/Login.aspx index 3a9597c3..a23b417a 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", @@ -78,11 +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 - } else { - // do nothing - } + 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 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 @@ -109,7 +118,7 @@ success: function(msg) { if (msg.d) { // Login confirmed, fetch auth cookie from nonce in-context - document.location = "/Security/FinalizeLogin.aspx?Nonce=" + bitIdNonce; + document.location = "/Security/FinalizeLogin?Nonce=" + bitIdNonce; } else { // Retry twice per second setTimeout(function() { diff --git a/Site5/Security/Login.aspx.cs b/Site5/Security/Login.aspx.cs index 660ba560..27855962 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; @@ -27,7 +28,7 @@ namespace Swarmops.Pages.Security if (!SwarmDb.Configuration.IsConfigured()) { - Response.Redirect ("/Pages/v5/Init/", true); + Response.Redirect ("/Init/", true); return; } @@ -77,7 +78,8 @@ namespace Swarmops.Pages.Security Response.AppendCookie (new HttpCookie ("DashboardMessage", HttpUtility.UrlEncode ( "

    You have been logged on as Sandbox Administrator to the Swarmops Development Sandbox.


    This machine runs the latest development build, so you may run into diagnostic code and half-finished features. All data here is bogus test data and is reset every night.


    In other words, welcome, and play away!

    "))); - FormsAuthentication.RedirectFromLoginPage ("1,1", true); + FormsAuthentication.SetAuthCookie ("1,1", true); + Response.Redirect ("/"); } // Check for SSL and force it @@ -234,7 +236,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 +250,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 +298,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; 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 { diff --git a/Site5/web.config b/Site5/web.config index 3e81f77d..8aa9a6ca 100644 --- a/Site5/web.config +++ b/Site5/web.config @@ -19,7 +19,7 @@ - + @@ -42,6 +42,7 @@ + @@ -53,18 +54,5 @@ - - - - - - - - - - - - - \ No newline at end of file