Пример #1
0
        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());
        }
Пример #2
0
        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());
        }
Пример #3
0
        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());
        }
Пример #4
0
 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());
 }