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 XmlSerializer serializer = new XmlSerializer(typeof(MainMenuItem[])); string mainMenuFile = "~/MainMenu-v5.xml"; if (CurrentUser.Identity == Person.OpenLedgersIdentity) { mainMenuFile = "~/MainMenu-v5-OpenLedgers.xml"; } using (TextReader reader = new StreamReader(Server.MapPath(mainMenuFile))) { MainMenuData = (MainMenuItem[])serializer.Deserialize(reader); } }
protected void ButtonCreate_Click(object sender, EventArgs e) { ParticipantTitle applicantLabel = (ParticipantTitle)(Enum.Parse(typeof(ParticipantTitle), this.DropApplicantLabel.SelectedValue)); ParticipantTitle activistLabel = (ParticipantTitle)(Enum.Parse(typeof(ParticipantTitle), this.DropActivistLabel.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)) { throw new ArgumentException("Organization name can't be empty"); } if (activistLabel == ParticipantTitle.Unknown || peopleLabel == ParticipantTitle.Unknown || asRoot == "0" || currencyCode == "0") { throw new ArgumentException("Necessary argument was not supplied (did client-side validation run?)"); } Currency newOrgCurrency = Currency.FromCode(currencyCode); Organization parent = CurrentOrganization; if (asRoot == "Root") { parent = null; } Organization newOrganization = Organization.Create(parent == null ? 0 : parent.Identity, newOrgName, newOrgName, newOrgName, string.Empty, newOrgName, Geography.RootIdentity, true, true, 0); newOrganization.EnableEconomy(newOrgCurrency); newOrganization.ApplicantLabel = applicantLabel; newOrganization.RegularLabel = peopleLabel; newOrganization.ActivistLabel = activistLabel; PositionTitle titleType = (PositionTitle)(Enum.Parse(typeof(PositionTitle), this.DropPositionLabel.SelectedValue)); Positions.CreateOrganizationDefaultPositions(newOrganization, titleType); Participation.Create(CurrentUser, newOrganization, Constants.DateTimeHigh); Positions.ForOrganization(newOrganization).AtLevel(PositionLevel.OrganizationExecutive)[0].Assign( CurrentUser, null /* assignedby */, null /* assigned by position */, "Initial executive", null /* expires */); string successMessage = String.Format(Resources.Pages.Admin.CreateOrganization_Success, Participant.Localized(peopleLabel, TitleVariant.Ship)); DashboardMessage.Set(successMessage); // Log in to new organization, then redirect to Edit Response.Redirect( "/Pages/v5/Security/SetCurrentOrganization.aspx?OrganizationId=" + newOrganization.Identity.ToString(CultureInfo.InvariantCulture) + "&ReturnUrl=/Admin/OrgSettings", true); }
public static string Localized(ParticipantTitle title, PersonGender gender) { string genderString = gender.ToString(); if (gender == PersonGender.Unknown) { genderString = "Generic"; } return(Localized(title, genderString)); }
protected void ButtonCreate_Click(object sender, EventArgs e) { string activistLabel = this.DropActivistLabel.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)) { 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?)"); } Currency newOrgCurrency = Currency.FromCode(currencyCode); Organization parent = CurrentOrganization; if (asRoot == "Root") { parent = null; } Organization newOrganization = Organization.Create(parent == null ? 0 : parent.Identity, newOrgName, newOrgName, newOrgName, string.Empty, newOrgName, Geography.RootIdentity, true, true, 0); newOrganization.EnableEconomy(newOrgCurrency); newOrganization.RegularLabel = peopleLabel; newOrganization.ActivistLabel = activistLabel; 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))); // Log in to new organization, then redirect to Edit Response.Redirect( "/Pages/v5/Security/SetCurrentOrganization.aspx?OrganizationId=" + newOrganization.Identity.ToString(CultureInfo.InvariantCulture) + "&ReturnUrl=/Pages/v5/Admin/EditOrganization.aspx", true); }
public static string Localized(ParticipantTitle title, TitleVariant variant = TitleVariant.Generic) { return(Logic_Swarm_ParticipantTitle.ResourceManager.GetString("Title_" + title + "_" + variant)); }
public static string Localized(ParticipantTitle title, string variantString) { return(Localized(title, (TitleVariant)(Enum.Parse(typeof(TitleVariant), variantString)))); }