This commit is contained in:
Rick Falkvinge
2014-12-25 12:53:18 +01:00
70 changed files with 2791 additions and 1631 deletions
+8 -8
View File
@@ -72,7 +72,8 @@
<Compile Include="Types\Financial\BasicFinancialTransactionTagSetType.cs" />
<Compile Include="Types\Financial\BasicFinancialTransactionTagType.cs" />
<Compile Include="Types\Financial\BasicFinancialValidation.cs" />
<Compile Include="Types\BasicPostalCode.cs" />
<Compile Include="Types\Structure\BasicGeographyUpdate.cs" />
<Compile Include="Types\Structure\BasicPostalCode.cs" />
<Compile Include="Types\Financial\BasicFinancialAccount.cs" />
<Compile Include="Types\Governance\BasicMeeting.cs" />
<Compile Include="Config.cs" />
@@ -97,8 +98,8 @@
<Compile Include="Types\Security\BasicAuthority.cs" />
<Compile Include="Types\Communications\BasicAutoMail.cs" />
<Compile Include="Types\BasicChurnDataPoint.cs" />
<Compile Include="Types\BasicCity.cs" />
<Compile Include="Types\BasicCountry.cs" />
<Compile Include="Types\Structure\BasicCity.cs" />
<Compile Include="Types\Structure\BasicCountry.cs" />
<Compile Include="Types\BasicDocument.cs" />
<Compile Include="Types\BasicExpenseClaim.cs" />
<Compile Include="Types\BasicExternalCredential.cs" />
@@ -147,7 +148,7 @@
<Compile Include="Interfaces\IHandleProvider.cs" />
<Compile Include="Interfaces\IHasIdentity.cs" />
<Compile Include="Types\BasicNewsletterFeed.cs" />
<Compile Include="Types\BasicGeography.cs" />
<Compile Include="Types\Structure\BasicGeography.cs" />
<Compile Include="Types\BasicPayout.cs" />
<Compile Include="Types\BasicPayrollItem.cs" />
<Compile Include="Types\BasicPermission.cs" />
@@ -156,7 +157,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\BasicMembership.cs" />
<Compile Include="Types\BasicOrganization.cs" />
<Compile Include="Types\Structure\BasicOrganization.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
@@ -171,9 +172,8 @@
<Compile Include="Types\BasicUptakeGeography.cs" />
<Compile Include="Types\BasicVolunteer.cs" />
<Compile Include="Types\BasicVolunteerRole.cs" />
<Compile Include="Types\BasicGeographyDesignation.cs" />
<Compile Include="Types\Structure\BasicGeographyDesignation.cs" />
<Compile Include="Types\BasicCurrency.cs" />
<Compile Include="Types\GeographyWithPeople.cs" />
<Compile Include="Types\BasicInternalPollVoter.cs" />
<Compile Include="Types\XmlSerializableDictionary.cs" />
</ItemGroup>
@@ -191,4 +191,4 @@
<Folder Include="Statistics\DataPoints\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>
</Project>
+6 -1
View File
@@ -284,6 +284,11 @@ namespace Swarmops.Basic.Enums
/// <summary>
/// For a person, the BitId address they use to login
/// </summary>
BitIdLoginAddress
BitIdLoginAddress,
/// <summary>
/// For a person, the last logged-on organization id. Used to go back there on new login.
/// </summary>
LastLoginOrganizationId
}
}
-19
View File
@@ -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;
}
}
@@ -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
}
}
@@ -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
}
}
@@ -1,65 +1,65 @@
using System;
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types
{
/// <summary>
/// A geographical node.
/// </summary>
[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
}
/// <summary>
/// The database id of this geography.
/// </summary>
public int GeographyId { get; private set; }
/// <summary>
/// The database id of the parent geography, for linking in a tree structure.
/// </summary>
public int ParentGeographyId { get; protected set; }
/// <summary>
/// The friendly name of the node (city, county, region, etc).
/// </summary>
public string Name { get; protected set; }
/// <summary>
/// The generation of this node. Used in tree-style listings.
/// </summary>
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
{
/// <summary>
/// A geographical node.
/// </summary>
[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
}
/// <summary>
/// The database id of this geography.
/// </summary>
public int GeographyId { get; private set; }
/// <summary>
/// The database id of the parent geography, for linking in a tree structure.
/// </summary>
public int ParentGeographyId { get; protected set; }
/// <summary>
/// The friendly name of the node (city, county, region, etc).
/// </summary>
public string Name { get; protected set; }
/// <summary>
/// The generation of this node. Used in tree-style listings.
/// </summary>
public int Generation { get; protected set; }
#region IHasIdentity Members
public int Identity
{
get { return this.GeographyId; }
}
#endregion
}
}
@@ -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; }
}
}
@@ -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; } }
}
}
@@ -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; }
}
}
@@ -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; }
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Swarmops.Database
/// </summary>
public static int DbVersionExpected
{
get { return 6; }
get { return 8; }
}
+2 -2
View File
@@ -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)
{
+4 -2
View File
@@ -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
+2 -2
View File
@@ -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())
+209
View File
@@ -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<BasicGeographyUpdate> result = new List<BasicGeographyUpdate>();
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<BasicGeographyUpdate> result = new List<BasicGeographyUpdate>();
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<BasicGeographyUpdate> result = new List<BasicGeographyUpdate>();
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();
}
}
}
}
+1
View File
@@ -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
{
+1
View File
@@ -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
{
+1
View File
@@ -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
{
+1
View File
@@ -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
{
+1
View File
@@ -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
{
+2 -1
View File
@@ -58,6 +58,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration.cs" />
<Compile Include="Database-GeographyUpdates.cs" />
<Compile Include="Database-CashAdvances.cs" />
<Compile Include="Database-Currencies.cs" />
<Compile Include="Database-FinancialTransactionTags.cs" />
@@ -142,4 +143,4 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>
</Project>
+2 -1
View File
@@ -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]
+15
View File
@@ -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)
+78
View File
@@ -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
@@ -111,7 +111,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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].
/// </summary>
internal static string CashAdvance_PaidOut_Subject {
get {
@@ -131,7 +131,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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.
/// </summary>
internal static string CashAdvance_Requested_Subject {
get {
@@ -149,7 +149,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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].
/// </summary>
internal static string ExpenseClaim_Attested_Subject {
get {
@@ -169,7 +169,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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.
/// </summary>
internal static string ExpenseClaim_Created_Subject {
get {
@@ -189,7 +189,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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].
/// </summary>
internal static string ExpenseClaim_Deattested_Subject {
get {
@@ -207,7 +207,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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].
/// </summary>
internal static string ExpenseClaim_Denied_Subject {
get {
@@ -227,7 +227,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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].
/// </summary>
internal static string ExpenseClaim_Devalidated_Subject {
get {
@@ -247,7 +247,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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].
/// </summary>
internal static string ExpenseClaim_PaidOut_Subject {
get {
@@ -267,7 +267,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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].
/// </summary>
internal static string ExpenseClaim_Validated_Subject {
get {
@@ -287,7 +287,7 @@ namespace Swarmops.Logic.App_GlobalResources {
}
/// <summary>
/// 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.
/// </summary>
internal static string InboundInvoice_Created_Subject {
get {
@@ -295,6 +295,89 @@ namespace Swarmops.Logic.App_GlobalResources {
}
}
/// <summary>
/// Looks up a localized string similar to A new [Regular] was manually added to [OrganizationName] within an area of yours..
/// </summary>
internal static string Membership_New_Added_Body {
get {
return ResourceManager.GetString("Membership_New_Added_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode] (manual).
/// </summary>
internal static string Membership_New_Added_Subject {
get {
return ResourceManager.GetString("Membership_New_Added_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to A new [Regular] has signed up for [OrganizationName] within an area of yours..
/// </summary>
internal static string Membership_New_Selfsignup_Body {
get {
return ResourceManager.GetString("Membership_New_Selfsignup_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode].
/// </summary>
internal static string Membership_New_Selfsignup_Subject {
get {
return ResourceManager.GetString("Membership_New_Selfsignup_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] [Regularship] renewed: [PersonName], [PersonGeography] [CountryCode] (manual).
/// </summary>
internal static string Membership_Renewed_Manual_Subject {
get {
return ResourceManager.GetString("Membership_Renewed_Manual_Subject", resourceCulture);
}
}
/// <summary>
/// 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]..
/// </summary>
internal static string OutboundComm_Resolved_Body {
get {
return ResourceManager.GetString("OutboundComm_Resolved_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] Comm recipients determined for [GeographyName]: [RecipientCount].
/// </summary>
internal static string OutboundComm_Resolved_Subject {
get {
return ResourceManager.GetString("OutboundComm_Resolved_Subject", resourceCulture);
}
}
/// <summary>
/// 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&apos; horizon. (These can fail later for a number of reasons, from broken computers to hospitalized recipients.)
///
///Time spent transmitting: [TransmissionTime]..
/// </summary>
internal static string OutboundComm_Sent_Body {
get {
return ResourceManager.GetString("OutboundComm_Sent_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] Comms transmitted: [GeographyName].
/// </summary>
internal static string OutboundComm_Sent_Subject {
get {
return ResourceManager.GetString("OutboundComm_Sent_Subject", resourceCulture);
}
}
/// <summary>
/// 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 {
}
/// <summary>
/// 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.
/// </summary>
internal static string Receipts_Filed_Subject {
get {
@@ -137,7 +137,7 @@ Expect more communication from the budget owner to follow on the matter.</value>
This means you should see the amount on your account shortly.</value>
</data>
<data name="CashAdvance_PaidOut_Subject" xml:space="preserve">
<value>[OrganizationName] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Cash Advance Paid: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="CashAdvance_Requested_Body" xml:space="preserve">
<value>[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.</value>
<comment>This is sent to the budget owner(s) only.</comment>
</data>
<data name="CashAdvance_Requested_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
<value>[[OrganizationName] - ACTION ITEM] Cash Advance Requested: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
</data>
<data name="ExpenseClaim_Attested_Body" xml:space="preserve">
<value>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.</value>
<comment>This is sent to the claimer.</comment>
</data>
<data name="ExpenseClaim_Attested_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim Attested: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Created_Body" xml:space="preserve">
<value>[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.</value>
<comment>This is sent to the budget owner(s)only.</comment>
</data>
<data name="ExpenseClaim_Created_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
<value>[[OrganizationName] - ACTION ITEM] Expense Claim Created: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
<comment>ACTION ITEM should be translated.</comment>
</data>
<data name="ExpenseClaim_Deattested_Body" xml:space="preserve">
@@ -172,14 +172,14 @@ Expect more communication from the budget owner to follow on the matter.</value>
<comment>This is sent to the claimer.</comment>
</data>
<data name="ExpenseClaim_Deattested_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim DE-attested: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Denied_Body" xml:space="preserve">
<value>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.</value>
<comment>This is sent to the claimer.</comment>
</data>
<data name="ExpenseClaim_Denied_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim DENIED: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Devalidated_Body" xml:space="preserve">
<value>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.</value>
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.</value>
</data>
<data name="ExpenseClaim_Devalidated_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim Receipts DE-validated: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_PaidOut_Body" xml:space="preserve">
<value>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.</value>
</data>
<data name="ExpenseClaim_PaidOut_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim Paid: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="ExpenseClaim_Validated_Body" xml:space="preserve">
<value>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
<comment>This is sent to the claimer.</comment>
</data>
<data name="ExpenseClaim_Validated_Subject" xml:space="preserve">
<value>[OrganizationName] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat]</value>
<value>[[OrganizationName]] Expense Claim Receipts Validated: [CurrencyCode] [BudgetAmountFloat]</value>
</data>
<data name="InboundInvoice_Created_Body" xml:space="preserve">
<value>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.</value>
</data>
<data name="InboundInvoice_Created_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
<value>[[OrganizationName] - ACTION ITEM] Invoice Filed: [CurrencyCode] [BudgetAmountFloat] - Attestation Needed</value>
</data>
<data name="Membership_New_Added_Body" xml:space="preserve">
<value>A new [Regular] was manually added to [OrganizationName] within an area of yours.</value>
</data>
<data name="Membership_New_Added_Subject" xml:space="preserve">
<value>[[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode] (manual)</value>
</data>
<data name="Membership_New_Selfsignup_Body" xml:space="preserve">
<value>A new [Regular] has signed up for [OrganizationName] within an area of yours.</value>
</data>
<data name="Membership_New_Selfsignup_Subject" xml:space="preserve">
<value>[[OrganizationName]] New [Regular]: [PersonName], [PersonGeography] [CountryCode]</value>
</data>
<data name="Membership_Renewed_Manual_Subject" xml:space="preserve">
<value>[[OrganizationName]] [Regularship] renewed: [PersonName], [PersonGeography] [CountryCode] (manual)</value>
</data>
<data name="OutboundComm_Resolved_Body" xml:space="preserve">
<value>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].</value>
</data>
<data name="OutboundComm_Resolved_Subject" xml:space="preserve">
<value>[[OrganizationName]] Comm recipients determined for [GeographyName]: [RecipientCount]</value>
</data>
<data name="OutboundComm_Sent_Body" xml:space="preserve">
<value>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].</value>
</data>
<data name="OutboundComm_Sent_Subject" xml:space="preserve">
<value>[[OrganizationName]] Comms transmitted: [GeographyName]</value>
</data>
<data name="Receipts_Filed_Body" xml:space="preserve">
<value>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.</value>
Please log on to Swarmops at [SystemUrl] to confirm or reject them.</value>
</data>
<data name="Receipts_Filed_Subject" xml:space="preserve">
<value>(ACTION ITEM) [OrganizationName] Receipts Filed - Validation Needed</value>
<value>[[OrganizationName] - ACTION ITEM] Receipts Filed - Validation Needed</value>
</data>
<data name="System_DatabaseSchemaUpgraded_Body" xml:space="preserve">
<value>Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -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<int, List<BasicGeography>> 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
+1
View File
@@ -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;
+6
View File
@@ -67,6 +67,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
@@ -100,6 +101,9 @@
<DesignTime>True</DesignTime>
<DependentUpon>Logic.Communications.Transmission.MailPayload.resx</DependentUpon>
</Compile>
<Compile Include="Automation\GetGeographyData.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Cache\GuidCache.cs" />
<Compile Include="Communications\ICommsRenderer.cs" />
<Compile Include="Communications\ICommsResolver.cs" />
@@ -236,6 +240,8 @@
<Compile Include="Governance\MotionAmendment.cs" />
<Compile Include="Governance\MotionAmendments.cs" />
<Compile Include="Governance\Motions.cs" />
<Compile Include="Structure\GeographyUpdate.cs" />
<Compile Include="Structure\GeographyUpdates.cs" />
<Compile Include="Structure\OrganizationParameters.cs" />
<Compile Include="Structure\PostalCode.cs" />
<Compile Include="Structure\PostalCodes.cs" />
+1
View File
@@ -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;
+1
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
namespace Swarmops.Logic.Structure
+1
View File
@@ -1,5 +1,6 @@
using System;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
namespace Swarmops.Logic.Structure
+1
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
namespace Swarmops.Logic.Structure
+1
View File
@@ -1,5 +1,6 @@
using System;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Financial;
+1
View File
@@ -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;
+1
View File
@@ -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;
+259
View File
@@ -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<int, int> geographyIdTranslation = new Dictionary<int, int>();
Dictionary<int, int> cityIdTranslation = new Dictionary<int, int>();
Dictionary<int, bool> cityIdsUsedLookup = new Dictionary<int, bool>();
// 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<int, int> 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
}
}
}
}
+24
View File
@@ -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<GeographyUpdates,GeographyUpdate,BasicGeographyUpdate>
{
static public GeographyUpdates GetUnprocessed()
{
return FromArray (SwarmDb.GetDatabaseForReading().GetUnprocessedGeographyUpdates());
}
static public GeographyUpdates GetCreatedSince (DateTime dateTimeSince)
{
return FromArray (SwarmDb.GetDatabaseForReading().GetGeographyUpdatesSince (dateTimeSince));
}
}
}
+1
View File
@@ -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;
+1
View File
@@ -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;
+1
View File
@@ -1,5 +1,6 @@
using System;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Logic.Structure
{
+1
View File
@@ -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
+42 -116
View File
@@ -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
{
/// <summary>
/// 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.
/// </summary>
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<Type, MethodInfo> _converterLookup = new Dictionary<Type, MethodInfo>();
}
}
+1
View File
@@ -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;
+23 -1
View File
@@ -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
{
+2 -2
View File
@@ -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`
+12 -2
View File
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CentralEurope" xml:space="preserve">
<value>Central Europe</value>
</data>
<data name="Country_DK" xml:space="preserve">
<value>Denmark</value>
</data>
@@ -126,6 +129,9 @@
<data name="Country_GH" xml:space="preserve">
<value>Ghana</value>
</data>
<data name="Country_NL" xml:space="preserve">
<value>Netherlands</value>
</data>
<data name="Country_NO" xml:space="preserve">
<value>Norway</value>
</data>
@@ -134,7 +140,6 @@
</data>
<data name="EasternEurope" xml:space="preserve">
<value>Eastern Europe</value>
<comment>(East of southern tip of Sweden, appx)</comment>
</data>
<data name="Europe" xml:space="preserve">
<value>Europe</value>
@@ -147,6 +152,12 @@
<value>Nordics</value>
<comment>(Finland Denmark Norway Sweden Iceland)</comment>
</data>
<data name="NorthernEurope" xml:space="preserve">
<value>Nothern Europe</value>
</data>
<data name="SouthernEurope" xml:space="preserve">
<value>Southern Europe</value>
</data>
<data name="USA_EastNorthCentral" xml:space="preserve">
<value>East North Central</value>
</data>
@@ -188,7 +199,6 @@
</data>
<data name="WesternEurope" xml:space="preserve">
<value>Western Europe</value>
<comment>(West of southern tip of Sweden, appx)</comment>
</data>
<data name="World" xml:space="preserve">
<value>World</value>
+8 -1
View File
@@ -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 ("<li class=\"{0}\">", 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 (
"<a href=\"{1}\"><img src=\"/Images/PageIcons/{0}-{3}.png\" height=\"20\" width=\"20\" />{2}</a>",
menuItem.ImageUrl, menuItem.NavigateUrl, localizedText, iconSize);
menuItem.ImageUrl, prettyNavUrl, localizedText, iconSize);
break;
case MenuItemType.Disabled:
case MenuItemType.BuildNumber:
+9 -3
View File
@@ -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 ("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + externalScriptUrl +
"/easyui/themes/default/{0}.css\" />\r\n",
controlName.Trim().ToLowerInvariant());
string controlNameLower = controlName.Trim().ToLowerInvariant();
if (controlNameLower != "unknown")
{
scriptRef.AppendFormat (
"<link rel=\"stylesheet\" type=\"text/css\" href=\"" + externalScriptUrl +
"/easyui/themes/default/{0}.css\" />\r\n",
controlNameLower);
}
}
this.LiteralReference.Text = scriptRef.ToString();
+32
View File
@@ -1,4 +1,5 @@
<%@ Application Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
@@ -28,6 +29,37 @@
{
// The culture was once set here for localization, but Mono resets CultureInfo before entering the page cycle.
// Setting the CultureInfo has been moved to PageV5Base.OnPreInit().
// If we've been called as "/Default.aspx", strip it mercilessly and redirect
/* -- DISABLED -- This didn't work on Mono -- more testing needed
string callUrl = Request.Url.ToString();
if (callUrl.EndsWith("/Default.aspx"))
{
Response.Redirect(callUrl.Substring(0, callUrl.Length - "/Default.aspx".Length), true); // "true" prevents further processing
} */
// Testing for page rewrite. Tests IN ORDER.
string[] rewriteCandidates =
{
"{0}/Default.aspx", // for dev.swarmops.com
"{0}Default.aspx", // for dev.swarmops.com/
"{0}.aspx", // for dev.swarmops.com/Security/Login
"/Pages/v5{0}.aspx", // for dev.swarmops.com/User/SelectLanguage
"/Pages/v5{0}" // for dev.swarmops.com/Ledgers/Json-SomethingData.aspx
};
foreach (string stringCandidate in rewriteCandidates)
{
string rewrittenCandidate = String.Format (stringCandidate, Request.Path);
if (File.Exists (Server.MapPath (rewrittenCandidate)))
{
Context.RewritePath (rewrittenCandidate);
}
}
}
+2 -2
View File
@@ -125,10 +125,10 @@
<div class="center980px">
<div class="currentuserinfo">
<div style="background-image:url('/Images/Icons/iconshock-user-16px.png');background-repeat:no-repeat;padding-left:16px;float:left"><asp:Label ID="LabelCurrentUserName" runat="server" /> | </div>
<div style="background-image:url('/Images/Icons/iconshock-workchair-16px.png');background-repeat:no-repeat;padding-left:17px;float:left"><span class="hasTooltip" rel="Logged into <%=this.CurrentOrganization.Name %>" title="Click here to switch to another organization."><a href="/Pages/v5/Security/ChangeOrganizations.aspx" id="LinkChangeOrganizations"><asp:Label ID="LabelCurrentOrganizationName" runat="server" /></a></span> |&nbsp;</div>
<div style="background-image:url('/Images/Icons/iconshock-workchair-16px.png');background-repeat:no-repeat;padding-left:17px;float:left"><span class="hasTooltip" rel="Logged into <%=this.CurrentOrganization.Name %>" title="Click here to switch to another organization."><a href="/Security/ChangeOrganizations" id="LinkChangeOrganizations"><asp:Label ID="LabelCurrentOrganizationName" runat="server" /></a></span> |&nbsp;</div>
<div style="background-image:url('/Images/Icons/iconshock-gamepad-16px.png');background-repeat:no-repeat;padding-left:20px;float:left"><asp:Label ID="LabelPreferences" runat="server" /> | </div>
<div style="background-image:url('/Images/Icons/iconshock-lock-16px.png');background-repeat:no-repeat;padding-left:16px;float:left"><asp:LinkButton ID="LinkLogout" runat="server" OnClick="LinkLogout_Click" /> |&nbsp;</div>
<a href="/Pages/v5/User/SelectLanguage.aspx"><asp:Image ID="ImageCultureIndicator" runat="server" ImageUrl="~/Images/Flags/uk-24px.png" /></a>
<a href="/User/SelectLanguage"><asp:Image ID="ImageCultureIndicator" runat="server" ImageUrl="~/Images/Flags/uk-24px.png" /></a>
</div>
<div class="logoimage"><a href="/"><asp:Image runat="server" ID="ImageLogo" AlternateText="Swarmops Logo"/></a></div>
<div class="break"></div>
@@ -1,4 +1,4 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateData" %>
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateCountry1.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateCountry1" %>
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
@@ -21,7 +21,7 @@
$.ajax({
type: "POST",
url: "PopulateData.aspx/InitializeProcessing",
url: "PopulateCountry1.aspx/InitializeProcessing",
data: "{'guid': '<%= this.UploadFile.GuidString %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
@@ -89,7 +89,7 @@
</div>
<div class="entryLabels">
Upload file for processing<br/><br/>
Upload <strong>geodata</strong> for processing<br/><br/>
</div>
</div>
<div clear="both"></div>
@@ -0,0 +1,167 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Threading;
using System.Web.Services;
using Swarmops.Basic.Enums;
using Swarmops.Database;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
namespace Swarmops.Frontend.Pages.v5.Admin.Hacks
{
public partial class PopulateCountry1 : PageV5Base
{
protected void Page_Load (object sender, EventArgs e)
{
PageTitle = "Populate Country 1 - Geotree";
PageIcon = "iconshock-battery-drill";
InfoBoxLiteral = "You've taken a wrong turn if you're even seeing this page. It's for development purposes.";
}
private void Localize()
{
}
[WebMethod (true)]
public static void InitializeProcessing (string guid)
{
// Start an async thread that does all the work, then return
// FORMAT OF FILE
//
// Tab separated fields
//
// [countrycode] [tab] [geo1] [tab] [geo2] [tab] .. [tab] [geo_n]
//
// example:
//
// NL [Tab] Noord-Holland [Tab] Greater Amsterdam
// NL [Tab] Noord-Holland [Tab] Greater Amsterdam [Tab] Amsterdam
// NL [Tab] Noord-Holland [Tab] Greater Amsterdam [Tab] Amsterdam [Tab] Wallen
//
// To populate all five nodes (including country), only the last line is necessary, but all these lines are valid.
//
// Nodes are not re-populated on repetition. Node names within a country scope are required to
// be unique.
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<string, int> geoNameLookup = new Dictionary<string, int>();
foreach (string lineRaw in lines)
{
count++;
string line = lineRaw.Trim();
string[] lineParts = line.Split ('\t');
if (lineParts.Length < 2)
{
continue; // at least country and one geo required
}
// set progress
int percent = (count*99)/lines.Length;
if (percent == 0)
{
percent = 1;
}
GuidCache.Set (guid + "-Progress", percent);
// process
string countryCode = lineParts[0].Trim().ToUpperInvariant();
int countryGeoId = Geography.RootIdentity;
if (geoNameLookup.ContainsKey (countryCode))
{
countryGeoId = geoNameLookup[countryCode];
}
else
{
Country country = Country.FromCode (countryCode);
if (countryGeoId == Geography.RootIdentity) // country not initialized as node
{
countryGeoId =
SwarmDb.GetDatabaseForWriting().CreateGeography (country.Name + " (" + country.Name + ")",
Geography.RootIdentity); // TODO: Locate country
SwarmDb.GetDatabaseForWriting().SetCountryGeographyId (country.Identity, countryGeoId);
geoNameLookup[countryCode] = countryGeoId;
}
Geographies countryGeographies = Geography.FromIdentity(countryGeoId).GetTree();
foreach (Geography geography in countryGeographies)
{
geoNameLookup[countryCode + geography.Name] = geography.Identity;
}
}
int lastGeoId = countryGeoId;
for (int partIndex = 1; partIndex < lineParts.Length; partIndex++)
{
if (geoNameLookup.ContainsKey (countryCode + lineParts[partIndex]))
{
// geography exists
lastGeoId = geoNameLookup[countryCode + lineParts[partIndex]];
}
else
{
// geography does not exist yet: create
int newGeoId = SwarmDb.GetDatabaseForWriting().CreateGeography (lineParts[partIndex], lastGeoId);
geoNameLookup[countryCode + lineParts[partIndex]] = newGeoId;
lastGeoId = newGeoId;
}
}
}
GuidCache.Set (guid + "-Progress", 100);
}
}
}
@@ -0,0 +1,106 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateCountry2.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateCountry2" %>
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %>
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="/Scripts/jquery.fileupload/jquery.iframe-transport.js" type="text/javascript" language="javascript"></script>
<!-- The basic File Upload plugin -->
<script src="/Scripts/jquery.fileupload/jquery.fileupload.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
});
function uploadCompletedCallback() {
$('#DivProcessing').slideDown().fadeIn();
$('#DivProgressProcessing').progressbar({ value: 0, max: 100 });
$.ajax({
type: "POST",
url: "PopulateCountry2.aspx/InitializeProcessing",
data: "{'guid': '<%= this.UploadFile.GuidString %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
setTimeout('updateProgressProcessing();', 1000);
}
});
}
function updateProgressProcessing() {
$.ajax({
type: "POST",
url: "/Automation/Json-ByGuid.aspx/GetProgress",
data: "{'guid': '<%= this.UploadFile.GuidString %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d > 99) {
$("#DivProgressProcessing .progressbar-value").animate(
{
width: "100%"
}, { queue: false });
window.location = '/';
} else {
// We're not done yet. Keep the progress bar on-screen and keep re-checking.
if (msg.d == 1) {
$('#DivProgressProcessing').progressbar({ value: 1 });
} else {
$("#DivProgressProcessing .progressbar-value").animate(
{
width: msg.d + "%"
}, { queue: false });
}
if (msg.d > 0 && !progressReceived) {
progressReceived = true;
}
setTimeout('updateProgressProcessing();', 1000);
}
},
error: function (msg) {
// Retry on call error, too
setTimeout('updateProgressProcessing();', 1000);
}
});
}
var progressReceived = false;
</script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<div class="DivEntry">
<div class="entryFields">
<Swarmops5:FileUpload runat="server" ID="UploadFile" Filter="NoFilter" DisplayCount="8" ClientUploadCompleteCallback="uploadCompletedCallback" />
</div>
<div class="entryLabels">
Upload <strong>postal codes</strong> for processing<br/><br/>
</div>
</div>
<div clear="both"></div>
<div id="Processing">
<div id="DivProgressProcessing"></div>
</div>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
</asp:Content>
@@ -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<string,bool> postalCodeDupes = new Dictionary<string, bool>();
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);
}
}
}
@@ -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" %>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="/Scripts/jquery.fileupload/jquery.iframe-transport.js" type="text/javascript" language="javascript"></script>
<!-- The basic File Upload plugin -->
<script src="/Scripts/jquery.fileupload/jquery.fileupload.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
});
function uploadCompletedCallback() {
$('#DivProcessing').slideDown().fadeIn();
$('#DivProgressProcessing').progressbar({ value: 0, max: 100 });
$.ajax({
type: "POST",
url: "PopulateFakePeople.aspx/InitializeProcessing",
data: "{'guid': '<%= this.UploadFile.GuidString %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
setTimeout('updateProgressProcessing();', 1000);
}
});
}
function updateProgressProcessing() {
$.ajax({
type: "POST",
url: "/Automation/Json-ByGuid.aspx/GetProgress",
data: "{'guid': '<%= this.UploadFile.GuidString %>'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d > 99) {
$("#DivProgressProcessing .progressbar-value").animate(
{
width: "100%"
}, { queue: false });
window.location = '/';
} else {
// We're not done yet. Keep the progress bar on-screen and keep re-checking.
if (msg.d == 1) {
$('#DivProgressProcessing').progressbar({ value: 1 });
} else {
$("#DivProgressProcessing .progressbar-value").animate(
{
width: msg.d + "%"
}, { queue: false });
}
if (msg.d > 0 && !progressReceived) {
progressReceived = true;
}
setTimeout('updateProgressProcessing();', 1000);
}
},
error: function (msg) {
// Retry on call error, too
setTimeout('updateProgressProcessing();', 1000);
}
});
}
var progressReceived = false;
</script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<div class="DivEntry">
<div class="entryFields">
<Swarmops5:FileUpload runat="server" ID="UploadFile" Filter="NoFilter" DisplayCount="8" ClientUploadCompleteCallback="uploadCompletedCallback" />
</div>
<div class="entryLabels">
Upload <strong>fake people</strong> for processing<br/><br/>
</div>
</div>
<div clear="both"></div>
<div id="Processing">
<div id="DivProgressProcessing"></div>
</div>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
</asp:Content>
@@ -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();
}
@@ -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()
+1 -1
View File
@@ -486,7 +486,7 @@
</div>
<div class="mainbar">
<div id="page-icon-encaps"><asp:Image ID="IconPage" runat="server" ImageUrl="~/Images/PageIcons/iconshock-ignitionkey-40px.png" /></div><h1><asp:Label ID="LabelPageTitle" Text="Installation" runat="server" /></h1>
<!--<div id="page-icon-encaps"><asp:Image ID="IconPage" runat="server" ImageUrl="~/Images/PageIcons/iconshock-ignitionkey-40px.png" /></div><h1><asp:Label ID="LabelPageTitle" Text="Installation" runat="server" /></h1>-->
<div class="box">
<div class="content">
+13 -205
View File
@@ -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<int, int> geographyIdTranslation = new Dictionary<int, int>();
Dictionary<int, int> cityIdTranslation = new Dictionary<int, int>();
Dictionary<string, int> countryIdTranslation = new Dictionary<string, int>();
Dictionary<int, bool> cityIdsUsedLookup = new Dictionary<int, bool>();
// 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<int, int> 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]
@@ -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);
+3 -2
View File
@@ -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 ("/");
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

+15 -6
View File
@@ -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("<asp:Literal ID="LiteralLoginSuccess" runat="server" />"); // 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() {
+24 -8
View File
@@ -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 (
"<p>You have been logged on as <strong>Sandbox Administrator</strong> to the Swarmops Development Sandbox.</p><br/><p>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.</p><br/><p><strong>In other words, welcome, and play away!</strong></p>")));
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;
}
+6
View File
@@ -358,6 +358,12 @@ div.loginbox
background-color: #E4ECFF;
}
input.InputManualCredentials {
border: solid 1px #A2BEFF;
padding: 2px;
}
span.loginalphabetasign
{
font-size: 24px;
+10
View File
@@ -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 {
+2 -14
View File
@@ -19,7 +19,7 @@
<customErrors mode="Off"/>
<httpRuntime maxRequestLength="40960" executionTimeout="180" targetFramework="4.5"/>
<authentication mode="Forms">
<forms loginUrl="~/Security/Login.aspx" name=".ActzAuth" path="/" protection="All" timeout="600" defaultUrl="/" cookieless="UseDeviceProfile"/>
<forms loginUrl="~/Security/Login" name=".ActzAuth" path="/" protection="All" timeout="600" defaultUrl="/" cookieless="UseDeviceProfile"/>
</authentication>
<authorization>
<deny users="?"/>
@@ -42,6 +42,7 @@
<add key="aspnet:UseLegacyEncryption" value="true"/>
<add key="aspnet:UseLegacyMachineKeyEncryption" value="true"/>
<add key="aspnet:UseLegacyFormsAuthenticationTicketCompatibility" value="true"/>
<add key="MonoServerDefaultIndexFiles" value="/"/>
</appSettings>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
@@ -53,18 +54,5 @@
<requestLimits maxAllowedContentLength="41943040"/>
</requestFiltering>
</security>
<rewrite>
<rules>
<rule name="aspxcloak">
<!--Removes the .aspx extension for all pages.-->
<match url="(.*)"/>
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="{R:1}.aspx"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>