コード例 #1
0
        public bool RecordResult(SectorTime result)
        {
            SetSectorTime set = new SetSectorTime();

            set.RaceId    = result.RaceId;
            set.SectorId  = result.SectorId;
            set.AthleteId = result.AthleteId;
            set.StartTime = result.StartTime;
            set.EndTime   = result.EndTime;
            set.Duration  = result.Duration;
            set.Execute();
            return(true);
        }
コード例 #2
0
        public void Execute_NoDates()
        {
            //input new record:
            SetSectorTime target = new SetSectorTime();

            target.RaceId    = 1;
            target.SectorId  = Sector.Swim;
            target.AthleteId = new Random().Next();
            target.Duration  = 955;
            target.Execute();

            //ensure result available:
            string sqlCommand = string.Format(TestSQL.TriathlonResult.SectorTimes.GetDurationFormat, target.RaceId, target.SectorId, target.AthleteId);
            int    duration   = TestDataHelper.GetScalar <int>(sqlCommand);

            Assert.AreEqual <int>(target.Duration, duration);
        }
コード例 #3
0
        public void Execute()
        {
            //input new record:
            SetSectorTime target = new SetSectorTime();

            target.RaceId    = 1;
            target.SectorId  = Sector.Swim;
            target.AthleteId = new Random().Next();
            target.StartTime = new DateTime(2008, 09, 19, 12, 00, 00);
            target.EndTime   = new DateTime(2008, 09, 19, 12, 20, 20);
            SectorTime.CalculateDuration(target.StartTime, target.EndTime);
            target.Execute();

            //ensure result available:
            string sqlCommand = string.Format(TestSQL.TriathlonResult.SectorTimes.GetDurationFormat, target.RaceId, target.SectorId, target.AthleteId);
            int    duration   = TestDataHelper.GetScalar <int>(sqlCommand);

            Assert.AreEqual <int>(target.Duration, duration);
        }
コード例 #4
0
        static void watcher_Created(object sender, FileSystemEventArgs e)
        {
            System.Console.WriteLine("Found file: {0}", e.FullPath);
            //read in the file contents:
            string content = File.ReadAllText(e.FullPath);

            //validate:
            string[] contentParts = content.Split(FileWatcherConfiguration.Current.FieldDelimiter.ToCharArray());
            if (!IsValid(contentParts))
            {
                File.Move(e.FullPath, string.Format("{0}.invalid", e.FullPath));
            }
            else
            {
                try
                {
                    SetSectorTime set = new SetSectorTime();
                    set.RaceId    = int.Parse(contentParts[0]);
                    set.SectorId  = int.Parse(contentParts[1]);
                    set.AthleteId = int.Parse(contentParts[2]);
                    set.Duration  = int.Parse(contentParts[5]);
                    set.Execute();
                    string processedFilePath = string.Format("{0}.processed", e.FullPath);
                    File.Delete(processedFilePath);
                    File.Move(e.FullPath, processedFilePath);
                    System.Console.WriteLine("Processed.");
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("Error: {0}", ex.Message);
                    string errorFilePath = string.Format("{0}.errored", e.FullPath);
                    File.Delete(errorFilePath);
                    File.Move(e.FullPath, errorFilePath);
                }
            }
        }