public static void UpdateSpeakers(string File) { Log.Info(nameof(UpdateSpeakers), File); var fi = new FileInfo(File); using (ExcelPackage package = new ExcelPackage(fi)) { ExcelWorksheet worksheet = package.Workbook.Worksheets["Redner"]; var row = 2; var id = DataContainer.Redner.Count > 0 ? DataContainer.Redner.Select(x => x.Id).Max() + 1 : 1; while (true) { var vers = worksheet.Cells[row, 1].Value; var name = worksheet.Cells[row, 2].Value; var vort = worksheet.Cells[row, 3].Value; if (vers == null) { break; } //Versammlung var rednerVersammlung = DataContainer.ConregationFindOrAdd(vers.ToString()); var s = DataContainer.SpeakerFind(name.ToString(), rednerVersammlung); if (s == null) { s = new Speaker { Name = name.ToString(), Id = id, Versammlung = rednerVersammlung, }; DataContainer.Redner.Add(s); id++; } //Vorträge var meineVotrgäge = vort.ToString().Split(new[] { ';', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var v in meineVotrgäge) { var nr = int.Parse(v, Helper.German); var t = TalkList.Find(nr); if (!(t is null) && !s.Vorträge.Select(y => y.Vortrag).Contains(t)) { s.Vorträge.Add(new TalkSong(t)); } } row++; } } // the using statement automatically calls Dispose() which closes the package. }
public static bool ExternePlanungen(string filename) { Log.Info(nameof(ExternePlanungen), filename); try { var file = new FileInfo(filename); using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (ExcelPackage package = new ExcelPackage(fs)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; var row = 2; while (true) { var datum = Helper.ConvertToString(worksheet.Cells[row, 1].Value); var redner = Helper.ConvertToString(worksheet.Cells[row, 2].Value); var vortrag = Helper.ConvertToString(worksheet.Cells[row, 3].Value); var vers = Helper.ConvertToString(worksheet.Cells[row, 4].Value); var versAdresse = Helper.ConvertToString(worksheet.Cells[row, 5].Value); row++; if (string.IsNullOrWhiteSpace(datum)) { break; } if (datum.StartsWith("Datum", true, Helper.German)) { continue; } if (string.IsNullOrWhiteSpace(redner)) { continue; } if (string.IsNullOrWhiteSpace(vers)) { vers = "Unbekannt"; } var kw = Helper.CalculateWeek(DateTime.Parse(datum, Helper.German)); var i = new Outside { Kw = kw }; //Redner var r = DataContainer.SpeakerFindOrAdd(redner.ToString(), DataContainer.MeineVersammlung); if (r == null) { continue; } i.Ältester = r; //Gast-Versammlung if (vers == "Urlaub") { DataContainer.Abwesenheiten.Add(new Busy(r, kw)); continue; } var v = DataContainer.ConregationFindOrAdd(vers); i.Versammlung = v; if (string.IsNullOrEmpty(i.Ältester.Versammlung.Anschrift1) && !string.IsNullOrEmpty(versAdresse)) { i.Ältester.Versammlung.Anschrift1 = versAdresse; } var vn = int.Parse(vortrag.ToString(), Helper.German); //Vortrag var t = TalkList.Find(vn); i.Vortrag = new TalkSong(t); if (!i.Ältester.Vorträge.Select(y => y.Vortrag).Contains(t)) { i.Ältester.Vorträge.Add(i.Vortrag); } if (!DataContainer.ExternerPlan.Any(x => x.Kw == i.Kw && x.Ältester == i.Ältester)) { DataContainer.ExternerPlan.Add(i); } } } } catch (Exception e) { Log.Error(nameof(ExternePlanungen), e.Message); ThemedMessageBox.Show("Fehler", $"Beim Einlesen der Excel-Datei ist es zu folgendem Fehler gekommen\n:{e.Message}", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); DataContainer.ExternerPlan.Clear(); return(false); } return(true); }
public static bool EigenePlanungen(string filename) { Log.Info(nameof(EigenePlanungen), filename); try { var file = new FileInfo(filename); using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (ExcelPackage package = new ExcelPackage(fs)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; var row = 2; while (true) { var datum = Helper.ConvertToString(worksheet.Cells[row, 1].Value); var redner = Helper.ConvertToString(worksheet.Cells[row, 2].Value); var vortrag = Helper.ConvertToString(worksheet.Cells[row, 3].Value); var thema = Helper.ConvertToString(worksheet.Cells[row, 4].Value); var vers = Helper.ConvertToString(worksheet.Cells[row, 5].Value); var versAdresse = Helper.ConvertToString(worksheet.Cells[row, 6].Value); var rednerMail = Helper.ConvertToString(worksheet.Cells[row, 7].Value); var rednerJwpub = Helper.ConvertToString(worksheet.Cells[row, 8].Value); var rednerTelefon = Helper.ConvertToString(worksheet.Cells[row, 9].Value); row++; if (string.IsNullOrWhiteSpace(datum) || datum.StartsWith("Datum", true, Helper.German)) { break; } if (string.IsNullOrWhiteSpace(redner) && string.IsNullOrWhiteSpace(thema)) //Keine Planung eingetragen { continue; } var kw = Helper.CalculateWeek(DateTime.Parse(datum.ToString(), Helper.German)); if (string.IsNullOrWhiteSpace(redner)) //Special Event eintragen { var se = new SpecialEvent { Kw = kw, Typ = SpecialEventTyp.Sonstiges, }; if (thema.Contains("Weltzentrale")) { se.Typ = SpecialEventTyp.Streaming; se.Name = thema; } else if (thema.Contains("Kreiskongress")) { se.Typ = SpecialEventTyp.Kreiskongress; } else if (thema.Contains("Sondervortrag") || thema.Contains("Streaming")) { se.Typ = SpecialEventTyp.Streaming; se.Name = thema; } else if (thema.Contains("Regionaler Kongress")) { se.Typ = SpecialEventTyp.RegionalerKongress; } else if (thema.Contains("Dienstwoche")) { se.Typ = SpecialEventTyp.Dienstwoche; } else if (thema.Contains("Dienstwoche")) { se.Typ = SpecialEventTyp.Dienstwoche; } DataContainer.MeinPlanAdd(se); continue; } var i = new Invitation { Kw = kw }; //Versammlung if (string.IsNullOrWhiteSpace(vers)) { vers = "Unbekannt"; } if (string.IsNullOrWhiteSpace(redner)) { redner = "Unbekannt"; } var v = DataContainer.ConregationFindOrAdd(vers); var r = DataContainer.SpeakerFindOrAdd(redner, v); i.Ältester = r; if (string.IsNullOrEmpty(i.Ältester.Versammlung.Anschrift1) && !string.IsNullOrEmpty(versAdresse)) { i.Ältester.Versammlung.Anschrift1 = versAdresse; } if (string.IsNullOrEmpty(i.Ältester.Telefon) && !string.IsNullOrEmpty(rednerTelefon)) { i.Ältester.Telefon = rednerTelefon; } if (string.IsNullOrEmpty(i.Ältester.Mail) && !string.IsNullOrEmpty(rednerMail)) { i.Ältester.Mail = rednerMail; } if (string.IsNullOrEmpty(i.Ältester.JwMail) && !string.IsNullOrEmpty(rednerJwpub)) { i.Ältester.JwMail = rednerJwpub; } //Vortrag var vn = int.Parse(vortrag.ToString(), Helper.German); var t = TalkList.Find(vn); i.Vortrag = new TalkSong(t); if (!i.Ältester.Vorträge.Select(y => y.Vortrag).Contains(t)) { i.Ältester.Vorträge.Add(i.Vortrag); } DataContainer.MeinPlanAdd(i); } } } catch (Exception e) { Log.Error(nameof(EigenePlanungen), e.Message); ThemedMessageBox.Show("Fehler", $"Beim Einlesen der Excel-Datei ist es zu folgendem Fehler gekommen\n:{e.Message}", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); DataContainer.MeinPlan.Clear(); return(false); } return(true); }