public override void UpdateDatabaseWithData(Session session, int raceIndex) { base.UpdateDatabaseWithData(session, raceIndex); int[] positionByDriverIndex = GetPositionsFromDriverIndex(); Result[,] results = new Result[Data.NumberOfDrivers, Data.NumberOfTracks]; for (int driverIndex = 0; driverIndex < Data.NumberOfDrivers; driverIndex++) { results[driverIndex, raceIndex].modified = true; //positions are returned as zero based. if (driverIndex >= positionByDriverIndex.Length) { results[driverIndex, raceIndex].position = driverIndex + 1; results[driverIndex, raceIndex].finishState = FinishingState.DidNotEnter; } else { results[driverIndex, raceIndex].position = positionByDriverIndex[driverIndex] + 1; results[driverIndex, raceIndex].finishState = 0; } } DriverResultsTableUpdater.SetResults(results, session, Data.NumberOfDrivers, Data.NumberOfTracks, Properties.Settings.Default.CurrentYear, Driver.GetDriverIndexDictionary(), Driver.GetDriverNumberArray()); }
public override void UpdateDatabaseWithData(Session session, int raceIndex) { base.UpdateDatabaseWithData(session, raceIndex); Result[,] results = new Result[Data.NumberOfDrivers, Data.NumberOfTracks]; int[] positionsByDriverIndex = GetPositionsByDriverIndex(GridOrder); for (int driverIndex = 0; driverIndex < Data.NumberOfDrivers; driverIndex++) { results[driverIndex, raceIndex].modified = true; //extract data from grid order. if (driverIndex >= positionsByDriverIndex.Length) { //if out of range results[driverIndex, raceIndex].position = driverIndex + 1; results[driverIndex, raceIndex].finishState = FinishingState.DidNotEnter; } else { //update normally results[driverIndex, raceIndex].position = positionsByDriverIndex[driverIndex] + 1; results[driverIndex, raceIndex].finishState = 0; } } DriverResultsTableUpdater.SetResults(results, session, Data.NumberOfDrivers, Data.NumberOfTracks, Properties.Settings.Default.CurrentYear, Driver.GetDriverIndexDictionary(), Driver.GetDriverNumberArray()); }
private void WriteGridResultsToDatabase() { Result[,] results = new Result[Data.NumberOfDrivers, Data.NumberOfTracks]; int driverIndexOfThisPosition; List <int> driverIndices = new List <int>(); for (int i = 0; i < Data.NumberOfDrivers; i++) { driverIndices.Add(i); } int[] gridOrder = new int[Data.NumberOfDrivers]; int position = 0; for (position = 0; position < GridOrder.Items.Count; position++) { driverIndexOfThisPosition = Driver.ConvertToDriverIndex(Convert.ToString(GridOrder.Items[position])); driverIndices.Remove(driverIndexOfThisPosition); gridOrder[position] = driverIndexOfThisPosition; results[driverIndexOfThisPosition, Data.RaceIndex].position = position + 1; results[driverIndexOfThisPosition, Data.RaceIndex].finishState = 0; results[driverIndexOfThisPosition, Data.RaceIndex].modified = true; } foreach (int driverIndex in driverIndices) { gridOrder[position] = driverIndex; results[driverIndex, Data.RaceIndex].position = position++ + 1; results[driverIndex, Data.RaceIndex].finishState = FinishingState.DNS; results[driverIndex, Data.RaceIndex].modified = true; } string filePath = GridData.GetTimingDataDirectory(Data.RaceIndex, Properties.Settings.Default.CurrentYear) + GridData.GetFileName(Session.Grid, Data.RaceIndex); GridData.WriteToFile(filePath, gridOrder); DriverResultsTableUpdater.SetResults(results, Session.Grid, Data.NumberOfDrivers, Data.NumberOfTracks, Properties.Settings.Default.CurrentYear, Driver.GetDriverIndexDictionary(), Driver.GetDriverNumberArray()); }
public virtual void SetSession(Session session) { this.Results = DriverResultsTableUpdater.GetResultsFromDatabase(session, Data.NumberOfDrivers, Data.NumberOfTracks, StratSim.Properties.Settings.Default.CurrentYear, Driver.GetDriverIndexDictionary()); DisplaySession = session; }
internal static void SetResults(Result[,] results, Session session) { DriverResultsTableUpdater.SetResults(results, session, Data.NumberOfDrivers, Data.NumberOfTracks, StratSim.Properties.Settings.Default.CurrentYear, Driver.GetDriverIndexDictionary(), Driver.GetDriverNumberArray()); }
internal static Result[,] GetResultsFromDatabase(Session session) { return DriverResultsTableUpdater.GetResultsFromDatabase(session, Data.NumberOfDrivers, Data.NumberOfTracks, StratSim.Properties.Settings.Default.CurrentYear, Driver.GetDriverIndexDictionary()); }
public void SetFirstSession(Session firstSession) { FirstSession = firstSession; FirstSessionResults = DriverResultsTableUpdater.GetResultsFromDatabase(firstSession, Data.NumberOfDrivers, Data.NumberOfTracks, StratSim.Properties.Settings.Default.CurrentYear, Driver.GetDriverIndexDictionary()); }