コード例 #1
0
ファイル: Helper.cs プロジェクト: famoser/Gymoberwil
        public static List<Stunde> GetNextHours()
        {
            DateTime dt = DateTime.Now;
            DateTime now = new DateTime();
            now += TimeSpan.FromHours(dt.Hour);
            now += TimeSpan.FromMinutes(dt.Minute);
            now += TimeSpan.FromSeconds(dt.Second + 1);
            int wochentag = (int)DateTime.Now.DayOfWeek;
            wochentag--;
            int count = 0;
            if (0 > wochentag || wochentag > 4)
            {
                if (wochentag == -1)
                {
                    //sonntag
                    count = 1;
                }
                else
                {
                    //samstag
                    count = 2;
                }
                wochentag = 0;
                // now == 0
                now = new DateTime();
            }
            List<Stunde> list = NextHours(now, wochentag);
            if (list.Count > 0)
            {
                Nextlesson = list[0].StartDateTime;
                Nextlesson = Nextlesson.AddDays(count);
            }
            else
            {
                //keine Stunden mehr heute
                if (wochentag == 4)
                {
                    list = NextHours(new DateTime(), 0);
                    count = 2;
                }
                else
                {
                    list = NextHours(new DateTime(), ++wochentag);
                }
                if (list.Count == 0)
                {
                    Nextlesson = DateTime.MinValue;
                    return null;
                }
                Nextlesson = list[0].StartDateTime;
                Nextlesson = Nextlesson.AddDays(1);
                Nextlesson = Nextlesson.AddDays(count);
            }

            if (now < Nextlesson)
            {
                return list;
            }
            else
            {
                Jetzt = list[0];
                return list.GetRange(1, list.Count-1);
            }
        }
コード例 #2
0
        public void MakeObjects()
        {
            Variables.Stunden = new List<List<Stunde>>();
            List<string> shortLektions = new List<string>() { "BG", "B", "C", "D", "E", "F", "GG", "G", "I", "L", "AM", "M", "MS", "P", "SK", "SP", "W", "WR" };
            List<int> index = new List<int>() { 1,2,3,4,5,6,7,8,11,12,14,15,16,19,23,23,24,24 };

            for (int a = 0; a < 5; a++)
            {
                Variables.Stunden.Add(new List<Stunde>());
                foreach (var item in Stundeen[a])
                {
                    Stunde st = new Stunde();
                    if (item.isFree)
                    {
                        st.SetLektion(Lektion.Frei,null);
                        st.Tag = (Wochentag)item.Tag;
                        st.zeit = item.Zeit;
                    }
                    else
                    {
                        if (shortLektions.Contains(item.fachshort))
                        {
                            int v = 0;
                            for (v = 0; v < shortLektions.Count; v++)
                            {
                                if (shortLektions[v] == item.fachshort)
                                {
                                    st.SetLektion((Lektion)index[v], null);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            st.SetLektion(Lektion.Anderes, item.fachshort);
                        }
                        st.Fach.Schwerpunktfach = item.isSchwerpunktfach;
                        st.Fach.SetLehrer(item.lehrpersonshort,null);
                        st.Tag = (Wochentag)item.Tag;
                        st.zeit = item.Zeit;
                        st.zimmernummer = Convert.ToInt16(item.zimmernummer);
                    }
                    Variables.Stunden[Variables.Stunden.Count - 1].Add(st);
                }
            }


            List<int> allfächer = new List<int>();
            foreach (var items in Variables.Stunden)
            {
                foreach (var item in items)
                {
                    allfächer.Add(item.fach);
                }
            }
            List<int> noduplicates = allfächer.Distinct().ToList();
            noduplicates.Remove(0);

            for (int i = 0; i < noduplicates.Count; i++)
            {
                Variables.Fächer[noduplicates[i]].isActive = true;
                Variables.Fächer[noduplicates[i]].index = i;
                Variables.Fächer[noduplicates[i]].color = i+1;
            }

            Einrichten5.Opacity = 0;
            Einrichten5.IsHitTestVisible = false;
            Einrichten6.Opacity = 1;
            Einrichten6.IsHitTestVisible = true;
            Save.SaveAll();
        }
コード例 #3
0
ファイル: MainPage.xaml.cs プロジェクト: famoser/Gymoberwil
        public async void Load()
        {
            progress.Text = "Beamer wird heruntergeladen...";
            progress.IsIndeterminate = true;
            progress.IsVisible = true;
            bool firsttime = Save.LoadAll();
            if (firsttime)
            {
                Variables.Stunden = new List<List<Stunde>>();

                Wochentag w = Wochentag.Montag;

                for (int a = 0; a < 5; a++)
                {
                    if (a == 1)
                    {
                        w = Wochentag.Dienstag;
                    }
                    else if (a == 2)
                    {
                        w = Wochentag.Mittwoch;
                    }
                    else if (a == 3)
                    {
                        w = Wochentag.Donnerstag;
                    }
                    else if (a == 4)
                    {
                        w = Wochentag.Freitag;
                    }
                    Variables.Stunden.Add(new List<Stunde>());

                    for (int i = 0; i < 12; i++)
                    {
                        Stunde st = new Stunde();
                        st.SetLektion(Lektion.Frei, null);
                        st.Tag = w;
                        st.zeit = i;
                        Variables.Stunden[a].Add(st);
                    }
                }
                var c = MessageBox.Show("Sie öffnen diese App zum ersten Mal. Diese App unterstützt das automatische Herunterladen des Stundenplanes von isy.gymoberwil.ch. Wollen Sie dies jetzt tun?", "Stundenplan herunterladen", MessageBoxButton.OKCancel);
                if (c == MessageBoxResult.OK)
                {
                    NavigationService.Navigate(new Uri("/Stundenplanaktualisieren.xaml?selecteditem=0", UriKind.Relative));
                }
            }

            int tries = 0;
            int matchcounter = 0;
            try
            {
                while (tries < 3)
                {
                    string html = await Helper.DownloadStringAsync(new Uri("https://schulnetz.sbl.ch/gymow/dview/showterminliste.php?id=6zfgfbejsdtwgv3hcuwegujdbg"));
                    if (html != null)
                    {
                        //Lehrer werden formatiert, um eine texterkennung durchzuführen (dem user zu sagen, ob ein Item auf dem Beamer ihn betrifft
                        List<string> Lehrer = new List<string>();
                        foreach (var day in Variables.Stunden)
                        {
                            foreach (var item in day)
                            {
                                Lehrkraft lk = item.GetLehrer;
                                if (lk != null && lk.Vorname != null && lk.Vorname.Count() > 2 && lk.Nachname != null && lk.Nachname.Count() > 2 && !Lehrer.Contains(lk.Vorname.Substring(0, 1) + ". " + lk.Nachname))
                                {
                                    Lehrer.Add(lk.Vorname.Substring(0, 1) + ". " + lk.Nachname);
                                }
                            }
                        }

                        //HTML wird formatiert
                        if (html.Contains("<tr>"))
                        {
                            html = html.Substring(html.IndexOf("<tr>"));
                            //wenn s html mol gfixxt wird....
                            /*
                            if (html.Contains("</tr>"))
                            {
                                html = html.Substring(0, html.LastIndexOf("</tr>") + ("</tr>").Count());
                            }
                             * */
                            html = html.Substring(0, html.LastIndexOf("</table>"));
                            Variables.BeamerItems = HTML.GetBeamerEntries(html.Trim());
                            /*
                            string[] key = new string[] { "&Auml;", "&auml;", "&Ouml;", "&ouml;", "&Uuml;", "&uuml;", "&szlig;" };
                            string[] value = new string[] { "Ä", "ä", "Ö", "ö;", "Ü;", "ü", "&" };
                            */
                            foreach (var item in Variables.BeamerItems)
                            {
                                foreach (var lehrperson in Lehrer)
                                {
                                    if (item.title.Contains(lehrperson))
                                    {
                                        item.important = true;
                                        break;
                                    }
                                }
                                if (item.title.Contains(Settings.klasse) && Settings.klasse != "")
                                {
                                    item.important = true;
                                }
                                if (item.important)
                                {
                                    matchcounter++;
                                }
                            }
                            Save.SaveBeamer();
                            Variables.BeamerActualized = DateTime.Now;
                            if (matchcounter == 0)
                            {
                                progress.Text = "";
                            }
                            else if (matchcounter == 1)
                            {
                                progress.Text = "Eine wichtige Nachricht auf dem Beamer";
                            }
                            else
                            {
                                progress.Text = matchcounter.ToString() + " wichtige Nachrichten auf dem Beamer";
                            }
                            progress.IsIndeterminate = false;
                            break;
                        }
                        else
                        {
                            //abbrechen
                        }
                        
                    }
                    else
                    {
                        if (++tries > 2)
                        {
                            Save.LoadBeamer();
                            progress.Text = "Keine Internetverbindung";
                            progress.IsIndeterminate = false;
                        }
                    }
                }
            }
            catch
            {
                Variables.BeamerItems = new List<Gymoberwil.Beamer>();
                progress.Text = "Beameraktualisierung fehlgeschlagen";
                progress.IsIndeterminate = false;
            }
            MakeNotifications();
            await PutTaskDelay();
            progress.Text = "";
            progress.IsVisible = false;
        }
コード例 #4
0
ファイル: Objects.cs プロジェクト: famoser/Gymoberwil
 public StundeSaveObject(Stunde s)
 {
     this.customanfangszeit = s.customanfangszeit;
     this.customendzeit = s.customendzeit;
     this.Tag = s.Tag;
     this.woche = s.woche;
     this.zeit = s.zeit;
     this.zimmernummer = s.zimmernummer;
     this.fach = s.fach;
 }