Пример #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            //copy scrape
            resortService = new ResortService(resortRepository);

            IList <Resort> resorts = resortService.GetAll();

            ScrapeResort scrape = new ScrapeResort();

            foreach (Resort resort in resorts)
            {
                scrape = LocationDataManager.GetScrapeResort(resort.Name, resort.CountryName);
                if (!string.IsNullOrEmpty(scrape.Name))
                {
                    UpdateResort(resort, scrape, resortService);
                }
                else
                {
                    //try without accents
                    scrape = LocationDataManager.GetScrapeResort(RemoveAccents(resort.Name), resort.CountryName);
                    if (!string.IsNullOrEmpty(scrape.Name))
                    {
                        UpdateResort(resort, scrape, resortService);
                    }
                }
            }

            label10.Text = "Finished";
        }
Пример #2
0
        private static void UpdateResort(Resort resort, ScrapeResort scrape, ResortService resortService)
        {
            resort.ResortStats.BaseLevel    = scrape.BaseLevel;
            resort.ResortStats.TopLevel     = scrape.TopLevel;
            resort.ResortStats.VerticalDrop = scrape.VerticalDrop;

            resort.ResortStats.LiftTotal          = scrape.LiftTotal;
            resort.ResortStats.QuadPlusCount      = scrape.QuadPlusCount;
            resort.ResortStats.QuadCount          = scrape.QuadCount;
            resort.ResortStats.TripleCount        = scrape.TripleCount;
            resort.ResortStats.DoubleCount        = scrape.DoubleCount;
            resort.ResortStats.SingleCount        = scrape.SingleCount;
            resort.ResortStats.SurfaceCount       = scrape.SurfaceCount;
            resort.ResortStats.GondolaCount       = scrape.GondolaCount;
            resort.ResortStats.FunicularCount     = scrape.FunicularCount;
            resort.ResortStats.SurfaceTrainCount  = scrape.SurfaceTrainCount;
            resort.ResortStats.RunTotal           = scrape.RunTotal;
            resort.ResortStats.RedRuns            = scrape.RedRuns;
            resort.ResortStats.BlueRuns           = scrape.BlueRuns;
            resort.ResortStats.GreenRuns          = scrape.GreenRuns;
            resort.ResortStats.BlackRuns          = scrape.BlackRuns;
            resort.ResortStats.LongestRunDistance = scrape.LongestRunDistance;
            resort.ResortStats.AverageSnowfall    = scrape.AverageSnowfall;
            resort.ResortStats.SnowmakingCoverage = scrape.SnowmakingCoverage;
            resort.ResortStats.SkiableTerrianSize = scrape.SkiableTerrianSize;

            resort.Display = true;

            resortService.Update(resort);
        }
Пример #3
0
        public static ScrapeResort GetScrapeResort(string name, string countryName)
        {
            ScrapeResort scrapeResort = new ScrapeResort();

            //TODO: put all this in a method
//            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQL2005_615410_sporthubConnectionString"].ConnectionString);
            SqlConnection conn = new SqlConnection("Data Source=tcp:esql2k501.discountasp.net;Initial Catalog=SQL2005_615410_sporthub;User ID=SQL2005_615410_sporthub_user;Password=first2009;");
            SqlCommand    cmd  = new SqlCommand("GetScrapeResort", conn);

            cmd.Parameters.Add(new SqlParameter("@Name", name));
            cmd.Parameters.Add(new SqlParameter("@CountryName", countryName));
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da      = new SqlDataAdapter(cmd);
            DataSet        dataSet = new DataSet();

            da.Fill(dataSet);

            //TODO: error handle
            try
            {
                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    scrapeResort = DataConverter.ToType <ScrapeResort>(dataSet.Tables[0].Rows[0]);
                }
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(scrapeResort);
        }