Example #1
0
 private void LoadCodeDict()
 {
     try
     {
         this.CodeDict = Worker.GetCodedic();
     }
     catch (WebException)
     {
         NoInternetReaction();
     }
 }
Example #2
0
        public static Lessons GetLessons(string group, int timestart, JsnDec codedic)
        {
            int timefinish = timestart + 86400;

            group = codedic.groups.FirstOrDefault(x => x.Value == group).Key;
            string reguest  = $"http://services.tsi.lv/schedule/api/service.asmx/GetLocalizedEvents?from={timestart}&to={timefinish}&teachers=&rooms=&groups={group}&lang=%27ru%27";
            string response = Getresponse(reguest);

            response = response.Replace("(", "");
            response = response.Replace(")", "");
            var  jser = new JavaScriptSerializer();
            Jsn1 dic  = jser.Deserialize <Jsn1>(response);
            Jsn2 dic2 = jser.Deserialize <Jsn2>(dic.d);

            return(new Lessons(dic2, codedic, timestart));
        }
Example #3
0
        public Lessons(Jsn2 jsn2, JsnDec codedic, int timestart)
        {
            LessonCount = jsn2.events.values.Count;
            timestamp   = timestart;
            //if (LessonCount != 0)
            {
                lessons = new Lesson[LessonCount];
                for (int i = 0; i < LessonCount; i++)
                {
                    lessons[i] = new Lesson();
                }


                for (int i = 0; i < LessonCount; i++)
                {
                    int      timeStampTemp = (int)jsn2.events.values.ElementAt(i).ElementAt(0);
                    DateTime dateTimeTemp  = new DateTime();
                    dateTimeTemp    = dateTimeTemp.AddSeconds(timeStampTemp);
                    lessons[i].time = $"{dateTimeTemp.Hour}:{dateTimeTemp.Minute}";
                    lessons[i].time = lessons[i].time.Replace(":0", ":00");

                    try
                    {
                        lessons[i].room    = codedic.rooms[((object[])jsn2.events.values.ElementAt(i).ElementAt(1))[0].ToString()];
                        lessons[i].groups  = codedic.groups[((object[])jsn2.events.values.ElementAt(i).ElementAt(2))[0].ToString()];
                        lessons[i].teacher = codedic.teachers[jsn2.events.values.ElementAt(i).ElementAt(3).ToString()];
                    }
                    catch (Exception)
                    {
                    }
                    lessons[i].name = (string)jsn2.events.values.ElementAt(i).ElementAt(4);

                    if (lessons[i].name.Length > 49)
                    {
                        lessons[i].name = lessons[i].name.Substring(0, 49) + ".";
                    }

                    lessons[i].comment = (string)jsn2.events.values.ElementAt(i).ElementAt(5);
                    lessons[i].cclass  = (string)jsn2.events.values.ElementAt(i).ElementAt(6);

                    lessons[i].teacher += "  " + lessons[i].comment;
                }
            }
        }
Example #4
0
        public void LoadTable(Lessons les, string grp, JsnDec dic)
        {
            Lab_group.Text = grp;
            int i = les.LessonCount;

            group    = grp;
            codedict = dic;

            //if (countOflesson == null)
            countOflesson = i;

            MakeVisible(false, countOflesson.Value);

            if (TableLoaded == false)
            {
                TableLoaded        = true;
                this.countOflesson = les.LessonCount;

                DateTime dt = new DateTime(1970, 1, 1);
                dt            = dt.AddSeconds(les.timestamp);
                Lab_date.Text = dt.ToString().Substring(0, 10);



                if (i != 0 && i < 7)
                {
                    LabFree.Visible = false;
                    do
                    {
                        switch (i)
                        {
                        case 5:
                        {
                            Lab_name4.Text    = les.lessons[4].name;
                            Lab_room4.Text    = les.lessons[4].room;
                            Lab_teacher4.Text = les.lessons[4].teacher;
                            Lab_time4.Text    = les.lessons[4].time;
                        }
                        break;

                        case 4:
                        {
                            Lab_name3.Text    = les.lessons[3].name;
                            Lab_room3.Text    = les.lessons[3].room;
                            Lab_teacher3.Text = les.lessons[3].teacher;
                            Lab_time3.Text    = les.lessons[3].time;
                        }
                        break;

                        case 3:
                        {
                            Lab_name2.Text    = les.lessons[2].name;
                            Lab_room2.Text    = les.lessons[2].room;
                            Lab_teacher2.Text = les.lessons[2].teacher;
                            Lab_time2.Text    = les.lessons[2].time;
                        }
                        break;

                        case 2:
                        {
                            Lab_name1.Text    = les.lessons[1].name;
                            Lab_room1.Text    = les.lessons[1].room;
                            Lab_teacher1.Text = les.lessons[1].teacher;
                            Lab_time1.Text    = les.lessons[1].time;
                        }
                        break;

                        case 1:
                        {
                            Lab_name0.Text    = les.lessons[0].name;
                            Lab_room0.Text    = les.lessons[0].room;
                            Lab_teacher0.Text = les.lessons[0].teacher;
                            Lab_time0.Text    = les.lessons[0].time;
                        }
                        break;
                        }
                        i = i - 1;
                    } while (i > 0);
                }
                else
                {
                    LabFree.Visible = true;
                }
            }
        }