Deploying for test

This commit is contained in:
Rick Falkvinge
2012-11-17 22:42:01 +00:00
parent 7d0b0838ea
commit ca932ec983
4 changed files with 631 additions and 422 deletions
+38
View File
@@ -1,4 +1,5 @@
using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using Activizr.Basic.Types;
@@ -232,5 +233,42 @@ namespace Activizr.Database
}
}
public int CreateCity(string cityName, int countryId, int geographyId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("CreateCity", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "cityName", cityName);
AddParameterWithName(command, "countryId", countryId);
AddParameterWithName(command, "geographyId", geographyId);
AddParameterWithName(command, "comment", string.Empty);
return Convert.ToInt32(command.ExecuteScalar());
}
}
public int CreatePostalCode(string postalCode, int cityId, int countryId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("CreatePostalCode", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "postalCode", postalCode);
AddParameterWithName(command, "cityId", cityId);
AddParameterWithName(command, "countryId", countryId);
return Convert.ToInt32(command.ExecuteScalar());
}
}
}
}
+5
View File
@@ -44,5 +44,10 @@ namespace Activizr.Logic.Structure
{
return FromBasic(PirateDb.GetDatabaseForReading().GetCityByName(cityName, countryCode));
}
public static City Create (string cityName, int countryId, int geographyId)
{
return City.FromIdentity(PirateDb.GetDatabaseForWriting().CreateCity(cityName, countryId, geographyId));
}
}
}
File diff suppressed because it is too large Load Diff
+41 -2
View File
@@ -6,6 +6,7 @@ using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
@@ -370,7 +371,18 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
// Get the postal codes and cities
Activizr.Site.Automation.City[] cities = geoDataFetcher.GetCitiesForCountry(countryCode);
Activizr.Site.Automation.City[] cities = null;
try
{
cities = geoDataFetcher.GetCitiesForCountry(countryCode);
}
catch (SoapHeaderException)
{
// This is typically a country that isn't populated with cities yet. Ignore.
continue;
}
_initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry/2);
@@ -380,12 +392,39 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page
foreach (Activizr.Site.Automation.PostalCode postalCode in postalCodes)
{
// cityIdsUsedLookup[postalCode.CityName] =
cityIdsUsedLookup[postalCode.CityId] = true;
}
_initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry*2/3);
// Insert cities
int newCountryId = countryIdTranslation[countryCode];
foreach (Activizr.Site.Automation.City city in cities)
{
if (cityIdsUsedLookup[city.CityId])
{
int newGeographyId = geographyIdTranslation[city.GeographyId];
int newCityId = PirateDb.GetDatabaseForWriting().CreateCity(city.Name, newCountryId,
newGeographyId);
cityIdTranslation[city.CityId] = newCityId;
}
}
// Insert postal codes
_initProgress = 10 + (int) (countryCount*initStepPerCountry + initStepPerCountry*5/6);
foreach (Activizr.Site.Automation.PostalCode postalCode in postalCodes)
{
int newCityId = cityIdTranslation[postalCode.CityId];
PirateDb.GetDatabaseForWriting().CreatePostalCode(postalCode.PostalCode, newCityId, newCountryId);
}
countryCount++;
_initProgress = 10 + (int) (countryCount*initStepPerCountry);
}
_initProgress = 100;