/// <summary> /// For a given tour, it determines if there were any errors loading /// that tour. /// </summary> /// <param name="tourData">Tour data to load - contains both pilot and tour ids.</param> /// <returns>true if loader errors found, false otherwise.</returns> private bool TourIsInError(CompleteTourData tourData) { if (tourData.Score == null || tourData.Stats == null) { return(true); } // See if we can find a match for this tour/person combo in the errors lists return(_threadParam.ScoreErrorList.Any(error => error.TourId == tourData.TourId && error.PilotName == tourData.PilotId) || _threadParam.StatsErrorList.Any(error => error.TourId == tourData.TourId && error.PilotName == tourData.PilotId)); }
/// <summary> /// For a given tour, it determines if there were any errors loading /// that tour. /// </summary> /// <param name="tourData">Tour data to load - contains both pilot and tour ids.</param> /// <returns>true if loader errors found, false otherwise.</returns> private bool TourIsInError(CompleteTourData tourData) { if (tourData.score == null || tourData.stats == null) return true; bool inError = false; // See if we can find a match for this tour/person combo in the errors lists. foreach (LoaderError error in _threadParam.scoreErrorList) { if (error.tourId == tourData.tourId && error.pilotName == tourData.pilotId) { inError = true; } } foreach (LoaderError error in _threadParam.statsErrorList) { if (error.tourId == tourData.tourId && error.pilotName == tourData.pilotId) { inError = true; } } return inError; }
/// <summary> /// Handles the post load complete processing. /// </summary> private void ProcessLoadCompleted() { List<CompleteTourData> results = new List<CompleteTourData>(); // Compile stats and scores into one logical unit. foreach (string pilotId in _threadParam.pilotIdList) { foreach (TourNode tour in _threadParam.toursToLoad) { CompleteTourData compTourData = new CompleteTourData(); compTourData.pilotId = pilotId; compTourData.tourId = tour.TourId; compTourData.score = FindPilotTourScore(pilotId, tour.TourId); compTourData.stats = FindPilotTourStats(pilotId, tour.TourId); results.Add(compTourData); } } // Write each complete tour data results out to disk. foreach(CompleteTourData tourData in results) { if (!TourIsInError(tourData)) { // write out as one logical whole. new XMLObjectSerialiser<AcesHighPilotScore>().WriteXMLFile(tourData.score, string.Format(".\\Data\\{0}_{1}_Score_{2}.xml", tourData.pilotId, tourData.score.TourType, tourData.score.TourId)); new XMLObjectSerialiser<AcesHighPilotStats>().WriteXMLFile(tourData.stats, string.Format(".\\Data\\{0}_{1}_Stats_{2}.xml", tourData.pilotId, tourData.stats.TourType, tourData.stats.TourId)); } } // Display any errors that the loader threads caught to the user. BuildAndDisplayAnyErrorMessage(); // Update the Registry and refresh the form. if (cmbBoxSquadSelect.SelectedItem.ToString() == _notSelectedText) ((MainMDI)MdiParent).RefreshPilotLists(this.txtbxPilotToLoad.Text); else ((MainMDI)MdiParent).RefreshSquadMemberPilotLists(this.cmbBoxSquadSelect.SelectedItem.ToString()); RestoreForm(); this.progressBarLoading.Value = 0; }