예제 #1
0
        //insert schools in db

        public static void insertParsedApartment(ApartmentData apartmentData)
        {
            insertParsedSchools(apartmentData.schoolsList);
            insertParsedReviews(apartmentData.reviewsList);
            insertParsedNTPI(apartmentData.NTPIList);
            insertParsedExpenseType(apartmentData.expensesTypeList);
            insertParsedApartmentList(apartmentData.apartmentsList);
            insertParsedPropertyAmenities(apartmentData.amenityTypesList);
        }
예제 #2
0
        static void Main(string[] args)
        {
            //do dapper entitiy mapping to map objects to DB tables
            DapperPlusManager.Entity <URL>().Table("url").Identity(x => x.id);
            DapperPlusManager.Entity <Property>().Table("property").Identity(x => x.id);
            DapperPlusManager.Entity <PropertyType>().Table("propertytype").Identity(x => x.id);

            URL myUrl;//URL to be parsed

            //get url from url helper and do basic null checks
            while ((myUrl = URLHelper.getNextURL()) != null && myUrl.url != null && myUrl.url.Length > 0)
            {
                Console.WriteLine("Parsing URL {0}", myUrl.url);                  //print the current url
                try{
                    var response = client.GetAsync(myUrl.url).Result;             //make an HTTP call and get the html for this URL

                    string content = response.Content.ReadAsStringAsync().Result; //save HTML into string

                    if (myUrl.urltype == (int)URL.URLType.PROPERTY_URL)
                    {
                        //if the url is of property type, instantiate property parser
                        PropertyParser parser = new PropertyParser(content, myUrl);

                        //parse the html
                        PropertyData propData = parser.parse();

                        //insert into DB
                        DBHelper.insertParsedProperties(propData);

                        Console.WriteLine("Stored {0} properties",
                                          (propData != null && propData.urlList != null)?propData.urlList.Count:0);
                    }
                    else if (myUrl.urltype == (int)URL.URLType.APARTMENT_URL)
                    {
                        //if the url is of apartment type, instantiate apartment parser
                        ApartmentParser parser = new ApartmentParser(content, myUrl);

                        //call the parse method
                        ApartmentData apartmentData = parser.parse();

                        DBHelper.insertParsedApartment(apartmentData);

                        Console.WriteLine("Stored data for property id {0}!", myUrl.property);
                    }
                    else
                    {
                        Console.WriteLine("Unknown URL Type");
                    }
                    DBHelper.markURLDone(myUrl);//update the status of URL as done in DB
                }
                catch (Exception e) {
                    ExceptionHelper.printException(e);
                }
            }
        }
예제 #3
0
        public static async void Enter(int id)
        {/*
          * CurrentData = await GetAllData(id);
          * if (CurrentData.id == 0)
          * {
          *     Notification.SendWithTime("~r~Ошибка загрузки квартиры #1");
          *     return;
          * }
          *
          * int i = CurrentData.interior_id;
          * User.Teleport(CurrentData.is_exterior
          *     ? new Vector3((float) IntList[i, 0], (float) IntList[i, 1], (float) IntList[i, 2])
          *     : new Vector3((float) House.HouseInts[i, 0], (float) House.HouseInts[i, 1],
          *         (float) House.HouseInts[i, 2]));
          *
          * User.SetVirtualWorld(CurrentData.id * -1);*/
            CurrentData = await GetAllData(id);

            var userId = User.Data.id;

            if ((int)await Client.Sync.Data.Get(-100000 + CurrentData.id, "pin") > 0 && CurrentData.user_id != userId)
            {
                if (User.IsAdmin(4))
                {
                    Notification.SendWithTime($"~g~Пароль: ~s~{(int) await Client.Sync.Data.Get(-100000 + CurrentData.id, "pin")}");
                }

                int pass = Convert.ToInt32(await Menu.GetUserInput("Пароль", null, 5));
                if (pass == (int)await Client.Sync.Data.Get(-100000 + CurrentData.id, "pin"))
                {
                    int i = CurrentData.interior_id;
                    User.Teleport(CurrentData.is_exterior
                        ? new Vector3((float)IntList[i, 0], (float)IntList[i, 1], (float)IntList[i, 2])
                        : new Vector3((float)House.HouseInts[i, 0], (float)House.HouseInts[i, 1],
                                      (float)House.HouseInts[i, 2]));

                    User.SetVirtualWorld(CurrentData.id * -1);
                }
                else
                {
                    Notification.SendWithTime("~r~Вы не верно ввели пароль");
                }
            }
            else
            {
                int i = CurrentData.interior_id;
                User.Teleport(CurrentData.is_exterior
                    ? new Vector3((float)IntList[i, 0], (float)IntList[i, 1], (float)IntList[i, 2])
                    : new Vector3((float)House.HouseInts[i, 0], (float)House.HouseInts[i, 1],
                                  (float)House.HouseInts[i, 2]));

                User.SetVirtualWorld(CurrentData.id * -1);
            }
        }
예제 #4
0
 public void UpdateEnergyUse(ApartmentData data, string newUse)
 {
     foreach (ApartmentButton aptb in aptButtons)
     {
         if (aptb.data == data)
         {
             aptb.UpdateEnergyUse(newUse);
             if (aptb == selectedApartment)
             {
                 UpdateInfoPanel(selectedApartment);
             }
         }
     }
 }
예제 #5
0
        public static async void Exit()
        {
            CurrentData = await GetAllData(User.GetPlayerVirtualWorld() * -1);

            if (CurrentData.id == 0)
            {
                Notification.SendWithTime("~r~Ошибка загрузки квартиры #2");
                return;
            }
            int i = CurrentData.build_id;

            User.Teleport(new Vector3((float)BuildList[i, 0], (float)BuildList[i, 1], (float)BuildList[i, 2]));
            User.SetVirtualWorld(0);
        }
예제 #6
0
        public ApartmentData parse()
        {
            ApartmentData apartmentData = new ApartmentData();

            apartmentData.apartmentsList   = getApartments(getHtmlNodeApartments());
            apartmentData.expensesTypeList = getExpenses(getHtmlNodeExpenses());

            apartmentData.description = getDescription(getHtmlNodeDescription());
            apartmentData.soundScore  = getSoundScore(getHtmlNodeSoundScore());

            apartmentData.reviewsList = getReviews(getHtmlNodeReviews());
            apartmentData.schoolsList = getSchools(getHtmlNodeSchools());
            apartmentData.NTPIList    = getNTPI(getHtmlNodeNTPI());
            return(apartmentData);
        }
예제 #7
0
 public void FlashWarning(ApartmentData data, bool flash)
 {
     foreach (ApartmentButton aptb in aptButtons)
     {
         if (aptb.data == data)
         {
             if (flash)
             {
                 aptb.animator.SetTrigger("red");
             }
             else
             {
                 aptb.animator.SetTrigger("green");
             }
         }
     }
 }
예제 #8
0
 public void EmptyApartment(ApartmentData data, bool evict)
 {
     foreach (ApartmentButton aptb in aptButtons)
     {
         if (aptb.data == data)
         {
             if (evict)
             {
                 aptb.animator.SetTrigger("empty");
                 aptb.EmptyApartment();
                 UpdateInfoPanel(aptb);
             }
             else
             {
                 aptb.animator.SetTrigger("green");
             }
         }
     }
 }
예제 #9
0
        public static async Task <ApartmentData> GetAllData(int id)
        {
            var data = await Client.Sync.Data.GetAll(-100000 + id);

            if (data == null)
            {
                return(new ApartmentData());
            }

            var bData     = new ApartmentData();
            var localData = (IDictionary <String, Object>)data;

            foreach (var property in typeof(ApartmentData).GetProperties())
            {
                property.SetValue(bData, localData[property.Name], null);
            }

            return(bData);
        }
        public void processAndSaveApartmentsFromPropertyPage(WebScraperModularized.data.Message propertyMessage)
        {
            URL myUrl = new URL();

            myUrl.url      = propertyMessage.url;
            myUrl.property = propertyMessage.id;

            var response = client.GetAsync(myUrl.url).Result;             //make an HTTP call and get the html for this URL

            string content = response.Content.ReadAsStringAsync().Result; //save HTML into string

            ApartmentParser parser = new ApartmentParser(content, myUrl);

            //call the parse method
            ApartmentData apartmentData = parser.parse();

            DBHelper.insertParsedApartment(apartmentData);

            Console.WriteLine("Stored data for property id {0}!", myUrl.property);
        }
예제 #11
0
        public static async void MenuExit()
        {
            var vw = User.GetPlayerVirtualWorld();

            if (vw >= 0)
            {
                return;
            }

            bool isFind = false;

            for (int i = 0; i < IntList.Length / 3; i++)
            {
                var pos = new Vector3((float)IntList[i, 0], (float)IntList[i, 1], (float)IntList[i, 2]);
                if (Main.GetDistanceToSquared(pos, GetEntityCoords(GetPlayerPed(-1), true)) > 2)
                {
                    continue;
                }
                isFind = true;
            }
            for (int i = 0; i < House.HouseInts.Length / 3; i++)
            {
                var pos = new Vector3((float)House.HouseInts[i, 0], (float)House.HouseInts[i, 1], (float)House.HouseInts[i, 2]);
                if (Main.GetDistanceToSquared(pos, GetEntityCoords(GetPlayerPed(-1), true)) > 2)
                {
                    continue;
                }
                isFind = true;
            }

            if (!isFind)
            {
                return;
            }
            CurrentData = await GetAllData(vw * -1);

            MenuList.ShowApartamentMenu(CurrentData);
        }
예제 #12
0
 public static void insertParsedApartment(ApartmentData apartmentData)
 {
     //TODO
 }