190523PX Changed storage to remove "XmlData" as root element; moved some XmlElements to attributes; added possible CSV fields (comment), updated payment amounts to Cents (still works with integers)
This commit is contained in:
parent
cb8d662f3b
commit
f2bc73ee4f
10
Cronjob.cs
10
Cronjob.cs
|
@ -10,12 +10,12 @@ namespace dezentrale
|
|||
{
|
||||
private static void CheckGreeting(Member m)
|
||||
{
|
||||
if (m.Status == Member.eStatus.Uninitialized)
|
||||
if (m.Status == Member.eStatus.Uninitialized && m.EMail.Length > 0)
|
||||
{
|
||||
m.StartLogEvent("Sending greetings", LogEvent.eEventType.Greetings, "cronjob");
|
||||
//Send greetings mail,//send mail to vorstand
|
||||
try
|
||||
{
|
||||
//Send greetings mail,//send mail to vorstand
|
||||
m.StartLogEvent("Sending greetings", LogEvent.eEventType.Greetings, "automatic");
|
||||
FormMail
|
||||
tmp = FormMail.GenerateNewMemberWelcome().ReplaceReflect(m);
|
||||
tmp.Send();
|
||||
|
@ -48,7 +48,7 @@ namespace dezentrale
|
|||
if ((ts.TotalDays < 7) || (m.SpawnDate > DateTime.Now) || (m.PaymentsTotal < m.PaymentAmount) || (m.AccountBalance < 0))
|
||||
return;
|
||||
|
||||
m.StartLogEvent("Sending activation mail", LogEvent.eEventType.Activation, "cronjob");
|
||||
m.StartLogEvent("Sending activation mail", LogEvent.eEventType.Activation, "automatic");
|
||||
//Send greetings mail, send mail to vorstand
|
||||
try
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ namespace dezentrale
|
|||
DateTime lastDegrade = m.LastBalanceDegrade;
|
||||
while (lastDegrade.Month != thisMonth) { lastDegrade = lastDegrade.AddMonths(1); months++; }
|
||||
while(lastDegrade.Year < thisYear) { lastDegrade = lastDegrade.AddYears(1); months += 12; }
|
||||
m.StartLogEvent($"Membership fee: {months} Months * {m.PaymentAmount} EUR = {months * m.PaymentAmount} EUR", LogEvent.eEventType.MembershipFee, "cronjob");
|
||||
m.StartLogEvent($"Membership fee: {months} Months * {m.PaymentAmount} EUR = {months * m.PaymentAmount} EUR", LogEvent.eEventType.MembershipFee, "automatic");
|
||||
m.AccountBalance -= (int) (((int) months) * m.PaymentAmount);
|
||||
m.LastBalanceDegrade = DateTime.Now;
|
||||
m.SaveToFile();
|
||||
|
|
50
Program.cs
50
Program.cs
|
@ -10,7 +10,7 @@ namespace dezentrale
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
public static uint VersionNumber { get; private set; } = 0x19052200;
|
||||
public static uint VersionNumber { get; private set; } = 0x19052300;
|
||||
public static string VersionString { get; private set; } = $"{VersionNumber:x}";
|
||||
|
||||
public static string AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
|
@ -20,6 +20,8 @@ namespace dezentrale
|
|||
|
||||
public static Configuration config = new Configuration();
|
||||
public static MemberList members = new MemberList();
|
||||
public static BankTransferList bankTransfers = new BankTransferList();
|
||||
|
||||
public enum eMode
|
||||
{
|
||||
CommandLine = 0,
|
||||
|
@ -92,7 +94,7 @@ namespace dezentrale
|
|||
|
||||
try
|
||||
{
|
||||
config = (Configuration)XmlData.LoadFromFile(ConfigFile);
|
||||
config = (Configuration)XmlData.LoadFromFile(ConfigFile, typeof(Configuration));
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
|
@ -139,17 +141,57 @@ namespace dezentrale
|
|||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum eCsvFields
|
||||
{
|
||||
Auftragskonto,
|
||||
}
|
||||
|
||||
public static void ProcessCSV(string fileName)
|
||||
{
|
||||
CsvFile csv = new CsvFile();
|
||||
try
|
||||
{
|
||||
csv.ReadFile(fileName);
|
||||
|
||||
bool headline = true;
|
||||
eCsvFields[] fields;
|
||||
foreach(List<string> l in csv.FileContents)
|
||||
{
|
||||
|
||||
if(headline)
|
||||
{
|
||||
//The first line is expected to have the headline field first, describing the contents
|
||||
fields = new eCsvFields[l.Count];
|
||||
for(int i = 0; i < l.Count; i++)
|
||||
{
|
||||
switch(l[i])
|
||||
{
|
||||
case "Auftragskonto": fields[i] = eCsvFields.Auftragskonto;
|
||||
break;
|
||||
/*
|
||||
"Buchungstag";
|
||||
"Valutadatum";
|
||||
"Buchungstext";
|
||||
"Verwendungszweck";
|
||||
"Glaeubiger ID";
|
||||
"Mandatsreferenz";
|
||||
"Kundenreferenz (End-to-End)";
|
||||
"Sammlerreferenz";
|
||||
"Lastschrift Ursprungsbetrag";
|
||||
"Auslagenersatz Ruecklastschrift";
|
||||
"Beguenstigter/Zahlungspflichtiger";
|
||||
"Kontonummer/IBAN";
|
||||
"Kontonummer";
|
||||
"BIC (SWIFT-Code)";
|
||||
"BLZ";
|
||||
"Betrag";
|
||||
"Waehrung";
|
||||
"Info"
|
||||
*/
|
||||
}
|
||||
}
|
||||
headline = false;
|
||||
}
|
||||
}
|
||||
} catch(Exception ex)
|
||||
{
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Cronjob.cs" />
|
||||
<Compile Include="model\BankTransfer.cs" />
|
||||
<Compile Include="model\BankTransferList.cs" />
|
||||
<Compile Include="model\CsvFile.cs" />
|
||||
<Compile Include="model\Country.cs" />
|
||||
<Compile Include="model\LogSubEvent.cs" />
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace dezentrale.model
|
||||
{
|
||||
public class BankTransfer
|
||||
{
|
||||
public int Amount { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace dezentrale.model
|
||||
{
|
||||
public class BankTransferList : List<BankTransfer>
|
||||
{
|
||||
[XmlElement] public DateTime LastUpdate { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ namespace dezentrale.model
|
|||
[XmlElement] public ConfigVSMail VS { get; set; } = new ConfigVSMail();
|
||||
|
||||
[XmlElement] public string MemberDirectory { get; set; } = "member-data";
|
||||
[XmlElement] public uint RegularPaymentAmount { get; set; } = 32;
|
||||
[XmlElement] public uint RegularPaymentAmount { get; set; } = 3200; //cents
|
||||
[XmlElement] public string LocalUser { get; set; } = "";
|
||||
[XmlElement] public string KeylockCombination { get; set; } = "0000";
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ namespace dezentrale.model
|
|||
ActionFinished,
|
||||
Error,
|
||||
}
|
||||
[XmlElement] public DateTime Timestamp { get; set; } = DateTime.Now;
|
||||
[XmlElement] public string LocalUser { get; set; } = Program.config.LocalUser;
|
||||
[XmlAttribute] public DateTime Timestamp { get; set; } = DateTime.Now;
|
||||
[XmlAttribute] public string LocalUser { get; set; } = Program.config.LocalUser;
|
||||
[XmlElement("SubEvent")] public List<LogSubEvent> SubEvents { get; set; } = new List<LogSubEvent>();
|
||||
[XmlElement] public bool Finished { get; set; } = false;
|
||||
[XmlAttribute] public bool Finished { get; set; } = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace dezentrale.model
|
|||
{
|
||||
public class LogSubEvent
|
||||
{
|
||||
[XmlAttribute] public LogEvent.eEventType Type { get; set; } = LogEvent.eEventType.Generic;
|
||||
[XmlElement] public string Topic { get; set; } = "";
|
||||
[XmlElement] public LogEvent.eEventType Type { get; set; } = LogEvent.eEventType.Generic;
|
||||
[XmlElement] public string Details { get; set; } = "";
|
||||
|
||||
}
|
||||
|
|
|
@ -70,16 +70,16 @@ namespace dezentrale.model
|
|||
//The main goal is to track every change to every property.
|
||||
//Therefore, private variables are defined and the get/set methods are handled manually.
|
||||
//A property change is then tracked using LogPropertyChange()
|
||||
[XmlElement] public uint Number { get { return number; } set { LogPropertyChange("Number", number, value); number = value; } }
|
||||
[XmlAttribute] public uint Number { get { return number; } set { LogPropertyChange("Number", number, value); number = value; } }
|
||||
[XmlAttribute] public eType Type { get { return type; } set { LogPropertyChange("Type", type, value); type = value; } }
|
||||
[XmlAttribute] public eStatus Status { get { return status; } set { LogPropertyChange("Status", status, value); status = value; } }
|
||||
[XmlElement] public eRole Role { get { return role; } set { LogPropertyChange("Role", role, value); role = value; } }
|
||||
[XmlElement] public eType Type { get { return type; } set { LogPropertyChange("Type", type, value); type = value; } }
|
||||
[XmlElement] public eStatus Status { get { return status; } set { LogPropertyChange("Status", status, value); status = value; } }
|
||||
[XmlElement] public string Remarks { get { return remarks; } set { LogPropertyChange("Remarks", remarks, value); remarks = value; } }
|
||||
[XmlElement] public uint MvMissCounter { get { return mvMiss; } set { LogPropertyChange("MvMissCounter", mvMiss, value); mvMiss = value; } }
|
||||
[XmlElement] public int AccountBalance { get { return accountBalance;}set{LogPropertyChange("AccountBalance",accountBalance,value);accountBalance=value;}}
|
||||
|
||||
//personal data
|
||||
[XmlElement] public string Nickname { get { return nickname; } set { LogPropertyChange("NickName", nickname, value); nickname = value; } }
|
||||
[XmlAttribute] public string Nickname { get { return nickname; } set { LogPropertyChange("NickName", nickname, value); nickname = value; } }
|
||||
[XmlElement] public string FirstName { get { return firstName; } set { LogPropertyChange("FirstName", firstName, value); firstName = value; } }
|
||||
[XmlElement] public string LastName { get { return lastName; } set { LogPropertyChange("LastName", lastName, value); lastName = value; } }
|
||||
[XmlElement] public string Street { get { return street; } set { LogPropertyChange("Street", street, value); street = value; } }
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace dezentrale.model
|
|||
try
|
||||
{
|
||||
LoadingFromFile = true;
|
||||
ml.Entries.Add((Member)XmlData.LoadFromFile(file));
|
||||
ml.Entries.Add((Member)XmlData.LoadFromFile(file, typeof(Member)));
|
||||
} catch(Exception ex)
|
||||
{
|
||||
LoadingFromFile = false;
|
||||
|
@ -99,6 +99,7 @@ namespace dezentrale.model
|
|||
m.MvInvitationByPost = false;
|
||||
m.SpawnDate = new DateTime(2019, 6, 1);
|
||||
m.PaymentClass = Member.ePaymentClass.Reduced;
|
||||
m.PaymentAmount = 995;
|
||||
m.MemberFormDate = new DateTime(2019, 5, 1);
|
||||
}
|
||||
|
||||
|
@ -123,6 +124,7 @@ namespace dezentrale.model
|
|||
m.MvInvitationByPost = false;
|
||||
m.SpawnDate = new DateTime(2019, 6, 1);
|
||||
m.PaymentClass = Member.ePaymentClass.Normal;
|
||||
m.PaymentAmount = 6400;
|
||||
m.MemberFormDate = new DateTime(2019, 5, 1);
|
||||
}
|
||||
|
||||
|
@ -141,12 +143,13 @@ namespace dezentrale.model
|
|||
m.Zipcode = "99867";
|
||||
m.City = "Gotha";
|
||||
m.CountryCode = Country.eCountry.Germany;
|
||||
m.Birthday = new DateTime(1748, 2, 6);
|
||||
m.Birthday = new DateTime(1900, 1, 1);// = 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.PaymentAmount = 2305;
|
||||
m.MemberFormDate = new DateTime(2019, 5, 23);
|
||||
}
|
||||
|
||||
|
@ -165,12 +168,13 @@ namespace dezentrale.model
|
|||
m.Zipcode = "";
|
||||
m.City = "Pittsburgh";
|
||||
m.CountryCode = Country.eCountry.UnitedStatesOfAmerica;
|
||||
m.Birthday = new DateTime(1876, 12, 31);
|
||||
m.Birthday = new DateTime(1900, 1, 1);// = 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.PaymentAmount = 3200;
|
||||
m.MemberFormDate = new DateTime(2019, 5, 1);
|
||||
}
|
||||
|
||||
|
@ -194,6 +198,7 @@ namespace dezentrale.model
|
|||
m.MvInvitationByPost = false;
|
||||
m.SpawnDate = new DateTime(2019, 5, 1);
|
||||
m.PaymentClass = Member.ePaymentClass.Normal;
|
||||
m.PaymentAmount = 3200;
|
||||
m.MemberFormDate = new DateTime(2019, 5, 1);
|
||||
}
|
||||
} catch(Exception ex)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace dezentrale.model
|
|||
public class XmlData
|
||||
{
|
||||
[XmlElement] public DateTime LastChanged { get; set; } = DateTime.Now;
|
||||
|
||||
/*
|
||||
[XmlIgnore]
|
||||
private static Type[] SerializeTypes =
|
||||
{
|
||||
|
@ -22,14 +22,14 @@ namespace dezentrale.model
|
|||
typeof(Configuration),
|
||||
typeof(Member),
|
||||
//typeof(MemberList),
|
||||
};
|
||||
};*/
|
||||
|
||||
public static XmlData LoadFromFile(string fileName)
|
||||
public static XmlData LoadFromFile(string fileName, Type type = null)
|
||||
{
|
||||
FileStream fs = null;
|
||||
try
|
||||
{
|
||||
XmlSerializer ser = new XmlSerializer(typeof(XmlData), XmlData.SerializeTypes);
|
||||
XmlSerializer ser = new XmlSerializer(type ?? typeof(XmlData));
|
||||
|
||||
fs = new FileStream(fileName, FileMode.Open);
|
||||
XmlData ds = (XmlData)ser.Deserialize(fs);
|
||||
|
@ -47,16 +47,18 @@ namespace dezentrale.model
|
|||
{
|
||||
try
|
||||
{
|
||||
if (ds == null) throw new NullReferenceException("XmlData.SaveToFile(fileName, ds): ds == null");
|
||||
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
string backupName = $"{fileName}.bak";
|
||||
if (File.Exists(backupName)) File.Delete(backupName);
|
||||
File.Move(fileName, backupName);
|
||||
}
|
||||
|
||||
|
||||
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
||||
ns.Add("", "");
|
||||
XmlSerializer ser = new XmlSerializer(typeof(XmlData), XmlData.SerializeTypes);
|
||||
XmlSerializer ser = new XmlSerializer(ds.GetType());
|
||||
FileStream fs;
|
||||
fs = new FileStream(fileName, FileMode.Create);
|
||||
ser.Serialize(fs, ds, ns);
|
||||
|
|
|
@ -278,6 +278,14 @@ namespace dezentrale.view
|
|||
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
||||
DropDownStyle = ComboBoxStyle.DropDownList,
|
||||
});
|
||||
//Role
|
||||
//MvMissCounter
|
||||
//AccountBalance
|
||||
/*
|
||||
[XmlElement] public DateTime LastPaymentProcessed { get; set; }
|
||||
[XmlElement] public uint PaymentsTotal { get; set; }
|
||||
[XmlElement] public DateTime LastBalanceDegrade { get; set; }
|
||||
*/
|
||||
parent.Controls.Add(new Label()
|
||||
{
|
||||
Text = "Remarks:",
|
||||
|
|
|
@ -75,9 +75,10 @@ namespace dezentrale.view
|
|||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog()
|
||||
{
|
||||
Filter = "CSV-Dateien (*.csv)|*.csv|Alle Dateien (*.*)|*.*",
|
||||
Filter = "Spaßkasse-CSV-Dateien (*.csv)|*.csv|Alle Dateien (*.*)|*.*",
|
||||
};
|
||||
DialogResult dr = ofd.ShowDialog();
|
||||
//ofd.FilterIndex
|
||||
if(dr == DialogResult.OK)
|
||||
Program.ProcessCSV(ofd.FileName);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue