diff --git a/DesktopIcon.ico b/DesktopIcon.ico new file mode 100644 index 0000000..4f29bc5 Binary files /dev/null and b/DesktopIcon.ico differ diff --git a/DesktopIcon.png b/DesktopIcon.png new file mode 100644 index 0000000..8f29426 Binary files /dev/null and b/DesktopIcon.png differ diff --git a/TestRun/Mitarbeiter - Kopie.xlsx b/TestRun/Mitarbeiter - Kopie.xlsx new file mode 100644 index 0000000..673fd62 Binary files /dev/null and b/TestRun/Mitarbeiter - Kopie.xlsx differ diff --git a/TestRun/Mitarbeiter.xlsx b/TestRun/Mitarbeiter.xlsx index 9015ddc..527672e 100644 Binary files a/TestRun/Mitarbeiter.xlsx and b/TestRun/Mitarbeiter.xlsx differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_14_44.pdf b/TestRun/Reihentestung_generiert_2021_01_03_14_44.pdf deleted file mode 100644 index 6e3b10f..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_14_44.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_14_47.pdf b/TestRun/Reihentestung_generiert_2021_01_03_14_47.pdf deleted file mode 100644 index db69439..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_14_47.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_14_49.pdf b/TestRun/Reihentestung_generiert_2021_01_03_14_49.pdf deleted file mode 100644 index 56ac77f..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_14_49.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_14_52.pdf b/TestRun/Reihentestung_generiert_2021_01_03_14_52.pdf deleted file mode 100644 index c301af1..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_14_52.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_14_54.pdf b/TestRun/Reihentestung_generiert_2021_01_03_14_54.pdf deleted file mode 100644 index 3baae7a..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_14_54.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_14_55.pdf b/TestRun/Reihentestung_generiert_2021_01_03_14_55.pdf deleted file mode 100644 index ce2de3f..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_14_55.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_14_57.pdf b/TestRun/Reihentestung_generiert_2021_01_03_14_57.pdf deleted file mode 100644 index 44e81a3..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_14_57.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_15_00.pdf b/TestRun/Reihentestung_generiert_2021_01_03_15_00.pdf deleted file mode 100644 index 9c67667..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_15_00.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_15_10.pdf b/TestRun/Reihentestung_generiert_2021_01_03_15_10.pdf deleted file mode 100644 index d35a226..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_15_10.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_15_14.pdf b/TestRun/Reihentestung_generiert_2021_01_03_15_14.pdf deleted file mode 100644 index 443adcd..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_15_14.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_15_15.pdf b/TestRun/Reihentestung_generiert_2021_01_03_15_15.pdf deleted file mode 100644 index 284429e..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_15_15.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_03_15_16.pdf b/TestRun/Reihentestung_generiert_2021_01_03_15_16.pdf deleted file mode 100644 index 47092d6..0000000 Binary files a/TestRun/Reihentestung_generiert_2021_01_03_15_16.pdf and /dev/null differ diff --git a/TestRun/Reihentestung_generiert_2021_01_04_02_20.pdf b/TestRun/Reihentestung_generiert_2021_01_04_02_20.pdf new file mode 100644 index 0000000..2777798 Binary files /dev/null and b/TestRun/Reihentestung_generiert_2021_01_04_02_20.pdf differ diff --git a/TestRun/Reihentestung_generiert_2021_01_04_02_23.pdf b/TestRun/Reihentestung_generiert_2021_01_04_02_23.pdf new file mode 100644 index 0000000..fd60ffe Binary files /dev/null and b/TestRun/Reihentestung_generiert_2021_01_04_02_23.pdf differ diff --git a/TestRun/Reihentestung_generiert_2021_01_04_02_24.pdf b/TestRun/Reihentestung_generiert_2021_01_04_02_24.pdf new file mode 100644 index 0000000..c8fabf4 Binary files /dev/null and b/TestRun/Reihentestung_generiert_2021_01_04_02_24.pdf differ diff --git a/TestRun/Reihentestung_generiert_2021_01_04_02_25.pdf b/TestRun/Reihentestung_generiert_2021_01_04_02_25.pdf new file mode 100644 index 0000000..83fc080 Binary files /dev/null and b/TestRun/Reihentestung_generiert_2021_01_04_02_25.pdf differ diff --git a/UserInterfaceDesktop/App.config b/UserInterfaceDesktop/App.config index 56efbc7..529b889 100644 --- a/UserInterfaceDesktop/App.config +++ b/UserInterfaceDesktop/App.config @@ -1,6 +1,6 @@ - + - - - + + + \ No newline at end of file diff --git a/UserInterfaceDesktop/DesktopIcon.ico b/UserInterfaceDesktop/DesktopIcon.ico new file mode 100644 index 0000000..4f29bc5 Binary files /dev/null and b/UserInterfaceDesktop/DesktopIcon.ico differ diff --git a/UserInterfaceDesktop/Entry.cs b/UserInterfaceDesktop/Entry.cs index 6699fc8..b8eda92 100644 --- a/UserInterfaceDesktop/Entry.cs +++ b/UserInterfaceDesktop/Entry.cs @@ -41,7 +41,7 @@ public async Task GetID() form.Add(new StringContent(Testee.Birthday.Day.ToString()), "birstday1"); form.Add(new StringContent(Testee.Birthday.Month.ToString()), "birstday2"); form.Add(new StringContent(Testee.Birthday.Year.ToString()), "birstday3"); - form.Add(new StringContent(Testee.Gender == GenderEnum.MALE ? "M" : "W"), "geschlecht"); + form.Add(new StringContent(Testee.Gender), "geschlecht"); form.Add(new StringContent(Testee.Forename), "vorname"); form.Add(new StringContent(Testee.Surname), "nachname"); form.Add(new StringContent(Testee.Email), "email1"); @@ -60,13 +60,7 @@ public async Task GetID() public void CreatePdf(PdfDocument pdfDocument, Document document, bool isLast) { - //string[] paths = { outputFolder, String.Format("{0}_{1}_{2}_{3}.pdf", Testee.Surname, Testee.Forename, RunNumber, ID),}; - //string fullPath = Path.Combine(paths); - //PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new FileStream(fullPath, FileMode.Create, FileAccess.Write))); - //Document document = new Document(pdfDocument); - - //String line = "Hello! Welcome to iTextPdf"; - //document.Add(new Paragraph(line)); + document.SetLeftMargin(100); Barcode128 b = new Barcode128(pdfDocument); b.SetCodeType(Barcode128.CODE128); b.SetCode(ID); diff --git a/UserInterfaceDesktop/ExcelParser.cs b/UserInterfaceDesktop/ExcelParser.cs index 7a763d8..95d104c 100644 --- a/UserInterfaceDesktop/ExcelParser.cs +++ b/UserInterfaceDesktop/ExcelParser.cs @@ -2,31 +2,80 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; namespace UserInterfaceDesktop { public class ExcelParser { + public static string[] AllowedCountries = { "DE", "AF", "EG", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "GQ", "AR", "AM", "AW", "AZ", "ET", "AU", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "CL", "CN", "CK", "CR", "CW", "DK", "CD", "DE", "DM", "DO", "DJ", "EC", "SV", "CI", "ER", "EE", "SZ", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "GH", "GI", "GD", "GR", "GL", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "HN", "HK", "IN", "ID", "IM", "IQ", "IR", "IE", "IS", "IL", "IT", "JM", "JP", "YE", "JE", "JO", "VG", "VI", "KY", "KH", "CM", "CA", "CV", "KZ", "QA", "KE", "KG", "KI", "CC", "CO", "KM", "XK", "HR", "CU", "KW", "LA", "LS", "LV", "LB", "LR", "LY", "LI", "LT", "LU", "MO", "MG", "MW", "MY", "MV", "ML", "MT", "MA", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MZ", "MM", "NA", "NR", "NP", "NC", "NZ", "NI", "NL", "NE", "NG", "NU", "KP", "MP", "MK", "NF", "NO", "OM", "AT", "TL", "PK", "PS", "PW", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "CG", "RE", "RW", "RO", "RU", "MF", "SB", "ZM", "WS", "SM", "BL", "ST", "SA", "SE", "CH", "SN", "RS", "SC", "SL", "ZW", "SG", "SX", "SK", "SI", "SO", "ES", "LK", "SH", "KN", "LC", "PM", "VC", "ZA", "SD", "GS", "KR", "SS", "SR", "SJ", "SY", "TJ", "TW", "TZ", "TH", "TG", "TK", "TO", "TT", "TD", "CZ", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "HU", "UY", "UZ", "VU", "VA", "VE", "AE", "US", "GB", "VN", "WF", "CX", "EH", "CF", "CY", }; + + public static string[] AllowedGenders = { "M", "W" }; + public static List Parse(string path) { var fi = new FileInfo(path); var p = new ExcelPackage(fi); var ws = p.Workbook.Worksheets["Personen"]; List persons = new List(); - for(int i = ws.Dimension.Start.Row + 1; i <= ws.Dimension.End.Row; i++) + for (int i = ws.Dimension.Start.Row + 1; i <= ws.Dimension.End.Row; i++) { + string gender = ws.Cells[i, 3].Text; + if (!Array.Exists(AllowedGenders, e => String.Equals(gender, e, StringComparison.OrdinalIgnoreCase))) + { + throw new Exception($"Fehler in Zeile {i}: Das Geschlecht wurde nicht erkannt. Es wird nur M und W unterstützt."); + } + string country = ws.Cells[i, 10].Text; + if (!Array.Exists(AllowedCountries, e => String.Equals(country, e, StringComparison.OrdinalIgnoreCase))) + { + throw new Exception($"Fehler in Zeile {i}: Das Herkunftsland wurde nicht erkannt. Bitte benutze eines der folgenden Kürzel: {String.Join(", ", AllowedCountries)}"); + } + string gsa = ws.Cells[i, 11].Text; + if (!Array.Exists(new string[] { "0", "1" }, e => String.Equals(gsa, e, StringComparison.OrdinalIgnoreCase))) + { + throw new Exception($"Fehler in Zeile {i}: Die Übermittelung an das Gesundheitsamt muss entweder 0 oder 1 sein."); + } + string first = ws.Cells[i, 12].Text; + if (!Array.Exists(new string[] { "0", "1" }, e => String.Equals(first, e, StringComparison.OrdinalIgnoreCase))) + { + throw new Exception($"Fehler in Zeile {i}: Die Angabe ob Ersttestung muss entweder 0 oder 1 sein."); + } + string symptoms = ws.Cells[i, 13].Text; + if (!Array.Exists(new string[] { "0", "1" }, e => String.Equals(symptoms, e, StringComparison.OrdinalIgnoreCase))) + { + throw new Exception($"Fehler in Zeile {i}: Die Angabe ob Symptome muss entweder 0 oder 1 sein."); + } + string surname = ws.Cells[i, 1].Text; + if (String.IsNullOrWhiteSpace(surname)) + { + throw new Exception($"Fehler in Zeile {i}: Nachname nicht gesetzt"); + } + string forename = ws.Cells[i, 2].Text; + if (String.IsNullOrWhiteSpace(forename)) + { + throw new Exception($"Fehler in Zeile {i}: Vorname nicht gesetzt"); + } + DateTime birthday = DateTime.Parse(ws.Cells[i, 4].Text); + if (birthday > DateTime.Now || birthday < DateTime.Now.AddYears(-150)) + { + throw new Exception($"Fehler in Zeile {i}: Bitte überprüfe den Geburtstag"); + } persons.Add(new Testee { - Surname = ws.Cells[i, 1].Text, - Forename = ws.Cells[i, 2].Text, - Gender = ws.Cells[i, 3].Text == "M" ? GenderEnum.MALE : GenderEnum.FEMALE, - Birthday = DateTime.Parse(ws.Cells[i, 4].Text), + Surname = surname, + Forename = forename, + Gender = gender, + Birthday = DateTime.Parse(ws.Cells[i, 4].Text ?? throw new Exception($"Fehler in Zeile {i}: Geburtstag nicht gesetzt")), Address = ws.Cells[i, 5].Text, ZIPCode = ws.Cells[i, 6].Text, City = ws.Cells[i, 7].Text, - Email = ws.Cells[i, 8].Text, - Phone = ws.Cells[i, 9].Text, + Email = ws.Cells[i, 8].Text ?? throw new Exception($"Fehler in Zeile {i}: Email nicht gesetzt"), + Phone = ws.Cells[i, 9].Text ?? throw new Exception($"Fehler in Zeile {i}: Telefonnummer nicht gesetzt"), + Country = country, + GSA = gsa, + Symptoms = symptoms, + FirstTest = first, Line = i, }); } diff --git a/UserInterfaceDesktop/MainWindow.xaml.cs b/UserInterfaceDesktop/MainWindow.xaml.cs index 70fcee3..dbec0b5 100644 --- a/UserInterfaceDesktop/MainWindow.xaml.cs +++ b/UserInterfaceDesktop/MainWindow.xaml.cs @@ -25,6 +25,7 @@ namespace UserInterfaceDesktop /// public partial class MainWindow : Window { + protected string output {get; set;} public MainWindow() { InitializeComponent(); @@ -87,6 +88,7 @@ private async void Generate_Button_Click(object sender, RoutedEventArgs e) { // Save document string outPutPath = dlg.FileName; + output = outPutPath; AddToLog($"Einlesen der Exceldatei von {excelPath}"); List persons = ExcelParser.Parse(excelPath); AddToLog("Exceldatei erfolgreich eingelesen"); @@ -126,7 +128,11 @@ private async void Generate_Button_Click(object sender, RoutedEventArgs e) } catch (Exception ex) { - + Progress.Value = 0; + Progress.IsIndeterminate = false; + AddToLog(ex.Message); + AddToLog($"Löschen der beschädigten PDF-Datei unter {output}"); + File.Delete(output); MessageBox.Show(ex.Message + "\r"); } } diff --git a/UserInterfaceDesktop/Notes.md b/UserInterfaceDesktop/Notes.md new file mode 100644 index 0000000..2940fc0 --- /dev/null +++ b/UserInterfaceDesktop/Notes.md @@ -0,0 +1,252 @@ +Countries + +DE, +AF, +EG, +AX, +AL, +DZ, +AS, +AD, +AO, +AI, +AQ, +AG, +GQ, +AR, +AM, +AW, +AZ, +ET, +AU, +BS, +BH, +BD, +BB, +BY, +BE, +BZ, +BJ, +BM, +BT, +BO, +BQ, +BA, +BW, +BV, +BR, +IO, +BN, +BG, +BF, +BI, +CL, +CN, +CK, +CR, +CW, +DK, +CD, +DE, +DM, +DO, +DJ, +EC, +SV, +CI, +ER, +EE, +SZ, +FK, +FO, +FJ, +FI, +FR, +GF, +PF, +TF, +GA, +GM, +GE, +GH, +GI, +GD, +GR, +GL, +GP, +GU, +GT, +GG, +GN, +GW, +GY, +HT, +HM, +HN, +HK, +IN, +ID, +IM, +IQ, +IR, +IE, +IS, +IL, +IT, +JM, +JP, +YE, +JE, +JO, +VG, +VI, +KY, +KH, +CM, +CA, +CV, +KZ, +QA, +KE, +KG, +KI, +CC, +CO, +KM, +XK, +HR, +CU, +KW, +LA, +LS, +LV, +LB, +LR, +LY, +LI, +LT, +LU, +MO, +MG, +MW, +MY, +MV, +ML, +MT, +MA, +MH, +MQ, +MR, +MU, +YT, +MX, +FM, +MD, +MC, +MN, +ME, +MS, +MZ, +MM, +NA, +NR, +NP, +NC, +NZ, +NI, +NL, +NE, +NG, +NU, +KP, +MP, +MK, +NF, +NO, +OM, +AT, +TL, +PK, +PS, +PW, +PA, +PG, +PY, +PE, +PH, +PN, +PL, +PT, +PR, +CG, +RE, +RW, +RO, +RU, +MF, +SB, +ZM, +WS, +SM, +BL, +ST, +SA, +SE, +CH, +SN, +RS, +SC, +SL, +ZW, +SG, +SX, +SK, +SI, +SO, +ES, +LK, +SH, +KN, +LC, +PM, +VC, +ZA, +SD, +GS, +KR, +SS, +SR, +SJ, +SY, +TJ, +TW, +TZ, +TH, +TG, +TK, +TO, +TT, +TD, +CZ, +TN, +TR, +TM, +TC, +TV, +UG, +UA, +HU, +UY, +UZ, +VU, +VA, +VE, +AE, +US, +GB, +VN, +WF, +CX, +EH, +CF, +CY, diff --git a/UserInterfaceDesktop/Testee.cs b/UserInterfaceDesktop/Testee.cs index e980b79..23a0a2a 100644 --- a/UserInterfaceDesktop/Testee.cs +++ b/UserInterfaceDesktop/Testee.cs @@ -8,7 +8,7 @@ namespace UserInterfaceDesktop public class Testee { public DateTime Birthday { get; set; } - public GenderEnum Gender { get; set; } + public string Gender { get; set; } public string Forename { get; set; } public string Surname { get; set; } public string Email { get; set; } @@ -16,11 +16,11 @@ public class Testee public string Address { get; set; } public string ZIPCode { get; set; } public string City { get; set; } - public string Country { get; } = "DE"; - public string GSA { get; } = "0"; + public string Country { get; set; } + public string GSA { get; set; } public string CoronaApp { get; } = "0"; - public string Symptoms { get; } = "0"; - public string FirstTest { get; } = "0"; + public string Symptoms { get; set; } + public string FirstTest { get; set; } public string TestReason { get; } = "0"; public string VAufendhalt3 { get; } = "2021"; public string BAufendhalt3 { get; } = "2021"; diff --git a/UserInterfaceDesktop/TextTemplate.ico b/UserInterfaceDesktop/TextTemplate.ico new file mode 100644 index 0000000..0925e56 Binary files /dev/null and b/UserInterfaceDesktop/TextTemplate.ico differ diff --git a/UserInterfaceDesktop/UserInterfaceDesktop.csproj b/UserInterfaceDesktop/UserInterfaceDesktop.csproj index 4e46fbb..b3bcb40 100644 --- a/UserInterfaceDesktop/UserInterfaceDesktop.csproj +++ b/UserInterfaceDesktop/UserInterfaceDesktop.csproj @@ -7,13 +7,33 @@ {9046B1B0-3EF9-4886-A810-E827DD7496C8} WinExe UserInterfaceDesktop - UserInterfaceDesktop + ReihentestungstoolBayern v4.7.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 true true + false + C:\Users\Alex\source\repos\CovidBulkBavaria\bin\Release\Desktop\ + true + Disk + false + Foreground + 7 + Days + false + false + true + de + Alexander Wulf + true + 6 + 0.2.0.%2a + false + true + true + true AnyCPU @@ -34,6 +54,24 @@ prompt 4 + + 167D3FFD7E0F559442EDA43CDDE264EB7C1798A5 + + + UserInterfaceDesktop_TemporaryKey.pfx + + + true + + + true + + + DesktopIcon.ico + + + true + ..\packages\Portable.BouncyCastle.1.8.5\lib\net40\BouncyCastle.Crypto.dll @@ -79,6 +117,7 @@ + @@ -132,14 +171,34 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs + + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + + + + \ No newline at end of file