Exemple #1
0
        public SCETakeCollection LoadData()
        {
            int current = 0;
            SCETakeCollection includes = new SCETakeCollection();

            foreach (List <string> each in _packings)
            {
                current++;

                if (_progress.Cancellation)
                {
                    break;
                }

                _progress.ReportProgress(string.Format("下載成績相關資料({0}%)", Math.Round(((float)current / (float)_packings.Count) * 100, 0)), 0);
                XmlElement xmlRecords = QueryCourse.GetSECTake(each.ToArray()).GetContent().BaseElement;

                foreach (XmlElement attend in xmlRecords.SelectNodes("Score"))
                {
                    SCETake include = new SCETake(attend);
                    includes.Add(include);
                }
            }

            return(includes);
        }
Exemple #2
0
        public SCAttendCollection LoadData()
        {
            int current = 0;
            SCAttendCollection objSCAttends = new SCAttendCollection();

            foreach (List <string> each in _packings)
            {
                current++;

                if (_progress.Cancellation)
                {
                    break;
                }

                //_progress.ReportProgress(string.Format("下載修課相關資料({0}%)", Math.Round(((float)current / (float)_packings.Count) * 100, 0)), 0);
                XmlElement xmlSCAttends = QueryCourse.GetSCAttendBrief(each.ToArray()).GetContent().BaseElement;

                foreach (XmlElement attend in xmlSCAttends.SelectNodes("Student"))
                {
                    SCAttend scattend = new SCAttend(attend);
                    objSCAttends.Add(scattend.Identity, scattend);
                }
            }

            return(objSCAttends);
        }
Exemple #3
0
        public SmartSchoolDataProvider(string courseid)
        {
            _courseid = courseid;
            DSResponse  dsrsp  = QueryCourse.GetCourseExam(courseid);
            DSXmlHelper helper = dsrsp.GetContent();
            Dictionary <string, string> examList = new Dictionary <string, string>();

            // 塞 Header
            _columnHeader = new ColumnHeader();
            _columnHeader.Columns.Add(new ColumnSetting("-1", "班級", 60));
            _columnHeader.Columns.Add(new ColumnSetting("-1", "座號", 40, new DecimalComparer()));
            _columnHeader.Columns.Add(new ColumnSetting("-1", "姓名", 70));
            _columnHeader.Columns.Add(new ColumnSetting("-1", "學號", 70));

            foreach (XmlNode node in helper.GetElements("Course"))
            {
                string examName = node.SelectSingleNode("ExamName").InnerText;
                string examid   = node.SelectSingleNode("RefExamID").InnerText;

                _columnHeader.Columns.Add(new ColumnSetting(examid, examName, 80, new DecimalComparer()));
                examList.Add(examid, examName);
            }
            _columnHeader.Columns.Add(new ColumnSetting("-1", "課程成績", 100, new DecimalComparer()));


            // 取回本課程所有學生的考試成績
            DSResponse scoreResp    = QueryCourse.GetSECTake(courseid);
            XmlElement scoreElement = scoreResp.GetContent().GetElement(".");


            // 塞 Row
            _rowCollection = new RowCollection();
            dsrsp          = QueryCourse.GetSCAttend(courseid);
            helper         = dsrsp.GetContent();

            foreach (XmlNode node in helper.GetElements("Student"))
            {
                RowEntity row = new RowEntity(node.Attributes["ID"].Value);
                row.AddCell("班級", new StudentCell(node.SelectSingleNode("ClassName").InnerText));
                row.AddCell("座號", new StudentCell(node.SelectSingleNode("SeatNumber").InnerText));
                row.AddCell("姓名", new StudentCell(node.SelectSingleNode("Name").InnerText));
                row.AddCell("學號", new StudentCell(node.SelectSingleNode("StudentNumber").InnerText));
                foreach (string examid in examList.Keys)
                {
                    ScoreInfo score = GetScore(scoreElement, examid, node.Attributes["ID"].Value);
                    row.AddCell(examList[examid], new ExamCell(score));
                }
                row.AddCell("課程成績", new ScoreExamCell(new ScoreInfo(node.Attributes["ID"].Value, node.SelectSingleNode("Score").InnerText)));
                _rowCollection.Add(node.Attributes["ID"].Value, row);
            }
        }
Exemple #4
0
        public static CourseCollection GetCourses(params string[] courseList)
        {
            DSResponse rsp = QueryCourse.GetCourseById(courseList);

            CourseCollection courses = new CourseCollection();

            foreach (XmlElement each in rsp.GetContent().GetElements("Course"))
            {
                Course course = new Course(each);
                courses.Add(course.Identity, course);
            }

            return(courses);
        }
Exemple #5
0
        protected override object OnBackgroundWorkerWorking()
        {
            try
            {
                List <AttendInfo> attends = new List <AttendInfo>();
                DSResponse        rsp     = QueryCourse.GetSCAttend(RunningID);
                _current_response = rsp.GetContent();

                foreach (XmlElement each in rsp.GetContent().GetElements("Student"))
                {
                    attends.Add(new AttendInfo(each));
                }

                return(attends);
            }
            catch (Exception ex)
            {
                return(ex);
            }
        }
Exemple #6
0
        private void bkw_DoWork(object sender, DoWorkEventArgs e)
        {
            string[] list = (string[])e.Argument;

            DSResponse rsp = QueryCourse.GetSCAttend(list);

            foreach (XmlElement each in rsp.GetContent().GetElements("Student"))
            {
                string attendID  = each.GetAttribute("ID");
                string studentID = each.SelectSingleNode("RefStudentID").InnerText;
                string courseID  = each.SelectSingleNode("RefCourseID").InnerText;

                AttInfo attInfo = new AttInfo(attendID, courseID, studentID);
                if (!_StudentAttenCourses.ContainsKey(studentID))
                {
                    _StudentAttenCourses.Add(studentID, new List <AttInfo>());
                }
                _StudentAttenCourses[studentID].Add(attInfo);

                _AttendInfoList.Add(attInfo);
            }
        }
Exemple #7
0
        public ModelPagedList <ModelCourse> Query([FromBody] QueryCourse param)
        {
            int page     = 1;
            int pageSize = 6;

            var query = DB.OnlineCourse.AsNoTracking().AsQueryable();

            if (param != null)
            {
                page     = param.PageIndex;
                pageSize = param.PageSize;

                if (!string.IsNullOrWhiteSpace(param.categoryA))
                {
                    query = query.Where(x => x.categoryA == param.categoryA);
                }

                if (!string.IsNullOrWhiteSpace(param.categoryB))
                {
                    query = query.Where(x => x.categoryB == param.categoryB);
                }

                if (!string.IsNullOrWhiteSpace(param.key))
                {
                    query = query.Where(x => x.name.Contains(param.key));
                }

                if (param.minPrice.HasValue)
                {
                    query = query.Where(x => x.price >= param.minPrice);
                }

                if (param.maxPrice.HasValue)
                {
                    query = query.Where(x => x.price <= param.maxPrice);
                }

                if (param.age.HasValue)
                {
                    query = query.Where(x => x.fromAge <= param.age && x.toAge >= param.age);
                }
            }

            int order    = 1;
            int orderAsc = 2;

            if (param != null)
            {
                if (param.order.HasValue)
                {
                    order = param.order.Value;
                }
                if (param.orderAsc.HasValue)
                {
                    orderAsc = param.orderAsc.Value;
                }
            }

            if (orderAsc == 1)
            {
                if (order == 1)
                {
                    query = query.OrderBy(x => x.viewCount);
                }
                else if (order == 2)
                {
                    query = query.OrderBy(x => x.publishedTime);
                }
                else
                {
                    query = query.OrderBy(x => x.price);
                }
            }
            else
            {
                if (order == 1)
                {
                    query = query.OrderByDescending(x => x.viewCount);
                }
                else if (order == 2)
                {
                    query = query.OrderByDescending(x => x.publishedTime);
                }
                else
                {
                    query = query.OrderByDescending(x => x.price);
                }
            }

            var result = query.ToPagedList(page, pageSize);

            List <Favorite> favs = new List <DAL.Favorite>();

            if (User.Identity.IsAuthenticated)
            {
                if (AuthCustomer != null)
                {
                    var ids = result.Select(x => x.courseId).ToList();
                    favs = DB.Favorite.AsNoTracking().Where(x => x.customerId == AuthCustomer.CustomerId && ids.Contains(x.courseId)).ToList();
                }
            }

            var model = new ModelPagedList <ModelCourse>()
            {
                Pagination = new Pagination(result),
                List       = result.Select(x => new ModelCourse(x)).ToList()
            };

            foreach (var m in model.List)
            {
                if (favs.Any(x => x.courseId == m.id))
                {
                    m.IsFavorite = true;
                }
            }

            return(model);
        }