private async Task <int> ExportStudentSchoolClassAttendances(XlsReader xlsReader, EcfTableWriter ecfTableWriter, string[] ecfHeaders) { var ecfRecordCounter = 0; if (ecfHeaders != null && ecfHeaders.Length > 0) { await ecfTableWriter.WriteHeadersAsync(ecfHeaders); } else { await ecfTableWriter.WriteHeadersAsync( EcfHeaders.StudentId, EcfHeaders.SchoolClassId); } while (xlsReader.ReadLine()) { var student = new ExportStudent(_config, xlsReader); var schoolClass = new ExportSchoolClass(_config, xlsReader); if (!string.IsNullOrEmpty(schoolClass.Id)) { ecfTableWriter.SetValue(EcfHeaders.StudentId, student.Id); ecfTableWriter.SetValue(EcfHeaders.SchoolClassId, schoolClass.Id); await ecfTableWriter.WriteAsync(); ecfRecordCounter++; } } return(ecfRecordCounter); }
private async Task <int> ExportStudents(CsvTableReader csvTableReader, EcfTableWriter ecfTableWriter, string[] ecfHeaders) { var ecfCache = new HashSet <string>(); var ecfRecordCounter = 0; await csvTableReader.ReadHeadersAsync(); if (ecfHeaders != null && ecfHeaders.Length > 0) { await ecfTableWriter.WriteHeadersAsync(ecfHeaders); } else { await ecfTableWriter.WriteHeadersAsync( EcfHeaders.Id, EcfHeaders.LastName, EcfHeaders.FirstName, EcfHeaders.MiddleName, EcfHeaders.NickName, EcfHeaders.Salutation, EcfHeaders.Gender, EcfHeaders.Birthdate); } while (await csvTableReader.ReadAsync() > 0) { var student = new ExportStudent(_config, csvTableReader); if (!ecfCache.Contains(student.Id)) { ecfTableWriter.SetValue(EcfHeaders.Id, student.Id); ecfTableWriter.SetValue(EcfHeaders.LastName, student.LastName); ecfTableWriter.SetValue(EcfHeaders.FirstName, student.FirstName); ecfTableWriter.SetValue(EcfHeaders.MiddleName, student.MiddleName); ecfTableWriter.SetValue(EcfHeaders.NickName, student.NickName); ecfTableWriter.SetValue(EcfHeaders.Salutation, student.Salutation); ecfTableWriter.SetValue(EcfHeaders.Gender, student.Gender); ecfTableWriter.SetValue(EcfHeaders.Birthdate, student.BirthDate); await ecfTableWriter.WriteAsync(); ecfCache.Add(student.Id); ecfRecordCounter++; } } return(ecfRecordCounter); }
private async Task <int> ExportStudentSubjects(CsvTableReader csvTableReader, EcfTableWriter ecfTableWriter, string[] ecfHeaders) { var ecfRecordCounter = 0; await csvTableReader.ReadHeadersAsync(); if (ecfHeaders != null && ecfHeaders.Length > 0) { await ecfTableWriter.WriteHeadersAsync(ecfHeaders); } else { await ecfTableWriter.WriteHeadersAsync( EcfHeaders.StudentId, EcfHeaders.SchoolClassId, EcfHeaders.SubjectId); } while (await csvTableReader.ReadAsync() > 0) { var student = new ExportStudent(_config, csvTableReader); var schoolClass = new ExportSchoolClass(_config, csvTableReader); if (!string.IsNullOrEmpty(schoolClass.Id)) { for (int i = 1; i < 20; i++) { var subject = new ExportSubject(_config, csvTableReader, $"Fach{i}"); if (!string.IsNullOrEmpty(subject.Id)) { ecfTableWriter.SetValue(EcfHeaders.StudentId, student.Id); ecfTableWriter.SetValue(EcfHeaders.SchoolClassId, schoolClass.Id); ecfTableWriter.SetValue(EcfHeaders.SubjectId, subject.Id); await ecfTableWriter.WriteAsync(); ecfRecordCounter++; } } } } return(ecfRecordCounter); }