public void Insert_single_and_multiple_with_generic_repository_and_rule_success() { var genericPerson = new MongoRepositoryBase <Person, TestConnection, PersonMapper>(); Person person = new Person("ferhat", "candas", DateTime.Now.AddYears(-15), 2000.52); List <PersonAddress> personAddresses = new List <PersonAddress>() { new PersonAddress("Fatih mah", "a", "Istanbul"), new PersonAddress("Kıvanc mah", "b", "Izmir"), new PersonAddress("Kemaliye mah", "c", "Trabzon"), }; var personDetail = new PersonDetail("*****@*****.**", "905379106194"); person.Addresses = personAddresses; person.PersonDetail = personDetail; genericPerson.Insert(person, x => x.Name == "test" || x.Name == "test2"); var personData = genericPerson.First(x => x.Id == person.Id, x => x.Name == "test" || x.Name == "test2"); personData.Name.Should().Be(person.Name); personData.Surname.Should().Be(person.Surname); personData.BirthDate.ToString("dd MM yyyy HH:mm:ss").Should().Be(person.BirthDate.ToString("dd MM yyyy HH:mm:ss")); personData.Salary.Should().Be(person.Salary); personData.Id.Should().Be(person.PersonDetail.PersonId); personData.PersonDetail.PersonId.Should().Be(person.PersonDetail.PersonId); personData.PersonDetail.Phone.Should().Be(person.PersonDetail.Phone); personData.PersonDetail.Email.Should().Be(person.PersonDetail.Email); personData.Addresses.ForEach(x => { x.PersonId.Should().Be(person.Id); }); }
static void GetLunchPost(Restaurant restaurant) { var repository = new MongoRepositoryBase <LunchDeal>("mongodb://localhost/LunchBox", "LunchDeals"); // IWebDriver browser = new ChromeDriver("C:\\chromeDriver\\"); try { //Firefox's proxy driver executable is in a folder already // on the host system's PATH environment variable. var link = restaurant.link.Split(new[] { ".com" }, StringSplitOptions.None)[1]; link = "https://m.facebook.com" + link + "posts/"; browser.Navigate().GoToUrl(link); var posts = browser.FindElements(By.CssSelector("#pages_msite_body_contents .story_body_container")); foreach (var post in posts) { try { var moreButton = post.FindElement(By.LinkText("More")); moreButton.Click(); } catch (Exception ex) { Console.WriteLine(ex.Message); } IWebElement time = null; IWebElement withoutMoreButton = null; IWebElement imagelocation = null; IWebElement image = null; try { time = post.FindElement(By.CssSelector("[data-sigil=\"m-feed-voice-subtitle\"] abbr")); withoutMoreButton = post.FindElement(By.CssSelector("[data-ad-preview=\"message\"] span")); imagelocation = post.FindElement(By.CssSelector("i.img")); } catch (Exception e) { Console.WriteLine(e); } ReadOnlyCollection <IWebElement> withMoreButtonVisible = null; ReadOnlyCollection <IWebElement> withMoreButtonInvisible = null; ReadOnlyCollection <IWebElement> dealImage = null; try { withMoreButtonVisible = post.FindElements(By.CssSelector( "#pages_msite_body_contents .story_body_container [data-ad-preview=\"message\"] span[data-sigil=\"expose\"] > p")); // withMoreButtonInvisible = post.FindElements(By.CssSelector( // "#pages_msite_body_contents .story_body_container [data-ad-preview=\"message\"] span[data-sigil=\"expose\"] div.text_exposed_show p")); dealImage = post.FindElements(By.CssSelector(".userContentWrapper .uiScaledImageContainer img")); } catch (Exception ex) { } try { if (Regex.IsMatch(time.Text, @"^\d+")) { if (withoutMoreButton.Text.ToLower().Contains("pietus") || withoutMoreButton.Text.ToLower().Contains("pietūs") || withoutMoreButton.Text.ToLower().Contains("pietū") || withoutMoreButton.Text.ToLower().Contains("dienos") || withoutMoreButton.Text.ToLower().Contains("pietu") || withoutMoreButton.Text.ToLower().Contains("pietums") || withoutMoreButton.Text.ToLower().Contains("sriuba")) { string text = withoutMoreButton.Text; if (withMoreButtonVisible != null) { foreach (var p in withMoreButtonVisible) { text = text + p.Text + Environment.NewLine; } } var deal = new LunchDeal(); deal.Description = text; deal.RestaurantId = restaurant.id; deal.id = restaurant.id; deal.time = time.Text; deal.Restaurant = restaurant; try { post.Click(); image = browser.FindElement(By.CssSelector("div[data-full-size-href]")); deal.ImageUrl = image.GetAttribute("data-full-size-href"); } catch (Exception e) { Console.WriteLine(e); } try { repository.UpdateOne(deal); } catch (Exception ex) { Console.WriteLine(ex.Message); repository.Insert(deal); } } } } catch (Exception e) { Console.WriteLine(e); } } } catch (Exception ex) { } // browser.Close(); // browser.Dispose(); Console.WriteLine("Done " + restaurant.name); // browser.Close(); // browser.Dispose(); }
static void Search(string query) { try { var tokken = "EAAFsGfQAdhoBAIf8OpfB1RTFFvORIXHEQxqp16Oo9BciBiN5iXnwQqauDZCg2cZBUSpc2dXZCiBTfVnoKlynI4QgCHrHvlk46rWhDtk8pk2VZBFn5JhmQ9iPvoCXa4F91ZAWXVFZCG8ReZCZAbYZAD9vsjiMCVaobGZB9l1JldQZCz7CA2XyvgZAK3CJSIBFgjmX3FqGhCFZABr4TkgZDZD"; var repository = new MongoRepositoryBase <Restaurant>("mongodb://localhost/LunchBox", "RestaurantsRaw"); var path = "https://graph.facebook.com/v3.1/search?fields=about,app_links,checkins,cover,description,engagement,hours,id,is_permanently_closed,is_verified,link,location,name,overall_star_rating,parking,payment_options,phone,price_range,rating_count,single_line_address,website,picture{height,url,width},photos&q=" + query + "&type=place&limit=999999&access_token=" + tokken; bool searchNext = true; while (searchNext) { var result = GetProductAsync(path).Result; foreach (var restaurant in result.data) { try { try { repository.UpdateOne(restaurant); } catch (Exception ex) { Console.WriteLine(ex.Message); restaurant.location.PointLocation = new GeoJsonPoint <GeoJson2DGeographicCoordinates>( new GeoJson2DGeographicCoordinates(restaurant.location.longitude, restaurant.location.latitude)); repository.Insert(restaurant); } Console.WriteLine("INSERTED: " + restaurant.name); } catch (Exception ex) { Console.WriteLine("FAILED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!: " + restaurant.name); Console.WriteLine(ex.Message); } } try { path = result.paging.next; Console.WriteLine("Search added for " + path); if (result.paging.next.Length > 0) { } else { searchNext = false; } } catch (Exception e) { searchNext = false; } } Console.WriteLine("Done "); } catch (Exception ex) { } }