private async Task <int> ExportSchoolClasses(XlsReader xlsReader, EcfTableWriter ecfTableWriter, string[] ecfHeaders) { var ecfCache = new HashSet <string>(); var ecfRecordCounter = 0; if (ecfHeaders != null && ecfHeaders.Length > 0) { await ecfTableWriter.WriteHeadersAsync(ecfHeaders); } else { await ecfTableWriter.WriteHeadersAsync( EcfHeaders.Id, EcfHeaders.Code); } while (xlsReader.ReadLine()) { var schoolClass = new ExportSchoolClass(_config, xlsReader); if (!string.IsNullOrEmpty(schoolClass.Id) && !ecfCache.Contains(schoolClass.Id)) { ecfTableWriter.SetValue(EcfHeaders.Id, schoolClass.Id); ecfTableWriter.SetValue(EcfHeaders.Code, schoolClass.Code); await ecfTableWriter.WriteAsync(); ecfCache.Add(schoolClass.Id); ecfRecordCounter++; } } return(ecfRecordCounter); }
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> 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); }