Esempio n. 1
0
        /// <summary>
        /// Method updates estate objects in database
        /// </summary>
        public void Update()
        {
            connection.Open();
            WebParser parser = new WebParser();

            //try
            //{
            for (int page = 0; page < parser.GetCountPages(); page++)
            {
                for (int estateObject = 0; estateObject < 50; estateObject++)
                {
                    string avitoId    = parser.GetEstateObjectId(estateObject + 1, 1);
                    string sourcePage = parser.GetSourcePage(avitoId);
                    command = new SQLiteCommand("insert into EstateObject (avitoId, dealType, price, locality, address, area, roomNumber, " +
                                                "floor, maxFloor, material, seller, description) values ('" + avitoId + "', " +
                                                "'" + parser.GetDealType(sourcePage) + "', " +
                                                "'" + parser.GetPrice(sourcePage) + "', " +
                                                "'" + parser.GetLocality(sourcePage) + "', " +
                                                "'" + parser.GetAddress(sourcePage) + "', " +
                                                "'" + parser.GetArea(sourcePage) + "', " +
                                                "'" + parser.GetRoomNumber(sourcePage) + "', " +
                                                "'" + parser.GetFloor(sourcePage) + "', " +
                                                "'" + parser.GetMaxFloor(sourcePage) + "', " +
                                                "'" + parser.GetMaterial(sourcePage) + "', " +
                                                "'" + parser.GetSellerName(sourcePage) + "', " +
                                                "'" + parser.GetDescription(sourcePage) + "');", connection);
                    command.ExecuteNonQuery();
                }
            }
            connection.Close();
            //}
            //catch (IndexOutOfRangeException)
            //{
            //    return;
            //}
        }