public AcesHighPilotStats GetPilotStats(string pilotId, TourNode tour, string statsUrl, ProxySettingsDTO proxySettings) { if (tour == null) { throw new ArgumentException("tour of type TourNode must be set!"); } if (pilotId == null) { throw new ArgumentException("pilotId of type string must be set!"); } if (proxySettings == null) { throw new ArgumentException("proxySettings of type ProxySettingsDTO must be set!"); } var postData = string.Format("playername={1}&selectTour={0}&action=1&Submit=Get+Stats", tour.TourSelectArg, pilotId); var statsPageDoc = _loader.LoadHtmlPageAsXmlByPost(statsUrl, postData, proxySettings); var xsltDocReader = new XmlTextReader("PilotStatsTransform.xslt"); var transformer = new XSLT2Transformer(statsPageDoc, xsltDocReader); var result = transformer.DoTransform(); // Deserialise the XmlDocument to a in-memory object. var stats = result.DeserialiseFromXmlDoc <AcesHighPilotStats>(); // And fill in the rest of the details ourselves. stats.GameId = pilotId.ToUpperFirstChar(); stats.TourId = tour.TourId.ToString(); stats.TourType = tour.TourType; stats.TourDetails = tour.BuildTourDetailsTag(); return(stats); }
public static string BuildTourDetailsTag(this TourNode tour) { var shortStartDate = string.Format("{1}-{0}-{2}", tour.TourStartDate.Day, tour.TourStartDate.Month, tour.TourStartDate.Year); var shortEndDate = string.Format("{1}-{0}-{2}", tour.TourEndDate.Day, tour.TourEndDate.Month, tour.TourEndDate.Year); return(string.Format("Tour {0} {1} to {2}", tour.TourId, shortStartDate, shortEndDate)); }
public void PerFixtureSetUp() { _xmlDocumentDoc = new XmlDocument(); _xmlDocumentDoc.Load("../../Data/POST-pilot-php20150915-144024.xml"); _tour = new TourNode { TourId = 111, TourType = "TourType", TourStartDate = DateTime.Now, TourEndDate = DateTime.Now.AddDays(1), TourSelectArg = "TourSelectArg" }; }
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button != MouseButtons.Left) { return; } if (e.Node != null) { return; } TourNode tourNode = (TourNode)e.Node; historyListView.Items.Clear(); foreach (Discovery discovery in DiscoveryService.GetByTour(tourNode.Tour)) { historyListView.Items.Add(new DiscoveryListViewItem(discovery)); } }
public void OnLoad() { AzusaContext.GetInstance().Splash.SetLabel("Abfragen der Warwalking Touren..."); TreeNode toursRoot = new TreeNode("Touren"); TreeNode lastTour = null; foreach (Tour tour in TourService.GetAllTours()) { lastTour = new TourNode(tour); toursRoot.Nodes.Add(lastTour); } toursRoot.Expand(); treeView1.Nodes.Add(toursRoot); if (lastTour != null) { treeView1.SelectedNode = lastTour; } }
/// <summary> /// Load a single AcesHighPilotScore objects from HTC web server for a give pilot, tour, and tour type. /// </summary> /// <param name="pilotId">Pilot in-game handle to retrieve score of.</param> /// <param name="tour">The tour</param> /// <param name="proxySettings">DTO object detailing how we should connect to the internet.</param> /// <param name="scoresUrl"></param> /// <returns>The score for the nominated pilot/tour/tour-type combination.</returns> public AcesHighPilotScore GetPilotScore(string pilotId, TourNode tour, string scoresUrl, ProxySettingsDTO proxySettings) { if (tour == null) { throw new ArgumentNullException("tour of type TourNode must be set!"); } if (pilotId == null) { throw new ArgumentNullException("pilotId of type string must be set!"); } if (scoresUrl == null) { throw new ArgumentNullException("scoresUrl of type string must be set!"); } if (proxySettings == null) { throw new ArgumentNullException("proxySettings of type ProxySettingsDTO must be set!"); } // Grab the web page and turn it into true XML. var postData = "playername=" + pilotId + "&selectTour=" + tour.TourSelectArg + "&action=1&Submit=Get+Scores"; var doc = _loader.LoadHtmlPageAsXmlByPost(scoresUrl, postData, proxySettings); // XSLT 2.0 parse the Xml score page and transform to our public format. var xsltDocReader = new XmlTextReader("PilotScoreTransform.xslt"); var xformer = new XSLT2Transformer(doc, xsltDocReader); var result = xformer.DoTransform(); // may throw Saxon.Api.DynamicError when cant convert // Deserialise the XmlDocument to a in-memory object. var score = result.DeserialiseFromXmlDoc <AcesHighPilotScore>(); // And fill in the rest of the details ourselves. score.GameId = pilotId.ToUpperFirstChar(); score.TourId = tour.TourId.ToString(); score.TourDetails = tour.BuildTourDetailsTag(); score.TourType = tour.TourType; // Yah! all done. return(score); }