void doUgcs(List <XMLement> ugcs) { AppController.poiHit(); XMLement raw = XMLement.createFromRawXml("<poi><name>VolksMond</name><description>Door andere gebruikers gemaakte media</description></poi>"); XMLement mmd = new XMLement("media"); foreach (XMLement x in ugcs) { mmd.addChild(x); } raw.addChild(mmd); AppController.sEventLog.WriteLine("hit {0} ugc:", ugcs.Count); AppController.sEventLog.WriteLine("\t", raw.toString()); if (sUgcViewerPage == null) { sUgcViewerPage = new PoiViewerPage(this); } if (sUgcViewerPage.setContent(raw)) { mIsActive = false; sUgcViewerPage.ShowDialog(); mBlendTimer.Change(0, 3000); } }
public XMLement getPOI(string id) { XMLement xml = new XMLement(Protocol.TAG_POI_GET_REQ); AppController.showStatus("getPOI"); xml.addAttribute(Protocol.ATTR_ID, id); lock (this) { xml = utopiaRequest(xml); } if (xml != null && xml.tag == Protocol.TAG_POI_GET_RSP) { xmlString = xml.toString(); return(xml); } else { return(null); } }
public bool setContent(XMLement xml) { setMenuText(0, "Volgende"); setMenuIcon(0, AppController.sVolgIcon); abortDownload(); XMLement name = xml.getChildByName("name"); if (name != null) { title = name.nodeText; } mAllMedia = xml.getChildByName("media"); AppController.sEventLog.WriteLine(mAllMedia.toString()); mDnlName = ""; drawNameText(); mMediaIndex = -1; mDownloadIndex = -1; mImage.x = 500; for (int i = 0; i < 10; i++) { dnlFileNames[i] = null; } if (mAllMedia.getChild(0) != null) { doDownloadMedium(0); } else { setMenuText(0, "Terug"); setMenuIcon(0, AppController.sTerugIcon); return(false); } return(true); }
/// <summary> /// login, select app and make a track /// currently no error recovery... /// </summary> public void start() { if (messageCallback != null) { messageCallback("login: "******"login-rsp") { StreamWriter userProps = new StreamWriter(AppController.sUserProps); if (userProps != null) { AppController.sUserName = mUser; AppController.sUserPass = mPass; userProps.WriteLine(mUser); userProps.WriteLine(mPass); userProps.Close(); } if (messageCallback != null) { messageCallback("login: succesful!"); } } else { return; } x = selectApp(); if (x != null) { if (messageCallback != null) { string s = x.toString(); messageCallback("select-app: succesful!"); } } mSendSamplesThread = new Thread(sendSamplesThread); mSendSamplesThread.Start(); XMLement xml = new XMLement(Protocol.TAG_UGC_OFF_REQ); lock (this) { xml = utopiaRequest(xml); } x = getRouteList(); if (x != null) { AppController.sRoutes = x; if (messageCallback != null) { string s = x.toString(); messageCallback("got route list!"); } } AppController.sActiveRoute = null; x = navState(); if (x != null) { string s = x.getAttributeValue("routeid"); if (s != null && s != "") { AppController.sActiveRoute = AppController.sRoutes.getChildForAttribute("id", s); AppController.sActiveRouteID = int.Parse(s); AppController.sActiveRouteMapPathHor = null; AppController.sActiveRouteMapPathVer = null; if (AppController.sActiveRoute == null) { AppController.sActiveRouteID = -1; } } if (messageCallback != null) { messageCallback("get_state: succesful!"); ; // do something with nav state } } x = doNavStart(); }
private XMLement doRequest(XMLement anElement, int lAttempt) { string url = mServer; if (mAgentKey != null) { url += "?agentkey=" + mAgentKey; } else { // login url += "?timeout=" + Diwi.Properties.Resources.KwxServerTimeout; } try { // create the web request sKwxWebRequest = (HttpWebRequest)WebRequest.Create(url); UTF8Encoding encoding = new UTF8Encoding(); byte[] postBytes = encoding.GetBytes(anElement.toString()); sKwxWebRequest.KeepAlive = true; sKwxWebRequest.Timeout = 25000; sKwxWebRequest.Method = "POST"; sKwxWebRequest.ContentType = "text/xml"; sKwxWebRequest.ContentLength = postBytes.Length; Stream postStream = sKwxWebRequest.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close(); // make the connect HttpWebResponse resp = (HttpWebResponse)sKwxWebRequest.GetResponse(); // get the page data StreamReader sr = new StreamReader(resp.GetResponseStream()); string pageData = sr.ReadToEnd(); sr.Close(); // get the status code (should be 200) // status = resp.StatusCode; // close the connection resp.Close(); AppController.showStatus(""); return(XMLement.createFromRawXml(pageData)); } catch (TimeoutException e) { AppController.sEventLog.WriteLine("Caught Timeout Excepotion;"); if (lAttempt < 3) { AppController.sEventLog.WriteLine("trying again..."); return(doRequest(anElement, lAttempt + 1)); } else { AppController.sEventLog.WriteLine("aborting after 3 attemps..."); } AppController.showStatus(""); return(null); } catch (WebException e) { AppController.showStatus(""); string str = string.Format("Caught WebException: {0}", e.Status.ToString()); AppController.sEventLog.WriteLine(str); return(new XMLement("web-exception")); } catch (Exception) { AppController.showStatus(""); return(null); } }
private void doGR(int i, string s) { XMLement getRoutesReq = AppController.sKwxClient.getRoute("109"); string s1 = getRoutesReq.toString(); }