public bool AttemptLogin(string username, string password) { NameValueCollection formData = new NameValueCollection(); formData.Add("uname", username); formData.Add("pwd", password); formData.Add("action", "login"); string xml = httpRequest(formData, null, null, null); //MessageBox.Show(xml); cls_YACRSResponse r = responseParser.parseIn(xml); if (r == null) { lastError = xml; return(false); } else if (r.M_error.Count > 0) { lastError = r.M_error[0]; return(false); } else { courseIdSupported = r.M_data.M_serverInfo.M_courseIdSupported; availableQus = r.M_data.M_serverInfo.M_globalQuType; return(true); } }
public cls_questionResponseInfo questionInfo(int qiID) { NameValueCollection formData = new NameValueCollection(); formData.Add("action", "quinfo"); formData.Add("id", currentSessionDetail.M_id.ToString()); if (qiID > 0) { formData.Add("qiID", qiID.ToString()); } string xml = httpRequest(formData, null, null, null); //if (qis==0) // Temp variable that limits number of times this is displayed for debugging // { // qis = 100; //Console.WriteLine(xml); // MessageBox.Show(xml); // } // qis--; cls_YACRSResponse r = responseParser.parseIn(xml); if ((r != null) && (r.M_data.M_questionResponseInfo.Count > 0)) { if (r.M_data.M_questionResponseInfo[0].M_id != 0) { lastQiID = r.M_data.M_questionResponseInfo[0].M_id; } return(r.M_data.M_questionResponseInfo[0]); } else { return(null); } }
internal override void setOwner(cls_YACRSResponse n_owner) { __owner = n_owner; foreach (cls_globalQuType tmp_globalQuType in m_globalQuType) { tmp_globalQuType.setOwner(__owner); } }
internal override void setOwner(cls_YACRSResponse n_owner) { __owner = n_owner; foreach (cls_optionInfo tmp_optionInfo in m_optionInfo) { tmp_optionInfo.setOwner(__owner); } }
public void addTime() { NameValueCollection formData = new NameValueCollection(); formData.Add("action", "addtime"); formData.Add("id", currentSessionDetail.M_id.ToString()); string xml = httpRequest(formData, null, null, null); cls_YACRSResponse r = responseParser.parseIn(xml); }
public List <int> getSessionQuestionIDs() { NameValueCollection formData = new NameValueCollection(); formData.Add("action", "getqids"); formData.Add("id", currentSessionDetail.M_id.ToString()); string xml = httpRequest(formData, null, null, null); //MessageBox.Show(xml); cls_YACRSResponse r = responseParser.parseIn(xml); if (r != null) { return(r.M_data.M_qid); } else { return(null); } }
public List <cls_sessionInfo> getSessionList() { Dictionary <int, string> output = new Dictionary <int, string>(); NameValueCollection formData = new NameValueCollection(); formData.Add("action", "sessionlist"); string xml = httpRequest(formData, null, null, null); //MessageBox.Show(xml); cls_YACRSResponse r = responseParser.parseIn(xml); if (r == null) { return(null); } else { return(r.M_data.M_sessionInfo); } }
internal override void setOwner(cls_YACRSResponse n_owner) { __owner = n_owner; foreach (cls_sessionInfo tmp_sessionInfo in m_sessionInfo) { tmp_sessionInfo.setOwner(__owner); } foreach (cls_questionResponseInfo tmp_questionResponseInfo in m_questionResponseInfo) { tmp_questionResponseInfo.setOwner(__owner); } if (m_sessionDetail != null) { m_sessionDetail.setOwner(__owner); } if (m_serverInfo != null) { m_serverInfo.setOwner(__owner); } }
public bool getSessionDetail(int id) { NameValueCollection formData = new NameValueCollection(); formData.Add("action", "sessiondetail"); formData.Add("id", id.ToString()); string xml = httpRequest(formData, null, null, null); //MessageBox.Show(xml); cls_YACRSResponse r = responseParser.parseIn(xml); if (r != null) { currentSessionDetail = r.M_data.M_sessionDetail; return(!(currentSessionDetail == null)); } else { return(false); } }
public int updateSession() { NameValueCollection formData = new NameValueCollection(); formData.Add("action", "sessiondetail"); if (currentSessionDetail.M_id > 0) { formData.Add("id", currentSessionDetail.M_id.ToString()); } formData.Add("title", currentSessionDetail.M_title.ToString()); formData.Add("courseIdentifier", currentSessionDetail.M_courseIdentifier.ToString()); formData.Add("allowGuests", currentSessionDetail.M_allowGuests?"1":"0"); formData.Add("visible", currentSessionDetail.M_visible ? "1" : "0"); formData.Add("questionMode", ((int)currentSessionDetail.M_questionMode).ToString()); formData.Add("defaultQuActiveSecs", currentSessionDetail.M_defaultQuActiveSecs.ToString()); formData.Add("allowQuReview", currentSessionDetail.M_allowQuReview ? "1" : "0"); formData.Add("ublogRoom", ((int)currentSessionDetail.M_ublogRoom).ToString()); formData.Add("maxMessagelength", currentSessionDetail.M_maxMessagelength.ToString()); formData.Add("allowTeacherQu", currentSessionDetail.M_allowTeacherQu ? "1" : "0"); string xml = httpRequest(formData, null, null, null); //MessageBox.Show(xml); cls_YACRSResponse r = responseParser.parseIn(xml); if (r != null) { currentSessionDetail = r.M_data.M_sessionDetail; if (currentSessionDetail == null) { return(0); } else { return(currentSessionDetail.M_id); } } else { return(0); } }
public string SetAndCheckURL(string url, out string nurl) { char[] charsToTrim = { ' ', '\t', '/', '\\', ':', '?' }; string tidiedUrl = url.Trim(charsToTrim) + "/"; if (tidiedUrl.IndexOf("http") != 0) { tidiedUrl = "http://" + tidiedUrl; } serverURL = tidiedUrl + "services.php"; string xml = httpRequest(null, null, null, null); cls_YACRSResponse r = responseParser.parseIn(xml); if (r == null) { serverOK = false; baseURL = null; nurl = url; return("Incorrect URL"); } else { nurl = serverURL.Substring(0, serverURL.IndexOf("services.php")); serverOK = true; baseURL = tidiedUrl; Match ver = versionParse.Match(r.M_version); if (ver.Success) { serverMajorVer = int.Parse(ver.Groups[1].Value); serverMinorVer = int.Parse(" " + ver.Groups[2].Value + " "); } else { serverMajorVer = 0; serverMinorVer = 0; } return("YACRS version " + r.M_version); } }
public cls_questionResponseInfo questionInfoShort() { NameValueCollection formData = new NameValueCollection(); formData.Add("action", "quinfoshort"); formData.Add("id", currentSessionDetail.M_id.ToString()); string xml = httpRequest(formData, null, null, null); cls_YACRSResponse r = responseParser.parseIn(xml); if ((r != null) && (r.M_data.M_questionResponseInfo.Count > 0)) { if (r.M_data.M_questionResponseInfo[0].M_id != 0) { lastQiID = r.M_data.M_questionResponseInfo[0].M_id; } return(r.M_data.M_questionResponseInfo[0]); } else { return(null); } }
internal override void setOwner(cls_YACRSResponse n_owner) { __owner = n_owner; }
abstract internal void setOwner(cls_YACRSResponse n_owner);
public cls_YACRSResponse parseIn(string source) { XmlTextReader parser; string elementname; StringReader sr = new StringReader(source); parser = new XmlTextReader(sr); the_YACRSResponse = null; try { while (parser.Read()) { switch (parser.NodeType) { case XmlNodeType.XmlDeclaration: break; case XmlNodeType.Element: elementname = parser.LocalName; int elementid = LookupElementID(elementname); containerids.Push(elementid); Dictionary <string, string> atts2 = new Dictionary <string, string>(); if (parser.HasAttributes) { while (parser.MoveToNextAttribute()) { atts2.Add(parser.Name, parser.Value); } parser.MoveToElement(); } if (elementid == ID_YACRSResponse) { tmpPart = new cls_YACRSResponse(); tmpPart.parseAttributes(atts2); } else { if (tmpPart != null) { tmpPart = tmpPart.startElement(elementid, atts2, parser.NamespaceURI, elementname); } } if ((parser.IsEmptyElement) && (elementname.Equals(tmpPart.getElementName()))) { containerids.Pop(); tmpPart.endElement(elementname); tmpPart = tmpPart.getParent(); } break; case XmlNodeType.EndElement: containerids.Pop(); elementname = parser.LocalName; tmpPart.endElement(elementname); if ((tmpPart.getParent() == null) && (tmpPart.getElementName().Equals("YACRSResponse")) && (elementname.Equals(tmpPart.getElementName()))) { the_YACRSResponse = (cls_YACRSResponse)tmpPart; tmpPart = null; } else if (elementname.Equals(tmpPart.getElementName())) { tmpPart = tmpPart.getParent(); } break; case XmlNodeType.Whitespace: case XmlNodeType.Text: if (tmpPart != null) { tmpPart.content(parser.Value, containerids.Peek()); } break; default: Console.Out.WriteLine("Node: " + parser.NodeType.ToString()); break; } } return(the_YACRSResponse); } catch (Exception e) { return(null); } }