/// <summary>
        /// Gets all the parks form the SQL Database.
        /// </summary>
        /// <returns>An <see cref="List{T}"/> of <see cref="ParkData"/>.</returns>
        public IList <ParkData> GetParks()
        {
            List <ParkData> parks    = new List <ParkData>();
            string          sqlQuery = "SELECT p.*, COALESCE(s.cnt, 0) AS SurveyCount " +
                                       "FROM park AS p " +
                                       "LEFT JOIN (SELECT parkCode, COUNT(parkCode) AS cnt " +
                                       "FROM survey_result " +
                                       "GROUP BY parkCode" +
                                       ") AS s ON p.parkCode = s.parkCode " +
                                       "ORDER BY p.parkCode;";

            try
            {
                using (SqlConnection conn = new SqlConnection(this.connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(sqlQuery, conn);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        ParkData park = this.ConvertSqlToPark(reader);
                        parks.Add(park);
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }

            return(parks);
        }
Beispiel #2
0
        private void GeneratePark(ParkData[] parks)
        {
            for (int i = 1; i < 5; i++)
            {
                string name = "";
                switch (i)
                {
                case 1:
                    name = "Backyard";
                    break;

                case 2:
                    name = "Boneyard";
                    break;

                case 3:
                    name = "Junkyard";
                    break;

                case 4:
                    name = "Rockyard";
                    break;

                default:
                    throw new System.ArgumentException("No name for Park[" + i + "]", "original");;
                }
                Locations[i] = new ParkData(name, i);
            }
        }
        /// <summary>
        /// Gets a Single park from the SQL Database via the park code.
        /// </summary>
        /// <param name="code">The park's unique code.</param>
        /// <returns>a <see cref="ParkData"/> model.</returns>
        public ParkData GetPark(string code)
        {
            ParkData park     = new ParkData();
            string   sqlQuery = "SELECT p.*, COALESCE(s.cnt, 0) AS SurveyCount " +
                                "FROM park AS p LEFT JOIN (SELECT parkCode, COUNT(parkCode) AS cnt " +
                                "FROM survey_result " +
                                "GROUP BY parkCode" +
                                ") AS s ON p.parkCode = s.parkCode " +
                                "WHERE p.parkCode = @parkCode " +
                                "ORDER BY p.parkCode;";

            try
            {
                using (SqlConnection conn = new SqlConnection(this.connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(sqlQuery, conn);
                    cmd.Parameters.AddWithValue("@parkCode", code);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        park = this.ConvertSqlToPark(reader);
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }

            return(park);
        }
Beispiel #4
0
 public ParkManager(Random RNG, int players)
 {
     Locations = new ParkData[6];
     GeneratePark(Locations);
     Locations[0] = new ParkData("Lab", 0);
     Locations[5] = new ParkData("Arena", 0);
     AddParts(RNG, players);
 }
Beispiel #5
0
        public string[] Execute(VehiclePark vehiclePark)
        {
            var layout = new ParkLayout(Int32.Parse(_parameters["sectors"]), Int32.Parse(_parameters["placesPerSector"]));
            var data   = new ParkData(Int32.Parse(_parameters["sectors"]));

            vehiclePark.VehicleParkCreated = true;
            vehiclePark.Layout             = layout;
            vehiclePark.Data = data;

            return(new[] { "Vehicle park created" });
        }
Beispiel #6
0
        public IActionResult DailySurvey()
        {
            if (this.Request.Cookies["SurveyComplete"] != null)
            {
                return(this.RedirectToAction("FavoriteParks"));
            }

            ParkData         park  = new ParkData();
            IList <ParkData> parks = this.parkDAO.GetParks();

            this.ViewData["ParkList"] = parks;
            return(this.View());
        }
        public IActionResult Detail(string code)
        {
            ParkData             park       = this.parkDAO.GetPark(code);
            string               advisories = string.Empty;
            IList <DailyWeather> forecast   = this.weatherDAO.GetWeather(code);

            if (forecast[0].Forecast == "snow")
            {
                advisories += "Snow advisory. Pack snowshoes. ";
            }

            if (forecast[0].Forecast == "rain" || forecast[0].Forecast == "thunderstorms")
            {
                advisories += "Rain advisory. Pack rain gear and wear waterproof shoes. ";
            }

            if (forecast[0].Forecast == "thunderstorms")
            {
                advisories += "Thunderstorm advisory. Seek shelter and avoid hiking on exposed ridges. ";
            }

            if (forecast[0].Forecast == "sunny")
            {
                advisories += "Weather advisory. Pack sunblock. ";
            }

            if (forecast[0].HiTemp > 75)
            {
                advisories += "Heat advisory. Bring an extra gallon of water. ";
            }

            if (forecast[0].HiTemp - forecast[0].LowTemp > 20)
            {
                advisories += "Temperature differential advisory.  Wear breathable layers. ";
            }

            if (forecast[0].LowTemp < 20)
            {
                advisories += "Cold advisory. Beware of exposure to frigid temperatures. ";
            }

            ParkDetailViewModel model = new ParkDetailViewModel
            {
                Park              = park,
                Forecast          = forecast,
                WeatherAdvisories = advisories
            };

            return(this.View(model));
        }
Beispiel #8
0
        private ParkData getPark(dynamic json, string parkName)
        {
            for (int i = 1; i < json.Count; i++)//0 is timestamp
            {
                if (json[i].Nome.ToString().Equals(parkName))
                {
                    ParkData park = new ParkData(mapping[parkName], true);
                    park.Capacidade = int.Parse(json[i].Capacidade.ToString());
                    park.Ocupado    = int.Parse(json[i].Ocupado.ToString());
                    park.Livre      = int.Parse(json[i].Livre.ToString());
                    return(park);
                }
            }

            return(new ParkData(parkName, false));
        }
Beispiel #9
0
        private List <ParkData> getAllPark(dynamic json)
        {
            List <ParkData> list = new List <ParkData>();

            for (int i = 1; i < json.Count; i++)
            {//0 is timestamp
                if (!invalidParks.Contains(json[i].Nome.ToString()))
                {
                    ParkData park = new ParkData(mapping[json[i].Nome.ToString()], true);
                    park.Capacidade = int.Parse(json[i].Capacidade.ToString());
                    park.Ocupado    = int.Parse(json[i].Ocupado.ToString());
                    park.Livre      = int.Parse(json[i].Livre.ToString());
                    list.Add(park);
                }
            }

            return(list);
        }
Beispiel #10
0
        public void manageDialogueSAS(ParkData park, string[] args)
        {
            string phrase = "";

            if (park.Found)
            {
                switch (args[1])
                {
                case ("SUBTYPE1"):
                case ("SUBTYPE2"):
                    if (park.Livre > 0)
                    {
                        phrase = answers.getParkIsFree(park);
                    }
                    else
                    {
                        phrase = answers.getParkIsNotFree(park);
                    }

                    break;

                case ("SUBTYPE3"):
                    if (park.Livre > 0)
                    {
                        phrase = answers.getParkFreeSpots(park);
                    }
                    else
                    {
                        phrase = answers.getParkNoFreeSpots(park);
                    }

                    break;
                }
            }
            else
            {
                phrase = answers.getParkNotFound(park.Nome);
            }


            t.Speak(phrase);
        }
        private bool addParkName(string name)
        {
            ParkData pd      = _data.currentPark;
            bool     success = false;

            if (name != "Unnamed Park" &&
                (pd.names.Count == 0 || pd.names[pd.names.Count - 1] != name))
            {
                Debug.LogMT("New park name " + name);
                pd.names.Add(name);
                if (_settings.updateParkSessionData)
                {
                    pd.sessions[pd.sessionIdx].names.Add(name);
                }
                success = true;
            }
            else
            {
                Debug.LogMT("No new park name");
            }
            return(success);
        }
Beispiel #12
0
        private void handleResponse(string response, string[] args)
        {
            dynamic json = JsonConvert.DeserializeObject(response);

            //Console.WriteLine(json.ToString());
            switch (args[0])
            {
            case "TYPE1":
            case "TYPE3":
                dManager.manageDialogueSAS(getAllPark(json), args);
                dManager.displayParks(getAllPark(json));
                break;

            case "TYPE2":
                ParkData park = getPark(json, args[2]);
                dManager.displayParks(new List <ParkData>(1)
                {
                    park
                });
                dManager.manageDialogueSAS(park, args);
                break;
            }
        }
        /// <summary>
        /// Converts the reader data into a <see cref="ParkData"/> model.
        /// </summary>
        /// <param name="reader">A <see cref="SqlDataReader"/></param>
        /// <returns>A <see cref="ParkData"/> model.</returns>
        private ParkData ConvertSqlToPark(SqlDataReader reader)
        {
            ParkData park = new ParkData
            {
                Name               = Convert.ToString(reader["parkName"]),
                Code               = Convert.ToString(reader["parkCode"]),
                State              = Convert.ToString(reader["state"]),
                Climate            = Convert.ToString(reader["climate"]),
                Campsites          = Convert.ToInt32(reader["numberOfCampsites"]),
                Acreage            = Convert.ToInt32(reader["acreage"]),
                AnnualVisitorCount = Convert.ToInt32(reader["annualVisitorCount"]),
                Description        = Convert.ToString(reader["parkDescription"]),
                Elevation          = Convert.ToInt32(reader["elevationInFeet"]),
                EntryFee           = Convert.ToDecimal(reader["entryFee"]),
                TrailMiles         = Convert.ToInt32(reader["milesOfTrail"]),
                YearFounded        = Convert.ToInt32(reader["yearFounded"]),
                Quote              = Convert.ToString(reader["inspirationalQuote"]),
                QuoteAuthor        = Convert.ToString(reader["inspirationalQuoteSource"]),
                NumSpecies         = Convert.ToInt32(reader["numberOfAnimalSpecies"]),
                SurveyCount        = Convert.ToInt32(reader["SurveyCount"])
            };

            return(park);
        }
Beispiel #14
0
 public string getParkNoFreeSpots(ParkData park)
 {
     return(parkNoFreeSpots[random.Next(0, parkNoFreeSpots.Length)].Replace("<NOME_PARQUE_ESTACIONAMENTO>", park.Nome));
 }
Beispiel #15
0
 public string getParkFreeSpots(ParkData park)
 {
     return(parkFreeSpots[random.Next(0, parkFreeSpots.Length)].Replace("<NOME_PARQUE_ESTACIONAMENTO>", park.Nome).Replace("<NUM_LIVRES>", park.Livre.ToString()));
 }
Beispiel #16
0
 public string getParkIsNotFree(ParkData park)
 {
     return(parkIsNotFree[random.Next(0, parkIsNotFree.Length)].Replace("<NOME_PARQUE_ESTACIONAMENTO>", park.Nome));
 }