Exemple #1
0
        private async void GetEmployeeListAsync(bool clear = false)
        {
            try
            {
                IsAIRunning = true;
                var employees = await uService.GetEmployees(clear);

                employees = employees.OrderBy(e => e.FirstLetterOfName).ToList();
                var groupedEmployees = employees.GroupBy(e => e.FirstLetterOfName);
                var listOfEmployees  = new List <GenericGroupedCollection <string, Employee> >();
                foreach (var group in groupedEmployees)
                {
                    var x = new GenericGroupedCollection <string, Employee>(group.Key);
                    x.AddRange(group.ToList());
                    listOfEmployees.Add(x);
                }
                listOfEmployees = listOfEmployees.OrderBy(l => l.Key).ToList();
                var badGroup = listOfEmployees.FirstOrDefault(l => l.Key == "-");
                if (badGroup != null)
                {
                    listOfEmployees.Remove(badGroup);
                    listOfEmployees.Add(badGroup);
                }
                EmployeeList = listOfEmployees;
            }
            catch (ArxiusException e)
            {
                MessagingCenter.Send(this, Properties.Resources.MsgNetworkError, e.Message);
            }
            IsAIRunning = false;
        }
Exemple #2
0
        public static UserPage GetUserPage(string page)
        {
            var ectsMatch = Regex.Matches(page, @"<tr><th>Punkty ECTS<\/th><td>(\d*)<\/td>", RegexOptions.Multiline);
            var ects      = ectsMatch.Count != 0 ? Convert.ToInt32(ectsMatch[0].Groups[1].ToString()) : 0;

            var dict = new List <GenericGroupedCollection <string, Course> >();
            var votedCoursesMatch = Regex.Matches(page, @"<tr><th>Czas:<\/th><td>(.*?)<\/td><\/tr><tr><td><\/td><td><ul class=""voted-courses"">(.*?)<\/td>", RegexOptions.Multiline);

            foreach (var match in votedCoursesMatch)
            {
                var courseList = new List <Course>();
                var _match     = match as Match;
                var time       = _match.Groups[1].ToString();
                var courses    = Regex.Matches(_match.Groups[2].ToString(), @"<li><a href=""(.*?)"">(.*?)<\/a><\/li>", RegexOptions.Multiline);
                foreach (var course in courses)
                {
                    var _course = course as Match;
                    courseList.Add(new Course()
                    {
                        Url = _course.Groups[1].ToString(), Name = _course.Groups[2].ToString()
                    });
                }
                var x = new GenericGroupedCollection <string, Course>(time);
                x.AddRange(courseList);
                dict.Add(x);
            }
            var userPage = new UserPage()
            {
                Ects = ects, RegistrationTimes = dict
            };
            var registrationMatch = Regex.Matches(page, @"<th>Zniesienie limitu 35 ECTS<\/th><td>(.*?)<\/td><\/tr><tr><th>Koniec zapisów<\/th><td>(.*?)<\/td>", RegexOptions.Multiline);

            if (registrationMatch.Count != 0)
            {
                userPage.EndTime          = registrationMatch[0].Groups[2].ToString();
                userPage.LimitRemovalTime = registrationMatch[0].Groups[1].ToString();
            }
            else
            {
                userPage.EndTime = userPage.LimitRemovalTime = null;
            }
            return(userPage);
        }
        private async void GetCoursesAsync(bool clear = false)
        {
            try
            {
                IsAIRunning = true;
                var courses = await cService.GetAllCourses(clear);

                var groupedCourses = courses.GroupBy(c => c.Semester);
                var allCourses     = new List <GenericGroupedCollection <string, Course> >();
                foreach (var group in groupedCourses)
                {
                    var x = new GenericGroupedCollection <string, Course>(group.Key);
                    x.AddRange(group.ToList());
                    allCourses.Add(x);
                }
                AllCourses = allCourses;
            }
            catch (ArxiusException e)
            {
                MessagingCenter.Send(this, Properties.Resources.MsgNetworkError, e.Message);
            }
            IsAIRunning = false;
        }