Loc freeze for sprint Black-7
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Swarmops.Database
|
||||
/// </summary>
|
||||
public static int DbVersionExpected
|
||||
{
|
||||
get { return 5; }
|
||||
get { return 6; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.App_GlobalResources;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
namespace Swarmops.Logic.Communications.Transmission
|
||||
@@ -53,9 +56,11 @@ namespace Swarmops.Logic.Communications.Transmission
|
||||
|
||||
public string ExpandMacros (string input)
|
||||
{
|
||||
// TODO: Replace all, of course
|
||||
// Replace a few technical items that would be found in system-level notifications
|
||||
|
||||
input = input.Replace ("[HostName]", Dns.GetHostName());
|
||||
input = input.Replace ("[DbVersion]", SwarmDb.DbVersionExpected.ToString(CultureInfo.InvariantCulture));
|
||||
input = input.Replace ("[SwarmopsVersion]", Formatting.SwarmopsVersion);
|
||||
|
||||
// Loop through supplied strings and replace them in the resource. Not very efficient but who cares
|
||||
|
||||
|
||||
@@ -90,6 +90,11 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ParticipantTitles.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="App_GlobalResources\Logic.Communications.Transmission.MailPayload.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Logic.Communications.Transmission.MailPayload.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Cache\GuidCache.cs" />
|
||||
<Compile Include="Communications\ICommsRenderer.cs" />
|
||||
<Compile Include="Communications\ICommsResolver.cs" />
|
||||
@@ -392,6 +397,10 @@
|
||||
<EmbeddedResource Include="App_GlobalResources\pt-BR\Logic.Communications.Transmission.NotificationPayload.pt-BR.resx" />
|
||||
<EmbeddedResource Include="App_GlobalResources\pt-BR\Logic.Financial.FinancialTransactionTagSetTypesStock.pt-BR.resx" />
|
||||
<EmbeddedResource Include="App_GlobalResources\pt-BR\Logic.Swarm.DashboardTodos.pt-BR.resx" />
|
||||
<EmbeddedResource Include="App_GlobalResources\Logic.Communications.Transmission.MailPayload.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Logic.Communications.Transmission.MailPayload.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="App_GlobalResources\ru-RU\Logic.Communications.Transmission.NotificationPayload.ru-RU.resx" />
|
||||
<EmbeddedResource Include="App_GlobalResources\ru-RU\Logic.Financial.FinancialTransactionTagSetTypesStock.ru-RU.resx" />
|
||||
<EmbeddedResource Include="App_GlobalResources\ru-RU\Logic.Swarm.DashboardTodos.ru-RU.resx" />
|
||||
|
||||
@@ -1,13 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using Swarmops.Logic.Cache;
|
||||
using Swarmops.Logic.Security;
|
||||
|
||||
namespace Swarmops.Logic.Support
|
||||
{
|
||||
public static class Formatting
|
||||
{
|
||||
private static string _swarmopsVersion;
|
||||
|
||||
public static string SwarmopsVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty (_swarmopsVersion))
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
_swarmopsVersion = "Debug Environment";
|
||||
return _swarmopsVersion;
|
||||
}
|
||||
// Read build number if not loaded, or set to "Private" if none
|
||||
string buildIdentity = (string)GuidCache.Get("_buildIdentity");
|
||||
|
||||
if (buildIdentity == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (HttpContext.Current != null) // frontend: use friendly format
|
||||
{
|
||||
using (
|
||||
StreamReader reader =
|
||||
File.OpenText (HttpContext.Current.Request.MapPath ("~/BuildIdentity.txt")))
|
||||
{
|
||||
buildIdentity = "Build " + reader.ReadLine();
|
||||
}
|
||||
|
||||
using (
|
||||
StreamReader reader =
|
||||
File.OpenText (HttpContext.Current.Request.MapPath ("~/SprintName.txt")))
|
||||
{
|
||||
buildIdentity += " (" + reader.ReadLine() + ")";
|
||||
}
|
||||
}
|
||||
else // backend: use build ID only
|
||||
{
|
||||
using (
|
||||
StreamReader reader =
|
||||
File.OpenText("/usr/share/swarmops/backend/BuildIdentity.txt"))
|
||||
{
|
||||
buildIdentity = reader.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
buildIdentity = "Private Build";
|
||||
}
|
||||
|
||||
GuidCache.Set("_buildIdentity", buildIdentity);
|
||||
_swarmopsVersion = buildIdentity;
|
||||
}
|
||||
}
|
||||
|
||||
return _swarmopsVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public static string CleanNumber (string input)
|
||||
{
|
||||
return LogicServices.CleanNumber (input);
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Swarmops.Logic.Swarm
|
||||
{
|
||||
public class Participant
|
||||
{
|
||||
public static string Localized (ParticipantTitle title, TitleVariant variant)
|
||||
public static string Localized (ParticipantTitle title, TitleVariant variant = TitleVariant.Generic)
|
||||
{
|
||||
return ParticipantTitles.ResourceManager.GetString ("Title_" + title + "_" + variant);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,24 @@ using Swarmops.Logic.Swarm;
|
||||
/// </summary>
|
||||
public class ControlV5Base : UserControl
|
||||
{
|
||||
public Authority _authority = null;
|
||||
public Organization _currentOrganization = null;
|
||||
public Person _currentUser = null;
|
||||
private Authority _authority;
|
||||
private Organization _currentOrganization;
|
||||
private Person _currentUser;
|
||||
|
||||
protected Organization CurrentOrganization
|
||||
{
|
||||
get { return this._currentOrganization; }
|
||||
}
|
||||
|
||||
protected Person CurrentUser
|
||||
{
|
||||
get { return this._currentUser; }
|
||||
}
|
||||
|
||||
protected Authority CurrentAuthority
|
||||
{
|
||||
get { return this._authority; }
|
||||
}
|
||||
|
||||
protected override void OnLoad (EventArgs e)
|
||||
{
|
||||
@@ -48,34 +63,4 @@ public class ControlV5Base : UserControl
|
||||
base.OnLoad (e);
|
||||
}
|
||||
|
||||
protected string GetBuildIdentity()
|
||||
{
|
||||
// Read build number if not loaded, or set to "Private" if none
|
||||
string buildIdentity = (string) GuidCache.Get ("_buildIdentity");
|
||||
|
||||
if (buildIdentity == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (StreamReader reader = File.OpenText (HttpContext.Current.Request.MapPath ("~/BuildIdentity.txt"))
|
||||
)
|
||||
{
|
||||
buildIdentity = "Build " + reader.ReadLine();
|
||||
}
|
||||
|
||||
using (StreamReader reader = File.OpenText (HttpContext.Current.Request.MapPath ("~/SprintName.txt")))
|
||||
{
|
||||
buildIdentity += " (" + reader.ReadLine() + ")";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
buildIdentity = "Private Build";
|
||||
}
|
||||
|
||||
GuidCache.Set ("_buildIdentity", buildIdentity);
|
||||
}
|
||||
|
||||
return buildIdentity;
|
||||
}
|
||||
}
|
||||
@@ -534,4 +534,22 @@
|
||||
<value>two-year</value>
|
||||
<comment>Like "a two-year membership"</comment>
|
||||
</data>
|
||||
<data name="Global_Address" xml:space="preserve">
|
||||
<value>Address</value>
|
||||
<comment>As in physical location</comment>
|
||||
</data>
|
||||
<data name="Global_City" xml:space="preserve">
|
||||
<value>City</value>
|
||||
</data>
|
||||
<data name="Global_Country" xml:space="preserve">
|
||||
<value>Country</value>
|
||||
<comment>As in the nation-state geographic boundary, not as in the music style</comment>
|
||||
</data>
|
||||
<data name="Global_DateOfBirth" xml:space="preserve">
|
||||
<value>Date of Birth</value>
|
||||
<comment>Population data record entry, rather than celebration day ("birthday")</comment>
|
||||
</data>
|
||||
<data name="Global_PostalCode" xml:space="preserve">
|
||||
<value>Postal Code</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -129,16 +129,33 @@
|
||||
<data name="AddPerson_ErrorStreet" xml:space="preserve">
|
||||
<value>A valid street or P.O. box is required.</value>
|
||||
</data>
|
||||
<data name="AddPerson_GeographyDetected" xml:space="preserve">
|
||||
<value>Geography detected</value>
|
||||
</data>
|
||||
<data name="AddPerson_Info" xml:space="preserve">
|
||||
<value>This is where you enter new people into the organization. As you register them for a <strong>{0} {1}</strong> lasting until <strong>{2}</strong>, they will receive a welcome message with a randomized login password in mail. The local officers will also be notified of the new person, for an opportunity to send them a welcome message.</value>
|
||||
<comment>{0} and {1} can be "one-year" and "Membership", for example. {2} is LongDateString.</comment>
|
||||
</data>
|
||||
<data name="AddPerson_LegalGender" xml:space="preserve">
|
||||
<value>Legal Gender</value>
|
||||
<comment>"Legal" to cut short discussions on 50 different genders for the time being</comment>
|
||||
</data>
|
||||
<data name="AddPerson_PersonSuccessfullyRegistered" xml:space="preserve">
|
||||
<value>The person was successfully added to the organization.</value>
|
||||
</data>
|
||||
<data name="AddPerson_StatisticalData" xml:space="preserve">
|
||||
<value>Statistical Data</value>
|
||||
<comment>Header for gender, date of birth</comment>
|
||||
</data>
|
||||
<data name="AddPerson_Street1PO" xml:space="preserve">
|
||||
<value>Street 1 (or P.O. Box)</value>
|
||||
</data>
|
||||
<data name="AddPerson_Street2" xml:space="preserve">
|
||||
<value>Street 2 - if applicable</value>
|
||||
</data>
|
||||
<data name="AddPerson_Title" xml:space="preserve">
|
||||
<value>Add [Regular]</value>
|
||||
<comment>The [Regular] is replaced in code. Singular form gender neutral.</comment>
|
||||
<value>Add {0}</value>
|
||||
<comment>The {0} is replaced in code. Singular form gender neutral of Participant.</comment>
|
||||
</data>
|
||||
<data name="ListFindPeople_Info" xml:space="preserve">
|
||||
<value>Use this to find people in the organization. You can search by geography and by name pattern ("Jo S" will match Joel Sander).</value>
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
using System.IO;
|
||||
using System.Web.UI;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Swarmops.Interface.Objects;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
||||
@@ -12,8 +14,17 @@ namespace Swarmops.Controls.Base
|
||||
{
|
||||
public MainMenuItem[] MainMenuData { get; set; }
|
||||
|
||||
private string _regularLocalized;
|
||||
private string _regularsLocalized;
|
||||
private string _regularshipLocalized;
|
||||
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
ParticipantTitle regular = CurrentOrganization.RegularLabel;
|
||||
_regularLocalized = Participant.Localized (regular);
|
||||
_regularsLocalized = Participant.Localized (regular, TitleVariant.Plural);
|
||||
_regularshipLocalized = Participant.Localized (regular, TitleVariant.Ship);
|
||||
|
||||
// TODO: Put a small cache on this
|
||||
|
||||
// TODO: Put plugins on it
|
||||
@@ -49,11 +60,13 @@ namespace Swarmops.Controls.Base
|
||||
localizedText = resourceObject.ToString();
|
||||
}
|
||||
}
|
||||
localizedText = localizedText.Replace ("[Regular]", _regularLocalized);
|
||||
// TODO IF APPLICABLE - add other [Regulars] [Regularship] etc.
|
||||
localizedText = Server.HtmlEncode (localizedText); // muy importante
|
||||
|
||||
if (menuItem.Type == MenuItemType.BuildNumber)
|
||||
{
|
||||
localizedText = GetBuildIdentity();
|
||||
localizedText = Swarmops.Logic.Support.Formatting.SwarmopsVersion;
|
||||
}
|
||||
|
||||
string iconSize = "40px";
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#<%=this.TextOrganizationName.ClientID %>').focus();
|
||||
$(document).ready(function() {
|
||||
$('#<%= TextOrganizationName.ClientID %>').focus();
|
||||
});
|
||||
|
||||
function validateFields() {
|
||||
@@ -24,7 +24,7 @@
|
||||
<Swarmops5:DropDown runat="server" ID="DropCurrencies"/>​<br/>
|
||||
<Swarmops5:DropDown runat="server" ID="DropPersonLabel" />​<br/>
|
||||
<Swarmops5:DropDown runat="server" ID="DropActivistLabel" />​<br/>
|
||||
<asp:Button ID="ButtonCreate" runat="server" CssClass="buttonAccentColor NoInputFocus" OnClientClick="return validateFields();" OnClick="ButtonCreate_Click" Text="CreateXYZ"/>
|
||||
<asp:Button ID="ButtonCreate" runat="server" CssClass="buttonAccentColor NoInputFocus" OnClientClick=" return validateFields(); " OnClick="ButtonCreate_Click" Text="CreateXYZ"/>
|
||||
</div>
|
||||
<div class="entryLabels">
|
||||
<asp:Label runat="server" ID="LabelOrganizationName" /><br/>
|
||||
@@ -33,7 +33,7 @@
|
||||
<asp:Label runat="server" ID="LabelPersonLabel" /><br/>
|
||||
<asp:Label runat="server" ID="LabelActivistLabel" />
|
||||
</div>
|
||||
<div style="clear:both"></div>
|
||||
<div style="clear: both"></div>
|
||||
</asp:Content>
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using Resources;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Swarm;
|
||||
@@ -11,7 +12,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
{
|
||||
public partial class CreateOrganization : PageV5Base
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
this.BoxTitle.Text = PageTitle = Resources.Pages.Admin.CreateOrganization_PageTitle;
|
||||
PageIcon = "iconshock-organization-add";
|
||||
@@ -33,40 +34,40 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
this.LabelNativeCurrency.Text = Resources.Pages.Admin.CreateOrganization_NewOrgCurrency;
|
||||
this.LabelPersonLabel.Text = Resources.Pages.Admin.CreateOrganization_RegularTitle;
|
||||
|
||||
this.ButtonCreate.Text = Resources.Global.Global_Create;
|
||||
this.ButtonCreate.Text = Global.Global_Create;
|
||||
|
||||
this.DropPersonLabel.Items.Clear();
|
||||
this.DropActivistLabel.Items.Clear();
|
||||
this.DropCurrencies.Items.Clear();
|
||||
this.DropCreateChild.Items.Clear();
|
||||
this.DropPersonLabel.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0"));
|
||||
this.DropActivistLabel.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0"));
|
||||
this.DropCurrencies.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0"));
|
||||
this.DropCreateChild.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0"));
|
||||
this.DropPersonLabel.Items.Add (new ListItem (Global.Global_SelectOne, "0"));
|
||||
this.DropActivistLabel.Items.Add (new ListItem (Global.Global_SelectOne, "0"));
|
||||
this.DropCurrencies.Items.Add (new ListItem (Global.Global_SelectOne, "0"));
|
||||
this.DropCreateChild.Items.Add (new ListItem (Global.Global_SelectOne, "0"));
|
||||
|
||||
|
||||
this.DropCreateChild.Items.Add(new ListItem(Resources.Pages.Admin.CreateOrganization_AsRoot, "Root"));
|
||||
this.DropCreateChild.Items.Add(
|
||||
new ListItem(
|
||||
String.Format(Resources.Pages.Admin.CreateOrganization_ChildOfX, CurrentOrganization.Name), "Child"));
|
||||
this.DropCreateChild.Items.Add (new ListItem (Resources.Pages.Admin.CreateOrganization_AsRoot, "Root"));
|
||||
this.DropCreateChild.Items.Add (
|
||||
new ListItem (
|
||||
String.Format (Resources.Pages.Admin.CreateOrganization_ChildOfX, CurrentOrganization.Name), "Child"));
|
||||
|
||||
List<string> localizedPersonLabels = new List<string>();
|
||||
|
||||
foreach (ParticipantTitle title in (ParticipantTitle[]) Enum.GetValues(typeof(ParticipantTitle)))
|
||||
foreach (ParticipantTitle title in (ParticipantTitle[]) Enum.GetValues (typeof (ParticipantTitle)))
|
||||
{
|
||||
string localizedPersonLabel =
|
||||
Participant.Localized(title, TitleVariant.Plural);
|
||||
Participant.Localized (title, TitleVariant.Plural);
|
||||
|
||||
localizedPersonLabels.Add(localizedPersonLabel + "|" + title.ToString());
|
||||
localizedPersonLabels.Add (localizedPersonLabel + "|" + title);
|
||||
}
|
||||
|
||||
localizedPersonLabels.Sort(); // Sorts _localized_
|
||||
|
||||
foreach (string localizedPersonLabel in localizedPersonLabels)
|
||||
{
|
||||
string[] parts = localizedPersonLabel.Split('|');
|
||||
this.DropPersonLabel.Items.Add(new ListItem(parts[0], parts[1]));
|
||||
this.DropActivistLabel.Items.Add(new ListItem(parts[0], parts[1]));
|
||||
string[] parts = localizedPersonLabel.Split ('|');
|
||||
this.DropPersonLabel.Items.Add (new ListItem (parts[0], parts[1]));
|
||||
this.DropActivistLabel.Items.Add (new ListItem (parts[0], parts[1]));
|
||||
}
|
||||
|
||||
Currencies currencies = Currencies.GetAll();
|
||||
@@ -75,39 +76,40 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
|
||||
foreach (Currency currency in currencies)
|
||||
{
|
||||
currencyStrings.Add(String.Format("{0} {1}|{0}", currency.Code, currency.Name));
|
||||
currencyStrings.Add (String.Format ("{0} {1}|{0}", currency.Code, currency.Name));
|
||||
}
|
||||
|
||||
currencyStrings.Sort();
|
||||
|
||||
foreach (string currencyString in currencyStrings)
|
||||
{
|
||||
string[] parts = currencyString.Split('|');
|
||||
string[] parts = currencyString.Split ('|');
|
||||
|
||||
this.DropCurrencies.Items.Add(new ListItem(parts[0], parts[1]));
|
||||
this.DropCurrencies.Items.Add (new ListItem (parts[0], parts[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void ButtonCreate_Click(object sender, EventArgs e)
|
||||
protected void ButtonCreate_Click (object sender, EventArgs e)
|
||||
{
|
||||
string activistLabel = this.DropActivistLabel.SelectedValue;
|
||||
ParticipantTitle peopleLabel = (ParticipantTitle)(Enum.Parse(typeof(ParticipantTitle),this.DropPersonLabel.SelectedValue));
|
||||
ParticipantTitle peopleLabel =
|
||||
(ParticipantTitle) (Enum.Parse (typeof (ParticipantTitle), this.DropPersonLabel.SelectedValue));
|
||||
string asRoot = this.DropCreateChild.SelectedValue;
|
||||
string currencyCode = this.DropCurrencies.SelectedValue;
|
||||
string newOrgName = this.TextOrganizationName.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(newOrgName))
|
||||
if (string.IsNullOrEmpty (newOrgName))
|
||||
{
|
||||
throw new ArgumentException("Organization name can't be empty");
|
||||
throw new ArgumentException ("Organization name can't be empty");
|
||||
}
|
||||
|
||||
if (activistLabel == "0" || peopleLabel == ParticipantTitle.Unknown || asRoot == "0" || currencyCode == "0")
|
||||
{
|
||||
throw new ArgumentException("Necessary argument was not supplied (did client-side validation run?)");
|
||||
throw new ArgumentException ("Necessary argument was not supplied (did client-side validation run?)");
|
||||
}
|
||||
|
||||
Currency newOrgCurrency = Currency.FromCode(currencyCode);
|
||||
Currency newOrgCurrency = Currency.FromCode (currencyCode);
|
||||
Organization parent = CurrentOrganization;
|
||||
|
||||
if (asRoot == "Root")
|
||||
@@ -115,25 +117,25 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
parent = null;
|
||||
}
|
||||
|
||||
Organization newOrganization = Organization.Create(parent == null ? 0 : parent.Identity, newOrgName,
|
||||
Organization newOrganization = Organization.Create (parent == null ? 0 : parent.Identity, newOrgName,
|
||||
newOrgName, newOrgName, string.Empty, newOrgName, Geography.RootIdentity, true, true, 0);
|
||||
newOrganization.EnableEconomy(newOrgCurrency);
|
||||
newOrganization.EnableEconomy (newOrgCurrency);
|
||||
|
||||
newOrganization.RegularLabel = peopleLabel;
|
||||
newOrganization.ActivistLabel = activistLabel;
|
||||
|
||||
Membership.Create(CurrentUser, newOrganization, DateTime.UtcNow.AddYears(2));
|
||||
Membership.Create (CurrentUser, newOrganization, DateTime.UtcNow.AddYears (2));
|
||||
|
||||
string successMessage = String.Format (Resources.Pages.Admin.CreateOrganization_Success,
|
||||
Participant.Localized (peopleLabel, TitleVariant.Ship));
|
||||
|
||||
Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode(successMessage)));
|
||||
Response.AppendCookie (new HttpCookie ("DashboardMessage", HttpUtility.UrlEncode (successMessage)));
|
||||
|
||||
// Log in to new organization, then redirect to Edit
|
||||
|
||||
Response.Redirect(
|
||||
Response.Redirect (
|
||||
"/Pages/v5/Security/SetCurrentOrganization.aspx?OrganizationId=" +
|
||||
newOrganization.Identity.ToString(CultureInfo.InvariantCulture) +
|
||||
newOrganization.Identity.ToString (CultureInfo.InvariantCulture) +
|
||||
"&ReturnUrl=/Pages/v5/Admin/EditOrganization.aspx", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="EditOrganization.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.EditOrganization" %>
|
||||
<%@ Import Namespace="Resources" %>
|
||||
<%@ Register tagPrefix="Swarmops5" tagName="FileUpload" src="~/Controls/v5/Base/FileUpload.ascx" %>
|
||||
<%@ Register tagPrefix="Swarmops5" tagName="DropDown" src="~/Controls/v5/Base/DropDown.ascx" %>
|
||||
|
||||
@@ -9,9 +10,9 @@
|
||||
$(document).ready(function() {
|
||||
$('#divTabs').tabs();
|
||||
$('.EditCheck').switchbutton({
|
||||
checkedLabel: '<%=Resources.Global.Global_On.ToUpperInvariant() %>',
|
||||
uncheckedLabel: '<%=Resources.Global.Global_Off.ToUpperInvariant() %>',
|
||||
}).change(function () {
|
||||
checkedLabel: '<%= Global.Global_On.ToUpperInvariant() %>',
|
||||
uncheckedLabel: '<%= Global.Global_Off.ToUpperInvariant() %>',
|
||||
}).change(function() {
|
||||
|
||||
if (suppressSwitchResponse) {
|
||||
return;
|
||||
@@ -29,7 +30,7 @@
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
success: function(msg) {
|
||||
if (msg.d.Success) {
|
||||
alertify.log(msg.d.DisplayMessage);
|
||||
if (msg.d.RequireForex && !($('#CheckEnableForex').prop("checked"))) {
|
||||
@@ -42,7 +43,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (msg) {
|
||||
error: function(msg) {
|
||||
// TODO: Reset switch, protest server unreachable
|
||||
}
|
||||
|
||||
@@ -57,10 +58,10 @@
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
success: function(msg) {
|
||||
initializeSettings(msg.d);
|
||||
},
|
||||
error: function (msg) {
|
||||
error: function(msg) {
|
||||
// TODO: try again? bail out?
|
||||
alert("The server did not respond with the organization's current settings.");
|
||||
}
|
||||
@@ -85,16 +86,15 @@
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.IconEdit {
|
||||
cursor: pointer;
|
||||
}
|
||||
#IconCloseEdit {
|
||||
cursor: pointer;
|
||||
|
||||
}
|
||||
.CheckboxContainer {
|
||||
float: right; padding-top: 6px;padding-right: 8px;
|
||||
}
|
||||
.IconEdit { cursor: pointer; }
|
||||
|
||||
#IconCloseEdit { cursor: pointer; }
|
||||
|
||||
.CheckboxContainer {
|
||||
float: right;
|
||||
padding-top: 6px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
Enable foreign currency accounts?<br/>
|
||||
Enable Value Added Tax (VAT)?<br/>
|
||||
</div>
|
||||
<div id="divUseAccountPlan" style="display: none; width:100%; text-align:center; margin-top:20px; margin-bottom: 20px; border-top: 1px solid <%=CommonV5.GetColor(ColorType.Base, ColorVariant.Light)%>; border-bottom: 1px solid <%=CommonV5.GetColor(ColorType.Base, ColorVariant.Light)%>; background-color: <%=CommonV5.GetColor(ColorType.Base, ColorVariant.XLight)%>">
|
||||
<div id="divUseAccountPlan" style="display: none; width: 100%; text-align: center; margin-top: 20px; margin-bottom: 20px; border-top: 1px solid <%= CommonV5.GetColor (ColorType.Base, ColorVariant.Light) %>; border-bottom: 1px solid <%= CommonV5.GetColor (ColorType.Base, ColorVariant.Light) %>; background-color: <%= CommonV5.GetColor (ColorType.Base, ColorVariant.XLight) %>">
|
||||
Use the <a href="/Pages/v5/Ledgers/AccountPlan.aspx">Account Plan</a> page to set detailed parameters for these accounts, once enabled.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,12 +11,12 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
{
|
||||
public partial class EditOrganization : PageV5Base
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
PageIcon = "iconshock-box-cog";
|
||||
PageTitle = Resources.Pages.Admin.EditOrganization_PageTitle;
|
||||
InfoBoxLiteral = Resources.Pages.Admin.EditOrganization_Info;
|
||||
PageAccessRequired = new Access(CurrentOrganization, AccessAspect.Administration, AccessType.Write);
|
||||
PageAccessRequired = new Access (CurrentOrganization, AccessAspect.Administration, AccessType.Write);
|
||||
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
@@ -35,69 +35,69 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
string participantship = Participant.Localized (CurrentOrganization.RegularLabel, TitleVariant.Ship);
|
||||
|
||||
this.LabelParticipationEntry.Text =
|
||||
String.Format(Resources.Pages.Admin.EditOrganization_ParticipationBeginsWhen, participants);
|
||||
String.Format (Resources.Pages.Admin.EditOrganization_ParticipationBeginsWhen, participants);
|
||||
this.LabelParticipationOrg.Text =
|
||||
String.Format(Resources.Pages.Admin.EditOrganization_ParticipationBeginsOrg, participants);
|
||||
String.Format (Resources.Pages.Admin.EditOrganization_ParticipationBeginsOrg, participants);
|
||||
this.LabelParticipationDuration.Text =
|
||||
String.Format(Resources.Pages.Admin.EditOrganization_ParticipationDuration, participantship);
|
||||
String.Format (Resources.Pages.Admin.EditOrganization_ParticipationDuration, participantship);
|
||||
this.LabelParticipationChurn.Text =
|
||||
String.Format(Resources.Pages.Admin.EditOrganization_ParticipationChurn, participantship);
|
||||
String.Format (Resources.Pages.Admin.EditOrganization_ParticipationChurn, participantship);
|
||||
this.LabelRenewalCost.Text =
|
||||
String.Format(Resources.Pages.Admin.EditOrganization_RenewalsCost,
|
||||
String.Format (Resources.Pages.Admin.EditOrganization_RenewalsCost,
|
||||
CurrentOrganization.Currency.DisplayCode);
|
||||
this.LabelParticipationCost.Text =
|
||||
String.Format(Resources.Pages.Admin.EditOrganization_ParticipationCost,
|
||||
String.Format (Resources.Pages.Admin.EditOrganization_ParticipationCost,
|
||||
participantship, CurrentOrganization.Currency.DisplayCode);
|
||||
|
||||
this.LabelRenewalsAffect.Text = Resources.Pages.Admin.EditOrganization_RenewalsAffect;
|
||||
this.LabelRenewalDateEffect.Text = Resources.Pages.Admin.EditOrganization_RenewalDateEffect;
|
||||
this.LabelRenewalReminder.Text = Resources.Pages.Admin.EditOrganization_RenewalReminders;
|
||||
this.LabelMemberNumber.Text =
|
||||
String.Format(Resources.Pages.Admin.EditOrganization_MemberNumberStyle, participantship);
|
||||
String.Format (Resources.Pages.Admin.EditOrganization_MemberNumberStyle, participantship);
|
||||
|
||||
this.DropMembersWhen.Items.Clear();
|
||||
this.DropMembersWhen.Items.Add(new ListItem("Application submitted", "Application"));
|
||||
this.DropMembersWhen.Items.Add(new ListItem("Application approved", "ApplicationApproval"));
|
||||
this.DropMembersWhen.Items.Add(new ListItem("Application submitted + paid", "ApplicationPayment"));
|
||||
this.DropMembersWhen.Items.Add(new ListItem("Application paid + approved", "ApplicationPaymentApproval"));
|
||||
this.DropMembersWhen.Items.Add(new ListItem("Invited and accepted", "InvitationAcceptance"));
|
||||
this.DropMembersWhen.Items.Add(new ListItem("Invited and paid", "InvitationPayment"));
|
||||
this.DropMembersWhen.Items.Add(new ListItem("Manual add only", "Manual"));
|
||||
this.DropMembersWhen.Items.Add (new ListItem ("Application submitted", "Application"));
|
||||
this.DropMembersWhen.Items.Add (new ListItem ("Application approved", "ApplicationApproval"));
|
||||
this.DropMembersWhen.Items.Add (new ListItem ("Application submitted + paid", "ApplicationPayment"));
|
||||
this.DropMembersWhen.Items.Add (new ListItem ("Application paid + approved", "ApplicationPaymentApproval"));
|
||||
this.DropMembersWhen.Items.Add (new ListItem ("Invited and accepted", "InvitationAcceptance"));
|
||||
this.DropMembersWhen.Items.Add (new ListItem ("Invited and paid", "InvitationPayment"));
|
||||
this.DropMembersWhen.Items.Add (new ListItem ("Manual add only", "Manual"));
|
||||
|
||||
this.DropMembersWhere.Items.Clear();
|
||||
this.DropMembersWhere.Items.Add(new ListItem("Root organization only", "Root"));
|
||||
this.DropMembersWhere.Items.Add(new ListItem("Most local org only", "Local"));
|
||||
this.DropMembersWhere.Items.Add(new ListItem("Root and most local org", "RootLocal"));
|
||||
this.DropMembersWhere.Items.Add(new ListItem("All applicable organizations", "All"));
|
||||
this.DropMembersWhere.Items.Add (new ListItem ("Root organization only", "Root"));
|
||||
this.DropMembersWhere.Items.Add (new ListItem ("Most local org only", "Local"));
|
||||
this.DropMembersWhere.Items.Add (new ListItem ("Root and most local org", "RootLocal"));
|
||||
this.DropMembersWhere.Items.Add (new ListItem ("All applicable organizations", "All"));
|
||||
|
||||
this.DropMembershipDuration.Items.Clear();
|
||||
this.DropMembershipDuration.Items.Add(new ListItem("One month", "OneMonth"));
|
||||
this.DropMembershipDuration.Items.Add(new ListItem("One year", "OneYear"));
|
||||
this.DropMembershipDuration.Items.Add(new ListItem("Two years", "TwoYears"));
|
||||
this.DropMembershipDuration.Items.Add(new ListItem("Five years", "FiveYears"));
|
||||
this.DropMembershipDuration.Items.Add(new ListItem("Forever", "Forever"));
|
||||
this.DropMembershipDuration.Items.Add (new ListItem ("One month", "OneMonth"));
|
||||
this.DropMembershipDuration.Items.Add (new ListItem ("One year", "OneYear"));
|
||||
this.DropMembershipDuration.Items.Add (new ListItem ("Two years", "TwoYears"));
|
||||
this.DropMembershipDuration.Items.Add (new ListItem ("Five years", "FiveYears"));
|
||||
this.DropMembershipDuration.Items.Add (new ListItem ("Forever", "Forever"));
|
||||
this.DropMembershipDuration.SelectedValue = "Year";
|
||||
|
||||
this.DropMembersChurn.Items.Clear();
|
||||
this.DropMembersChurn.Items.Add(new ListItem("Expiry date reached", "Expiry"));
|
||||
this.DropMembersChurn.Items.Add(new ListItem("Not paid final reminder", "NotPaid"));
|
||||
this.DropMembersChurn.Items.Add(new ListItem("Never", "Never"));
|
||||
this.DropMembersChurn.Items.Add (new ListItem ("Expiry date reached", "Expiry"));
|
||||
this.DropMembersChurn.Items.Add (new ListItem ("Not paid final reminder", "NotPaid"));
|
||||
this.DropMembersChurn.Items.Add (new ListItem ("Never", "Never"));
|
||||
|
||||
this.DropRenewalDateEffect.Items.Clear();
|
||||
this.DropRenewalDateEffect.Items.Add(new ListItem("Date of renewal", "RenewalDate"));
|
||||
this.DropRenewalDateEffect.Items.Add(new ListItem("Previous expiry", "FromExpiry"));
|
||||
this.DropRenewalDateEffect.Items.Add (new ListItem ("Date of renewal", "RenewalDate"));
|
||||
this.DropRenewalDateEffect.Items.Add (new ListItem ("Previous expiry", "FromExpiry"));
|
||||
|
||||
this.DropRenewalsAffect.Items.Clear();
|
||||
this.DropRenewalsAffect.Items.Add(new ListItem("All related organizations", "All"));
|
||||
this.DropRenewalsAffect.Items.Add(new ListItem("One organization at a time", "One"));
|
||||
this.DropRenewalsAffect.Items.Add (new ListItem ("All related organizations", "All"));
|
||||
this.DropRenewalsAffect.Items.Add (new ListItem ("One organization at a time", "One"));
|
||||
|
||||
this.DropRenewalReminder.Items.Clear();
|
||||
this.DropRenewalReminder.Items.Add(new ListItem("30, 14, 7, 1 days before", "Standard"));
|
||||
this.DropRenewalReminder.Items.Add(new ListItem("Never", "Never"));
|
||||
this.DropRenewalReminder.Items.Add (new ListItem ("30, 14, 7, 1 days before", "Standard"));
|
||||
this.DropRenewalReminder.Items.Add (new ListItem ("Never", "Never"));
|
||||
|
||||
this.DropMemberNumber.Items.Clear();
|
||||
this.DropMemberNumber.Items.Add(new ListItem("Global for installation", "Global"));
|
||||
this.DropMemberNumber.Items.Add(new ListItem("Local for each organzation", "Local"));
|
||||
this.DropMemberNumber.Items.Add (new ListItem ("Global for installation", "Global"));
|
||||
this.DropMemberNumber.Items.Add (new ListItem ("Local for each organzation", "Local"));
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
@@ -130,7 +130,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static CallResult SwitchToggled(string switchName, bool switchValue)
|
||||
public static CallResult SwitchToggled (string switchName, bool switchValue)
|
||||
{
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
@@ -158,13 +158,13 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
FinancialAccount coldAccount = authData.CurrentOrganization.FinancialAccounts.AssetsBitcoinCold;
|
||||
if (coldAccount == null)
|
||||
{
|
||||
coldAccount = FinancialAccount.Create(authData.CurrentOrganization, "Bitcoin Assets Cold",
|
||||
coldAccount = FinancialAccount.Create (authData.CurrentOrganization, "Bitcoin Assets Cold",
|
||||
FinancialAccountType.Asset, null);
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Cold Address 1",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Cold Address 1",
|
||||
FinancialAccountType.Asset, coldAccount);
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Cold Address 2 (rename these)",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Cold Address 2 (rename these)",
|
||||
FinancialAccountType.Asset, coldAccount);
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Cold Address... etc",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Cold Address... etc",
|
||||
FinancialAccountType.Asset, coldAccount);
|
||||
|
||||
authData.CurrentOrganization.FinancialAccounts.AssetsBitcoinCold = coldAccount;
|
||||
@@ -174,7 +174,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
}
|
||||
else
|
||||
{
|
||||
workAccounts.Add(coldAccount);
|
||||
workAccounts.Add (coldAccount);
|
||||
}
|
||||
break;
|
||||
case "BitcoinHot":
|
||||
@@ -187,7 +187,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
if (hotAccount == null)
|
||||
{
|
||||
authData.CurrentOrganization.FinancialAccounts.AssetsBitcoinHot =
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Bitcoin Wallet Hot",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Bitcoin Wallet Hot",
|
||||
FinancialAccountType.Asset, null);
|
||||
|
||||
result.DisplayMessage =
|
||||
@@ -195,7 +195,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
}
|
||||
else
|
||||
{
|
||||
workAccounts.Add(hotAccount);
|
||||
workAccounts.Add (hotAccount);
|
||||
}
|
||||
break;
|
||||
case "Forex":
|
||||
@@ -212,10 +212,10 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
}
|
||||
|
||||
authData.CurrentOrganization.FinancialAccounts.IncomeCurrencyFluctuations =
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Forex holding gains",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Forex holding gains",
|
||||
FinancialAccountType.Income, null);
|
||||
authData.CurrentOrganization.FinancialAccounts.CostsCurrencyFluctuations =
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Forex holding losses",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Forex holding losses",
|
||||
FinancialAccountType.Cost, null);
|
||||
|
||||
result.DisplayMessage =
|
||||
@@ -243,8 +243,8 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
}
|
||||
else
|
||||
{
|
||||
workAccounts.Add(forexGain);
|
||||
workAccounts.Add(forexLoss);
|
||||
workAccounts.Add (forexGain);
|
||||
workAccounts.Add (forexLoss);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -260,10 +260,10 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
}
|
||||
|
||||
authData.CurrentOrganization.FinancialAccounts.AssetsVatInbound =
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Inbound VAT",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Inbound VAT",
|
||||
FinancialAccountType.Asset, null);
|
||||
authData.CurrentOrganization.FinancialAccounts.DebtsVatOutbound =
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Outbound VAT",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Outbound VAT",
|
||||
FinancialAccountType.Debt, null);
|
||||
|
||||
result.DisplayMessage = "Inbound and outbound VAT accounts were created.";
|
||||
@@ -275,8 +275,8 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
workAccounts.Add(vatInbound);
|
||||
workAccounts.Add(vatOutbound);
|
||||
workAccounts.Add (vatInbound);
|
||||
workAccounts.Add (vatOutbound);
|
||||
}
|
||||
break;
|
||||
case "Paypal":
|
||||
@@ -284,21 +284,21 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
if (assetsPaypal == null)
|
||||
{
|
||||
authData.CurrentOrganization.FinancialAccounts.AssetsPaypal =
|
||||
FinancialAccount.Create(authData.CurrentOrganization, "Paypal account",
|
||||
FinancialAccount.Create (authData.CurrentOrganization, "Paypal account",
|
||||
FinancialAccountType.Asset, null);
|
||||
|
||||
result.DisplayMessage = "An account was created for Paypal account tracking.";
|
||||
}
|
||||
else
|
||||
{
|
||||
workAccounts.Add(assetsPaypal);
|
||||
workAccounts.Add (assetsPaypal);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (workAccounts.Count > 0 && String.IsNullOrEmpty(result.DisplayMessage))
|
||||
if (workAccounts.Count > 0 && String.IsNullOrEmpty (result.DisplayMessage))
|
||||
{
|
||||
if (switchValue) // switch has been turned on
|
||||
{
|
||||
@@ -326,7 +326,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
|
||||
foreach (FinancialAccount account in workAccounts)
|
||||
{
|
||||
if (account.GetLastRows(5).Count > 0)
|
||||
if (account.GetLastRows (5).Count > 0)
|
||||
{
|
||||
transactionsOnAccount = true;
|
||||
}
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
|
||||
<script type="text/javascript" language="javascript">
|
||||
$(document).ready(function() {
|
||||
UpdatePostalPrefix('XX', $('#<%=DropCountries.ClientControlID%>').val());
|
||||
UpdatePostalPrefix('XX', $('#<%= DropCountries.ClientControlID %>').val());
|
||||
|
||||
$('#<%=this.TextPostal.ClientID%>').on('input', function() {
|
||||
$('#<%= TextPostal.ClientID %>').on('input', function() {
|
||||
if (CheckPostalCode()) {
|
||||
if ($('#<%=this.TextPostal.ClientID%>').val().length == postalCodeLength) {
|
||||
$('#<%=this.TextDateOfBirth.ClientID%>').focus();
|
||||
if ($('#<%= TextPostal.ClientID %>').val().length == postalCodeLength) {
|
||||
$('#<%= TextDateOfBirth.ClientID %>').focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#<%=this.TextCity.ClientID%>').on('input', function () {
|
||||
$('#<%= TextCity.ClientID %>').on('input', function() {
|
||||
CheckPostalCity();
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
});
|
||||
|
||||
function CheckPostalCity() {
|
||||
var currentCity = $('#<%=this.TextCity.ClientID%>').val().toLowerCase();
|
||||
var currentCity = $('#<%= TextCity.ClientID %>').val().toLowerCase();
|
||||
if (currentCity in cityNameLookup) {
|
||||
var geoId = cityNameLookup[currentCity];
|
||||
$('#spanDetectedGeo').text(geographyIdLookup[geoId]);
|
||||
@@ -33,18 +33,18 @@
|
||||
}
|
||||
|
||||
function CheckPostalCode() {
|
||||
var currentPostalCode = $('#<%=this.TextPostal.ClientID%>').val().toLowerCase();
|
||||
var currentPostalCode = $('#<%= TextPostal.ClientID %>').val().toLowerCase();
|
||||
if (currentPostalCode.length > postalCodeLengthCheck) {
|
||||
currentPostalCode = currentPostalCode.substring(0, postalCodeLengthCheck);
|
||||
}
|
||||
if (currentPostalCode in postalCodeLookup) {
|
||||
var cityId = postalCodeLookup[currentPostalCode];
|
||||
$('#<%=this.TextCity.ClientID%>').attr("disabled", "disabled").val(cityIdLookup[cityId].Name);
|
||||
$('#<%= TextCity.ClientID %>').attr("disabled", "disabled").val(cityIdLookup[cityId].Name);
|
||||
$('#spanDetectedGeo').text(geographyIdLookup[cityIdLookup[cityId].GeoId]);
|
||||
postalCodeIdentified = true;
|
||||
return true;
|
||||
} else if (postalCodeIdentified) {
|
||||
$('#<%=this.TextCity.ClientID%>').removeAttr("disabled").val('');
|
||||
$('#<%= TextCity.ClientID %>').removeAttr("disabled").val('');
|
||||
$('#spanDetectedGeo').text('');
|
||||
postalCodeIdentified = false;
|
||||
}
|
||||
@@ -56,12 +56,12 @@
|
||||
var postalTargetLength = postalCodeLength * 15 - 5;
|
||||
var cityTargetLength = 235 - 15 * postalCodeLength;
|
||||
|
||||
$('#<%=this.TextPostal.ClientID%>').animate({ width: postalTargetLength + "px" });
|
||||
$('#<%=this.TextCity.ClientID%>').animate({ width: cityTargetLength + "px" });
|
||||
$('#<%= TextPostal.ClientID %>').animate({ width: postalTargetLength + "px" });
|
||||
$('#<%= TextCity.ClientID %>').animate({ width: cityTargetLength + "px" });
|
||||
|
||||
if (!postalCodeVisible) {
|
||||
setTimeout(function() {
|
||||
$('#<%=this.TextPostal.ClientID%>').fadeIn(200);
|
||||
$('#<%= TextPostal.ClientID %>').fadeIn(200);
|
||||
}, 100);
|
||||
$('#spanLabelPostal').animate({ width: 'toggle' }, 400);
|
||||
postalCodeVisible = true;
|
||||
@@ -70,8 +70,8 @@
|
||||
} else if (postalCodeVisible) {
|
||||
// Remove postal code altogether, if visible now
|
||||
|
||||
$('#<%=this.TextPostal.ClientID%>').animate({ width: 0 }, 200).fadeOut(100);
|
||||
$('#<%=this.TextCity.ClientID%>').animate({ width: "255px" }, 600);
|
||||
$('#<%= TextPostal.ClientID %>').animate({ width: 0 }, 200).fadeOut(100);
|
||||
$('#<%= TextCity.ClientID %>').animate({ width: "255px" }, 600);
|
||||
$('#spanLabelPostal').animate({ width: 'toggle' }, 400);
|
||||
|
||||
postalCodeVisible = false;
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
function UpdatePostalPrefix(oldValue, newValue) {
|
||||
$('#spanCountryPrefix').text(newValue);
|
||||
$('#<%=this.TextCity.ClientID%>').removeAttr("disabled").val('');
|
||||
$('#<%= TextCity.ClientID %>').removeAttr("disabled").val('');
|
||||
$('#spanDetectedGeo').text('');
|
||||
|
||||
// Get postal code data for country. Heavy op; should not be done from mobile
|
||||
@@ -94,7 +94,7 @@
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
success: function(msg) {
|
||||
postalCodeLookup = {};
|
||||
cityIdLookup = {};
|
||||
cityNameLookup = {};
|
||||
@@ -102,8 +102,8 @@
|
||||
|
||||
postalCodeLength = msg.d.PostalCodeLength;
|
||||
postalCodeLengthCheck = msg.d.PostalCodeLengthCheck;
|
||||
$('#<%=TextPostal.ClientID%>').attr('maxlength', postalCodeLength).attr('placeholder', '12345678'.substring(0, postalCodeLength));
|
||||
msg.d.PostalCodes.forEach(function (element, index, array) {
|
||||
$('#<%= TextPostal.ClientID %>').attr('maxlength', postalCodeLength).attr('placeholder', '12345678'.substring(0, postalCodeLength));
|
||||
msg.d.PostalCodes.forEach(function(element, index, array) {
|
||||
postalCodeLookup[element.Code.toLowerCase()] = element.CityId;
|
||||
});
|
||||
msg.d.CityNames.forEach(function(element, index, array) {
|
||||
@@ -119,7 +119,7 @@
|
||||
AnimatePostalCodeLength();
|
||||
CheckPostalCode();
|
||||
},
|
||||
error: function (msg) {
|
||||
error: function(msg) {
|
||||
console.log(msg);
|
||||
geographyIdLookup = {};
|
||||
postalCodeLookup = {};
|
||||
@@ -132,12 +132,10 @@
|
||||
function ValidateFields() {
|
||||
var isValid = true;
|
||||
|
||||
isValid = ValidateTextField('#<%=this.TextCity.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorCity" />") && isValid;
|
||||
isValid = ValidateTextField('#<%=this.TextStreet1.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorStreet" />") && isValid;
|
||||
isValid = ValidateTextField('#<%=this.TextMail.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorMail" />") && isValid;
|
||||
isValid = ValidateTextField('#<%=this.TextName.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorName" />") && isValid;
|
||||
|
||||
// TODO: Actually validate geography?
|
||||
isValid = ValidateTextField('#<%= TextCity.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorCity" />") && isValid;
|
||||
isValid = ValidateTextField('#<%= TextStreet1.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorStreet" />") && isValid;
|
||||
isValid = ValidateTextField('#<%= TextMail.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorMail" />") && isValid;
|
||||
isValid = ValidateTextField('#<%= TextName.ClientID %>', "<asp:Literal runat="server" ID="LiteralErrorName" />") && isValid; // TODO: Actually validate geography?
|
||||
|
||||
return isValid;
|
||||
}
|
||||
@@ -164,42 +162,41 @@
|
||||
var postalCodeIdentified = false;
|
||||
|
||||
var onDocReadyAlert = '<asp:Literal ID="LiteralLoadAlert" runat="server" />';
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
|
||||
<h2>Adding [Regular]</h2>
|
||||
<h2><asp:Label runat="server" ID="BoxTitle" /></h2>
|
||||
<div class="entryFields">
|
||||
<asp:TextBox runat="server" ID="TextName" />​<br/>
|
||||
<Swarmops5:DropDown runat="server" OnClientChange="UpdatePostalPrefix" ID="DropCountries"/>​<br/>
|
||||
<Swarmops5:DropDown runat="server" OnClientChange=" UpdatePostalPrefix " ID="DropCountries"/>​<br/>
|
||||
<asp:TextBox runat="server" ID="TextMail" />​<br/>
|
||||
<asp:TextBox runat="server" ID="TextPhone" />​<br/>
|
||||
<br/>
|
||||
<asp:TextBox runat="server" ID="TextStreet1" />​<br/>
|
||||
<asp:TextBox runat="server" ID="TextStreet2" />​<br/>
|
||||
<div style="float:right;margin-right:5px"><asp:TextBox runat="server" ID="TextPostal" /> <asp:TextBox runat="server" ID="TextCity" /></div><div style="width:40px;overflow:hidden"><span id="spanCountryPrefix">XX</span>–</div>
|
||||
<div style="float: right; margin-right: 5px"><asp:TextBox runat="server" ID="TextPostal" /> <asp:TextBox runat="server" ID="TextCity" /></div><div style="width: 40px; overflow: hidden"><span id="spanCountryPrefix">XX</span>–</div>
|
||||
<span id="spanDetectedGeo">...</span> <br/>
|
||||
<br/>
|
||||
<asp:TextBox runat="server" ID="TextDateOfBirth" />​<br/>
|
||||
<Swarmops5:DropDown runat="server" ID="DropGenders" />​<br/>
|
||||
<asp:Button ID="ButtonSubmit" runat="server" CssClass="buttonAccentColor NoInputFocus" OnClientClick="return ValidateFields();" OnClick="ButtonSubmit_Click" Text="Register"/>
|
||||
<asp:Button ID="ButtonSubmit" runat="server" CssClass="buttonAccentColor NoInputFocus" OnClientClick=" return ValidateFields(); " OnClick="ButtonSubmit_Click" Text="Register"/>
|
||||
</div>
|
||||
<div class="entryLabels">
|
||||
Name<br />
|
||||
Country<br />
|
||||
Mail<br />
|
||||
Phone<br />
|
||||
<h2>ADDRESS</h2>
|
||||
Street 1 or P.O.<br />
|
||||
Street 2 (optional)<br />
|
||||
<span id="spanLabelPostal" style="display:inline-block; overflow: hidden">Postal Code, </span><span style="display:inline-block; overflow: hidden">City</span><br />
|
||||
<span id="SpanGeoDetected">Geography detected</span><span id="SpanGeoSelect" style="display:none">Select Geograhpy</span><br />
|
||||
<h2>STATISTICAL DATA</h2>
|
||||
Date of Birth<br />
|
||||
Legal gender<br />
|
||||
<asp:Label ID="LabelName" runat="server" /><br />
|
||||
<asp:Label ID="LabelCountry" runat="server" /><br />
|
||||
<asp:Label ID="LabelMail" runat="server" /><br />
|
||||
<asp:Label ID="LabelPhone" runat="server" /><br />
|
||||
<h2><asp:Label ID="LabelHeaderAddresss" runat="server" /></h2>
|
||||
<asp:Label ID="LabelStreet1" runat="server" /><br />
|
||||
<asp:Label ID="LabelStreet2" runat="server" /><br />
|
||||
<span id="spanLabelPostal" style="display: inline-block; overflow: hidden"><asp:Label ID="LabelPostalCode" runat="server" />, </span><span style="display: inline-block; overflow: hidden"><asp:Label runat="server" ID="LabelCity" /></span><br />
|
||||
<span id="SpanGeoDetected"><asp:Label ID="LabelGeographyDetected" runat="server" /></span><span id="SpanGeoSelect" style="display: none"><asp:Label ID="LabelSelectGeography" runat="server" Text="XYZ Select Geography" /></span><br />
|
||||
<h2><asp:Label ID="LabelHeaderStatData" runat="server" /></h2>
|
||||
<asp:Label ID="LabelDateOfBirth" runat="server" /><br />
|
||||
<asp:Label ID="LabelLegalGender" runat="server" /><br />
|
||||
</div>
|
||||
<div style="clear:both"></div>
|
||||
<div style="clear: both"></div>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Resources;
|
||||
using Swarmops.Logic.Communications;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Swarm;
|
||||
@@ -13,7 +13,7 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
|
||||
{
|
||||
public partial class AddPerson : PageV5Base
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
// Override style widths - (this will cause problems with a future responsive design; come back here to fix that)
|
||||
|
||||
@@ -38,13 +38,13 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
|
||||
|
||||
foreach (Country country in allCountries)
|
||||
{
|
||||
string countryLocalName = GeographyNames.ResourceManager.GetString("Country_" + country.Code);
|
||||
if (string.IsNullOrEmpty(countryLocalName))
|
||||
string countryLocalName = GeographyNames.ResourceManager.GetString ("Country_" + country.Code);
|
||||
if (string.IsNullOrEmpty (countryLocalName))
|
||||
{
|
||||
countryLocalName = country.Name + "*"; // In English. Asterisk indicates resource missing.
|
||||
}
|
||||
string countryDisplay = country.Code + " " + countryLocalName;
|
||||
this.DropCountries.Items.Add(new ListItem(countryDisplay, country.Code));
|
||||
this.DropCountries.Items.Add (new ListItem (countryDisplay, country.Code));
|
||||
}
|
||||
|
||||
if (CurrentOrganization.DefaultCountry != null)
|
||||
@@ -53,9 +53,9 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
|
||||
}
|
||||
|
||||
this.DropGenders.Items.Clear();
|
||||
this.DropGenders.Items.Add(new ListItem(Global.Global_UnknownUndisclosed, "Unknown"));
|
||||
this.DropGenders.Items.Add(new ListItem(Global.Global_Female, "Female"));
|
||||
this.DropGenders.Items.Add(new ListItem(Global.Global_Male, "Male"));
|
||||
this.DropGenders.Items.Add (new ListItem (Global.Global_UnknownUndisclosed, "Unknown"));
|
||||
this.DropGenders.Items.Add (new ListItem (Global.Global_Female, "Female"));
|
||||
this.DropGenders.Items.Add (new ListItem (Global.Global_Male, "Male"));
|
||||
}
|
||||
|
||||
private void Localize()
|
||||
@@ -65,9 +65,25 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
|
||||
this.LiteralErrorName.Text = Resources.Pages.Swarm.AddPerson_ErrorName;
|
||||
this.LiteralErrorStreet.Text = Resources.Pages.Swarm.AddPerson_ErrorStreet;
|
||||
|
||||
InfoBoxLiteral = String.Format(Resources.Pages.Swarm.AddPerson_Info, Global.Timespan_OneYear,
|
||||
this.BoxTitle.Text = PageTitle = String.Format (Resources.Pages.Swarm.AddPerson_Title,
|
||||
Participant.Localized (CurrentOrganization.RegularLabel));
|
||||
InfoBoxLiteral = String.Format (Resources.Pages.Swarm.AddPerson_Info, Global.Timespan_OneYear,
|
||||
Participant.Localized (CurrentOrganization.RegularLabel, TitleVariant.Ship),
|
||||
DateTime.Today.AddYears(1).ToLongDateString());
|
||||
DateTime.Today.AddYears (1).ToLongDateString());
|
||||
|
||||
this.LabelName.Text = Resources.Global.Global_Name;
|
||||
this.LabelCountry.Text = Resources.Global.Global_Country;
|
||||
this.LabelMail.Text = Resources.Global.Global_Mail;
|
||||
this.LabelPhone.Text = Resources.Global.Global_Phone;
|
||||
this.LabelHeaderAddresss.Text = Resources.Global.Global_Address.ToUpperInvariant();
|
||||
this.LabelStreet1.Text = Resources.Pages.Swarm.AddPerson_Street1PO;
|
||||
this.LabelStreet2.Text = Resources.Pages.Swarm.AddPerson_Street2;
|
||||
this.LabelPostalCode.Text = Resources.Global.Global_PostalCode;
|
||||
this.LabelCity.Text = Resources.Global.Global_City;
|
||||
this.LabelHeaderStatData.Text = Resources.Pages.Swarm.AddPerson_StatisticalData;
|
||||
this.LabelDateOfBirth.Text = Resources.Global.Global_DateOfBirth;
|
||||
this.LabelLegalGender.Text = Resources.Pages.Swarm.AddPerson_LegalGender;
|
||||
|
||||
|
||||
this.TextDateOfBirth.Attributes["placeholder"] = Global.Global_DateFormatShortReadable;
|
||||
this.TextName.Attributes["placeholder"] = "Joe Smith";
|
||||
@@ -77,10 +93,9 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
|
||||
this.TextPostal.Attributes["placeholder"] = "12345";
|
||||
}
|
||||
|
||||
protected void ButtonSubmit_Click(object sender, EventArgs e)
|
||||
protected void ButtonSubmit_Click (object sender, EventArgs e)
|
||||
{
|
||||
string randomPassword = Authentication.CreateRandomPassword(24);
|
||||
|
||||
string randomPassword = Authentication.CreateRandomPassword (24);
|
||||
|
||||
|
||||
// Person.Create()
|
||||
|
||||
+85
-85
@@ -25,6 +25,7 @@
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
@@ -33,111 +34,110 @@
|
||||
<asp:ScriptManager runat="server" ID="ScriptManagerBlahblah" />
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(function() {
|
||||
|
||||
/* document.ready goes here */
|
||||
/* document.ready goes here */
|
||||
|
||||
setTimeout(function() {
|
||||
recheckLogin();
|
||||
}, 1000);
|
||||
setTimeout(function() {
|
||||
recheckLogin();
|
||||
}, 1000);
|
||||
|
||||
|
||||
$('.InputManualCredentials').on('input', function () {
|
||||
onInputCredentials();
|
||||
});
|
||||
$('.InputManualCredentials').on('input', function() {
|
||||
onInputCredentials();
|
||||
});
|
||||
|
||||
$('#TextLogin').focus();
|
||||
$('#TextLogin').focus();
|
||||
|
||||
}); // end of document.ready
|
||||
}); // end of document.ready
|
||||
|
||||
|
||||
var manualCredentialsTestTrigger;
|
||||
var manualCredentialsTestTrigger;
|
||||
|
||||
function onInputCredentials() {
|
||||
clearTimeout(manualCredentialsTestTrigger);
|
||||
function onInputCredentials() {
|
||||
clearTimeout(manualCredentialsTestTrigger);
|
||||
|
||||
manualCredentialsTestTrigger = setTimeout(function () {
|
||||
testManualCredentials();
|
||||
}, 1000);
|
||||
}
|
||||
manualCredentialsTestTrigger = setTimeout(function() {
|
||||
testManualCredentials();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function testManualCredentials() {
|
||||
// Submit credentials to server. If valid, they will validate through the recheckLogin call.
|
||||
function testManualCredentials() {
|
||||
// Submit credentials to server. If valid, they will validate through the recheckLogin call.
|
||||
|
||||
var jsonData = {};
|
||||
jsonData.credentialsLogin = $('#TextLogin').val();
|
||||
jsonData.credentialsPass = $('#TextPass').val();
|
||||
jsonData.credentials2FA = $('#Text2FA').val();
|
||||
jsonData.logonUriEncoded = bitIdUri;
|
||||
var jsonData = {};
|
||||
jsonData.credentialsLogin = $('#TextLogin').val();
|
||||
jsonData.credentialsPass = $('#TextPass').val();
|
||||
jsonData.credentials2FA = $('#Text2FA').val();
|
||||
jsonData.logonUriEncoded = bitIdUri;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "Login.aspx/TestCredentials",
|
||||
data: $.toJSON(jsonData),
|
||||
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
|
||||
}
|
||||
},
|
||||
error: function (msg) {
|
||||
// retry after a second
|
||||
setTimeout(function () {
|
||||
testManualCredentials();
|
||||
}, 1000);
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "Login.aspx/TestCredentials",
|
||||
data: $.toJSON(jsonData),
|
||||
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
|
||||
}
|
||||
},
|
||||
error: function(msg) {
|
||||
// retry after a second
|
||||
setTimeout(function() {
|
||||
testManualCredentials();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function recheckLogin() {
|
||||
function recheckLogin() {
|
||||
|
||||
var jsonData = {};
|
||||
jsonData.uriEncoded = bitIdUri;
|
||||
jsonData.nonce = bitIdNonce;
|
||||
var jsonData = {};
|
||||
jsonData.uriEncoded = bitIdUri;
|
||||
jsonData.nonce = bitIdNonce;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "Login.aspx/TestLogin",
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
if (msg.d) {
|
||||
// Login confirmed, fetch auth cookie from nonce in-context
|
||||
document.location = "/Security/FinalizeLogin.aspx?Nonce=" + bitIdNonce;
|
||||
} else {
|
||||
// Retry twice per second
|
||||
setTimeout(function () {
|
||||
recheckLogin();
|
||||
}, 500);
|
||||
}
|
||||
},
|
||||
error: function (msg) {
|
||||
// we don't want the polling to die just because of a transient error
|
||||
setTimeout(function () {
|
||||
recheckLogin();
|
||||
}, 1000);
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "Login.aspx/TestLogin",
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function(msg) {
|
||||
if (msg.d) {
|
||||
// Login confirmed, fetch auth cookie from nonce in-context
|
||||
document.location = "/Security/FinalizeLogin.aspx?Nonce=" + bitIdNonce;
|
||||
} else {
|
||||
// Retry twice per second
|
||||
setTimeout(function() {
|
||||
recheckLogin();
|
||||
}, 500);
|
||||
}
|
||||
},
|
||||
error: function(msg) {
|
||||
// we don't want the polling to die just because of a transient error
|
||||
setTimeout(function() {
|
||||
recheckLogin();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var bitIdUri = '<asp:Literal ID="LiteralUri" runat="server" />';
|
||||
var bitIdNonce = '<asp:Literal ID="LiteralNonce" runat="server" />';
|
||||
|
||||
</script>
|
||||
var bitIdUri = '<asp:Literal ID="LiteralUri" runat="server" />';
|
||||
var bitIdNonce = '<asp:Literal ID="LiteralNonce" runat="server" />';
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<!-- Main menu, emptied out here -->
|
||||
|
||||
<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"><asp:Label ID="LabelCurrentOrganizationName" runat="server" /> | </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><asp:Image ID="ImageCultureIndicator" runat="server" ImageUrl="~/Images/Flags/uk-24px.png" /></div>
|
||||
<div class="logoimage"><a href="/"><img style="border:none" src="/Security/Images/Swarmops-Logo.png" alt="Swarmops Logo" /></a></div>
|
||||
<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"><asp:Label ID="LabelCurrentOrganizationName" runat="server" /> | </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><asp:Image ID="ImageCultureIndicator" runat="server" ImageUrl="~/Images/Flags/uk-24px.png" /></div>
|
||||
<div class="logoimage"><a href="/"><img style="border: none" src="/Security/Images/Swarmops-Logo.png" alt="Swarmops Logo" /></a></div>
|
||||
<div class="break"></div>
|
||||
<div class="topmenu">
|
||||
<div class="searchbox"><asp:TextBox ID="SearchBox" ReadOnly="true" runat="server" /></div>
|
||||
@@ -167,11 +167,11 @@
|
||||
<h2 class="blue"><asp:Label ID="LabelSidebarManualLoginHeader" runat="server" /><span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content" style="line-height:24px">
|
||||
<div class="content" style="line-height: 24px">
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr><td><asp:Literal ID="LiteralCredentialsUser" runat="server" /> </td><td align="right"><input id="TextLogin" class="InputManualCredentials" type="text" /></td></tr>
|
||||
<tr><td><asp:Literal ID="LiteralCredentialsPass" runat="server" /> </td><td align="right"><input id="TextPass" class="InputManualCredentials" type="password" /></td></tr>
|
||||
<tr style="display:none"><td><asp:Literal id="LiteralCredentials2FA" runat="server" /> </td><td><input id="Text2FA" class="InputManualCredentials" type="password" /></td></tr>
|
||||
<tr style="display: none"><td><asp:Literal id="LiteralCredentials2FA" runat="server" /> </td><td><input id="Text2FA" class="InputManualCredentials" type="password" /></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -180,7 +180,7 @@
|
||||
<h2 class="blue">Dev's Cheat Button<span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content" style="line-height:14px">
|
||||
<div class="content" style="line-height: 14px">
|
||||
<p>Since we're running on localhost, on a nonstandard port, with a debugger attached, and under Windows, this is clearly not a production environment. Since it's unlikely that the outside Internet has access to this machine, which means you can't login with BitID, a cheat button has been provided for you.</p><p>Press the button below to log on as Sandbox Administrator.</p>
|
||||
|
||||
<div align="right"><asp:Button ID="ButtonCheat" runat="server" OnClick="ButtonCheat_Click" Text="Cheat Button" /></div>
|
||||
@@ -192,8 +192,8 @@
|
||||
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
<div class="link-row-encaps" onclick="return false;" >
|
||||
<div class="link-row-icon" style="background-image:url('/Images/Icons/iconshock-databaseconnect-16px.png')"></div>
|
||||
<div class="link-row-encaps" onclick=" return false; " >
|
||||
<div class="link-row-icon" style="background-image: url('/Images/Icons/iconshock-databaseconnect-16px.png')"></div>
|
||||
<asp:Label ID="LabelSidebarResetPassword" runat="server" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,8 +8,10 @@ using System.Web.Security;
|
||||
using System.Web.Services;
|
||||
using System.Web.UI;
|
||||
using NBitcoin;
|
||||
using Resources;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Cache;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
@@ -19,13 +21,13 @@ namespace Swarmops.Pages.Security
|
||||
{
|
||||
private static string _buildIdentity;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
// Check if this is the first run ever. If so, redirect to Init.
|
||||
|
||||
if (!SwarmDb.Configuration.IsConfigured())
|
||||
{
|
||||
Response.Redirect("/Pages/v5/Init/", true);
|
||||
Response.Redirect ("/Pages/v5/Init/", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,17 +52,17 @@ namespace Swarmops.Pages.Security
|
||||
signature = Request.Params["signature"]
|
||||
};
|
||||
|
||||
ProcessRespondBitId(credentials, Response);
|
||||
ProcessRespondBitId (credentials, Response);
|
||||
return;
|
||||
}
|
||||
if (Request.ContentType == "application/json")
|
||||
{
|
||||
BitIdCredentials credentials =
|
||||
new JavaScriptSerializer().Deserialize<BitIdCredentials>(
|
||||
new StreamReader(Request.InputStream).ReadToEnd());
|
||||
new JavaScriptSerializer().Deserialize<BitIdCredentials> (
|
||||
new StreamReader (Request.InputStream).ReadToEnd());
|
||||
// TODO: untested but seems to work. Throws?
|
||||
|
||||
ProcessRespondBitId(credentials, Response);
|
||||
ProcessRespondBitId (credentials, Response);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -69,13 +71,13 @@ namespace Swarmops.Pages.Security
|
||||
// If this is the Dev Sandbox, autologin
|
||||
|
||||
if (Request.Url.Host == "dev.swarmops.com" &&
|
||||
PilotInstallationIds.IsPilot(PilotInstallationIds.DevelopmentSandbox) &&
|
||||
PilotInstallationIds.IsPilot (PilotInstallationIds.DevelopmentSandbox) &&
|
||||
Request.QueryString["SuppressAutologin"] != "true")
|
||||
{
|
||||
Response.AppendCookie(new HttpCookie("DashboardMessage",
|
||||
HttpUtility.UrlEncode(
|
||||
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.RedirectFromLoginPage ("1,1", true);
|
||||
}
|
||||
|
||||
// Check for SSL and force it
|
||||
@@ -85,9 +87,9 @@ namespace Swarmops.Pages.Security
|
||||
string cloudFlareVisitorScheme = Request.Headers["CF-Visitor"];
|
||||
bool cloudFlareSsl = false;
|
||||
|
||||
if (!string.IsNullOrEmpty(cloudFlareVisitorScheme))
|
||||
if (!string.IsNullOrEmpty (cloudFlareVisitorScheme))
|
||||
{
|
||||
if (cloudFlareVisitorScheme.Contains("\"scheme\":\"https\""))
|
||||
if (cloudFlareVisitorScheme.Contains ("\"scheme\":\"https\""))
|
||||
{
|
||||
cloudFlareSsl = true;
|
||||
}
|
||||
@@ -97,13 +99,13 @@ namespace Swarmops.Pages.Security
|
||||
|
||||
// Rewrite if applicable
|
||||
|
||||
if (Request.Url.ToString().StartsWith("http://") && !cloudFlareSsl)
|
||||
if (Request.Url.ToString().StartsWith ("http://") && !cloudFlareSsl)
|
||||
// only check client-side as many server sites de-SSL the connection before reaching the web server
|
||||
{
|
||||
if (!Request.Url.ToString().StartsWith("http://dev.swarmops.com/") &&
|
||||
!Request.Url.ToString().StartsWith("http://localhost:"))
|
||||
if (!Request.Url.ToString().StartsWith ("http://dev.swarmops.com/") &&
|
||||
!Request.Url.ToString().StartsWith ("http://localhost:"))
|
||||
{
|
||||
Response.Redirect(Request.Url.ToString().Replace("http:", "https:"));
|
||||
Response.Redirect (Request.Url.ToString().Replace ("http:", "https:"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,35 +118,35 @@ namespace Swarmops.Pages.Security
|
||||
// Generate BitID tokens
|
||||
|
||||
Guid guid = Guid.NewGuid();
|
||||
string guidString = guid.ToString().Replace("-", "");
|
||||
string guidString = guid.ToString().Replace ("-", "");
|
||||
|
||||
string nonce = guidString + DateTime.UtcNow.Ticks.ToString("x8");
|
||||
string nonce = guidString + DateTime.UtcNow.Ticks.ToString ("x8");
|
||||
|
||||
string hostName = Request.Url.Host;
|
||||
|
||||
string bitIdUri = "bitid://" + hostName + "/Security/Login.aspx?x=" + nonce;
|
||||
|
||||
if (Request.Url.ToString().StartsWith("http://") && !cloudFlareSsl)
|
||||
if (Request.Url.ToString().StartsWith ("http://") && !cloudFlareSsl)
|
||||
{
|
||||
bitIdUri += "&u=1";
|
||||
}
|
||||
|
||||
this.LiteralUri.Text = HttpUtility.UrlEncode(bitIdUri);
|
||||
this.LiteralUri.Text = HttpUtility.UrlEncode (bitIdUri);
|
||||
this.LiteralNonce.Text = nonce;
|
||||
|
||||
GuidCache.Set(bitIdUri + "-Logon", "Unauth");
|
||||
GuidCache.Set (bitIdUri + "-Logon", "Unauth");
|
||||
|
||||
// TODO: need to NOT USE GOOGLE CHARTS for this but bring home a free QR package
|
||||
|
||||
this.ImageBitIdQr.ImageUrl =
|
||||
"https://chart.googleapis.com/chart?cht=qr&chs=400x400&chl=" + HttpUtility.UrlEncode(bitIdUri);
|
||||
"https://chart.googleapis.com/chart?cht=qr&chs=400x400&chl=" + HttpUtility.UrlEncode (bitIdUri);
|
||||
}
|
||||
|
||||
|
||||
protected void ProcessRespondBitId(BitIdCredentials credentials, HttpResponse response)
|
||||
protected void ProcessRespondBitId (BitIdCredentials credentials, HttpResponse response)
|
||||
{
|
||||
BitcoinAddress testAddress = new BitcoinAddress(credentials.address);
|
||||
if (testAddress.VerifyMessage(credentials.uri, credentials.signature))
|
||||
BitcoinAddress testAddress = new BitcoinAddress (credentials.address);
|
||||
if (testAddress.VerifyMessage (credentials.uri, credentials.signature))
|
||||
{
|
||||
// woooooo
|
||||
|
||||
@@ -152,27 +154,27 @@ namespace Swarmops.Pages.Security
|
||||
{
|
||||
if (CurrentUser != null)
|
||||
{
|
||||
if ((string) GuidCache.Get(credentials.uri + "-Intent") == "Register")
|
||||
if ((string) GuidCache.Get (credentials.uri + "-Intent") == "Register")
|
||||
{
|
||||
// the currently logged-on user desires to register this address
|
||||
// so set currentUser bitid
|
||||
CurrentUser.BitIdAddress = credentials.address;
|
||||
// Then go do something else, I guess? Flag somehow to original page
|
||||
// that the op is completed?
|
||||
GuidCache.Set(credentials.uri + "-Intent", "Complete");
|
||||
GuidCache.Set (credentials.uri + "-Intent", "Complete");
|
||||
}
|
||||
}
|
||||
|
||||
if (GuidCache.Get(credentials.uri + "-Logon") as string == "Unauth")
|
||||
if (GuidCache.Get (credentials.uri + "-Logon") as string == "Unauth")
|
||||
{
|
||||
Person person = Person.FromBitIdAddress(credentials.address);
|
||||
Person person = Person.FromBitIdAddress (credentials.address);
|
||||
|
||||
// TODO: If above throws, show friendly "unknown wallet" message
|
||||
|
||||
// TODO: Determine last logged-on organization. Right now, log on to Sandbox.
|
||||
|
||||
GuidCache.Set(credentials.uri + "-LoggedOn",
|
||||
person.Identity.ToString(CultureInfo.InvariantCulture) + ",1,,BitId 2FA");
|
||||
GuidCache.Set (credentials.uri + "-LoggedOn",
|
||||
person.Identity.ToString (CultureInfo.InvariantCulture) + ",1,,BitId 2FA");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -184,8 +186,8 @@ namespace Swarmops.Pages.Security
|
||||
|
||||
response.StatusCode = 200;
|
||||
response.SetJson();
|
||||
response.Write("{\"address\":\"" + credentials.address + "\",\"signature\":\"" + credentials.signature +
|
||||
"\"}");
|
||||
response.Write ("{\"address\":\"" + credentials.address + "\",\"signature\":\"" + credentials.signature +
|
||||
"\"}");
|
||||
response.End();
|
||||
}
|
||||
else
|
||||
@@ -195,30 +197,30 @@ namespace Swarmops.Pages.Security
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static bool TestLogin(string uriEncoded, string nonce)
|
||||
public static bool TestLogin (string uriEncoded, string nonce)
|
||||
{
|
||||
try
|
||||
{
|
||||
string uri = HttpUtility.UrlDecode(uriEncoded);
|
||||
string uri = HttpUtility.UrlDecode (uriEncoded);
|
||||
|
||||
// a little sloppy nonce and uri checking rather than full parsing
|
||||
// TODO: Full URI parse, the above is not enough
|
||||
if (!uri.Contains(nonce) || !uri.Contains(HttpContext.Current.Request.Url.Host))
|
||||
if (!uri.Contains (nonce) || !uri.Contains (HttpContext.Current.Request.Url.Host))
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
string result = (string) GuidCache.Get(uri + "-LoggedOn");
|
||||
if (string.IsNullOrEmpty(result))
|
||||
string result = (string) GuidCache.Get (uri + "-LoggedOn");
|
||||
if (string.IsNullOrEmpty (result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// We have a successful login when we get here
|
||||
|
||||
GuidCache.Delete(uri + "-Logon");
|
||||
GuidCache.Delete(uri + "-LoggedOn");
|
||||
GuidCache.Set(nonce + "-Identity", result);
|
||||
GuidCache.Delete (uri + "-Logon");
|
||||
GuidCache.Delete (uri + "-LoggedOn");
|
||||
GuidCache.Set (nonce + "-Identity", result);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -232,22 +234,22 @@ namespace Swarmops.Pages.Security
|
||||
|
||||
[WebMethod]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static bool TestCredentials(string credentialsLogin, string credentialsPass, string credentials2FA,
|
||||
public static bool TestCredentials (string credentialsLogin, string credentialsPass, string credentials2FA,
|
||||
string logonUriEncoded)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(credentialsLogin.Trim()) && !string.IsNullOrEmpty(credentialsPass.Trim()))
|
||||
if (!string.IsNullOrEmpty (credentialsLogin.Trim()) && !string.IsNullOrEmpty (credentialsPass.Trim()))
|
||||
{
|
||||
string logonUri = HttpUtility.UrlDecode(logonUriEncoded);
|
||||
string logonUri = HttpUtility.UrlDecode (logonUriEncoded);
|
||||
|
||||
try
|
||||
{
|
||||
Person authenticatedPerson = Swarmops.Logic.Security.Authentication.Authenticate(credentialsLogin,
|
||||
Person authenticatedPerson = Authentication.Authenticate (credentialsLogin,
|
||||
credentialsPass);
|
||||
|
||||
// TODO: Determine last logged-on organization. Right now, log on to Sandbox.
|
||||
|
||||
GuidCache.Set(logonUri + "-LoggedOn",
|
||||
authenticatedPerson.Identity.ToString(CultureInfo.InvariantCulture) + ",1,,AuthPlain");
|
||||
GuidCache.Set (logonUri + "-LoggedOn",
|
||||
authenticatedPerson.Identity.ToString (CultureInfo.InvariantCulture) + ",1,,AuthPlain");
|
||||
return true;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
@@ -260,19 +262,19 @@ namespace Swarmops.Pages.Security
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
protected override void OnPreInit (EventArgs e)
|
||||
{
|
||||
base.OnPreInit(e);
|
||||
base.OnPreInit (e);
|
||||
}
|
||||
|
||||
private void Localize()
|
||||
{
|
||||
this.LabelCurrentOrganizationName.Text = Resources.Global.Global_Organization;
|
||||
this.LabelCurrentOrganizationName.Text = Global.Global_Organization;
|
||||
this.LabelCurrentUserName.Text = Participant.Localized (ParticipantTitle.Person, TitleVariant.Generic);
|
||||
this.LabelPageTitle.Text = Resources.Pages.Security.Login_PageTitle;
|
||||
this.LabelPreferences.Text = Resources.Global.Global_NA;
|
||||
this.LabelSidebarInfoHeader.Text = Resources.Global.Sidebar_Information;
|
||||
this.LabelSidebarHelpHeader.Text = Resources.Global.Sidebar_Help;
|
||||
this.LabelPreferences.Text = Global.Global_NA;
|
||||
this.LabelSidebarInfoHeader.Text = Global.Sidebar_Information;
|
||||
this.LabelSidebarHelpHeader.Text = Global.Sidebar_Help;
|
||||
this.LabelSidebarInfoContent.Text = Resources.Pages.Security.Login_Info;
|
||||
this.LabelSidebarManualLoginHeader.Text = Resources.Pages.Security.Login_ManualLogin;
|
||||
this.LabelHeader.Text = Resources.Pages.Security.Login_Header;
|
||||
@@ -293,7 +295,8 @@ namespace Swarmops.Pages.Security
|
||||
try
|
||||
{
|
||||
using (
|
||||
StreamReader reader = File.OpenText(HttpContext.Current.Request.MapPath("~/BuildIdentity.txt")))
|
||||
StreamReader reader = File.OpenText (HttpContext.Current.Request.MapPath ("~/BuildIdentity.txt"))
|
||||
)
|
||||
{
|
||||
_buildIdentity = "Build " + reader.ReadLine();
|
||||
}
|
||||
@@ -308,7 +311,7 @@ namespace Swarmops.Pages.Security
|
||||
}
|
||||
|
||||
|
||||
protected void ButtonLogin_Click(object sender, EventArgs args)
|
||||
protected void ButtonLogin_Click (object sender, EventArgs args)
|
||||
{
|
||||
// Check the host names and addresses again as a security measure - after all, we can be called from outside our intended script
|
||||
/*
|
||||
@@ -330,7 +333,7 @@ namespace Swarmops.Pages.Security
|
||||
}*/
|
||||
}
|
||||
|
||||
protected void ButtonCheat_Click(object sender, EventArgs e)
|
||||
protected void ButtonCheat_Click (object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user