Exemplo n.º 1
0
        /// <summary>
        /// Zoekt vrije sectors waar de tram (qua lengte) op kan staan
        /// </summary>
        /// <param name="spoor">spoor waarin sectoren gezocht moeten worden</param>
        /// <param name="tram">tram die geplaatst moet worden</param>
        /// <returns></returns>
        private List <Sector> vrijeSectoren(Spoor spoor, Tram tram, int beginsectornummer, bool reverse)
        {
            List <Sector> spoorSectors = RemiseManager.sectorenVanSpoor(spoor.Id);
            List <Sector> sectors      = new List <Sector>();

            if (reverse)
            {
                spoorSectors.Reverse();          // Reverse list, zodat de tram eerst op de achterste sectoren v/h spoor komt te staan
            }
            foreach (Sector s in spoorSectors)
            {
                if (s.Blokkade)
                {
                    sectors.Clear();
                }
                if (sectors.Count < tram.lengte)
                {
                    if (s.Beschikbaar && !s.Blokkade && s.Tram == null && s.Nummer >= beginsectornummer)
                    {
                        sectors.Add(s);
                    }
                    else
                    {
                        sectors.Clear();
                    }
                }
            }

            return(sectors);
        }
Exemplo n.º 2
0
        public static List <Spoor> LaadSporen()
        {
            List <Spoor> sporen = new List <Spoor>();

            try
            {
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                OracleCommand command = new OracleCommand("SELECT * FROM SPOOR");
                command.CommandType = CommandType.Text;
                command.Connection  = connection;

                OracleDataReader reader = command.ExecuteReader();

                if (!reader.HasRows)
                {
                    return(sporen);
                }
                else
                {
                    while (reader.Read())
                    {
                        int    id            = Convert.ToInt32(reader["ID"]);
                        Remise remise        = RemiseManager.remiseViaId(Convert.ToInt32(reader["Remise_ID"]));
                        int    nummer        = Convert.ToInt32(reader["Nummer"]);
                        int    lengte        = Convert.ToInt32(reader["Lengte"]);
                        bool   beschikbaar   = convertBool(Convert.ToString(reader["Beschikbaar"]));
                        bool   inUitrijSpoor = convertBool(Convert.ToString(reader["InUitRijspoor"]));

                        sporen.Add(new Spoor(id, remise, nummer, lengte, beschikbaar, inUitrijSpoor, RemiseManager.sectorenVanSpoor(id)));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
            return(sporen);
        }