Merge branch 'populate'
This commit is contained in:
@@ -209,7 +209,19 @@ namespace Swarmops.Basic.Enums
|
||||
/// <summary>
|
||||
/// Free-text description of an inbound invoice (what's it for?)
|
||||
/// </summary>
|
||||
InboundInvoiceDescription
|
||||
InboundInvoiceDescription,
|
||||
/// <summary>
|
||||
/// Geopos - longitude. Float in degrees. Positive is north.
|
||||
/// </summary>
|
||||
Longitude,
|
||||
/// <summary>
|
||||
/// Geopos - latitude. Float in degrees. Positive is east.
|
||||
/// </summary>
|
||||
Latitude,
|
||||
/// <summary>
|
||||
/// A National ID number, if any. Like US SSN.
|
||||
/// </summary>
|
||||
NationalIdNumber
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+23
-1
@@ -267,12 +267,34 @@ namespace Swarmops.Logic.Swarm
|
||||
set { OptionalData.SetOptionalDataString(ObjectOptionalDataType.CryptoRevocation, value); }
|
||||
}
|
||||
|
||||
[Obsolete ("Use NationalIdNumber instead")]
|
||||
public virtual string PersonalNumber
|
||||
{
|
||||
get { return OptionalData.GetOptionalDataString(ObjectOptionalDataType.PersonalNumber); }
|
||||
set { OptionalData.SetOptionalDataString(ObjectOptionalDataType.PersonalNumber, value); }
|
||||
}
|
||||
|
||||
public virtual string NationalIdNumber
|
||||
{
|
||||
get { return OptionalData.GetOptionalDataString(ObjectOptionalDataType.NationalIdNumber); }
|
||||
set { OptionalData.SetOptionalDataString(ObjectOptionalDataType.NationalIdNumber, value); }
|
||||
}
|
||||
|
||||
public virtual string Longitude
|
||||
{
|
||||
get { return OptionalData.GetOptionalDataString(ObjectOptionalDataType.Longitude); }
|
||||
set { OptionalData.SetOptionalDataString(ObjectOptionalDataType.Longitude, value); }
|
||||
}
|
||||
|
||||
public virtual string Latitude
|
||||
{
|
||||
get { return OptionalData.GetOptionalDataString(ObjectOptionalDataType.Latitude); }
|
||||
set { OptionalData.SetOptionalDataString(ObjectOptionalDataType.Latitude, value); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public virtual bool MailUnreachable
|
||||
{
|
||||
@@ -511,7 +533,7 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
if (countryCode.Length > 0)
|
||||
{
|
||||
country = SwarmDb.GetDatabaseForReading().GetCountry(countryCode);
|
||||
country = Structure.Country.FromCode(countryCode);
|
||||
}
|
||||
|
||||
// Clean data
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="PopulateData.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Hacks.PopulateData" %>
|
||||
<%@ 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">
|
||||
<Swarmops5:ExternalScripts ID="ExternalScripts1" Package="easyui" Control="tree" 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>
|
||||
<link rel="stylesheet" type="text/css" href="/Style/v5-easyui-elements.css">
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
|
||||
<asp:TextBox runat="server" ID="TextData" TextMode="MultiLine" Rows="20" Width="100%" />
|
||||
|
||||
<asp:Button ID="ButtonProcess" runat="server" CssClass="buttonAccentColor NoInputFocus" OnClick="ButtonProcess_Click" Text="Process"/>
|
||||
<div style="clear:both"></div>
|
||||
</asp:Content>
|
||||
|
||||
|
||||
|
||||
<asp:Content ID="Content6" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
|
||||
</asp:Content>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Swarmops.Basic.Enums;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.Admin.Hacks
|
||||
{
|
||||
public partial class PopulateData : PageV5Base
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.PageTitle = "Populate Data";
|
||||
this.PageIcon = "iconshock-battery-drill";
|
||||
this.InfoBoxLiteral = "You've taken a wrong turn if you're even seeing this page. It's for development purposes.";
|
||||
}
|
||||
|
||||
|
||||
private void Localize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void ButtonProcess_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
string data = this.TextData.Text;
|
||||
|
||||
string[] lines = data.Split('\n');
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
foreach (string lineRaw in lines)
|
||||
{
|
||||
string line = lineRaw.Trim();
|
||||
string[] lineParts = line.Split('\t');
|
||||
|
||||
if (lineParts.Length < 12)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Response.AppendCookie(new HttpCookie("DashboardMessage", "Data was successfully processed."));
|
||||
|
||||
// Redirect to dashboard
|
||||
|
||||
Response.Redirect("/", true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user