Exemple #1
0
        public static void AddStudentsSubjects(EcfTableReader ecfTableReader, List <Students> students, List <SimpleCache> schoolTerms)
        {
            while (ecfTableReader.ReadAsync().Result > 0)
            {
                var studentId = ecfTableReader.GetValue <string>("StudentId");
                var student   = students.Find(s => s.EcfId.Equals(studentId));

                var schoolTermId = ecfTableReader.GetValue <string>("SchoolTermId");
                var schoolTerm   = schoolTerms.Find(t => t.EcfId.Equals(schoolTermId));

                var classTermId = ecfTableReader.GetValue <string>("SchoolClassId");

                if (!String.IsNullOrEmpty(studentId) && !String.IsNullOrEmpty(schoolTermId) && !String.IsNullOrEmpty(classTermId) && (student != null) && (schoolTerm != null))
                {
                    var career = student.Career.Find(c => c.EcfValues.SchoolTermId.Equals(schoolTermId) && c.EcfValues.ClassTermId.Equals(classTermId));

                    if (career != null)
                    {
                        career.StudentSubjects.Add(new StudentSubjects(
                                                       ecfTableReader.GetValue <string>("SubjectId"),
                                                       ecfTableReader.GetValue <string>("TeacherId"),
                                                       ecfTableReader.GetValue <string>("Grade1ValueId"),
                                                       ecfTableReader.GetValue <string>("CourseNo"),
                                                       ecfTableReader.GetValue <string>("CourseTypeId"),
                                                       ecfTableReader.GetValue <string>("Grade1AchievementTypeId"),
                                                       ecfTableReader.GetValue <string>("Passfail")
                                                       ));
                    }
                }
            }
        }
        private async Task <int> ImportCustodians(FbConnection fbConnection, EcfTableReader ecfTableReader)
        {
            var recordCounter = 0;

            while (ecfTableReader.ReadAsync().Result > 0)
            {
                // read needed field-values
                var ecfId = ecfTableReader.GetValue <string>("Id");

                DbResult dbResult = await RecordExists.ByGuidExtern(fbConnection, MappingTables.Map(_currentCsv), _tenantId, ecfId);

                if (dbResult.Success)
                {
                    // UPDATE
                    await RecordUpdate.Custodian(fbConnection, ecfTableReader, _tenantId, (int)dbResult.Value);
                }
                else
                {
                    // INSERT
                    await RecordInsert.Custodian(fbConnection, ecfTableReader, _tenantId);
                }

                recordCounter += 1;
            }

            return(await Task.FromResult(recordCounter));
        }
Exemple #3
0
        public static void ProcessStudents(EcfTableReader ecfTableReader, List <Students> students, List <SimpleCache> schoolTerms)
        {
            while (ecfTableReader.ReadAsync().Result > 0)
            {
                var studentId = ecfTableReader.GetValue <string>("StudentId");
                var student   = students.Find(s => s.EcfId.Equals(studentId));

                var schoolTermId = ecfTableReader.GetValue <string>("SchoolTermId");
                var schoolTerm   = schoolTerms.Find(t => t.EcfId.Equals(schoolTermId));

                var classTermId = ecfTableReader.GetValue <string>("SchoolClassId");

                if (!String.IsNullOrEmpty(studentId) && !String.IsNullOrEmpty(schoolTermId) && !String.IsNullOrEmpty(classTermId) && (student != null) && (schoolTerm != null))
                {
                    student.Career.Add(new Career(
                                           ecfTableReader.GetValue <string>("Id"),
                                           ecfTableReader.GetValue <string>("SchoolTermId"),
                                           ecfTableReader.GetValue <string>("SchoolClassId"),
                                           ecfTableReader.GetValue <string>("Status")
                                           )
                                       );
                }
            }

            // Sort student careers
            students.ForEach(s => s.Career.Sort((x, y) => x.EcfValues.SchoolTermId.CompareTo(y.EcfValues.SchoolTermId)));

            students.ForEach(s => s.SetLastGewechseltToN());

            //students.ForEach(s => s.Career.ForEach(c => Console.WriteLine($"Student: {c.EcfIds.StudentId} - {c.EcfIds.SchoolTermId} - {c.Gewechselt}")));
        }
Exemple #4
0
        public static void ProcessStudentsSubjects(EcfTableReader ecfTableReader, List <Students> students)
        {
            while (ecfTableReader.ReadAsync().Result > 0)
            {
                var studentId    = ecfTableReader.GetValue <string>("StudentId");
                var student      = students.Find(s => s.EcfId.Equals(studentId));
                var schoolTermId = ecfTableReader.GetValue <string>("SchoolTermId");
                var classTermId  = ecfTableReader.GetValue <string>("SchoolClassId");
                var subjectId    = ecfTableReader.GetValue <string>("SubjectId");

                if (!String.IsNullOrEmpty(studentId) && !String.IsNullOrEmpty(schoolTermId) && !String.IsNullOrEmpty(classTermId) && !String.IsNullOrEmpty(subjectId) && (student != null))
                {
                    var careerId = ecfTableReader.GetValue <string>("Id");
                    var career   = student.Career.Find(c => c.EcfValues.Id.Equals(careerId));

                    if (career == null)
                    {
                        career = new Career(
                            ecfTableReader.GetValue <string>("Id"),
                            ecfTableReader.GetValue <string>("SchoolTermId"),
                            ecfTableReader.GetValue <string>("SchoolClassId"),
                            ecfTableReader.GetValue <string>("StudentId")
                            );

                        student.Career.Add(career);
                    }

                    StudentSubjects studentSubjects = new StudentSubjects(
                        ecfTableReader.GetValue <string>("SubjectId"),
                        ecfTableReader.GetValue <string>("TeacherId"),
                        ecfTableReader.GetValue <string>("Grade1ValueId"),
                        ecfTableReader.GetValue <string>("CourseNo"),
                        ecfTableReader.GetValue <string>("CourseTypeId"),
                        ecfTableReader.GetValue <string>("Grade1AchievementTypeId"),
                        ecfTableReader.GetValue <string>("Passfail")
                        );

                    career.StudentSubjects.Add(studentSubjects);
                }
            }
        }
Exemple #5
0
        private async Task ValidateStudentsFile(DirectoryInfo ecfFolder)
        {
            using var csvReader = new CsvReader(Path.Combine(ecfFolder.FullName, EcfTables.Students + ".csv"), true);

            var ecfTableReader = new EcfTableReader(csvReader);

            await ecfTableReader.ReadHeadersAsync();

            Assert.Equal(5, ecfTableReader.Headers.Count);
            Assert.Equal(EcfHeaders.Id, ecfTableReader.Headers[0]);
            Assert.Equal(EcfHeaders.LastName, ecfTableReader.Headers[1]);
            Assert.Equal(EcfHeaders.FirstName, ecfTableReader.Headers[2]);
            Assert.Equal(EcfHeaders.Gender, ecfTableReader.Headers[3]);
            Assert.Equal(EcfHeaders.Birthdate, ecfTableReader.Headers[4]);

            await ecfTableReader.ReadAsync();

            Assert.Equal("Duck", ecfTableReader.GetValue <string>(EcfHeaders.LastName));
            Assert.Equal("Tick", ecfTableReader.GetValue <string>(EcfHeaders.FirstName));
            Assert.Equal(EcfGender.Female, ecfTableReader.GetValue <EcfGender>(EcfHeaders.Gender));
            Assert.Equal(new Date(2001, 1, 1), ecfTableReader.GetValue <Date>(EcfHeaders.Birthdate));
        }