コード例 #1
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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Thread start point for the stats loader thread.
        /// </summary>
        /// <param name="obj">DataLoaderThreadParams</param>
        public void LoaderThreadEntryPoint(object obj)
        {
            DataLoaderThreadParams param = (DataLoaderThreadParams)obj;

            try
            {
                bool onlyOneToLoad = param.toursToLoad.Count * param.pilotIdList.Count == 1;

                foreach (TourNode tour in param.toursToLoad)
                {
                    foreach (string pilotId in param.pilotIdList)
                    {
                        //
                        // Load the Stats objects.
                        //
                        string statsURL = ConfigurationManager.AppSettings["statsURL"];
                        HTCPilotStatsSvc statsSvc = new HTCPilotStatsSvc();
                        try
                        {
                            param.statsList.Add(statsSvc.GetPilotStats(pilotId, tour, param.proxySettings, statsURL));
                        }
                        catch (Exception e)
                        {
                            LoaderError loaderError = new LoaderError();
                            loaderError.tourId = tour.TourId;
                            loaderError.pilotName = pilotId;
                            loaderError.errorMessage = string.Format(" - could not load stats objects for pilot {0} for {1} tour {2}.", pilotId, tour.TourType.ToString(), tour.TourId);
                            param.statsErrorList.Add(loaderError);
                            Utility.WriteDebugTraceFile(e);
                        }

                        // Wait between calls.
                        Thread.Sleep(_waitTimeMillsecondsBetweenHttpCallsToHtc);
                        progressBarLoading.Invoke(param.updateProgressCallBack);

                        //
                        // Load the scores objects.
                        //
                        HTCPilotScoreSvc scoreSvc = new HTCPilotScoreSvc();
                        string scoresURL = ConfigurationManager.AppSettings["scoresURL"];
                        try
                        {
                            param.scoreList.Add(scoreSvc.GetPilotScore(pilotId, tour, param.proxySettings, scoresURL));
                        }
                        catch (Exception e)
                        {
                            LoaderError error = new LoaderError();
                            error.tourId = tour.TourId;
                            error.pilotName = pilotId;
                            error.errorMessage = string.Format(" - could not load scores objects for pilot {0} for {1} tour {2}.", pilotId, tour.TourType.ToString(), tour.TourId);
                            param.scoreErrorList.Add(error);
                            Utility.WriteDebugTraceFile(e);
                        }

                        progressBarLoading.Invoke(param.updateProgressCallBack);

                        if (!onlyOneToLoad)
                            Thread.Sleep(_waitTimeMillsecondsBetweenHttpCallsToHtc);
                    }
                }

            }
            finally
            {
                btnLoad.Invoke(param.loadCompletedCallBack);
            }
        }