Ejemplo n.º 1
0
 public SelectPartialTimes(ref DBConnection conn, AthleteDto athlete, CompetitionDto competition)
 {
     _conn        = conn;
     PartialTimes = new PartialTimesDto();
     _athlete     = athlete;
     _competition = competition;
 }
 private static void GeneratePartialTimes(PartialTimesDto partialTime, object[] row)
 {
     for (var i = 3; i <= Competition.NumberMilestone + 2; i++)
     {
         row[i] = PartialTimeString(partialTime.Time[i - 3]);
     }
 }
Ejemplo n.º 3
0
 public UpdatePartialTimes(ref DBConnection conn, string dni, PartialTimesDto partial)
 {
     _partial = partial;
     _dni     = dni;
     _conn    = conn;
 }
Ejemplo n.º 4
0
        private void BtSeleccionar_OnClick(object sender, RoutedEventArgs e)
        {
            var openFile = new OpenFileDialog {
                Filter      = @"*.csv|*.CSV",
                Multiselect = false
            };

            openFile.ShowDialog();
            _file = openFile.FileName;

            CsvLoader loader = new CsvTimes(new[] { _file });

            if (loader.Returned is IEnumerable <PartialTimesObjects> objects)
            {
                var dnis = new string[objects.Count()];
                for (var i = 0; i < objects.Count(); i++)
                {
                    dnis[i] = service.SelectDniFromDorsal(objects.ElementAt(i).Dorsal,
                                                          objects.ElementAt(i).CompetitionId);
                }

                var index = 0;
                IList <PartialTimesDto> noInserted    = new List <PartialTimesDto>();
                IList <string>          noInsertedDni = new List <string>();
                var countI = 0;
                var countU = 0;
                var notes  = string.Join("\n", loader.Errores);
                foreach (var times in objects)
                {
                    try {
                        _dto = new PartialTimesDto {
                            CompetitionDto = new CompetitionService().SearchCompetitionById(new CompetitionDto {
                                ID = times.CompetitionId
                            }),
                            Time = times.Times
                        };


                        var status = new EnrollService(_dto.CompetitionDto).SelectStatusEnroll(dnis[index]);

                        if (dnis[index] != null && status.Equals("REGISTERED"))
                        {
                            new EnrollService(_dto.CompetitionDto).InsertHasRegisteredTimes(dnis[index], _dto.Time[0],
                                                                                            _dto.Time[_dto.Time.Length - 1]);
                            timesService.InsertPartialTime(dnis[index], _dto);
                            countI++;
                        }
                        else
                        {
                            var s = $"El atleta {times.Dorsal} no esta registrado. \n";
                            if (notes.Contains(s))
                            {
                                notes += s;
                            }
                            else
                            {
                                notes += $"Linea {index + 1}: {s}";
                            }
                        }
                    }
                    catch (InvalidOperationException) {
                        if (_dto != null)
                        {
                            noInserted.Add(_dto);
                            noInsertedDni.Add(dnis[index]);
                        }
                    }

                    index++;
                }

                if (noInserted.Count > 0)
                {
                    var result  = MessageBoxResult.None;
                    var message = "¿Quiere sobreescribir los tiempos?";
                    result = MessageBox.Show(message, "Error", MessageBoxButton.YesNo);

                    if (result == MessageBoxResult.Yes)
                    {
                        index = 0;
                        foreach (var noInsert in noInserted)
                        {
                            timesService.UpdateAthleteRegisteredDorsal(noInsertedDni[index++], noInsert);
                            countU++;
                        }
                    }
                }

                PrintInsert(notes, countI, countU);
            }
        }
Ejemplo n.º 5
0
        public void UpdateAthleteRegisteredDorsal(string dni, PartialTimesDto noInsert)
        {
            var insert = new UpdatePartialTimes(ref _conn, dni, noInsert);

            insert.Execute();
        }
Ejemplo n.º 6
0
        public void InsertPartialTime(string dni, PartialTimesDto partialTimes)
        {
            var insert = new InsertPartialTimes(ref _conn, dni, partialTimes);

            insert.Execute();
        }