Minor fixes & optimizations
This commit is contained in:
@@ -137,12 +137,17 @@ namespace Activizr.Logic.Pirates
|
||||
return new Membership(basic);
|
||||
}
|
||||
|
||||
public static Membership FromIdentity (int membershipId)
|
||||
public static Membership FromIdentity(int membershipId)
|
||||
{
|
||||
return FromBasic(PirateDb.GetDatabaseForReading().GetMembership(membershipId));
|
||||
}
|
||||
|
||||
public static Membership FromPersonAndOrganization (int personId, int organizationId)
|
||||
public static Membership FromIdentityAggressive(int membershipId)
|
||||
{
|
||||
return FromBasic(PirateDb.GetDatabaseForWriting().GetMembership(membershipId));
|
||||
}
|
||||
|
||||
public static Membership FromPersonAndOrganization(int personId, int organizationId)
|
||||
{
|
||||
return FromBasic(PirateDb.GetDatabaseForReading().GetActiveMembership(personId, organizationId));
|
||||
}
|
||||
@@ -151,7 +156,7 @@ namespace Activizr.Logic.Pirates
|
||||
{
|
||||
int membershipId = PirateDb.GetDatabaseForWriting().CreateMembership(personId, organizationId, expires);
|
||||
|
||||
return FromIdentity(membershipId);
|
||||
return FromIdentityAggressive(membershipId);
|
||||
}
|
||||
|
||||
public static Membership Create (Person person, Organization organization, DateTime expires)
|
||||
|
||||
@@ -368,12 +368,17 @@ namespace Activizr.Logic.Pirates
|
||||
|
||||
#endregion
|
||||
|
||||
public static Person FromIdentity (int personId)
|
||||
public static Person FromIdentity(int personId)
|
||||
{
|
||||
return FromBasic(PirateDb.GetDatabaseForReading().GetPerson(personId));
|
||||
}
|
||||
|
||||
public Authority GetAuthority ()
|
||||
public static Person FromIdentityAggressive(int personId)
|
||||
{
|
||||
return FromBasic(PirateDb.GetDatabaseForWriting().GetPerson(personId)); // Note "for writing". Intentional. Queries master db and bypasses replication lag.
|
||||
}
|
||||
|
||||
public Authority GetAuthority()
|
||||
{
|
||||
return Authorization.GetPersonAuthority(Identity);
|
||||
}
|
||||
@@ -527,7 +532,7 @@ namespace Activizr.Logic.Pirates
|
||||
|
||||
// Resolve the geography
|
||||
|
||||
Person newPerson = Person.FromIdentity(personId);
|
||||
Person newPerson = Person.FromIdentityAggressive(personId); // aggressive bypasses replication lag, avoids race condition
|
||||
newPerson.ResolveGeography();
|
||||
|
||||
// Generate the salted password hash and set it
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Activizr.Logic.Pirates
|
||||
|
||||
public static PersonRole Create (int personId, RoleType roleType, int organizationId, int nodeId)
|
||||
{
|
||||
return FromIdentity(PirateDb.GetDatabaseForWriting().CreateRole(personId, roleType, organizationId, nodeId));
|
||||
return FromIdentityAggressive(PirateDb.GetDatabaseForWriting().CreateRole(personId, roleType, organizationId, nodeId));
|
||||
}
|
||||
|
||||
public static PersonRole FromBasic (BasicPersonRole basic)
|
||||
@@ -27,11 +27,16 @@ namespace Activizr.Logic.Pirates
|
||||
return new PersonRole(basic);
|
||||
}
|
||||
|
||||
public static PersonRole FromIdentity (int roleId)
|
||||
public static PersonRole FromIdentity(int roleId)
|
||||
{
|
||||
return FromBasic(PirateDb.GetDatabaseForReading().GetRole(roleId));
|
||||
}
|
||||
|
||||
public static PersonRole FromIdentityAggressive(int roleId)
|
||||
{
|
||||
return FromBasic(PirateDb.GetDatabaseForWriting().GetRole(roleId)); // Note "for writing". Intentional. Queries master db and bypasses replication lag to avoid race conditions.
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Person Person
|
||||
|
||||
@@ -36,14 +36,19 @@ namespace Activizr.Logic.Structure
|
||||
{
|
||||
}
|
||||
|
||||
public static Organization FromIdentity (int identity)
|
||||
public static Organization FromIdentity(int identity)
|
||||
{
|
||||
|
||||
return FromBasic(OrganizationCache.GetOrganization(identity));
|
||||
//return FromBasic(PirateDb.GetDatabaseForReading().GetOrganization(identity));
|
||||
}
|
||||
|
||||
public static Organization FromBasic (BasicOrganization basic)
|
||||
public static Organization FromIdentityAggressive(int identity)
|
||||
{
|
||||
return FromBasic(PirateDb.GetDatabaseForWriting().GetOrganization(identity)); // Note "for writing". Intentional. Queries master db; bypasses replication lag.
|
||||
}
|
||||
|
||||
public static Organization FromBasic(BasicOrganization basic)
|
||||
{
|
||||
return new Organization(basic);
|
||||
}
|
||||
@@ -624,7 +629,7 @@ namespace Activizr.Logic.Structure
|
||||
|
||||
public static Organization Create (int parentOrganizationId, string nameInternational, string name, string nameShort, string domain, string mailPrefix, int anchorGeographyId, bool acceptsMembers, bool autoAssignNewMembers, int defaultCountryId)
|
||||
{
|
||||
return FromIdentity(OrganizationCache.CreateOrganization(parentOrganizationId,
|
||||
return FromIdentityAggressive(OrganizationCache.CreateOrganization(parentOrganizationId,
|
||||
nameInternational,
|
||||
name,
|
||||
nameShort,
|
||||
|
||||
@@ -494,7 +494,7 @@
|
||||
</div>
|
||||
<div id="DivDatabaseWritable" style="display:none">
|
||||
<h2>Connect to database</h2>
|
||||
<p>Before you fill this in, you will need to have created a database on a MySQL server that this web server can access, and set up user accounts that can access it. We <strong>very strongly</strong> recommend having three separate accounts - one for reading (needs SELECT only), one for writing (needs EXECUTE only), and one for admin. All three accounts also need SELECT permissions on the mysql database.</p>
|
||||
<p>Before you fill this in, you will need to have created a database on a MySQL server that this web server can access, and set up user accounts that can access it. We <strong>very strongly</strong> recommend having three separate accounts - one for reading (needs SELECT only), one for writing (SELECT and EXECUTE), and one for admin. All three accounts also need SELECT permissions on the mysql database.</p>
|
||||
|
||||
<div class="entrylabels" style="width:120px">
|
||||
<br/>
|
||||
|
||||
@@ -454,7 +454,7 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
|
||||
_initMessage = string.Format("Setting up {0:N0} cities for {1}...", cities.Length, countryCode);
|
||||
|
||||
string sql = "INSERT INTO Cities (CityName, GeographyId, CountryId, Comment) VALUES ";
|
||||
StringBuilder sqlCityBuild = new StringBuilder("INSERT INTO Cities (CityName, GeographyId, CountryId, Comment) VALUES ", 65536);
|
||||
bool insertComma = false;
|
||||
|
||||
foreach (Activizr.Site.Automation.City city in cities)
|
||||
@@ -470,18 +470,20 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
|
||||
|
||||
if (insertComma)
|
||||
{
|
||||
sql += ",";
|
||||
sqlCityBuild.Append(",");
|
||||
}
|
||||
|
||||
sql += "('" + city.Name.Replace("'", "\'") + "'," + newGeographyId.ToString() + "," +
|
||||
newCountryId.ToString() + ",'')";
|
||||
sqlCityBuild.Append("('" + city.Name.Replace("'", "\'") + "'," + newGeographyId.ToString() + "," +
|
||||
newCountryId.ToString() + ",'')");
|
||||
insertComma = true;
|
||||
|
||||
cityIdTranslation[city.CityId] = ++cityIdHighwater; // Note that we assume the assigned ID here.
|
||||
}
|
||||
}
|
||||
|
||||
PirateDb.GetDatabaseForAdmin().ExecuteAdminCommand(sql + ";"); // Inserts all cities in one bulk op, to save roundtrips
|
||||
sqlCityBuild.Append(";");
|
||||
|
||||
PirateDb.GetDatabaseForAdmin().ExecuteAdminCommand(sqlCityBuild.ToString()); // Inserts all cities in one bulk op, to save roundtrips
|
||||
|
||||
// Insert postal codes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user