コード例 #1
0
        public static async void SetMagellanSubjectIds(FbConnection fbConnection, int tenantId, List <Students> students, List <SimpleCache> schoolTerms)
        {
            foreach (var student in students)
            {
                foreach (var career in student.Career)
                {
                    foreach (var studentSubject in career.StudentSubjects)
                    {
                        DbResult dbResult = await RecordExists.Subject(fbConnection, tenantId, studentSubject.EcfValues.SubjectId);

                        if (dbResult.Success)
                        {
                            studentSubject.MagellanValues.SubjectId = (int)dbResult.Value;

                            dbResult = await RecordExists.ByGuidExtern(fbConnection, MagellanTables.Teachers, tenantId, studentSubject.EcfValues.TeacherId);

                            if (dbResult.Success)
                            {
                                studentSubject.MagellanValues.TeacherId = (int)dbResult.Value;
                            }

                            dbResult = await RecordExists.ByCodeAndTenant(fbConnection, MagellanTables.GradeValues, tenantId, studentSubject.EcfValues.Grade1ValueId);

                            if (dbResult.Success)
                            {
                                studentSubject.MagellanValues.Grade1ValueId = (int)dbResult.Value;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
/*
 *      public static bool GetSchoolTermParts(string schoolTermId, out string validFrom, out string validTo)
 *      {
 *          string[] schoolTermParts = schoolTermId.Split('-');
 *          validFrom = null;
 *          validTo = null;
 *
 *          if (schoolTermParts.Length == 2)
 *          {
 *              int year = -1;
 *              int section = -1;
 *
 *              if (!String.IsNullOrEmpty(schoolTermParts[0]))
 *              {
 *                  year = int.Parse(schoolTermParts[0]);
 *              }
 *
 *              if (!String.IsNullOrEmpty(schoolTermParts[1]))
 *              {
 *                  section = int.Parse(schoolTermParts[1]);
 *              }
 *
 *              switch (section)
 *              {
 *                  case 1:
 *                      validFrom = $"01.08.{year}";
 *                      validTo = $"31.01.{year + 1}";
 *                      break;
 *                  case 2:
 *                      validFrom =$"01.02.{year + 1}";
 *                      validTo = $"31.07.{year + 1}";
 *                      break;
 *              }
 *
 *              return true;
 *          }
 *
 *          return false;
 *      }
 *
 */
        public static async Task <DbResult> GetSubject(FbConnection fbConnection, Dictionary <string, int> subjects, string code)
        {
            if (subjects.TryGetValue(code, out int id))
            {
                return(new DbResult(true, id));
            }
            else
            {
                DbResult dbResult = await RecordExists.ByCode(fbConnection, MappingTables.Map("ForeignLanguages"), code);

                return(dbResult);
            }
        }
コード例 #4
0
        public static async void SetMagellanIds(FbConnection fbConnection, int tenantId, List <Students> students, List <SimpleCache> schoolTerms)
        {
            foreach (var student in students)
            {
                foreach (var career in student.Career)
                {
                    // Find SchoolTerm
                    var schoolTerm = schoolTerms.Find(t => t.EcfId.Equals(career.EcfValues.SchoolTermId));

                    if (schoolTerm != null)
                    {
                        career.MagellanValues.SchoolTermId = schoolTerm.MagellanId;

                        // Find SchoolClassTerm
                        DbResult dbResult = await RecordExists.SchoolClassTerm(fbConnection, tenantId, career.EcfValues.ClassTermId);

                        if (dbResult.Success)
                        {
                            career.MagellanValues.ClassTermId = (int)dbResult.Value;

                            // Find SchoolClass
                            dbResult = await RecordExists.SchoolClassByTerm(fbConnection, tenantId, career.EcfValues.ClassTermId);

                            if (dbResult.Success)
                            {
                                career.MagellanValues.SchoolClassId = (int)dbResult.Value;

                                // Find SchoolClassAttendance
                                dbResult = await RecordExists.StudentSchoolClassAttendances(fbConnection, tenantId, career.MagellanValues.ClassTermId, student.MagellanId);

                                if (dbResult.Success)
                                {
                                    career.MagellanValues.StudentTermId = (int)dbResult.Value;
                                }
                            }
                        }
                    }
                }
            }
        }