190517PX Added address class, Combo box extension for key-value selction, some mail content, test data, deleted user list

This commit is contained in:
phantomix 2019-05-17 17:53:35 +02:00
parent f928ab0f29
commit 0c0166fd44
11 changed files with 855 additions and 44 deletions

View File

@ -10,7 +10,7 @@ namespace dezentrale
{
public class Program
{
public static uint VersionNumber { get; private set; } = 0x19051600;
public static uint VersionNumber { get; private set; } = 0x19051700;
public static string VersionString { get; private set; } = $"{VersionNumber:x}";
public static string AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
@ -35,6 +35,7 @@ namespace dezentrale
{
bool printHelp = false;
Console.WriteLine($"dezentrale-members, Version {VersionString}");
Console.WriteLine($"Working directory: {DmDirectory}");
List<string> clArgs = new List<string>();
foreach(string argIt in args)
@ -106,6 +107,7 @@ namespace dezentrale
}
members.Entries.Sort();
members.Deleted.Sort();
} catch (Exception ex)
{
Console.WriteLine("Error while accessing program data:");

View File

@ -60,6 +60,11 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="model\Address.cs" />
<Compile Include="model\Country.cs" />
<Compile Include="view\ComboBoxKV.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="view\frmEditEntry.cs">
<SubType>Form</SubType>
</Compile>

19
model/Address.cs Normal file
View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace dezentrale.model
{
public class Address : XmlData
{
[XmlElement] public string Street { get; set; } = "";
[XmlElement] public string HouseNumber { get; set; } = "";
[XmlElement] public string Zipcode { get; set; } = "";
[XmlElement] public string City { get; set; } = "";
[XmlElement] public string State { get; set; } = "";
[XmlElement] public Country.eCountry CountryCode { get; set; } = Country.eCountry.Germany;
}
}

549
model/Country.cs Normal file
View File

@ -0,0 +1,549 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace dezentrale.model
{
public class Country
{
public eCountry Code { get; set; }
public string A2 { get; set; }
public string A3 { get; set; }
public string Name { get; set; }
public override string ToString() { return Name; }
public enum eCountry
{
Afghanistan = 4,
AlandIslands = 248,
Albania = 8,
Algeria = 12,
AmericanSamoa = 16,
Andorra = 20,
Angola = 24,
Anguilla = 660,
Antarctica = 10,
AntiguaAndBarbuda = 28,
Argentina = 32,
Armenia = 51,
Aruba = 533,
Australia = 36,
Austria = 40,
Azerbaijan = 31,
Bahamas = 44,
Bahrain = 48,
Bangladesh = 50,
Barbados = 52,
Belarus = 112,
Belgium = 56,
Belize = 84,
Benin = 204,
Bermuda = 60,
Bhutan = 64,
Bolivia = 68,
Bonaire = 535,
BosniaAndHerzegovina= 70,
Botswana = 72,
BouvetIsland = 74,
Brazil = 76,
BritishIndianOceanTerritory = 86,
BruneiDarussalam = 96,
Bulgaria = 100,
BurkinaFaso = 854,
Burundi = 108,
CaboVerde = 132,
Cambodia = 116,
Cameroon = 120,
Canada = 124,
CaymanIslands = 136,
CentralAfricanRepublic = 140,
Chad = 148,
Chile = 152,
China = 156,
ChristmasIsland = 162,
CocosKeelingIslands = 166,
Colombia = 170,
Comoros = 174,
CongoDemocratiRepublic = 180,
Congo = 178,
CookIslands = 184,
CostaRica = 188,
CoteDIvoire = 384,
Croatia = 191,
Cuba = 192,
Curacao = 531,
Cyprus = 196,
Czechia = 203,
Denmark = 208,
Djibouti = 262,
Dominica = 212,
DominicanRepublic = 214,
Ecuador = 218,
Egypt = 818,
ElSalvador = 222,
EquatorialGuinea = 226,
Eritrea = 232,
Estonia = 233,
Eswatini = 748,
Ethiopia = 231,
FalklandIslands = 238,
FaroeIslands = 234,
Fiji = 242,
Finland = 246,
France = 250,
FrenchGuiana = 254,
FrenchPolynesia = 258,
FrenchSouthernTerritories = 260,
Gabon = 266,
Gambria = 270,
Georgia = 268,
Germany = 276,
Ghana = 288,
Gibraltar = 292,
Greece = 300,
Greenland = 292,
Grenada = 308,
Guadeloupe = 312,
Guam = 316,
Guatemala = 320,
Guernsey = 831,
Guinea = 324,
GuineaBissau = 624,
Guyana = 328,
Haiti = 332,
HeardIslandAndMcDonaldIslands = 334,
HolySee = 336,
Honduras = 340,
HongKong = 344,
Hungary = 348,
Iceland = 352,
India = 356,
Indonesia = 360,
Iran = 364,
Iraq = 368,
Ireland = 372,
IsleOfMan = 822,
Israel = 376,
Italy = 380,
Jamaica = 388,
Japan = 392,
Jersey = 832,
Jordan = 400,
Kazakhstan = 398,
Kenya = 404,
Kiribati = 296,
KoreaDemocraticPeoplesRepublic = 408,
KoreaRepublic = 410,
Kuwait = 414,
Kyrgyzstan = 417,
Lao = 418,
Latvia = 428,
Lebanon = 422,
Lesotho = 426,
Liberia = 430,
Libya = 434,
Liechtenstein = 438,
Lithuania = 440,
Luxembourg = 442,
Macao = 446,
Madagascar = 450,
Malawi = 454,
Malaysia = 458,
Maldives = 462,
Mali = 466,
Malta = 470,
MarshallIslands = 585,
Martinique = 474,
Mauritania = 478,
Mauritius = 480,
Mayotte = 175,
Mexico = 484,
Micronesia = 583,
Moldova = 498,
Monaco = 492,
Mongolia = 496,
Montenegro = 499,
Montserrat = 500,
Morocco = 504,
Mozambique = 508,
Myanmar = 104,
Namibia = 516,
Nauru = 520,
Nepal = 524,
Netherlands = 528,
NewCaledonia = 540,
NewZealand = 554,
Nicaragua = 558,
Niger = 562,
Nigeria = 566,
Niue = 570,
NorfolkIsland = 574,
NorthMacedonia = 807,
NorthernMarianaIslands = 580,
Norway = 578,
Oman = 512,
Pakistan = 586,
Palau = 585,
Palestine = 275,
Panama = 591,
PapuaNewGuinea = 598,
Paraguay = 600,
Peru = 604,
Philippines = 608,
Pitcairn = 612,
Poland = 616,
Portugal = 620,
PuertoRico = 630,
Qatar = 634,
Reunion = 638,
Romania = 642,
RussianFederation = 643,
Rwanda = 646,
SaintBarthelemy = 652,
SaintHelena = 654,
SaintKittsAndNevis = 659,
SaintLucia = 662,
SaintMartin = 663,
SaintPierre = 666,
SaintVincent = 670,
Samoa = 882,
SanMarino = 674,
SaoTomeAndPrincipe = 678,
SaudiArabia = 682,
Senegal = 686,
Serbia = 688,
Seychelles = 690,
SierraLeone = 694,
Singapore = 702,
SintMaarten = 534,
Slovakia = 703,
Slovenia = 705,
SolomonIslands = 90,
Somalia = 706,
SouthAfrica = 710,
SouthGeorgia = 239,
SouthSudan = 728,
Spain = 724,
SriLanka = 144,
Sudan = 729,
Suriname = 740,
Svalbard = 744,
Sweden = 752,
Switzerland = 756,
SyrianArabRepublic = 760,
Taiwan = 158,
Tajikistan = 762,
Tanzania = 834,
Thailand = 764,
TimorLeste = 626,
Togo = 768,
Tokelau = 772,
Tonga = 776,
TrinidadAndTobago = 780,
Tunisia = 788,
Turkey = 792,
Turkmenistan = 795,
TurksAndCaicosIslands = 796,
Tuvalu = 798,
Uganda = 800,
Ukraine = 804,
UnitedArabEmirates = 784,
UnitedKingdom = 826,
UnitedStatesMinorOutlyingIslands = 581,
UnitedStatesOfAmerica = 840,
Uruguay = 858,
Uzbekistan = 860,
Vanuatu = 548,
Venezuela = 862,
VietNam = 704,
VirginIslandsBritish = 92,
VirginIslandsUS = 850,
WallisAndFutuna = 876,
WesternSahara = 732,
Yemen = 887,
Zambia = 894,
Zimbabwe = 716,
}
private static List<Country> cl = null;
public static List<Country> GetList()
{
if (cl != null) return cl;
//See https://www.iso.org/iso-3166-country-codes.html
return cl = new List<Country>()
{
new Country() { A2 = "AF", A3 = "AFG", Code = eCountry.Afghanistan, Name = "Afghanistan" },
new Country() { A2 = "AX", A3 = "ALA", Code = eCountry.AlandIslands, Name = "Åland Islands" },
new Country() { A2 = "AL", A3 = "ALB", Code = eCountry.Albania, Name = "Albania" },
new Country() { A2 = "DZ", A3 = "DZA", Code = eCountry.Algeria, Name = "Algeria" },
new Country() { A2 = "AS", A3 = "ASM", Code = eCountry.AmericanSamoa, Name = "American Samoa" },
new Country() { A2 = "AD", A3 = "AND", Code = eCountry.Andorra, Name = "Andorra" },
new Country() { A2 = "AO", A3 = "AGO", Code = eCountry.Angola, Name = "Angola" },
new Country() { A2 = "AI", A3 = "AIA", Code = eCountry.Anguilla, Name = "Anguilla" },
new Country() { A2 = "AQ", A3 = "ATA", Code = eCountry.Antarctica, Name = "Antarctica" },
new Country() { A2 = "AG", A3 = "ATG", Code = eCountry.AntiguaAndBarbuda, Name = "Antigua and Barbuda" },
new Country() { A2 = "AR", A3 = "ARG", Code = eCountry.Argentina, Name = "Argentina" },
new Country() { A2 = "AM", A3 = "ARM", Code = eCountry.Armenia, Name = "Armenia" },
new Country() { A2 = "AW", A3 = "ABW", Code = eCountry.Aruba, Name = "Aruba" },
new Country() { A2 = "AU", A3 = "AUS", Code = eCountry.Australia, Name = "Australia" },
new Country() { A2 = "AT", A3 = "AUT", Code = eCountry.Austria, Name = "Austria" },
new Country() { A2 = "AZ", A3 = "AZE", Code = eCountry.Azerbaijan, Name = "Azerbaijan" },
new Country() { A2 = "BS", A3 = "BHS", Code = eCountry.Bahamas, Name = "Bahamas (the)" },
new Country() { A2 = "BH", A3 = "BHR", Code = eCountry.Bahrain, Name = "Bahrain" },
new Country() { A2 = "BD", A3 = "BGD", Code = eCountry.Bangladesh, Name = "Bangladesh" },
new Country() { A2 = "BB", A3 = "BRB", Code = eCountry.Barbados, Name = "Barbados" },
new Country() { A2 = "BY", A3 = "BLR", Code = eCountry.Belarus, Name = "Belarus" },
new Country() { A2 = "BE", A3 = "BEL", Code = eCountry.Belgium, Name = "Belgium" },
new Country() { A2 = "BZ", A3 = "BLZ", Code = eCountry.Belize, Name = "Belize" },
new Country() { A2 = "BJ", A3 = "BEN", Code = eCountry.Benin, Name = "Benin" },
new Country() { A2 = "BM", A3 = "BMU", Code = eCountry.Bermuda, Name = "Bermuda" },
new Country() { A2 = "BT", A3 = "BTN", Code = eCountry.Bhutan, Name = "Bhutan" },
new Country() { A2 = "BO", A3 = "BOL", Code = eCountry.Bolivia, Name = "Bolivia (Plurinational State of)" },
new Country() { A2 = "BQ", A3 = "BES", Code = eCountry.Bonaire, Name = "Bonaire, Sint Eustatius and Saba" },
new Country() { A2 = "BA", A3 = "BIH", Code = eCountry.BosniaAndHerzegovina,Name = "Bosnia and Herzegovina" },
new Country() { A2 = "BW", A3 = "BWA", Code = eCountry.Botswana, Name = "Botswana" },
new Country() { A2 = "BV", A3 = "BVT", Code = eCountry.BouvetIsland, Name = "Bouvet Island" },
new Country() { A2 = "BR", A3 = "BRA", Code = eCountry.Brazil, Name = "Brazil" },
new Country() { A2 = "IO", A3 = "IOT", Code = eCountry.BritishIndianOceanTerritory, Name = "British Indian Ocean Territory (the)" },
new Country() { A2 = "BN", A3 = "BRN", Code = eCountry.BruneiDarussalam, Name = "Brunei Darussalam" },
new Country() { A2 = "BG", A3 = "BGR", Code = eCountry.Bulgaria, Name = "Bulgaria" },
new Country() { A2 = "BF", A3 = "BFA", Code = eCountry.BurkinaFaso, Name = "Burkina Faso" },
new Country() { A2 = "BI", A3 = "BDI", Code = eCountry.Burundi, Name = "Burundi" },
new Country() { A2 = "CV", A3 = "CPV", Code = eCountry.CaboVerde, Name = "Cabo Verde" },
new Country() { A2 = "KH", A3 = "KHM", Code = eCountry.Cambodia, Name = "Cambodia" },
new Country() { A2 = "CM", A3 = "CMR", Code = eCountry.Cameroon, Name = "Cameroon" },
new Country() { A2 = "CA", A3 = "CAN", Code = eCountry.Canada, Name = "Canada" },
new Country() { A2 = "KY", A3 = "CYM", Code = eCountry.CaymanIslands, Name = "Cayman Islands (the)" },
new Country() { A2 = "CF", A3 = "CAF", Code = eCountry.CentralAfricanRepublic, Name = "Central African Republic (the)" },
new Country() { A2 = "TD", A3 = "TCD", Code = eCountry.Chad, Name = "Chad" },
new Country() { A2 = "CL", A3 = "CHL", Code = eCountry.Chile, Name = "Chile" },
new Country() { A2 = "CN", A3 = "CHN", Code = eCountry.China, Name = "China" },
new Country() { A2 = "CX", A3 = "CXR", Code = eCountry.ChristmasIsland, Name = "Christmas Island" },
new Country() { A2 = "CC", A3 = "CCK", Code = eCountry.CocosKeelingIslands, Name = "Cocos (Keeling) Islands (the)" },
new Country() { A2 = "CO", A3 = "COL", Code = eCountry.Colombia, Name = "Colombia" },
new Country() { A2 = "KM", A3 = "COM", Code = eCountry.Comoros, Name = "Comoros (the)" },
new Country() { A2 = "CD", A3 = "COD", Code = eCountry.CongoDemocratiRepublic, Name = "Congo (the Democratic Republic of the)" },
new Country() { A2 = "CG", A3 = "COG", Code = eCountry.Congo, Name = "Congo (the)" },
new Country() { A2 = "CK", A3 = "COK", Code = eCountry.CookIslands, Name = "Cook Islands (the)" },
new Country() { A2 = "CR", A3 = "CRI", Code = eCountry.CostaRica, Name = "Costa Rica" },
new Country() { A2 = "CI", A3 = "CIV", Code = eCountry.CoteDIvoire, Name = "Côte d'Ivoire" },
new Country() { A2 = "HR", A3 = "HRV", Code = eCountry.Croatia, Name = "Croatia" },
new Country() { A2 = "CU", A3 = "CUB", Code = eCountry.Cuba, Name = "Cuba" },
new Country() { A2 = "CW", A3 = "CUW", Code = eCountry.Curacao, Name = "Curaçao" },
new Country() { A2 = "CY", A3 = "CYP", Code = eCountry.Cyprus, Name = "Cyprus" },
new Country() { A2 = "CZ", A3 = "CZE", Code = eCountry.Czechia, Name = "Czechia" },
new Country() { A2 = "DK", A3 = "DNK", Code = eCountry.Denmark, Name = "Denmark" },
new Country() { A2 = "DJ", A3 = "DJI", Code = eCountry.Djibouti, Name = "Djibouti" },
new Country() { A2 = "DM", A3 = "DMA", Code = eCountry.Dominica, Name = "Dominica" },
new Country() { A2 = "DO", A3 = "DOM", Code = eCountry.DominicanRepublic, Name = "Dominican Republic (the)" },
new Country() { A2 = "EC", A3 = "ECU", Code = eCountry.Ecuador, Name = "Ecuador" },
new Country() { A2 = "EG", A3 = "EGY", Code = eCountry.Egypt, Name = "Egypt" },
new Country() { A2 = "SV", A3 = "SLV", Code = eCountry.ElSalvador, Name = "El Salvador" },
new Country() { A2 = "GQ", A3 = "GNQ", Code = eCountry.EquatorialGuinea, Name = "Equatorial Guinea" },
new Country() { A2 = "ER", A3 = "ERI", Code = eCountry.Eritrea, Name = "Eritrea" },
new Country() { A2 = "EE", A3 = "EST", Code = eCountry.Estonia, Name = "Estonia" },
new Country() { A2 = "SZ", A3 = "SWZ", Code = eCountry.Eswatini, Name = "Eswatini" },
new Country() { A2 = "ET", A3 = "ETH", Code = eCountry.Ethiopia, Name = "Ethiopia" },
new Country() { A2 = "FK", A3 = "FLK", Code = eCountry.FalklandIslands, Name = "Falkland Islands (the) [Malvinas]" },
new Country() { A2 = "FO", A3 = "FRO", Code = eCountry.FaroeIslands, Name = "Faroe Islands (the)" },
new Country() { A2 = "FJ", A3 = "FJI", Code = eCountry.Fiji, Name = "Fiji" },
new Country() { A2 = "FI", A3 = "FIH", Code = eCountry.Finland, Name = "Finland" },
new Country() { A2 = "FR", A3 = "FRA", Code = eCountry.France, Name = "France" },
new Country() { A2 = "GF", A3 = "GUF", Code = eCountry.FrenchGuiana, Name = "French Guiana" },
new Country() { A2 = "PF", A3 = "PYF", Code = eCountry.FrenchPolynesia, Name = "French Polynesia" },
new Country() { A2 = "TF", A3 = "ATF", Code = eCountry.FrenchSouthernTerritories, Name = "French Southern Territories (the)" },
new Country() { A2 = "GA", A3 = "GAB", Code = eCountry.Gabon, Name = "Gabon" },
new Country() { A2 = "GM", A3 = "GMB", Code = eCountry.Gambria, Name = "Gambria (the)" },
new Country() { A2 = "GE", A3 = "GEO", Code = eCountry.Georgia, Name = "Georgia" },
new Country() { A2 = "DE", A3 = "DEU", Code = eCountry.Germany, Name = "Germany" },
new Country() { A2 = "GH", A3 = "GHA", Code = eCountry.Ghana, Name = "Ghana" },
new Country() { A2 = "GI", A3 = "GIB", Code = eCountry.Gibraltar, Name = "Gibraltar" },
new Country() { A2 = "GR", A3 = "GRC", Code = eCountry.Greece, Name = "Greece" },
new Country() { A2 = "GL", A3 = "GRL", Code = eCountry.Greenland, Name = "Greenland" },
new Country() { A2 = "GD", A3 = "GRD", Code = eCountry.Grenada, Name = "Grenada" },
new Country() { A2 = "GP", A3 = "GLP", Code = eCountry.Guadeloupe, Name = "Guadeloupe" },
new Country() { A2 = "GU", A3 = "GUM", Code = eCountry.Guam, Name = "Guam" },
new Country() { A2 = "GT", A3 = "GTM", Code = eCountry.Guatemala, Name = "Guatemala" },
new Country() { A2 = "GG", A3 = "GGY", Code = eCountry.Guernsey, Name = "Guernsey" },
new Country() { A2 = "GN", A3 = "GIN", Code = eCountry.Guinea, Name = "Guinea" },
new Country() { A2 = "GW", A3 = "GNB", Code = eCountry.GuineaBissau, Name = "Guinea-Bissau" },
new Country() { A2 = "GY", A3 = "GUY", Code = eCountry.Guyana, Name = "Guyana" },
new Country() { A2 = "HT", A3 = "HTI", Code = eCountry.Haiti, Name = "Haiti" },
new Country() { A2 = "HM", A3 = "HMD", Code = eCountry.HeardIslandAndMcDonaldIslands, Name = "Heard Island and McDonald Islands" },
new Country() { A2 = "VA", A3 = "VAT", Code = eCountry.HolySee, Name = "Holy See (the)" },
new Country() { A2 = "HN", A3 = "HND", Code = eCountry.Honduras, Name = "Honduras" },
new Country() { A2 = "HK", A3 = "HKG", Code = eCountry.HongKong, Name = "Hong Kong" },
new Country() { A2 = "HU", A3 = "HUN", Code = eCountry.Hungary, Name = "Hungary" },
new Country() { A2 = "IS", A3 = "ISL", Code = eCountry.Iceland, Name = "Iceland" },
new Country() { A2 = "IN", A3 = "IND", Code = eCountry.India, Name = "India" },
new Country() { A2 = "ID", A3 = "IDN", Code = eCountry.Indonesia, Name = "Indonesia" },
new Country() { A2 = "IR", A3 = "IRN", Code = eCountry.Iran, Name = "Iran (Islamic Republic of)" },
new Country() { A2 = "IQ", A3 = "IRQ", Code = eCountry.Iraq, Name = "Iraq" },
new Country() { A2 = "IE", A3 = "IRL", Code = eCountry.Ireland, Name = "Ireland" },
new Country() { A2 = "IM", A3 = "IMN", Code = eCountry.IsleOfMan, Name = "Isle of Man" },
new Country() { A2 = "IL", A3 = "ISR", Code = eCountry.Israel, Name = "Israel" },
new Country() { A2 = "IT", A3 = "ITA", Code = eCountry.Italy, Name = "Italy" },
new Country() { A2 = "JM", A3 = "JAM", Code = eCountry.Jamaica, Name = "Jamaica" },
new Country() { A2 = "JP", A3 = "JPN", Code = eCountry.Japan, Name = "Japan" },
new Country() { A2 = "JE", A3 = "JEY", Code = eCountry.Jersey, Name = "Jersey" },
new Country() { A2 = "JO", A3 = "JOR", Code = eCountry.Jordan, Name = "Jordan" },
new Country() { A2 = "KZ", A3 = "KAZ", Code = eCountry.Kazakhstan, Name = "Kazakhstan" },
new Country() { A2 = "KE", A3 = "KEN", Code = eCountry.Kenya, Name = "Kenya" },
new Country() { A2 = "KI", A3 = "KIR", Code = eCountry.Kiribati, Name = "Kiribati" },
new Country() { A2 = "KP", A3 = "PRK", Code = eCountry.KoreaDemocraticPeoplesRepublic, Name = "Korea (the Democratic People's Republic of)" },
new Country() { A2 = "KR", A3 = "KOR", Code = eCountry.KoreaRepublic, Name = "Korea (the Republic of)" },
new Country() { A2 = "KW", A3 = "KWT", Code = eCountry.Kuwait, Name = "Kuwait" },
new Country() { A2 = "KG", A3 = "KGZ", Code = eCountry.Kyrgyzstan, Name = "Kyrgyzstan" },
new Country() { A2 = "LA", A3 = "LAO", Code = eCountry.Lao, Name = "Lao People's Democratic Republic (the)" },
new Country() { A2 = "LV", A3 = "LVA", Code = eCountry.Latvia, Name = "Latvia" },
new Country() { A2 = "LB", A3 = "LBN", Code = eCountry.Lebanon, Name = "Lebanon" },
new Country() { A2 = "LS", A3 = "LSO", Code = eCountry.Lesotho, Name = "Lesotho" },
new Country() { A2 = "LR", A3 = "LBR", Code = eCountry.Liberia, Name = "Liberia" },
new Country() { A2 = "LY", A3 = "LBY", Code = eCountry.Libya, Name = "Libya" },
new Country() { A2 = "LI", A3 = "LIE", Code = eCountry.Liechtenstein, Name = "Liechtenstein" },
new Country() { A2 = "LT", A3 = "LTU", Code = eCountry.Lithuania, Name = "Lithuania" },
new Country() { A2 = "LU", A3 = "LUX", Code = eCountry.Luxembourg, Name = "Luxembourg" },
new Country() { A2 = "MO", A3 = "MAC", Code = eCountry.Macao, Name = "Macao" },
new Country() { A2 = "MG", A3 = "MDG", Code = eCountry.Madagascar, Name = "Madagascar" },
new Country() { A2 = "MW", A3 = "MWI", Code = eCountry.Malawi, Name = "Malawi" },
new Country() { A2 = "MY", A3 = "MYS", Code = eCountry.Malaysia, Name = "Malaysia" },
new Country() { A2 = "MV", A3 = "MDV", Code = eCountry.Maldives, Name = "Maldives" },
new Country() { A2 = "ML", A3 = "MLI", Code = eCountry.Mali, Name = "Mali" },
new Country() { A2 = "MT", A3 = "MLT", Code = eCountry.Malta, Name = "Malta" },
new Country() { A2 = "MH", A3 = "MHL", Code = eCountry.MarshallIslands, Name = "Marshall Islands (the)" },
new Country() { A2 = "MQ", A3 = "MTQ", Code = eCountry.Martinique, Name = "Martinique" },
new Country() { A2 = "MR", A3 = "MRT", Code = eCountry.Mauritania, Name = "Mauritania" },
new Country() { A2 = "MU", A3 = "MUS", Code = eCountry.Mauritius, Name = "Mauritius" },
new Country() { A2 = "YT", A3 = "MYT", Code = eCountry.Mayotte, Name = "Mayotte" },
new Country() { A2 = "MX", A3 = "MEX", Code = eCountry.Mexico, Name = "Mexico" },
new Country() { A2 = "FM", A3 = "FSM", Code = eCountry.Micronesia, Name = "Micronesia (Federated States of)" },
new Country() { A2 = "MD", A3 = "MDA", Code = eCountry.Moldova, Name = "Moldova (the Republic of)" },
new Country() { A2 = "MC", A3 = "MCO", Code = eCountry.Monaco, Name = "Monaco" },
new Country() { A2 = "MN", A3 = "MNG", Code = eCountry.Mongolia, Name = "Mongolia" },
new Country() { A2 = "ME", A3 = "MNE", Code = eCountry.Montenegro, Name = "Montenegro" },
new Country() { A2 = "MS", A3 = "MSR", Code = eCountry.Montserrat, Name = "Montserrat" },
new Country() { A2 = "MA", A3 = "MAR", Code = eCountry.Morocco, Name = "Morocco" },
new Country() { A2 = "MZ", A3 = "MOZ", Code = eCountry.Mozambique, Name = "Mozambique" },
new Country() { A2 = "MM", A3 = "MMR", Code = eCountry.Myanmar, Name = "Myanmar" },
new Country() { A2 = "NA", A3 = "NAM", Code = eCountry.Namibia, Name = "Namibia" },
new Country() { A2 = "NR", A3 = "NRU", Code = eCountry.Nauru, Name = "Nauru" },
new Country() { A2 = "NP", A3 = "NPL", Code = eCountry.Nepal, Name = "Nepal" },
new Country() { A2 = "NL", A3 = "NLD", Code = eCountry.Netherlands, Name = "Netherlands (the)" },
new Country() { A2 = "NC", A3 = "NCL", Code = eCountry.NewCaledonia, Name = "New Caledonia" },
new Country() { A2 = "NZ", A3 = "NZL", Code = eCountry.NewZealand, Name = "New Zealand" },
new Country() { A2 = "NI", A3 = "NIC", Code = eCountry.Nicaragua, Name = "Nicaragua" },
new Country() { A2 = "NE", A3 = "NER", Code = eCountry.Niger, Name = "Niger (the)" },
new Country() { A2 = "NG", A3 = "NGA", Code = eCountry.Nigeria, Name = "Nigeria" },
new Country() { A2 = "NU", A3 = "NIU", Code = eCountry.Niue, Name = "Niue" },
new Country() { A2 = "NF", A3 = "NFK", Code = eCountry.NorfolkIsland, Name = "Norfolk Island" },
new Country() { A2 = "MK", A3 = "MKD", Code = eCountry.NorthMacedonia, Name = "North Macedonia" },
new Country() { A2 = "MP", A3 = "MNP", Code = eCountry.NorthernMarianaIslands, Name = "Northern Mariana Islands (the)" },
new Country() { A2 = "NO", A3 = "NOR", Code = eCountry.Norway, Name = "Norway" },
new Country() { A2 = "OM", A3 = "OMN", Code = eCountry.Oman, Name = "Oman" },
new Country() { A2 = "PK", A3 = "PAK", Code = eCountry.Pakistan, Name = "Pakistan" },
new Country() { A2 = "PW", A3 = "PLW", Code = eCountry.Palau, Name = "Palau" },
new Country() { A2 = "PS", A3 = "PSE", Code = eCountry.Palestine, Name = "Palestine, State of" },
new Country() { A2 = "PA", A3 = "PAN", Code = eCountry.Panama, Name = "Panama" },
new Country() { A2 = "PG", A3 = "PNG", Code = eCountry.PapuaNewGuinea, Name = "Papua New Guinea" },
new Country() { A2 = "PY", A3 = "PRY", Code = eCountry.Paraguay, Name = "Paraguay" },
new Country() { A2 = "PE", A3 = "PER", Code = eCountry.Peru, Name = "Peru" },
new Country() { A2 = "PH", A3 = "PHL", Code = eCountry.Philippines, Name = "Philippines (the)" },
new Country() { A2 = "PN", A3 = "PCN", Code = eCountry.Pitcairn, Name = "Pitcairn" },
new Country() { A2 = "PL", A3 = "POL", Code = eCountry.Poland, Name = "Poland" },
new Country() { A2 = "PT", A3 = "PRT", Code = eCountry.Portugal, Name = "Portugal" },
new Country() { A2 = "PR", A3 = "PRI", Code = eCountry.PuertoRico, Name = "Puerto Rico" },
new Country() { A2 = "QA", A3 = "QAT", Code = eCountry.Qatar, Name = "Qatar" },
new Country() { A2 = "RE", A3 = "REU", Code = eCountry.Reunion, Name = "Réunion" },
new Country() { A2 = "RO", A3 = "ROU", Code = eCountry.Romania, Name = "Romania" },
new Country() { A2 = "RU", A3 = "RUS", Code = eCountry.RussianFederation, Name = "Russian Federation (the)" },
new Country() { A2 = "RW", A3 = "RWA", Code = eCountry.Rwanda, Name = "Rwanda" },
new Country() { A2 = "BL", A3 = "BLM", Code = eCountry.SaintBarthelemy, Name = "Saint Barthélemy" },
new Country() { A2 = "SH", A3 = "SHN", Code = eCountry.SaintHelena, Name = "Saint Helena, Ascension and Tristan da Cunha" },
new Country() { A2 = "KN", A3 = "KNA", Code = eCountry.SaintKittsAndNevis, Name = "Saint Kitts and Nevis" },
new Country() { A2 = "LC", A3 = "LCA", Code = eCountry.SaintLucia, Name = "Saint Lucia" },
new Country() { A2 = "MF", A3 = "MAF", Code = eCountry.SaintMartin, Name = "Saint Martin (French part)" },
new Country() { A2 = "PM", A3 = "SPM", Code = eCountry.SaintPierre, Name = "Saint Pierre and Miquelon" },
new Country() { A2 = "VC", A3 = "VCT", Code = eCountry.SaintVincent, Name = "Saint Vincent and the Grenadines" },
new Country() { A2 = "WS", A3 = "WSM", Code = eCountry.Samoa, Name = "Samoa" },
new Country() { A2 = "SM", A3 = "SMR", Code = eCountry.SanMarino, Name = "San Marino" },
new Country() { A2 = "ST", A3 = "STP", Code = eCountry.SaoTomeAndPrincipe, Name = "Sao Tome and Principe" },
new Country() { A2 = "SA", A3 = "SAU", Code = eCountry.SaudiArabia, Name = "Saudi Arabia" },
new Country() { A2 = "SN", A3 = "SEN", Code = eCountry.Senegal, Name = "Senegal" },
new Country() { A2 = "RS", A3 = "SRB", Code = eCountry.Serbia, Name = "Serbia" },
new Country() { A2 = "SC", A3 = "SYC", Code = eCountry.Seychelles, Name = "Seychelles" },
new Country() { A2 = "SL", A3 = "SLE", Code = eCountry.SierraLeone, Name = "Sierra Leone" },
new Country() { A2 = "SG", A3 = "SGP", Code = eCountry.Singapore, Name = "Singapore" },
new Country() { A2 = "SX", A3 = "SXM", Code = eCountry.SintMaarten, Name = "Sint Maarten (Dutch part)" },
new Country() { A2 = "SK", A3 = "SVK", Code = eCountry.Slovakia, Name = "Slovakia" },
new Country() { A2 = "SI", A3 = "SVN", Code = eCountry.Slovenia, Name = "Slovenia" },
new Country() { A2 = "SB", A3 = "SLB", Code = eCountry.SolomonIslands, Name = "Solomon Islands" },
new Country() { A2 = "SO", A3 = "SOM", Code = eCountry.Somalia, Name = "Somalia" },
new Country() { A2 = "ZA", A3 = "ZAF", Code = eCountry.SouthAfrica, Name = "South Africa" },
new Country() { A2 = "GS", A3 = "SGS", Code = eCountry.SouthGeorgia, Name = "South Georgia and the South Sandwich Islands" },
new Country() { A2 = "SS", A3 = "SSD", Code = eCountry.SouthSudan, Name = "South Sudan" },
new Country() { A2 = "ES", A3 = "ESP", Code = eCountry.Spain, Name = "Spain" },
new Country() { A2 = "LK", A3 = "LKA", Code = eCountry.SriLanka, Name = "Sri Lanka" },
new Country() { A2 = "SD", A3 = "SDN", Code = eCountry.Sudan, Name = "Sudan (the)" },
new Country() { A2 = "SR", A3 = "SUR", Code = eCountry.Suriname, Name = "Suriname" },
new Country() { A2 = "SJ", A3 = "SJM", Code = eCountry.Svalbard, Name = "Svalbard and Jan Mayen" },
new Country() { A2 = "SE", A3 = "SWE", Code = eCountry.Sweden, Name = "Sweden" },
new Country() { A2 = "CH", A3 = "CHE", Code = eCountry.Switzerland, Name = "Switzerland" },
new Country() { A2 = "SY", A3 = "SYR", Code = eCountry.SyrianArabRepublic, Name = "Syrian Arab Republic (the)" },
new Country() { A2 = "TW", A3 = "TWN", Code = eCountry.Taiwan, Name = "Taiwan (Province of China)" },
new Country() { A2 = "TJ", A3 = "TJK", Code = eCountry.Tajikistan, Name = "Tajikistan" },
new Country() { A2 = "TZ", A3 = "TZA", Code = eCountry.Tanzania, Name = "Tanzania, the United Republic of" },
new Country() { A2 = "TH", A3 = "THA", Code = eCountry.Thailand, Name = "Thailand" },
new Country() { A2 = "TL", A3 = "TLS", Code = eCountry.TimorLeste, Name = "Timor-Leste" },
new Country() { A2 = "TG", A3 = "TGO", Code = eCountry.Togo, Name = "Togo" },
new Country() { A2 = "TK", A3 = "TKL", Code = eCountry.Tokelau, Name = "Tokelau" },
new Country() { A2 = "TO", A3 = "TON", Code = eCountry.Tonga, Name = "Tonga" },
new Country() { A2 = "TT", A3 = "TTO", Code = eCountry.TrinidadAndTobago, Name = "Trinidad and Tobago" },
new Country() { A2 = "TN", A3 = "TUN", Code = eCountry.Tunisia, Name = "Tunisia" },
new Country() { A2 = "TR", A3 = "TUR", Code = eCountry.Turkey, Name = "Turkey" },
new Country() { A2 = "TM", A3 = "TKM", Code = eCountry.Turkmenistan, Name = "Turkmenistan" },
new Country() { A2 = "TC", A3 = "TCA", Code = eCountry.TurksAndCaicosIslands, Name = "Turks and Caicos Islands (the)" },
new Country() { A2 = "TV", A3 = "TUV", Code = eCountry.Tuvalu, Name = "Tuvalu" },
new Country() { A2 = "UG", A3 = "UGA", Code = eCountry.Uganda, Name = "Uganda" },
new Country() { A2 = "UA", A3 = "UKR", Code = eCountry.Ukraine, Name = "Ukraine" },
new Country() { A2 = "AE", A3 = "ARE", Code = eCountry.UnitedArabEmirates, Name = "United Arab Emirates (the)" },
new Country() { A2 = "GB", A3 = "GBR", Code = eCountry.UnitedKingdom, Name = "United Kingdom of Great Britain and Northern Ireland (the)" },
new Country() { A2 = "UM", A3 = "UMI", Code = eCountry.UnitedStatesMinorOutlyingIslands, Name = "United States Minor Outlying Islands (the)" },
new Country() { A2 = "US", A3 = "USA", Code = eCountry.UnitedStatesOfAmerica, Name = "United States of America (the)" },
new Country() { A2 = "UY", A3 = "URY", Code = eCountry.Uruguay, Name = "Uruguay" },
new Country() { A2 = "UZ", A3 = "UZB", Code = eCountry.Uzbekistan, Name = "Uzbekistan" },
new Country() { A2 = "VU", A3 = "VUT", Code = eCountry.Vanuatu, Name = "Vanuatu" },
new Country() { A2 = "VE", A3 = "VEN", Code = eCountry.Venezuela, Name = "Venezuela (Bolivarian Republic of)" },
new Country() { A2 = "VN", A3 = "VNM", Code = eCountry.VietNam, Name = "Viet Nam" },
new Country() { A2 = "VG", A3 = "VGB", Code = eCountry.VirginIslandsBritish, Name = "Virgin Islands (British)" },
new Country() { A2 = "VI", A3 = "VIR", Code = eCountry.VirginIslandsUS, Name = "Virgin Islands (U.S.)" },
new Country() { A2 = "WF", A3 = "WLF", Code = eCountry.WallisAndFutuna, Name = "Wallis and Futuna" },
new Country() { A2 = "EH", A3 = "ESH", Code = eCountry.WesternSahara, Name = "Western Sahara" },
new Country() { A2 = "YE", A3 = "YEM", Code = eCountry.Yemen, Name = "Yemen" },
new Country() { A2 = "ZM", A3 = "ZMB", Code = eCountry.Zambia, Name = "Zambia" },
new Country() { A2 = "ZW", A3 = "ZWE", Code = eCountry.Zimbabwe, Name = "Zimbabwe" },
};
}
}
}

View File

@ -86,22 +86,24 @@ namespace dezentrale.model
public static FormMail GenerateNewMemberWelcome()
{
FormMail ret = new FormMail();
ret.To = "{Nickname} <{EMail}>";
ret.Subject = "Willkommen in der dezentrale, {Nickname}!";
ret.Body = "Hello {Nickname}!\n"
return new FormMail()
{
To = "{Nickname} <{EMail}>",
Subject = "Willkommen in der dezentrale, {Nickname}!",
Body = "Hello {Nickname}!\n"
+ "\n"
+ "Welcome to the dezentrale Hackspace.\n"
+ "Your membership number is {Number}\n";
return ret;
+ "Your membership number is {Number}\n",
};
}
public static FormMail GenerateNewMemberVorstand()
{
FormMail ret = new FormMail();
ret.To = "{VSName} <{VSEMail}>";
ret.Subject = "Neuer Mitgliedsantrag, Nummer = {Number}, nick = {Nickname}!";
ret.Body = "Hallo Vorstandsliste,!\n"
return new FormMail()
{
To = "{VSName} <{VSEMail}>",
Subject = "Neuer Mitgliedsantrag, Nummer = {Number}, nick = {Nickname}!",
Body = "Hallo Vorstandsliste,!\n"
+ "\n"
+ "Folgender Nutzer wurde in die Datenbank aufgenommen.\n"
+ "Mitgliednummer: {Number}\n"
@ -112,8 +114,45 @@ namespace dezentrale.model
+ "Damit beginnt eine 7-Tage-Einspruchsfrist für den Vorstand.\n"
+ "\n"
+ "\n"
+ "Dies ist eine automatisch generierte E-Mail.\n";
return ret;
+ "Dies ist eine automatisch generierte E-Mail.\n",
};
}
public static FormMail GenerateAutoTypeFoerdermitglied()
{
return new FormMail()
{
To = "{Nickname} <{EMail}>",
Subject = "Mitgliedschaft geändert in \"Fördermitglied\"",
Body = "Hallo {Nickname},!\n"
+ "\n"
+ "Dein Mitgliedsstatus bei uns war bisher \"reguläres Mitglied\".\n"
+ "Da du zu den letzten beiden Mitgliedsversammlungen nicht anwesend warst,"
+ " wurde dein Status automatisch zu \"Fördermitglied\" geändert.\n"
+ "\n"
+ "Für dich bedeutet dies keinerlei Änderungen. Die Beschlussfähigkeit"
+ " zukünftiger Mitgliedsversammlungen kann auf diese Weise besser erreicht werden.\n"
+ "\n"
+ "Du kannst zu diesen Versammlungen als Gast anwesend sein oder deinen Status zum Anfang"
+ " der MV wieder auf \"reguläres Mitglied\" ändern.\n"
+ "\n"
+ "Dies ist eine automatisch generierte E-Mail.\n",
};
}
public static FormMail GenerateManualTypeChanged()
{
return new FormMail()
{
To = "{Nickname} <{EMail}>",
Subject = "Mitgliedschaft geändert in \"{Type}\"",
Body = "Hallo {Nickname},!\n"
+ "\n"
+ "Dein Mitgliedsstatus bei uns wurde manuell geändert zu \"{Type}\".\n"
+ "\n"
+ "Dies ist eine automatisch generierte E-Mail.\n",
};
}
}
}

View File

@ -49,15 +49,15 @@ namespace dezentrale.model
[XmlElement] public eStatus Status { get; set; } = eStatus.Uninitialized;
[XmlElement] public List<string> OpenPayments { get; set; } = new List<string>(); //todo: data type
[XmlElement] public List<LogEntry> Log { get; set; } = new List<LogEntry>();
[XmlElement] public string Remarks { get; set; } = "";
[XmlElement] public uint MvCounter { get; set; }
//personal data
[XmlElement] public string Nickname { get; set; } = "";
[XmlElement] public string FirstName { get; set; } = "";
[XmlElement] public string LastName { get; set; } = "";
[XmlElement] public string AddressStreet { get; set; } = "";
[XmlElement] public string AddressNumber { get; set; } = "";
[XmlElement] public string Zipcode { get; set; } = "";
[XmlElement] public string City { get; set; } = "";
[XmlElement] public Address Address { get; set; } = new Address() { CountryCode = Country.eCountry.Germany };
[XmlElement] public DateTime Birthday { get; set; }
[XmlElement] public string EMail { get; set; } = "";
[XmlElement] public string PgpFingerprint { get; set; } = "";
@ -68,7 +68,6 @@ namespace dezentrale.model
[XmlElement] public ePaymentClass PaymentClass { get; set; } = ePaymentClass.Normal;
[XmlElement] public DateTime MemberFormDate { get; set; }
[XmlElement] public string Remarks { get; set; } = "";
public Member() { }
public Member(uint number)

View File

@ -6,13 +6,17 @@ namespace dezentrale.model
{
public class MemberList : XmlData
{
[XmlElement("Member")] public List<Member> Entries { get; set; } = new List<Member>();
[XmlElement("Member")] public List<Member> Entries { get; set; } = new List<Member>();
[XmlElement("Deleted")] public List<Member> Deleted { get; set; } = new List<Member>();
public uint GetFreeNumber()
{
//Note: This assumes a sorted list in Entries.
if (Entries.Count < 1) return 1;
return Entries[Entries.Count - 1].Number + 1;
uint ret = Entries[Entries.Count - 1].Number + 1;
if (Deleted.Count < 1) return ret;
uint ret2 = Deleted[Deleted.Count - 1].Number + 1;
return ret > ret2 ? ret : ret2;
}
public Member CreateMember(bool addToList = false)
{
@ -24,7 +28,21 @@ namespace dezentrale.model
{
return Entries.Find(x => x.Number == number);
}
public bool Remove(Member m)
{
if (m == null) return false;
if (m.Role != Member.eRole.Normal)
return false; //throw new Exception("Role is Vorstand!");
bool ret = Entries.Remove(m);
Deleted.Add(m);
Deleted.Sort();
return ret;
}
public bool SaveToFile(string memberFile)
{
return SaveToFile(memberFile, this);
}
public static new MemberList LoadFromFile(string memberFile)
{
MemberList ml = (MemberList)XmlData.LoadFromFile(memberFile);
@ -34,12 +52,132 @@ namespace dezentrale.model
public static bool SaveToFile(string memberFile, MemberList ml)
{
ml.Entries.Sort();
ml.Deleted.Sort();
return XmlData.SaveToFile(memberFile, ml);
}
public void Cronjob()
public void Cronjob(Member m)
{
throw new NotImplementedException();
//Sanity check: Is m in Entries?
//yes, this is slow when iterating through a list.
if (Entries.IndexOf(m) < 0) return;
}
public void Cronjob(List<Member> partialList = null)
{
if (partialList == null) partialList = Entries;
foreach(Member m in partialList) Cronjob(m);
}
#if DEBUG
public void GenerateTestData()
{
Entries.Clear();
Deleted.Clear();
Member m;
//the brackets are unnecessary but keep everything tidy.
m = CreateMember(true);
{
m.Role = Member.eRole.Schatzmeister;
m.Type = Member.eType.Regulaer;
m.Status = Member.eStatus.Active;
//OpenPayments
//Log
m.Remarks = "riecht nach Knoblauch";
m.MvCounter = 2;
m.Nickname = "DoeJohnz";
m.FirstName = "John";
m.LastName = "Doe";
m.Address = new Address() { Street = "Homestreet", HouseNumber = "123", Zipcode = "12345", City = "Musterstadt", CountryCode = Country.eCountry.Germany };
m.Birthday = new DateTime(1980, 1, 1);
m.EMail = "John Doe <john.doe@example.com>";
m.PgpFingerprint = "";
m.MvInvitationByPost = false;
m.SpawnDate = new DateTime(2019, 6, 1);
m.PaymentClass = Member.ePaymentClass.Reduced;
m.MemberFormDate = new DateTime(2019, 5, 1);
}
m = CreateMember(true);
{
m.Role = Member.eRole.Vorstandsvorsitzender;
m.Type = Member.eType.Regulaer;
m.Status = Member.eStatus.Active;
m.Remarks = "";
m.MvCounter = 2;
m.Nickname = "putin";
m.FirstName = "Vladimir";
m.LastName = "Putin";
m.Address = new Address() { Street = "Am Kreml", HouseNumber = "1a", Zipcode = "12345", City = "Moskau", CountryCode = Country.eCountry.RussianFederation };
m.Birthday = new DateTime(1960, 12, 24);
m.EMail = "putin <h4x0r@kgb.ru@example.com>";
m.PgpFingerprint = "encrypted ;-)";
m.MvInvitationByPost = false;
m.SpawnDate = new DateTime(2019, 6, 1);
m.PaymentClass = Member.ePaymentClass.NerdClass4;
m.MemberFormDate = new DateTime(2019, 5, 1);
}
m = CreateMember(true);
{
m.Role = Member.eRole.Normal;
m.Type = Member.eType.Regulaer;
m.Status = Member.eStatus.Uninitialized;
m.Remarks = "";
m.MvCounter = 2;
m.Nickname = "AW23";
m.FirstName = "Adam";
m.LastName = "Weishaupt";
m.Address = new Address() { Street = "Parkallee", HouseNumber = "13", Zipcode = "99867", City = "Gotha", CountryCode = Country.eCountry.Germany };
m.Birthday = new DateTime(1748, 2, 6);
m.EMail = "";
m.PgpFingerprint = "";
m.MvInvitationByPost = false;
m.SpawnDate = new DateTime(2019, 5, 23);
m.PaymentClass = Member.ePaymentClass.Normal;
m.MemberFormDate = new DateTime(2019, 5, 23);
}
m = CreateMember(true);
{
m.Role = Member.eRole.Normal;
m.Type = Member.eType.Regulaer;
m.Status = Member.eStatus.Greeted;
m.Remarks = "";
m.MvCounter = 2;
m.Nickname = "HeinzQuetschab";
m.FirstName = "Heinz";
m.LastName = "Ketchup";
m.Address = new Address() { Street = "", HouseNumber = "", Zipcode = "", City = "Pittsburgh", CountryCode = Country.eCountry.UnitedStatesOfAmerica, State = "Pennsylvania" };
m.Birthday = new DateTime(1876, 12, 31);
m.EMail = "heinz <quetschab@example.com>";
m.PgpFingerprint = "";
m.MvInvitationByPost = false;
m.SpawnDate = new DateTime(2019, 5, 1);
m.PaymentClass = Member.ePaymentClass.Normal;
m.MemberFormDate = new DateTime(2019, 5, 1);
}
m = CreateMember(true);
{
m.Role = Member.eRole.Normal;
m.Type = Member.eType.Regulaer;
m.Remarks = "";
m.MvCounter = 1;
m.Nickname = "Joshua";
m.FirstName = "Keiner";
m.LastName = "Niemand";
m.Address = new Address() { Street = "str.", HouseNumber = "1", Zipcode = "1", City = "Musterstadt", CountryCode = Country.eCountry.Germany };
m.Birthday = new DateTime(1980, 1, 1);
m.EMail = "joshua <joshua@wopr.gov@example.com>";
m.PgpFingerprint = "";
m.MvInvitationByPost = false;
m.SpawnDate = new DateTime(2019, 5, 1);
m.PaymentClass = Member.ePaymentClass.Normal;
m.MemberFormDate = new DateTime(2019, 5, 1);
}
}
#endif
}
}

View File

@ -20,17 +20,18 @@ namespace dezentrale.model
typeof(string),
typeof(DateTime),
typeof(Configuration),
typeof(ConfigSmtp),
typeof(ConfigVSMail),
typeof(FormMail),
typeof(LogEntry),
typeof(Member),
typeof(Member.ePaymentClass),
typeof(Member.eRole),
typeof(Member.eStatus),
typeof(Member.eType),
typeof(MemberList),
typeof(MemberPayment),
//typeof(ConfigSmtp),
//typeof(ConfigVSMail),
//typeof(FormMail),
//typeof(LogEntry),
//typeof(Member),
//typeof(Member.ePaymentClass),
//typeof(Member.eRole),
//typeof(Member.eStatus),
//typeof(Member.eType),
//typeof(MemberPayment),
};
public static XmlData LoadFromFile(string fileName)

19
view/ComboBoxKV.cs Normal file
View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace dezentrale.view
{
public class ComboBoxKV : ComboBox
{
}
public class ComboKeyValue
{
public string Key { get; set; }
public object Value { get; set; }
public object Tag { get; set; }
}
}

View File

@ -13,7 +13,7 @@ namespace dezentrale.view
public LVMembers() : base()
{
this.View = View.Details;
this.View = View.Details; //This gives us a traditional "list" view.
this.CheckBoxes = true;
this.FullRowSelect = true;
@ -26,12 +26,16 @@ namespace dezentrale.view
this.ContextMenu = cm;
}
public void AddMenuItem(string text, EventHandler handler, bool enabled = true)
public MenuItem AddMenuItem(string text, EventHandler handler = null, MenuItem parent = null, bool enabled = true)
{
MenuItem mi = new MenuItem() { Text = text };
mi.Enabled = enabled;
if(handler != null) mi.Click += handler;
cm.MenuItems.Add(mi);
if (handler != null) mi.Click += handler;
if (parent != null) parent.MenuItems.Add(mi);
else cm.MenuItems.Add(mi);
return mi;
}
public Member GetFirstSelectedMember()
@ -58,6 +62,10 @@ namespace dezentrale.view
lvi.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = $"{(m.Type == Member.eType.Foerdermitglied ? "F" : "R")}" });
lvi.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = $"{m.Status}" });
lvi.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = $"{(m.EMail.Length < 1 ? "" : "📧")}{(m.PgpFingerprint.Length < 1 ? "" : "🔑")}" }); //U+1F4E7, U+1F511
if (m.Status == Member.eStatus.Disabled)
lvi.ForeColor = System.Drawing.Color.DarkGray;
else
lvi.ForeColor = System.Drawing.Color.Black;
}
return lvi;
}
@ -79,6 +87,7 @@ namespace dezentrale.view
public void LoadFromList(List<Member> entries)
{
this.SuspendLayout();
this.Items.Clear();
foreach (Member m in Program.members.Entries)
this.Items.Add(UpdateLvi(new ListViewItem(), m));

View File

@ -26,6 +26,7 @@ namespace dezentrale.view
lstMembers.Width = this.ClientSize.Width - 4;
lstMembers.Height = this.ClientSize.Height - 4;
lstMembers.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
lstMembers.DoubleClick += lstMembers_Edit;
lstMembers.AddMenuItem("Add new member", lstMembers_Add);
lstMembers.AddMenuItem("Edit selected one", lstMembers_Edit);
lstMembers.AddMenuItem("Delete selected one", lstMembers_Delete);
@ -34,31 +35,54 @@ namespace dezentrale.view
lstMembers.AddMenuItem("Cronjob checked ones", lstMembers_CronjobChecked);
lstMembers.AddMenuItem("Cronjob all", lstMembers_CronjobAll);
lstMembers.AddMenuItem("-", null);
#if DEBUG
lstMembers.AddMenuItem("Generate Testdata", lstMembers_GenerateTestdata, null, true);
#endif
lstMembers.AddMenuItem("Main Settings", null);
this.ResumeLayout(false);
//Fill list with data from members
lstMembers.LoadFromList(Program.members.Entries);
}
private void lstMembers_CronjobSelected(object sender, EventArgs e)
private void CronjobMember(Member m)
{
Member m = lstMembers.GetFirstSelectedMember();
if (m != null)
{
Program.members.Cronjob(m);
lstMembers.UpdateEntry(m);
}
}
private void lstMembers_CronjobSelected(object sender, EventArgs e)
{
Member m = lstMembers.GetFirstSelectedMember();
CronjobMember(m);
}
private void lstMembers_CronjobChecked(object sender, EventArgs e)
{
throw new NotImplementedException();
lstMembers.SuspendLayout();
foreach (Member m in lstMembers.GetCheckedMembers()) CronjobMember(m);
lstMembers.ResumeLayout(false);
}
private void lstMembers_CronjobAll(object sender, EventArgs e)
{
throw new NotImplementedException();
lstMembers.SuspendLayout();
foreach (Member m in Program.members.Entries) CronjobMember(m);
lstMembers.ResumeLayout(false);
}
#if DEBUG
private void lstMembers_GenerateTestdata(object sender, EventArgs e)
{
if (Program.members.Entries.Count > 0)
{
DialogResult dr = MessageBox.Show(this, $"Generating testdata will overwrite the current member list.\nUse this on a test system only!\n Really overwrite current member list?", "Really overwrite list?", MessageBoxButtons.YesNo);
if (dr == DialogResult.No) return;
}
Program.members.GenerateTestData();
lstMembers.LoadFromList(Program.members.Entries);
}
#endif
private void lstMembers_Edit(object sender, EventArgs e)
{
Member m = lstMembers.GetFirstSelectedMember();
@ -82,8 +106,15 @@ namespace dezentrale.view
DialogResult dr = MessageBox.Show(this, $"Deleting a member cannot be undone!\nDo you really want to delete member {m.Number:D3} ({m.Nickname})?", "Really delete member?", MessageBoxButtons.YesNo);
if(dr == DialogResult.Yes)
{
MemberList.SaveToFile(Program.MemberFile, Program.members);
try
{
if (!Program.members.Remove(m)) throw new Exception($"Program.members.Remove({m}) returned false.");
} catch(Exception ex)
{
MessageBox.Show($"Cannot remove member:\n{ex.Message}");
return;
}
Program.members.SaveToFile(Program.MemberFile);
lstMembers.RemoveEntry(m);
}
}