Exemplo n.º 1
0
        public SemesterSource(string selectedSemesterId)
        {
            currentSemesterId       = Semester.Get().Id;
            this.selectedSemesterId = selectedSemesterId;

            semesterIds = new Dictionary <string, List <string> >();
            years       = new List <string>();

            var attendedIds = Me.Get().AttendedIds;
            var ids         = new List <string>(attendedIds.Keys);

            ids.Sort((lhs, rhs) => rhs.CompareTo(lhs));

            foreach (var id in ids)
            {
                var courseCount = attendedIds[id].Count;

                string year, semester;
                id.ParseSemesterId(out year, out semester);

                if (!semesterIds.ContainsKey(year))
                {
                    semesterIds[year] = new List <string>();
                    years.Add(year);
                }

                semesterIds[year].Add(id);
            }
        }
Exemplo n.º 2
0
        public static int CourseHandler(CourseOptions opts)
        {
            var attended = Me.Get().Attended(opts.All ? null : Semester.Get().Id);

            foreach (var pair in attended)
            {
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine("{0} ({1}门课)", Semester.IdToString(pair.Key), pair.Value.Count);

                foreach (var course in pair.Value)
                {
                    Console.ResetColor();
                    Console.Write(course.Name);
                    if (course.Schedules.Count > 0)
                    {
                        var location = course.Schedules[0].Location;
                        if (!string.IsNullOrEmpty(location))
                        {
                            Console.ForegroundColor = ConsoleColor.DarkRed;
                            Console.Write(" {0}", location);
                        }

                        Console.ForegroundColor = ConsoleColor.DarkYellow;
                        foreach (var schedule in course.Schedules)
                        {
                            Console.Write(" {0}-{1} ({2})", schedule.Day, schedule.Slot, schedule.Weeks);
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
            Console.ResetColor();
            return(0);
        }
Exemplo n.º 3
0
        public static int SemesterHandler(SemesterOptions opts)
        {
            var semester = Semester.Get();

            Console.WriteLine("{0} 第{1}周", Semester.IdToString(semester.Id), semester.WeekNow());
            return(0);
        }
Exemplo n.º 4
0
        public void Populate()
        {
            var title = SemesterId == Semester.Get().Id ? "当前学期" : SemesterId.SemesterString();

            SemesterButton.SetTitle(title + " ▾", UIControlState.Normal);
            TableView.Source = new CourseListSource(SemesterId);
            TableView.ReloadData();
        }
Exemplo n.º 5
0
        public static int UpdateHandler(UpdateOptions opts)
        {
            var userId = AppConfig.Get().UserId;

            API.UserId   = userId;
            API.Password = ReadPassword(string.Format("Password for {0}: ", userId));

            if (opts.All)
            {
                Semester.Update().Wait();
                Me.Update().Wait();
                Me.UpdateAttended().Wait();
                Me.UpdateMaterials().Wait();
            }
            else
            {
                Me.UpdateMaterials(Semester.Get().Id).Wait();
            }

            return(0);
        }
Exemplo n.º 6
0
 public CourseListController(IntPtr handle)
     : base(handle)
 {
     SemesterId = Semester.Get().Id;
 }