Checkpoint commit and dbupgrade 7
This commit is contained in:
@@ -4,4 +4,4 @@
|
||||
0004 - Added BankProfile tables and stored procs to insert/update. [Rick Falkvinge]
|
||||
0005 - Changed PostalCodeLength for NO DK to 4; for GH to zero; added Country.Currency. [Rick Falkvinge]
|
||||
0006 - Added Memberships.LocalNumber and .FamilyNumber; added CurrencyExchangeRate tables/procs. [Rick Falkvinge]
|
||||
|
||||
0007 - NL update; added Lat/Long to PostalCodes and to People, indexed [RF]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
UPDATE `Countries` SET `CurrencyCode`='EUR', `PostalCodeLength`='6' WHERE `CountryCode`='NL'
|
||||
|
||||
#
|
||||
|
||||
ALTER TABLE `PostalCodes`
|
||||
CHANGE COLUMN `Lat` `Latitude` DOUBLE NOT NULL DEFAULT 0.0 ,
|
||||
CHANGE COLUMN `Long` `Longitude` DOUBLE NOT NULL DEFAULT 0.0
|
||||
|
||||
#
|
||||
|
||||
ALTER TABLE `People`
|
||||
ADD COLUMN `Latitude` DOUBLE NOT NULL DEFAULT 0.0 AFTER `GeographyId`,
|
||||
ADD COLUMN `Longitude` DOUBLE NOT NULL DEFAULT 0.0 AFTER `Latitude`,
|
||||
ADD INDEX `Index_Latitude` (`Latitude` ASC),
|
||||
ADD INDEX `Index_Longitude` (`Longitude` ASC)
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateCountry1.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateCountry1" %>
|
||||
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
|
||||
<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %>
|
||||
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
|
||||
|
||||
<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: "PopulateCountry1.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 file 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,167 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Web.Services;
|
||||
using Swarmops.Basic.Enums;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Cache;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.Admin.Hacks
|
||||
{
|
||||
public partial class PopulateCountry1 : PageV5Base
|
||||
{
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
PageTitle = "Populate Country 1 - Geotree";
|
||||
PageIcon = "iconshock-battery-drill";
|
||||
InfoBoxLiteral = "You've taken a wrong turn if you're even seeing this page. It's for development purposes.";
|
||||
}
|
||||
|
||||
|
||||
private void Localize()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[WebMethod (true)]
|
||||
public static void InitializeProcessing (string guid)
|
||||
{
|
||||
// Start an async thread that does all the work, then return
|
||||
|
||||
|
||||
// FORMAT OF FILE
|
||||
//
|
||||
// Tab separated fields
|
||||
//
|
||||
// [countrycode] [tab] [geo1] .. [geo_n]
|
||||
//
|
||||
// example:
|
||||
//
|
||||
// NL [Tab] Greater Amsterdam
|
||||
// NL [Tab] Greater Amsterdam [Tab] Amsterdam
|
||||
// NL [Tab] Greater Amsterdam [Tab] Amsterdam [Tab] Wallen
|
||||
//
|
||||
// To populate all four nodes, only the last line is necessary, but all three lines are valid.
|
||||
//
|
||||
// Nodes are not re-populated on repetition. Node names within a country scope are required to
|
||||
// be unique.
|
||||
|
||||
|
||||
if (!PilotInstallationIds.IsPilot (PilotInstallationIds.SwarmopsLive) && !Debugger.IsAttached)
|
||||
{
|
||||
throw new UnauthorizedAccessException("This may only run on Swarmops Master");
|
||||
}
|
||||
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Unknown,
|
||||
AccessType.Write)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
Thread initThread = new Thread (ProcessUploadThread);
|
||||
initThread.Start (guid);
|
||||
}
|
||||
|
||||
private static void ProcessUploadThread (object guidObject)
|
||||
{
|
||||
string guid = (string) guidObject;
|
||||
Documents documents = Documents.RecentFromDescription (guid);
|
||||
Document uploadedDoc = documents[0];
|
||||
string data = string.Empty;
|
||||
int count = 0;
|
||||
|
||||
using (StreamReader reader = uploadedDoc.GetReader (1252))
|
||||
{
|
||||
data = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
string[] lines = data.Split ('\n');
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
Dictionary<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 file 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,110 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Web.Services;
|
||||
using Swarmops.Basic.Enums;
|
||||
using Swarmops.Logic.Cache;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.Admin.Hacks
|
||||
{
|
||||
public partial class PopulateCountry2 : PageV5Base
|
||||
{
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
PageTitle = "Populate Country - Postal Codes, Cities";
|
||||
PageIcon = "iconshock-battery-drill";
|
||||
InfoBoxLiteral = "You've taken a wrong turn if you're even seeing this page. It's for development purposes.";
|
||||
}
|
||||
|
||||
|
||||
private void Localize()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[WebMethod (true)]
|
||||
public static void InitializeProcessing (string guid)
|
||||
{
|
||||
// Start an async thread that does all the work, then return
|
||||
|
||||
if (!PilotInstallationIds.IsPilot(PilotInstallationIds.SwarmopsLive) && !Debugger.IsAttached)
|
||||
{
|
||||
throw new UnauthorizedAccessException("This may only run on Swarmops Master");
|
||||
}
|
||||
|
||||
|
||||
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.CurrentUser.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Unknown,
|
||||
AccessType.Write)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
Thread initThread = new Thread (ProcessUploadThread);
|
||||
initThread.Start (guid);
|
||||
}
|
||||
|
||||
private static void ProcessUploadThread (object guidObject)
|
||||
{
|
||||
string guid = (string) guidObject;
|
||||
Documents documents = Documents.RecentFromDescription (guid);
|
||||
Document uploadedDoc = documents[0];
|
||||
string data = string.Empty;
|
||||
int count = 0;
|
||||
|
||||
using (StreamReader reader = uploadedDoc.GetReader (1252))
|
||||
{
|
||||
data = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
string[] lines = data.Split ('\n');
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
foreach (string lineRaw in lines)
|
||||
{
|
||||
count++;
|
||||
string line = lineRaw.Trim();
|
||||
string[] lineParts = line.Split ('\t');
|
||||
|
||||
if (lineParts.Length < 12)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int percent = (count*99)/lines.Length;
|
||||
if (percent == 0)
|
||||
{
|
||||
percent = 1;
|
||||
}
|
||||
GuidCache.Set (guid + "-Progress", percent);
|
||||
|
||||
string name = lineParts[0] + " " + lineParts[1];
|
||||
PersonGender gender = lineParts[2] == "male" ? PersonGender.Male : PersonGender.Female;
|
||||
DateTime dateOfBirth = DateTime.Parse (lineParts[7], new CultureInfo ("en-US"), DateTimeStyles.None);
|
||||
Country country = Country.FromCode (lineParts[6]);
|
||||
|
||||
|
||||
Person newPerson = Person.Create (name, string.Empty, string.Empty, lineParts[8], lineParts[3],
|
||||
lineParts[4].Replace (" ", ""), lineParts[5], lineParts[6], dateOfBirth, gender);
|
||||
|
||||
newPerson.NationalIdNumber = lineParts[9];
|
||||
newPerson.Longitude = lineParts[10];
|
||||
newPerson.Latitude = lineParts[11];
|
||||
|
||||
newPerson.AddMembership (1, DateTime.Today.AddDays (random.Next (365)));
|
||||
}
|
||||
|
||||
GuidCache.Set (guid + "-Progress", 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user