public List <RollcallStudent> getRollcallStudents() { return(cellTable.Select(c => { var rs = RollcallStudent.create(c.Key, c.Value.state); rs.absentReason = c.Value.absentReasonText; return rs; }).ToList()); }
public List <RollcallStudent> getRollcallStudents() { List <RollcallStudent> rollcallStudents = new List <RollcallStudent>(); var rollpageFrame = parseFrameDocument(ROLLCALL_FRAME); var innerT = rollpageFrame.documentElement.outerHTML; var htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(innerT); var studentsTable = htmlDoc.DocumentNode.SelectSingleNode("//table[@id='ctl00_ContentPlaceHolder1_ChkLStno']"); try { foreach (var tdElm in studentsTable.SelectNodes(".//td")) { var inputElm = tdElm.SelectSingleNode("./input"); var labelElm = tdElm.SelectSingleNode("./label"); if (labelElm == null || inputElm == null) { continue; } // Only if the input checkbox is checked, it has an attribute CHECKED='' // with an empty string value. So if we don't get the default value 'NO', // then it means the checkbox is checked, indicating the student is absent (not signed). var isChecked = inputElm.GetAttributeValue("CHECKED", "NO") != "NO"; var student = new Student() { ip = netStatesManager.getIp(), studentId = labelElm.InnerHtml.Substring(0, 8), name = labelElm.InnerHtml.Substring(12, 3).Replace(" ", "") }; rollcallStudents.Add(RollcallStudent.create(student, !isChecked)); } return(rollcallStudents); } catch (Exception err) { Log.err(TAG, "ERROR occurs while loading rollcall student. ", err); throw err; } }