Exemple #1
0
        async Task ExecuteLoadTimetableCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                RozvrhoveAkce.Clear();
                string loggedUser = await DataStore.GetLoggedUserID();

                var akce = await DataStore.GetUserRozvrhoveAkceAsync(loggedUser);

                foreach (var a in akce)
                {
                    RozvrhoveAkce.Add(a);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
        public async Task <List <RozvrhovaAkce> > GetUserRozvrhoveAkceAsync(string id)
        {
            if (id != null)
            {
                using (WebClient wc = new WebClient())
                {
                    try
                    {
                        string address       = client.BaseAddress + $"api/User/RozvrhoveAkce/{id}";
                        string jsonString    = wc.DownloadString(address);
                        var    rozvrhoveAkce = RozvrhoveAkce.FromJson(jsonString);
                        return(await Task.Run(() => rozvrhoveAkce));
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Json read failed..\n" + ex.ToString());
                        return(null);
                    }
                }
            }

            return(null);
        }
Exemple #3
0
        /// <summary>
        /// Vytvoří rozvrhové akce a zaregistruje je u vyučujících a místností
        /// </summary>
        public override void LoadRozvrhoveAkce()
        {
            string CSVfile = (@".\csv\rozvrhove_akce.csv");

            using (StreamReader sr = new StreamReader(CSVfile, Encoding.UTF8))
            {
                string line;
                int    it = 1;
                while ((line = sr.ReadLine()) != null)
                {
                    if (it++ == 1)
                    {
                        continue;
                    }
                    // id; predmetId; typVyuky; vyucujiciId; mistnostId; den; zacatek; delka
                    string[]  explode       = line.Split(';');
                    int       id            = int.Parse(explode[0]);
                    int       idPredmetu    = int.Parse(explode[1]);
                    TypyVyuky typ           = (TypyVyuky)Enum.Parse(typeof(TypyVyuky), explode[2]);
                    int       idVyucujiciho = int.Parse(explode[3]);
                    int       idMistnosti   = int.Parse(explode[4]);
                    Dny       den           = (Dny)Enum.Parse(typeof(Dny), explode[5]);
                    int       zacatek       = int.Parse(explode[6]);
                    int       delka         = int.Parse(explode[7]);

                    RozvrhovaAkce ra = new RozvrhovaAkce(id, Predmety[idPredmetu], typ, Vyucujici[idVyucujiciho], Mistnosti[idMistnosti], den, zacatek, delka);
                    RozvrhoveAkce.Add(id, ra);
                    Predmety[ra.Predmet.Id].RozvrhoveAkce.Add(ra.Id, ra);
                    for (int i = 0; i < delka; i++)
                    {
                        Vyucujici[idVyucujiciho].Rozvrh[den].Add(zacatek + i, ra);
                        Mistnosti[idMistnosti].Rozvrh[den].Add(zacatek + i, ra);
                    }
                }
            }
        }