private void UpdateTagCache() { // get the xml list of tags from the server string sResponse = WebCommunications.SendGetRequest("http://dwlapi.azurewebsites.net/api/reflection/KnowledgeBaseServer/KnowledgeBaseServer/KnowledgeServer/ListTags", true); sResponse = Master.CleanResponse(sResponse); //txtSnippetContent.Text = m_sHomeFolder; List <string> lFileLines = new List <string>(); List <string> lSourceLines = new List <string>(); // get data from xml XElement pTagsXml = XElement.Parse(sResponse); foreach (XElement pTagXml in pTagsXml.Elements("Tag")) { if (pTagXml.Attribute("Source").Value == "true") { lSourceLines.Add(pTagXml.Value); } else { lFileLines.Add(pTagXml.Value); } } // save the lines into files File.WriteAllLines(m_sBaseDir + "_tagcache.dat", lFileLines.ToArray()); File.WriteAllLines(m_sBaseDir + "_sourcecache.dat", lSourceLines.ToArray()); }
private void Query(string sQuery) { this.InitBrowser(); // save current point if (m_sCurrentPage != "" && m_sCurrentPage != null) { m_dPageScrollPoints[m_sCurrentPage] = m_pWebView.ScrollY; } int iScrollPoint = 0; string sHTML = ""; if (!m_dLoadedPages.ContainsKey(sQuery)) { string sFixedQuery = HttpUtility.UrlEncode(sQuery); string sResponse = WebCommunications.SendGetRequest("http://dwlapi.azurewebsites.net/api/reflection/KnowledgeBaseServer/KnowledgeBaseServer/KnowledgeServer/ConstructPage?squery=" + sFixedQuery, true); // fix response and add to it sResponse = Master.CleanResponse(sResponse); Console.WriteLine(m_sHead); sHTML = "<html><head>" + m_sHead + "<style>" + m_sCSS + "</style></head>" + sResponse + "</html>"; m_dLoadedPages.Add(sQuery, sHTML); m_dPageScrollPoints.Add(sQuery, 0); iScrollPoint = 0; m_lNavTitles.Add(sQuery); this.RefreshDrawer(); } else { sHTML = m_dLoadedPages[sQuery]; iScrollPoint = m_dPageScrollPoints[sQuery]; } m_sCurrentPage = sQuery; //m_pWebView.StopLoading(); m_pWebView.LoadUrl("about:blank"); m_pWebView.LoadData(sHTML, "text/html", "UTF-8"); m_pWebView.ScrollY = iScrollPoint; //m_pWebView.Reload(); }
private void RandomTag() { string sResponse = WebCommunications.SendGetRequest("http://dwlapi.azurewebsites.net/api/reflection/KnowledgeBaseServer/KnowledgeBaseServer/KnowledgeServer/RandomTag", true); this.Query(Master.CleanResponse(sResponse)); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == Result.Ok) { // TODO: HANDLE EXTRA HERE string sType = data.GetStringExtra("Type"); XElement pResponse = null; bool bRestartRequested = false; if (sType == "initial") { string sRule = data.GetStringExtra("Rule"); string sInitialCorrectKoan = data.GetStringExtra("CorrectKoan"); string sInitialIncorrectKoan = data.GetStringExtra("IncorrectKoan"); string sBody = Master.BuildCommonBody(Master.BuildGameIDBodyPart(m_sGameID) + "<param name='sRule'>" + sRule + "</param><param name='sBuddhaNatureKoan'>" + sInitialCorrectKoan + "</param><param name='sNonBuddhaNatureKoan'>" + sInitialIncorrectKoan + "</param>"); string sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetGameURL("Zendo") + "SubmitInitialKoans", sBody, true); if (Master.CleanResponse(sResponse) != "") { pResponse = Master.ReadResponse(sResponse); } } else if (sType == "build") { string sKoan = data.GetStringExtra("Koan"); bool bMondo = data.GetBooleanExtra("Mondo", false); string sBody = Master.BuildCommonBody(Master.BuildGameIDBodyPart(m_sGameID) + "<param name='sKoan'>" + sKoan + "</param>"); string sResponse = ""; if (!bMondo) { sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetGameURL("Zendo") + "SubmitKoan", sBody, true); } else { sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetGameURL("Zendo") + "SubmitMondo", sBody, true); } if (Master.CleanResponse(sResponse) != "") { pResponse = Master.ReadResponse(sResponse); } bRestartRequested = true; } else if (sType == "analysis") { bool bHasBuddhaNature = data.GetBooleanExtra("HasBuddhaNature", false); string sBody = Master.BuildCommonBody(Master.BuildGameIDBodyPart(m_sGameID) + "<param name='bHasBuddhaNature'>" + bHasBuddhaNature + "</param>"); string sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetGameURL("Zendo") + "SubmitPendingKoanAnalysis", sBody, true); if (Master.CleanResponse(sResponse) != "") { pResponse = Master.ReadResponse(sResponse); } } else if (sType == "predict") { bool bPrediction = data.GetBooleanExtra("Prediction", false); string sBody = Master.BuildCommonBody(Master.BuildGameIDBodyPart(m_sGameID) + "<param name='bPrediction'>" + bPrediction + "</param>"); string sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetGameURL("Zendo") + "SubmitMondoPrediction", sBody, true); if (Master.CleanResponse(sResponse) != "") { pResponse = Master.ReadResponse(sResponse); } bRestartRequested = true; } else if (sType == "guess") { string sGuess = data.GetStringExtra("Guess"); string sBody = Master.BuildCommonBody(Master.BuildGameIDBodyPart(m_sGameID) + "<param name='sGuess'>" + Master.EncodeXML(sGuess) + "</param>"); string sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetGameURL("Zendo") + "SubmitGuess", sBody, true); if (Master.CleanResponse(sResponse) != "") { pResponse = Master.ReadResponse(sResponse); } bRestartRequested = true; } else if (sType == "disprove") { bool bSuccessfullyDisproved = data.GetBooleanExtra("Disprove", false); if (!bSuccessfullyDisproved) { string sAltResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetGameURL("Zendo") + "GrantEnlightenment", Master.BuildCommonBody(Master.BuildGameIDBodyPart(m_sGameID)), true); if (Master.CleanResponse(sAltResponse) != "") { pResponse = Master.ReadResponse(sAltResponse); } } else { string sKoan = data.GetStringExtra("Koan"); bool bHasBuddhaNature = data.GetBooleanExtra("HasBuddhaNature", false); string sBody = Master.BuildCommonBody(Master.BuildGameIDBodyPart(m_sGameID) + "<param name='sKoan'>" + sKoan + "</param><param name='bHasBuddhaNature'>" + bHasBuddhaNature + "</param>"); string sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetGameURL("Zendo") + "DisproveGuess", sBody, true); if (Master.CleanResponse(sResponse) != "") { pResponse = Master.ReadResponse(sResponse); } } } if (pResponse != null) { var pBuilder = new AlertDialog.Builder(this); pBuilder.SetMessage(pResponse.Element("Text").Value); pBuilder.SetPositiveButton("Ok", (e, s) => { return; }); pBuilder.Show(); } else if (bRestartRequested) { this.ForceRestart(); } else { this.GetUserBoard(); } } }