public static void SetMap(AirBnbRoomMap map, StreamlinePropertyCollection collection) { var index = collection.CreateIndex(); list = new List <PropertyInfo>(); foreach (var airbnbAccount in map.List) { foreach (var room in airbnbAccount.Rooms) { var streamlineInfo = index.GetByAirBnbName(room.RoomTitle); if (streamlineInfo == null) { N.Note("Can't fine property in Streamline data by AirBnb title " + room.RoomTitle); continue; } var propertyInfo = new PropertyInfo { AirbnbAccountEmail = airbnbAccount.AccountEmail, AirbnbID = room.RoomID, AirbnbTitle = room.RoomTitle, SenStayID = streamlineInfo.SenStayID, StreamlineEditID = streamlineInfo.StreamlineEditID }; list.Add(propertyInfo); } } }
public static void LoadSenStay() { var StreamlinePropertyList = StreamlinePropertyCollection.Load(); if (StreamlinePropertyList == null) { throw new Exception("Streamline codes are not parsed yet"); } Indexes.SenStay = StreamlinePropertyList.CreateIndex(); }
public static void ParseFolder(string Path) { var seasons = StreamlineSeasonGroup.Load(); var streamlineCollection = StreamlinePropertyCollection.Load(); var units = streamlineCollection.CreateIndex(); var map = new PriceMap(); var files = Temp.GetFileList(@"*.csv", Path); foreach (var file in files) { ProcessSourceFile(file, units, seasons, map); } CreatePriceScripts(map, units, seasons); var airbnbRooms = AirBnbRoomMap.Load(); PropertyMap.SetMap(airbnbRooms, streamlineCollection); CreateAirbnbNY022(map, airbnbRooms); }
static void Main(string[] args) { Console.WriteLine("Pricing sync for AirBnb"); Config.I.UseProxy = true; AirBnbAccounts.Load(); var roomsMap = AirBnbRoomMap.Load(); var streamlineCollection = StreamlinePropertyCollection.Load(); PropertyMap.SetMap(roomsMap, streamlineCollection); var property = PropertyMap.GetBySenstayID("LA029"); var proxyNum = 0; var airAccount = AirBnbAccounts.GetAccountByEmail(property.AirbnbAccountEmail); var email = airAccount.Email; N.Note("Processing account " + email + " with proxy " + airAccount.ProxyAddress[proxyNum]); var profile = SeleniumProxy.GetFirefoxProfileWithProxy(airAccount.ProxyAddress, proxyNum); using (var driver = SeleniumFactory.GetFirefoxDriver(profile)) { var signInSucceed = AirBnbLogin.Process(driver, airAccount); if (signInSucceed.Status != AirBnbLoginStatus.Sucess) { N.Note("Password for " + email + " is wrong or account unreachable"); try { driver.Quit(); } catch { // ignored } } AirBnbCalendar.SetPricesForUnit(driver, property, AirbnbUnitDailyPriceList.Load()); } }
public static void Process(IWebDriver driver, bool grabAdditionalInfo) { var URL = @"https://www.resortpro.net/new/admin/index.html"; driver.GoTo(URL); var wait = driver.CreateWaitDriver(); //<div id="dock-container" var dockContainerElement = driver.FindElement(By.Id("dock-container")); //<a href="javascript:YAHOO.frontdesk.UpdateContentCached('menu_configuration.html', 'dedicated=1')" var configurationLinkElement = dockContainerElement.FindAByHrefStartsWith("javascript:YAHOO.frontdesk.UpdateContentCached('menu_configuration.html',"); configurationLinkElement.Click(); driver.JustWait(1); //<div id="menuExpandedContainer"> var menuExpandedContainerElement = driver.FindElement(By.Id("menuExpandedContainer")); //<a href="javascript:YAHOO.frontdesk.UpdateContent('general_homes.html', 'lodging_type_id=3&status_id=2');">Vacation Rentals (170)</a> var vacationRentalsElement = menuExpandedContainerElement.FindAByHrefStartsWith("javascript:YAHOO.frontdesk.UpdateContent('general_homes.html',"); vacationRentalsElement.Click(); driver.JustWait(5); //<select id="status_id" style="width:100px;" size="1" name="status_id"> // set type to AirBnb var statusIdElement = new SelectElement(driver.FindElement(By.Id("status_id"))); // 80 is AirBnb's magic number //<option value="0">Any Status</option> statusIdElement.SelectByValue("0"); driver.JustWait(1); //<form id="table_navigation_form" action="javascript:YAHOO.frontdesk.table_navigation_function();" method="get"> var navFormElement = driver.FindElement(By.Id("table_navigation_form")); //<input type="submit" value="GO" name="ss"> // Can be passed var goButtonElement = navFormElement.FindElement(By.CssSelector("[value=\"GO\"]")); goButtonElement.Click(); driver.JustWait(4); //<input type="button" onclick="javascript:table_pager_submit('table_navigation_form', 1, 1, '');" value="Show All" name="button_view_all"> var showAllInputElement = driver.FindElement(By.CssSelector("[name=\"button_view_all\"]")); //var showAllInputElement = navFormElement.FindTagByAttributeStartsWith("input", "onclick", "javascript:table_pager_submit('table_navigation_form',"); showAllInputElement.Click(); driver.JustWait(10); driver.FindElement(By.Id("frontdesk_content")); var basetableElement = driver.FindElement(By.CssSelector(".basetable.fixedHeader")); var trs = basetableElement.FindElements(By.TagName("tr")); var i = 0; var items = new Collection <StreamlinePropertyInfo>(); foreach (var tr in trs) { //if (i++ == 0) continue; var propertyItem = new StreamlinePropertyInfo(); var editLinkElement = tr.FindTagByAttributeStartsWith("a", "onclick", "javascript:HomeEdit("); if (editLinkElement == null) { //Console.WriteLine("ERROR"); continue; } i++; var hrefAttr = editLinkElement.GetAttribute("onclick"); var streamlineEditId = hrefAttr.ExtractNumber(); propertyItem.StreamlineEditID = streamlineEditId; items.Add(propertyItem); Console.WriteLine("Property #" + i); } var updated = new StreamlinePropertyCollection(); i = 0; foreach (var item in items) { if (item.StreamlineEditID <= 0) { continue; } i++; var numTrys = 0; loopMark: try { var propertyScraper = new PropertyScraper(driver); propertyScraper.Scrap(item, grabAdditionalInfo); updated.Add(item); } catch { if (numTrys++ < 3) { Console.WriteLine("Retry #" + numTrys + " " + item.StreamlineEditID + " " + i); goto loopMark; } } } updated.Save(); Console.Write(Config.I.PropertyCollectionJsonPath + " saved at " + updated.DateCreated); var Json = updated.ToJson(); Console.Write(Json); }