Пример #1
0
        public void RunTests()
        {
            HTCPilotStatsSvc   statsSvc = new HTCPilotStatsSvc();
            AcesHighPilotStats stats    = statsSvc.GetPilotStatsMultiThreaded("99MecInf", TourType.MainArenaTour, 76, new ProxySettingsDTO());

            HTCPilotScoreSvc   scoreSvc = new HTCPilotScoreSvc();
            AcesHighPilotScore score    = scoreSvc.GetPilotScore("99MecInf", TourType.MainArenaTour, 76, new ProxySettingsDTO());

            int i = 0;

            /*
             * TourNode tour = TourDefinitions.Instance.GetTourDetails(76, TourType.MainArenaTour);
             *
             * Sender httpSender = new Sender(new ProxySettingsDTO());
             * StreamReader prototype = File.OpenText("individual_scores.http.txt");
             * httpSender.RequestString = "gameid=" + "99MecInf" + "&tour=" + tour.FullyQualifiedTourIdentifier;
             * httpSender.URLEncodeRequestString();
             * httpSender.Initialise(prototype, "http://www.hitechcreations.com/cgi-bin/105score/105score.pl");
             * StreamReader response = httpSender.Send();
             *
             *
             * string PilotVsBuffer = response.ReadToEnd();
             * StringReader pilotVsStringReader = new StringReader(PilotVsBuffer);
             *
             * // Use the cool sgml reader to 'interpret' the HTML as XML :) very nice!
             * SgmlReader pilotVsSgmlReader = new SgmlReader();
             * pilotVsSgmlReader.DocType = "HTML";
             * pilotVsSgmlReader.InputStream = pilotVsStringReader;
             * statsXmlDoc.Load(pilotVsSgmlReader);
             *
             * statsXmlDoc.Save(Console.Out);
             * statsXmlDoc.Save(@"C:\response.xml");
             */
        }
Пример #2
0
        public void RunTests()
        {
            HTCPilotStatsSvc statsSvc = new HTCPilotStatsSvc();
            AcesHighPilotStats stats = statsSvc.GetPilotStatsMultiThreaded("99MecInf", TourType.MainArenaTour, 76, new ProxySettingsDTO());

            HTCPilotScoreSvc scoreSvc = new HTCPilotScoreSvc();
            AcesHighPilotScore score = scoreSvc.GetPilotScore("99MecInf", TourType.MainArenaTour, 76, new ProxySettingsDTO());

            int i = 0;

            /*
            TourNode tour = TourDefinitions.Instance.GetTourDetails(76, TourType.MainArenaTour);

            Sender httpSender = new Sender(new ProxySettingsDTO());
            StreamReader prototype = File.OpenText("individual_scores.http.txt");
            httpSender.RequestString = "gameid=" + "99MecInf" + "&tour=" + tour.FullyQualifiedTourIdentifier;
            httpSender.URLEncodeRequestString();
            httpSender.Initialise(prototype, "http://www.hitechcreations.com/cgi-bin/105score/105score.pl");
            StreamReader response = httpSender.Send();

            string PilotVsBuffer = response.ReadToEnd();
            StringReader pilotVsStringReader = new StringReader(PilotVsBuffer);

            // Use the cool sgml reader to 'interpret' the HTML as XML :) very nice!
            SgmlReader pilotVsSgmlReader = new SgmlReader();
            pilotVsSgmlReader.DocType = "HTML";
            pilotVsSgmlReader.InputStream = pilotVsStringReader;
            statsXmlDoc.Load(pilotVsSgmlReader);

            statsXmlDoc.Save(Console.Out);
            statsXmlDoc.Save(@"C:\response.xml");
            */
        }
Пример #3
0
        /// <summary>
        /// Thread start point for the stats loader thread.
        /// </summary>
        /// <param name="obj">DataLoaderThreadParams</param>
        public void LoaderThreadEntryPoint(object obj)
        {
            var param = (DataLoaderThreadParams)obj;

            try
            {
                var onlyOneToLoad = param.ToursToLoad.Count * param.PilotIdList.Count == 1;

                foreach (var tour in param.ToursToLoad)
                {
                    foreach (var pilotId in param.PilotIdList)
                    {
                        //
                        // Load the Stats objects.
                        //
                        var statsUrl = ConfigurationManager.AppSettings["statsURL"];
                        try
                        {
                            param.StatsList.Add(HTCPilotStatsSvc.GetPilotStats(pilotId, tour, statsUrl, param.ProxySettings));
                        }
                        catch (Exception e)
                        {
                            var loaderError = new LoaderError
                            {
                                TourId       = tour.TourId,
                                PilotName    = pilotId,
                                ErrorMessage =
                                    string.Format(" - could not load stats objects for pilot {0} for {1} tour {2}.",
                                                  pilotId, tour.TourType, tour.TourId)
                            };
                            param.StatsErrorList.Add(loaderError);
                            Utility.WriteDebugTraceFile(e);
                        }

                        // Wait between calls.
                        Thread.Sleep(WaitTimeMillsecondsBetweenHttpCallsToHtc);
                        progressBarLoading.Invoke(param.ProgressCallBack);

                        //
                        // Load the scores objects.
                        //
                        var scoresUrl = ConfigurationManager.AppSettings["scoresURL"];
                        try
                        {
                            param.ScoreList.Add(HTCPilotScoreSvc.GetPilotScore(pilotId, tour, scoresUrl, param.ProxySettings));
                        }
                        catch (Exception e)
                        {
                            var error = new LoaderError
                            {
                                TourId       = tour.TourId,
                                PilotName    = pilotId,
                                ErrorMessage =
                                    string.Format(" - could not load scores objects for pilot {0} for {1} tour {2}.",
                                                  pilotId, tour.TourType, tour.TourId)
                            };
                            param.ScoreErrorList.Add(error);
                            Utility.WriteDebugTraceFile(e);
                        }

                        progressBarLoading.Invoke(param.ProgressCallBack);

                        if (!onlyOneToLoad)
                        {
                            Thread.Sleep(WaitTimeMillsecondsBetweenHttpCallsToHtc);
                        }
                    }
                }
            }
            finally
            {
                btnLoad.Invoke(param.CompletedCallBack);
            }
        }