Exemplo n.º 1
0
        static void Main(string[] args)
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);

            try
            {
                Console.WriteLine(Global.Titel);

                Global.IstInputNotenCsvVorhanden();

                var         prds        = new Periodes();
                var         fchs        = new Fachs();
                var         lehs        = new Lehrers(prds);
                var         klss        = new Klasses(lehs, prds);
                var         schuelers   = new Schuelers(klss, lehs);
                Excelzeilen excelzeilen = new Excelzeilen();
                schuelers.Unterrichte();
                excelzeilen.AddRange(klss.Notenlisten(schuelers, lehs));
                excelzeilen.ToExchange(lehs);
                lehs.FehlendeUndDoppelteEinträge(schuelers);
                System.Diagnostics.Process.Start(Global.Ziel);
                //Global.MailSenden(new Klasse(), new Lehrer(), "Liste alle Dokumente für den APA", "Siehe Anlage.", klss.Dokumente());
                //System.Windows.Forms.Clipboard.SetText(excelzeilen.ToClipboard());
                Console.WriteLine("Tabelle ZulassungskonferenzBC in Zwischenablage geschrieben.");
                Console.ReadKey();
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadKey();
                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Heiliger Bimbam! Es ist etwas schiefgelaufen! Die Verarbeitung wird gestoppt.");
                Console.WriteLine("");
                Console.WriteLine(ex);
                Console.ReadKey();
                Environment.Exit(0);
            }
        }
Exemplo n.º 2
0
        public Klasses(Lehrers lehrers, Periodes periodes)
        {
            Lehrers = lehrers;

            using (OleDbConnection oleDbConnection = new OleDbConnection(Global.ConU))
            {
                try
                {
                    string queryString = @"SELECT 
Class.CLASS_ID, 
Class.Name, 
Class.TeacherIds, 
Class.Longname, 
Teacher.Name,
Class.ClassLevel, 
Class.PERIODS_TABLE_ID,
Department.Name,
Class.TimeRequest,
Class.ROOM_ID,
Class.Text
FROM (Class LEFT JOIN Department ON Class.DEPARTMENT_ID = Department.DEPARTMENT_ID) LEFT JOIN Teacher ON Class.TEACHER_ID = Teacher.TEACHER_ID
WHERE (((Class.SCHOOL_ID)=177659) AND ((Class.TERM_ID)=" + periodes.Count + ") AND ((Class.Deleted)=False) AND ((Class.TERM_ID)=" + periodes.Count + ") AND ((Class.SCHOOLYEAR_ID)=" + Global.AktSjUnt + ") AND ((Department.SCHOOL_ID)=177659) AND ((Department.SCHOOLYEAR_ID)=" + Global.AktSjUnt + ") AND ((Teacher.SCHOOL_ID)=177659) AND ((Teacher.SCHOOLYEAR_ID)=" + Global.AktSjUnt + ") AND ((Teacher.TERM_ID)=" + periodes.Count + "))ORDER BY Class.Name ASC; ";

                    OleDbCommand oleDbCommand = new OleDbCommand(queryString, oleDbConnection);
                    oleDbConnection.Open();
                    OleDbDataReader oleDbDataReader = oleDbCommand.ExecuteReader();

                    while (oleDbDataReader.Read())
                    {
                        List <Lehrer> klassenleitungen = new List <Lehrer>();

                        foreach (var item in (Global.SafeGetString(oleDbDataReader, 2)).Split(','))
                        {
                            klassenleitungen.Add((from l in lehrers
                                                  where l.IdUntis.ToString() == item
                                                  select l).FirstOrDefault());
                        }

                        var klasseName = Global.SafeGetString(oleDbDataReader, 1);

                        Klasse klasse = new Klasse()
                        {
                            IdUntis          = oleDbDataReader.GetInt32(0),
                            NameUntis        = klasseName,
                            Klassenleitungen = klassenleitungen,
                            Jahrgang         = Global.SafeGetString(oleDbDataReader, 5),
                            Bereichsleitung  = Global.SafeGetString(oleDbDataReader, 7),
                            Beschreibung     = Global.SafeGetString(oleDbDataReader, 3),
                            Url = "https://www.berufskolleg-borken.de/bildungsgange/" + Global.SafeGetString(oleDbDataReader, 10)
                        };

                        if ((from a in Global.AbschlussKlassen
                             where klasse != null
                             where klasse.NameUntis != null
                             where klasse.NameUntis.StartsWith(a)
                             select a).Any())
                        {
                            this.Add(klasse);
                        }
                    }
                    ;

                    Console.WriteLine(("Klassen " + ".".PadRight(this.Count / 150, '.')).PadRight(48, '.') + (" " + this.Count).ToString().PadLeft(30), '.');

                    oleDbDataReader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    throw new Exception(ex.ToString());
                }
                finally
                {
                    oleDbConnection.Close();
                }
            }
        }
Exemplo n.º 3
0
        public Lehrers(Periodes periodes)
        {
            using (OleDbConnection oleDbConnection = new OleDbConnection(Global.ConU))
            {
                try
                {
                    string queryString = @"SELECT DISTINCT 
Teacher.Teacher_ID, 
Teacher.Name, 
Teacher.Longname, 
Teacher.FirstName,
Teacher.Email,
Teacher.Flags,
Teacher.Title,
Teacher.ROOM_ID,
Teacher.Text2,
Teacher.Text3,
Teacher.PlannedWeek
FROM Teacher 
WHERE (((SCHOOLYEAR_ID)= " + Global.AktSjUnt + ") AND  ((TERM_ID)=" + periodes.Count + ") AND ((Teacher.SCHOOL_ID)=177659) AND (((Teacher.Deleted)=No))) ORDER BY Teacher.Name;";

                    OleDbCommand oleDbCommand = new OleDbCommand(queryString, oleDbConnection);
                    oleDbConnection.Open();
                    OleDbDataReader oleDbDataReader = oleDbCommand.ExecuteReader();

                    while (oleDbDataReader.Read())
                    {
                        Lehrer lehrer = new Lehrer()
                        {
                            IdUntis    = oleDbDataReader.GetInt32(0),
                            Kürzel     = Global.SafeGetString(oleDbDataReader, 1),
                            Nachname   = Global.SafeGetString(oleDbDataReader, 2),
                            Vorname    = Global.SafeGetString(oleDbDataReader, 3),
                            Mail       = Global.SafeGetString(oleDbDataReader, 4),
                            Anrede     = Global.SafeGetString(oleDbDataReader, 5) == "n" ? "Herr" : Global.SafeGetString(oleDbDataReader, 5) == "W" ? "Frau" : "",
                            Titel      = Global.SafeGetString(oleDbDataReader, 6),
                            Funktion   = Global.SafeGetString(oleDbDataReader, 8),
                            Dienstgrad = Global.SafeGetString(oleDbDataReader, 9)
                        };

                        if (!lehrer.Mail.EndsWith("@berufskolleg-borken.de") && lehrer.Kürzel != "LAT" && lehrer.Kürzel != "?")
                        {
                            Console.WriteLine("Untis2Exchange Fehlermeldung: Der Lehrer " + lehrer.Kürzel + " hat keine Mail-Adresse in Untis. Bitte in Untis eintragen.");
                        }
                        if (lehrer.Anrede == "" && lehrer.Kürzel != "LAT" && lehrer.Kürzel != "?")
                        {
                            Console.WriteLine("Untis2Exchange Fehlermeldung: Der Lehrer " + lehrer.Kürzel + " hat kein Geschlecht in Untis. Bitte in Untis eintragen.");
                        }

                        this.Add(lehrer);
                    }
                    ;

                    Console.WriteLine(("Lehrer " + ".".PadRight(this.Count / 150, '.')).PadRight(48, '.') + (" " + this.Count).ToString().PadLeft(30), '.');

                    oleDbDataReader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    oleDbConnection.Close();
                }
            }
        }