Example #1
0
        private void rankByPrviPreskok(List <RezultatPreskok> rezultati, bool vecaEOcenaImaPrednost, int redBrojOffset)
        {
            PropertyDescriptor[] propDesc;
            ListSortDirection[]  sortDir;
            if (vecaEOcenaImaPrednost)
            {
                propDesc = new PropertyDescriptor[] {
                    TypeDescriptor.GetProperties(typeof(RezultatPreskok))["Total"],
                    TypeDescriptor.GetProperties(typeof(RezultatPreskok))["E"],
                    TypeDescriptor.GetProperties(typeof(RezultatPreskok))["PrezimeIme"]
                };
                sortDir = new ListSortDirection[] {
                    ListSortDirection.Descending,
                    ListSortDirection.Descending,
                    ListSortDirection.Ascending
                };
            }
            else
            {
                propDesc = new PropertyDescriptor[] {
                    TypeDescriptor.GetProperties(typeof(RezultatPreskok))["Total"],
                    TypeDescriptor.GetProperties(typeof(RezultatPreskok))["PrezimeIme"]
                };
                sortDir = new ListSortDirection[] {
                    ListSortDirection.Descending,
                    ListSortDirection.Ascending
                };
            }
            rezultati.Sort(new SortComparer <RezultatPreskok>(propDesc, sortDir));

            RezultatPreskok prevRezultat = null;
            short           prevRank     = 0;

            for (int i = 0; i < rezultati.Count; i++)
            {
                rezultati[i].RedBroj = (short)(i + 1 + redBrojOffset);

                if (rezultati[i].Total == null)
                {
                    rezultati[i].Rank = null;
                }
                else
                {
                    if (!ranksAreEqual(rezultati[i], prevRezultat, false, vecaEOcenaImaPrednost))
                    {
                        rezultati[i].Rank = rezultati[i].RedBroj;
                    }
                    else
                    {
                        rezultati[i].Rank = prevRank;
                    }

                    prevRezultat = rezultati[i];
                    prevRank     = rezultati[i].Rank.Value;
                }
            }
        }
Example #2
0
        public virtual void addGimnasticar(GimnasticarUcesnik g, Ocena o,
                                           RezultatskoTakmicenje rezTak)
        {
            RezultatPreskok r = new RezultatPreskok();

            r.Gimnasticar = g;
            r.setOcena(o);
            Rezultati.Add(r);
            rankRezultati(rezTak.Propozicije);
        }
Example #3
0
        public virtual void editOcena(Ocena o, RezultatskoTakmicenje rezTak)
        {
            RezultatPreskok r = getRezultat(o.Gimnasticar);

            if (r != null)
            {
                r.setOcena(o);
                rankRezultati(rezTak.Propozicije);
            }
        }
Example #4
0
        public virtual void addGimnasticar(GimnasticarUcesnik g, Ocena o, 
            RezultatskoTakmicenje rezTak)
        {
            RezultatPreskok r = new RezultatPreskok();
            r.Gimnasticar = g;
            r.setOcena(o);
            Rezultati.Add(r);

            rankRezultati();
            updateKvalStatus(rezTak.Propozicije);
        }
Example #5
0
        public virtual void deleteGimnasticar(GimnasticarUcesnik g,
                                              RezultatskoTakmicenje rezTak)
        {
            RezultatPreskok r = getRezultat(g);

            if (r != null)
            {
                Rezultati.Remove(r);
                rankRezultati(rezTak.Propozicije);
            }
        }
Example #6
0
 public virtual void initDrugoKolo(RezultatPreskok r, bool naOsnovuObaPreskoka, bool postojeObaPreskoka)
 {
     if (!naOsnovuObaPreskoka || !postojeObaPreskoka)
     {
         initDrugoKolo(r);
     }
     else
     {
         D_DrugoKolo    = null;
         E_DrugoKolo    = null;
         TotalDrugoKolo = r.TotalObeOcene;
     }
 }
Example #7
0
        public virtual void loadFromDump(StringReader reader, IdMap map)
        {
            DeoTakmicenjaKod = (DeoTakmicenjaKod)Enum.Parse(typeof(DeoTakmicenjaKod), reader.ReadLine());
            Sprava           = (Sprava)Enum.Parse(typeof(Sprava), reader.ReadLine());

            int brojRezultata = int.Parse(reader.ReadLine());

            for (int i = 0; i < brojRezultata; ++i)
            {
                reader.ReadLine();  // id
                RezultatPreskok r = new RezultatPreskok();
                r.loadFromDump(reader, map);
                Rezultati.Add(r);
            }
        }
Example #8
0
 private bool ranksAreEqual(RezultatPreskok r1, RezultatPreskok r2, bool obaPreskoka, bool vecaEOcenaImaPrednost)
 {
     if (r1 == null || r2 == null)
     {
         return(false);
     }
     if (!obaPreskoka)
     {
         return(r1.Total == r2.Total && (!vecaEOcenaImaPrednost || r1.E == r2.E));
     }
     else
     {
         return(r1.TotalObeOcene == r2.TotalObeOcene && (!vecaEOcenaImaPrednost || r1.EObeOcene == r2.EObeOcene));
     }
 }
Example #9
0
        public virtual void deleteOcena(Ocena o, RezultatskoTakmicenje rezTak, bool removeRezultat)
        {
            RezultatPreskok r = getRezultat(o.Gimnasticar);

            if (r != null)
            {
                if (removeRezultat)
                {
                    Rezultati.Remove(r);
                }
                else
                {
                    r.clearOcena();
                }
                rankRezultati(rezTak.Propozicije);
            }
        }
Example #10
0
 public virtual void initPrvoKolo(RezultatPreskok r, bool naOsnovuObaPreskoka, bool postojeObaPreskoka)
 {
     if (!naOsnovuObaPreskoka || !postojeObaPreskoka)
     {
         // Ovo takodje obradjuje situaciju kada je u propozicijama za prvo kolo stavljeno
         // da se preskok racuna na osnovu oba preskoka, ali ni za jednog gimnasticara ne
         // postoji ocena za oba preskoka. Ova situacija najverovatnije nastaje kada se u
         // prvom kolu kao prvi preskok unosila konacna ocena za oba preskoka.
         // U tom slucaju, za ocenu prvog kola treba uzeti prvu ocenu.
         initPrvoKolo(r);
     }
     else
     {
         D_PrvoKolo    = null;
         E_PrvoKolo    = null;
         TotalPrvoKolo = r.TotalObeOcene;
     }
 }
Example #11
0
        public virtual void addOcena(Ocena o, RezultatskoTakmicenje rezTak,
            bool createRezultat)
        {
            RezultatPreskok rezultat;
            if (createRezultat)
            {
                rezultat = new RezultatPreskok();
                rezultat.Gimnasticar = o.Gimnasticar;
                Rezultati.Add(rezultat);
            }
            else
            {
                rezultat = getRezultat(o.Gimnasticar);
            }

            if (rezultat != null)
            {
                rezultat.setOcena(o);
                rankRezultati();
                updateKvalStatus(rezTak.Propozicije);
            }
        }
Example #12
0
        public virtual void addOcena(Ocena o, RezultatskoTakmicenje rezTak,
                                     bool createRezultat)
        {
            RezultatPreskok rezultat;

            if (createRezultat)
            {
                rezultat             = new RezultatPreskok();
                rezultat.Gimnasticar = o.Gimnasticar;
                Rezultati.Add(rezultat);
            }
            else
            {
                rezultat = getRezultat(o.Gimnasticar);
            }

            if (rezultat != null)
            {
                rezultat.setOcena(o);
                rankRezultati(rezTak.Propozicije);
            }
        }
Example #13
0
        public virtual void create(RezultatskoTakmicenje rezTak, IList <Ocena> ocene)
        {
            IList <GimnasticarUcesnik> gimnasticari;

            if (deoTakKod == DeoTakmicenjaKod.Takmicenje1)
            {
                gimnasticari = getGimnasticari(ocene, rezTak);
            }
            else
            {
                gimnasticari = rezTak.Takmicenje3.getGimnasticariKvalifikanti(Sprava.Preskok);
            }

            IDictionary <int, RezultatPreskok> rezultatiMap = new Dictionary <int, RezultatPreskok>();

            foreach (GimnasticarUcesnik g in gimnasticari)
            {
                RezultatPreskok r = new RezultatPreskok();
                r.Gimnasticar = g;
                rezultatiMap.Add(g.Id, r);
            }

            foreach (Ocena o in ocene)
            {
                if (o.Sprava == Sprava.Preskok && rezultatiMap.ContainsKey(o.Gimnasticar.Id))
                {
                    rezultatiMap[o.Gimnasticar.Id].setOcena(o);
                }
            }

            Rezultati.Clear();
            foreach (RezultatPreskok r in rezultatiMap.Values)
            {
                Rezultati.Add(r);
            }
            rankRezultati(rezTak.Propozicije);
        }
Example #14
0
        public virtual void create(RezultatskoTakmicenje rezTak, IList<Ocena> ocene)
        {
            IList<GimnasticarUcesnik> gimnasticari;
            if (deoTakKod == DeoTakmicenjaKod.Takmicenje1)
                gimnasticari = getGimnasticari(ocene, rezTak);
            else
                gimnasticari = rezTak.Takmicenje3.getUcesniciGimKvalifikanti(Sprava.Preskok);

            IDictionary<int, RezultatPreskok> rezultatiMap = new Dictionary<int, RezultatPreskok>();
            foreach (GimnasticarUcesnik g in gimnasticari)
            {
                RezultatPreskok rezultat = new RezultatPreskok();
                rezultat.Gimnasticar = g;
                rezultatiMap.Add(g.Id, rezultat);
            }

            foreach (Ocena o in ocene)
            {
                if (o.Sprava == Sprava.Preskok && rezultatiMap.ContainsKey(o.Gimnasticar.Id))
                    rezultatiMap[o.Gimnasticar.Id].setOcena(o);
            }

            List<RezultatPreskok> rezultati = new List<RezultatPreskok>(rezultatiMap.Values);
            Rezultati.Clear();
            foreach (RezultatPreskok rez in rezultati)
                Rezultati.Add(rez);

            rankRezultati();
            updateKvalStatus(rezTak.Propozicije);
        }
Example #15
0
 private bool resultsAreEqual(RezultatPreskok r1, RezultatPreskok r2, bool obaPreskoka)
 {
     if (r1 == null || r2 == null)
         return false;
     return (!obaPreskoka && r1.Total == r2.Total && r1.E == r2.E)
             || (obaPreskoka && r1.TotalObeOcene == r2.TotalObeOcene && r1.EObeOcene == r2.EObeOcene);
 }
Example #16
0
        private bool nadjiIstiFinRezultatIzKluba(RezultatPreskok rezultat, List<RezultatPreskok> rezultati, List<bool> porediDrzavu,
            bool obaPreskoka)
        {
            for (int i = 0; i < rezultati.Count; ++i)
            {
                RezultatPreskok r = rezultati[i];
                if (r.KvalStatus != KvalifikacioniStatus.Q || !resultsAreEqual(r, rezultat, obaPreskoka))
                    continue;

                if (porediDrzavu[i])
                {
                    if (r.Gimnasticar.DrzavaUcesnik.Id == rezultat.Gimnasticar.DrzavaUcesnik.Id)
                        return true;
                }
                else
                {
                    if (r.Gimnasticar.KlubUcesnik.Id == rezultat.Gimnasticar.KlubUcesnik.Id)
                        return true;
                }
            }
            return false;
        }
Example #17
0
        public virtual void initRezultati(IList<GimnasticarUcesnik> gimnasticari)
        {
            Rezultati.Clear();
            foreach (GimnasticarUcesnik g in gimnasticari)
            {
                RezultatPreskok r = new RezultatPreskok();
                r.Gimnasticar = g;
                Rezultati.Add(r);
            }

            // posto nepostoje ocene, sledeci poziv samo sortira po prezimenu i na
            // osnovu toga dodeljuje RedBroj
            rankRezultati();
        }