public void ShouldReturnContactsTransactionsInventoryItemsForMatchAll() { var faker = _searchHelper.GetSaleInvoiceFaker(); var invoiceDetail = faker.Generate(); var response = new InvoiceProxy().InsertInvoice(invoiceDetail); Assert.True(response != null && response.IsSuccessfull); _searchHelper.CreatSaleInventoryItem(invoiceDetail.Summary); _searchHelper.CreateContact(companyName: invoiceDetail.Summary); Thread.Sleep(5000); // Need to wait for entities to be indexed var searchProxy = new SearchProxy(); var results = searchProxy.Search("*:*", SearchScope.All, 1, 25); Assert.NotNull(results); Assert.NotNull(results.DataObject); Assert.True(results.DataObject.InventoryItems.Count > 0, "No inventory items returned."); Assert.True(results.DataObject.Contacts.Count > 0, "No contacts returned."); Assert.True(results.DataObject.InventoryItems.Count > 0, "No inventory items returned."); Assert.True(results.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0."); Assert.True(results.DataObject.TotalContactsFound > 0, "transaction count is 0."); Assert.True(results.DataObject.TotalTransactionsFound > 0, "transaction count is 0."); }
public void IndexedContactShouldMatchEntityData() { var searchProxy = new SearchProxy(); var contactHelper = new ContactHelper(); var contactResponse = contactHelper.AddContact(); Thread.Sleep(2000); var contact = new ContactProxy().GetContact(contactResponse.InsertedContactId).DataObject; var searchResults = searchProxy.Search(contact.EmailAddress, SearchScope.Contacts, 1, 10); Assert.IsNotNull(searchResults.DataObject); Assert.IsTrue(searchResults.DataObject.Contacts.Count > 0); var indexedContact = searchResults.DataObject.Contacts.First(x => ReplaceEm(x.ContactEmail) == contact.EmailAddress); Assert.IsNotNull(indexedContact); Assert.AreEqual(contact.GivenName + " " + contact.FamilyName, ReplaceEm(indexedContact.Name)); Assert.AreEqual(contact.MobilePhone, indexedContact.MobilePhone); Assert.AreEqual(contact.PrimaryPhone, indexedContact.MainPhone); Assert.AreEqual(contact.Id, indexedContact.Id); Assert.AreEqual("Contact", indexedContact.EntityType); Assert.AreEqual(contact.CompanyId ?? 0, indexedContact.CompanyId); Assert.AreEqual(contact.TwitterId, indexedContact.TwitterId); }
public void IndexedContactShouldMatchEntityData() { var contactInfo = _searchHelper.CreateContact(); Thread.Sleep(5000); // Need to wait for entities to be indexed var searchProxy = new SearchProxy(); var contact = new ContactProxy().GetContact(contactInfo.ContactId).DataObject; var searchResults = searchProxy.Search(contact.EmailAddress, SearchScope.Contacts, 1, 10); Assert.NotNull(searchResults.DataObject); Assert.True(searchResults.DataObject.Contacts.Count > 0); var indexedContact = searchResults.DataObject.Contacts.First(x => ReplaceEm(x.ContactEmail) == contact.EmailAddress); Assert.NotNull(indexedContact); Assert.Equal(contact.GivenName + " " + contact.FamilyName, ReplaceEm(indexedContact.Name)); Assert.Equal(contact.MobilePhone, indexedContact.MobilePhone); Assert.Equal(contact.PrimaryPhone, indexedContact.MainPhone); Assert.Equal(contact.Id, indexedContact.Id); Assert.Equal("Contact", indexedContact.EntityType); Assert.Equal(contact.CompanyId ?? 0, indexedContact.CompanyId); Assert.Equal(contact.TwitterId, indexedContact.TwitterId); }
public void IndexedInventoryItemShouldMatchEntityData() { var searchProxy = new SearchProxy(); var itemInfo = _searchHelper.CreatSaleInventoryItem(); Thread.Sleep(5000); var searchResults = searchProxy.Search(itemInfo.ItemDetail.Code, SearchScope.InventoryItems, 1, 10); Assert.NotNull(searchResults.DataObject); Assert.True(searchResults.DataObject.InventoryItems.Count > 0); var indexedInventoryItem = searchResults.DataObject.InventoryItems.First(x => ReplaceEm(x.Code) == itemInfo.ItemDetail.Code); Assert.NotNull(indexedInventoryItem); Assert.Equal(itemInfo.ItemDetail.BuyingPrice, indexedInventoryItem.BuyingPrice); Assert.Equal(itemInfo.ItemDetail.Description, ReplaceEm(indexedInventoryItem.Description)); Assert.Equal(itemInfo.ItemDetail.Type, indexedInventoryItem.Type); Assert.Equal("Item", indexedInventoryItem.EntityType); Assert.Equal(itemInfo.ItemId, indexedInventoryItem.Id); Assert.Equal(itemInfo.ItemDetail.SellingPrice, indexedInventoryItem.SellingPrice); Assert.Equal(itemInfo.ItemDetail.StockOnHand.HasValue ? itemInfo.ItemDetail.StockOnHand : 0M, indexedInventoryItem.StockOnHand); Assert.Equal(itemInfo.ItemDetail.PrimarySupplierItemCode, indexedInventoryItem.SupplierItemCode); }
public void ShouldReturnInventoryItemsForScopedSearch() { var itemInfo = _searchHelper.CreatSaleInventoryItem(); Thread.Sleep(5000); var searchProxy = new SearchProxy(); var result1 = searchProxy.Search(itemInfo.ItemDetail.Description, SearchScope.InventoryItems, 1, 25); Assert.NotNull(result1); Assert.NotNull(result1.DataObject); Assert.True(result1.DataObject.InventoryItems.Count > 0, "No inventory items returned."); Assert.True(result1.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0."); Assert.True(result1.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts"); Assert.True(result1.DataObject.TotalContactsFound == 0, "Should not return contacts for search scoped to Contacts"); Assert.Contains(result1.DataObject.InventoryItems, i => i.Id == itemInfo.ItemId); var result2 = searchProxy.Search(itemInfo.ItemDetail.Code, SearchScope.InventoryItems, 1, 25); Assert.NotNull(result2); Assert.NotNull(result2.DataObject); Assert.True(result2.DataObject.InventoryItems.Count > 0, "No inventory items returned."); Assert.True(result2.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0."); Assert.Contains(result2.DataObject.InventoryItems, i => i.Id == itemInfo.ItemId); var result3 = searchProxy.Search(itemInfo.ItemDetail.Code, SearchScope.InventoryItems, 1, 25); Assert.NotNull(result3); Assert.NotNull(result3.DataObject); Assert.True(result3.DataObject.InventoryItems.Count > 0, "No inventory items returned."); Assert.True(result3.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0."); Assert.Contains(result3.DataObject.InventoryItems, i => i.Id == itemInfo.ItemId); }
// TODO: Implement lazy load pattern so each instance creation doesn't create every object instance for no reason")] public TMDbClient(ITMDbSettings settings) : base(settings.BaseUrl) { if (settings.ApiKey.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(settings.ApiKey)); } Settings = settings; Account = new AccountProxy(this); Authentication = new AuthenticationProxy(this); Certifications = new CertificationsProxy(this); Changes = new ChangesProxy(this); Collections = new CollectionsProxy(this); Configuration = new ConfigurationProxy(this); Credits = new CreditsProxy(this); Discover = new DiscoverProxy(this); Exports = new ExportsProxy(this); Find = new FindProxy(this); Genres = new GenresProxy(this); GuestSessions = new GuestSessionsProxy(this); Keywords = new KeywordsProxy(this); Lists = new ListsProxy(this); Movies = new MoviesProxy(this); Network = new NetworkProxy(this); People = new PeopleProxy(this); Reviews = new ReviewsProxy(this); Search = new SearchProxy(this); Trending = new TrendingProxy(this); TVEpisodeGroups = new TVEpisodeGroupsProxy(this); TVEpisodes = new TVEpisodesProxy(this); TV = new TVProxy(this); TVSeasons = new TVSeasonsProxy(this); }
public void ShouldReturnContactsForScopedSearch() { var createdContactInfo = _searchHelper.CreateContact(); Thread.Sleep(5000); // Need to wait for entities to be indexed var searchProxy = new SearchProxy(); var results1 = searchProxy.Search($"{createdContactInfo.ContactDetail.GivenName} {createdContactInfo.ContactDetail.FamilyName}", SearchScope.Contacts, 1, 25); Assert.NotNull(results1); Assert.True(results1.DataObject.Contacts.Count > 0, "No contacts returned."); Assert.True(results1.DataObject.TotalContactsFound > 0, "transaction count is 0."); Assert.True(results1.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts"); Assert.True(results1.DataObject.TotalInventoryItemsFound == 0, "Should not return items for search scoped to Contacts"); Assert.Contains(results1.DataObject.Contacts, c => c.Id == createdContactInfo.ContactId); var results2 = searchProxy.Search(createdContactInfo.ContactDetail.EmailAddress, SearchScope.Contacts, 1, 25); Assert.NotNull(results2); Assert.True(results2.DataObject.Contacts.Count > 0, "No contacts returned."); Assert.True(results2.DataObject.TotalContactsFound > 0, "transaction count is 0."); Assert.Contains(results2.DataObject.Contacts, c => c.Id == createdContactInfo.ContactId); var companyProxy = new CompanyProxy(); var companyResponse = companyProxy.GetCompany(createdContactInfo.ContactDetail.CompanyId.Value); var results3 = searchProxy.Search(companyResponse.DataObject.Name, SearchScope.Contacts, 1, 25); Assert.NotNull(results3); Assert.True(results3.DataObject.Contacts.Count > 0, "No contacts returned."); Assert.True(results3.DataObject.TotalContactsFound > 0, "transaction count is 0."); Assert.Contains(results3.DataObject.Contacts, c => c.Id == createdContactInfo.ContactId); }
private void SearchController_OnSearchComplete(SearchProxy search) { Task.Run(async() => { try { var results = await Services.Instance.Handler.FindMultiple(new ResultProxy() { SearchId = search.Id }); Dispatcher.Invoke(() => { var window = new ResultsWindow((List <ResultProxy>)results, search.Term); window.Show(); }); } catch (Exception e) { throw; } }); // As the one received from the event has been throught the database, and the one in the list hase not, they are different, while still in reality being the same. // Matching them on thier ExecutedAt, ensures the correct one is found and removed. // This is needed incase many searhes are done rapidly, and one done later is finished before one done earlier. var item = model.CurrentSearches.Where(x => x.ExecutedAt == search.ExecutedAt).ToList().First(); Dispatcher.Invoke(() => model.CurrentSearches.Remove(item)); }
public SearchWindow(SearchProxy search) { InitializeComponent(); DataContext = model = new SearchWindowModel(search); CreateResultWindow(search.Term); }
public void ShouldReturnPurchasesOnlyWhenTransactionEntityTypeSpecified() { var searchProxy = new SearchProxy(); var results = searchProxy.Search("test", SearchScope.Transactions, 1, 25, "transactions.purchase"); Assert.IsNotNull(results, "No search results returned."); Assert.IsNotNull(results.DataObject, "No search result object returned."); Assert.IsTrue(results.DataObject.Transactions.TrueForAll(x => x.Type == "P")); }
public void ShouldReturnContactsForScopedSearch() { var searchProxy = new SearchProxy(); var results = searchProxy.Search("test", SearchScope.Contacts, 1, 25); Assert.IsNotNull(results, "No search results returned."); Assert.IsTrue(results.DataObject.Contacts.Count > 0, "No contacts returned."); Assert.IsTrue(results.DataObject.TotalContactsFound > 0, "transaction count is 0."); Assert.IsTrue(results.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts"); Assert.IsTrue(results.DataObject.TotalInventoryItemsFound == 0, "Should not return items for search scoped to Contacts"); }
public SearchWindowModel(SearchProxy search) { Search = search; Title = $"Search - {SearchTerm}"; SearchTarget = Core.Enums.Target.GetSearchTarget(Search.Target); Task.Run(async() => SearchResults = new ObservableCollection <ResultProxy>(await Services.Instance.Handler.FindMultiple(new ResultProxy() { SearchId = search.Id }))); }
public void ShouldReturnNotResults() { var searchProxy = new SearchProxy(); var results = searchProxy.Search("qwerty", SearchScope.All, 1, 25); Assert.IsNotNull(results, "No search results returned."); Assert.IsNotNull(results.DataObject, "No search result object returned."); Assert.AreEqual(0, results.DataObject.InventoryItems.Count); Assert.AreEqual(0, results.DataObject.Contacts.Count); Assert.AreEqual(0, results.DataObject.InventoryItems.Count); Assert.AreEqual(0, results.DataObject.TotalInventoryItemsFound); Assert.AreEqual(0, results.DataObject.TotalContactsFound); Assert.AreEqual(0, results.DataObject.TotalTransactionsFound); }
public void ShouldReturnNotResults() { var searchProxy = new SearchProxy(); var results = searchProxy.Search("zzzzzzzzzzzzzzzzzzzzzz", SearchScope.All, 1, 25); Assert.NotNull(results); Assert.NotNull(results.DataObject); Assert.Equal(0, results.DataObject.InventoryItems.Count); Assert.Equal(0, results.DataObject.Contacts.Count); Assert.Equal(0, results.DataObject.InventoryItems.Count); Assert.Equal(0, results.DataObject.TotalInventoryItemsFound); Assert.Equal(0, results.DataObject.TotalContactsFound); Assert.Equal(0, results.DataObject.TotalTransactionsFound); }
public void ShouldReturnContactsTransactionsInventoryItemsForScopedAllSearch() { var searchProxy = new SearchProxy(); var results = searchProxy.Search("test", SearchScope.All, 1, 25); Assert.IsNotNull(results, "No search results returned."); Assert.IsNotNull(results.DataObject, "No search result object returned."); Assert.IsTrue(results.DataObject.InventoryItems.Count > 0, "No inventory items returned."); Assert.IsTrue(results.DataObject.Contacts.Count > 0, "No contacts returned."); Assert.IsTrue(results.DataObject.InventoryItems.Count > 0, "No inventory items returned."); Assert.IsTrue(results.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0."); Assert.IsTrue(results.DataObject.TotalContactsFound > 0, "transaction count is 0."); Assert.IsTrue(results.DataObject.TotalTransactionsFound > 0, "transaction count is 0."); }
public string doSearch(string query) { List <string> result = new List <string>(); const string ApiUrl = "https://api.1881bedrift.no/search//"; //GetResult - list var qList = new SearchQuery { Msisdn = "", Password = "", UserName = "", QueryLevel = QueryLevels.Medium, Query = query, PageSize = "5", Page = "1", IncludedCatalogues = new List <string>() { "0", "1" } }; using (var target = new SearchProxy()) { var r = new SearchResponse(); try { r = target.GetResult(new Uri(ApiUrl), qList); } catch (SearchProxyException e) { return(e.Message); } foreach (ResultItem l in r.Results) { string thisresult = string.Format("{0}, {1}, {2}, {3}", l.ResultType, this.getContactPoint(l), l.ResultType.ToString() == "Person" ? this.getPersonName(l) : this.getCompanyName(l), this.getAddress(l)); result.Add(thisresult); } } return(string.Join("\n", result)); }
public void ShouldReturnContactsMatchAllSearch() { var createdContactInfo = _searchHelper.CreateContact(); Thread.Sleep(5000); // Need to wait for entities to be indexed var searchProxy = new SearchProxy(); var results1 = searchProxy.Search("*:*", SearchScope.Contacts, 1, 25); Assert.NotNull(results1); Assert.True(results1.DataObject.Contacts.Count > 0, "No contacts returned."); Assert.True(results1.DataObject.TotalContactsFound > 0, "transaction count is 0."); Assert.True(results1.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts"); Assert.True(results1.DataObject.TotalInventoryItemsFound == 0, "Should not return items for search scoped to Contacts"); }
public void ShouldReturnInventoryItemsForMatchAllSearch() { var itemInfo = _searchHelper.CreatSaleInventoryItem(); Thread.Sleep(5000); var searchProxy = new SearchProxy(); var result1 = searchProxy.Search("*:*", SearchScope.InventoryItems, 1, 25); Assert.NotNull(result1); Assert.NotNull(result1.DataObject); Assert.True(result1.DataObject.InventoryItems.Count > 0, "No inventory items returned."); Assert.True(result1.DataObject.TotalInventoryItemsFound > 0, "Inventory item count is 0."); Assert.True(result1.DataObject.TotalTransactionsFound == 0, "Should not return transactions for search scoped to Contacts"); Assert.True(result1.DataObject.TotalContactsFound == 0, "Should not return contacts for search scoped to Contacts"); }
public void ShouldReturnSaleTransactionForScopedSearchByInvoiceNumber() { var searchProxy = new SearchProxy(); var faker = _searchHelper.GetSaleInvoiceFaker(); var invoiceDetail = faker.Generate(); var response = new InvoiceProxy().InsertInvoice(invoiceDetail); Assert.True(response != null && response.IsSuccessfull); Thread.Sleep(5000); // Need to wait for entities to be indexed var results1 = searchProxy.Search(response.DataObject.GeneratedInvoiceNumber, SearchScope.Transactions, 1, 25); Assert.NotNull(results1); Assert.True(results1.DataObject.Transactions.Count > 0, "No transactions returned."); Assert.True(results1.DataObject.TotalTransactionsFound > 0, "transaction count is 0."); Assert.Equal(0, results1.DataObject.TotalContactsFound); Assert.Equal(0, results1.DataObject.TotalInventoryItemsFound); Assert.Contains(results1.DataObject.Transactions, t => t.Id == response.DataObject.InsertedEntityId); }
public void ShouldReturnPurchasesOnlyWhenTransactionEntityTypeSpecified() { var invoiceProxy = new InvoiceProxy(); var saleInfo = _searchHelper.GetSaleInvoiceFaker().Generate(); var saleResponse = invoiceProxy.InsertInvoice(saleInfo); Assert.True(saleResponse != null && saleResponse.IsSuccessfull); var purchaseInfo = _searchHelper.GetPurchaseInvoiceFaker(saleInfo.Summary).Generate(); var purchaseResponse = invoiceProxy.InsertInvoice(purchaseInfo); Assert.True(purchaseResponse != null && purchaseResponse.IsSuccessfull); Thread.Sleep(5000); // Need to wait for entities to be indexed var searchProxy = new SearchProxy(); var results = searchProxy.Search(purchaseInfo.Summary, SearchScope.Transactions, 1, 25, "transactions.purchase"); Assert.NotNull(results); Assert.NotNull(results.DataObject); Assert.True(results.DataObject.Transactions.TrueForAll(x => x.Type == "P")); }
private void ExecuteSearch_Click(object sender, RoutedEventArgs e) { var target = (SearchTarget)(TargetsDropDown.SelectedIndex + 1); if (!EnsureValidInputs(target)) { return; } var term = SearchBox.Text; var path = model.SearchPath; var subfolders = IncludeSubfoldersToggle.IsChecked; _ = int.TryParse(AmountBox.Text, out var desiredAmount); if (desiredAmount > 100) { desiredAmount = 100; } var executed = DateTime.Now; var search = new SearchProxy() { ExecutedAt = executed, Target = target, Term = term, DesiredAmount = desiredAmount, IncludeSubFolders = subfolders, Path = path }; Task.Run(() => { Dispatcher.Invoke(() => model.CurrentSearches.Add(search)); Services.Instance.SearchController.GetResults(search); }); }
public void IndexedTransactionShouldMatchEntityData() { var searchProxy = new SearchProxy(); var invoice = new InvoiceProxy().GetInvoice(_invoiceHelper.InvoiceId1.Value).DataObject; Assert.IsNotNull(invoice.BillingContactId, "Contact not found"); var contact = new ContactProxy().GetContact(invoice.BillingContactId.Value).DataObject; var searchResults = searchProxy.Search(_invoiceHelper.InvoiceId1Summary, SearchScope.Transactions, 1, 100); Assert.IsNotNull(searchResults.DataObject); Assert.IsTrue(searchResults.DataObject.Transactions.Count > 0); var indexedTransaction = searchResults.DataObject.Transactions.First(x => x.Id == invoice.TransactionId); Assert.AreEqual(invoice.DueDate, indexedTransaction.DueDate); Assert.AreEqual(invoice.BillingContactOrganisationName, indexedTransaction.Company); Assert.AreEqual(contact.EmailAddress, ReplaceEm(indexedTransaction.ContactEmail)); Assert.AreEqual(invoice.InvoiceNumber, indexedTransaction.InvoiceNumber); Assert.AreEqual(invoice.PurchaseOrderNumber, indexedTransaction.PurchaseOrderNumber); Assert.AreEqual(invoice.NotesExternal, indexedTransaction.ExternalNotes); Assert.AreEqual(invoice.NotesInternal, indexedTransaction.Notes); Assert.AreEqual(invoice.TransactionType, indexedTransaction.Type); }
public void IndexedInventoryItemShouldMatchEntityData() { var searchProxy = new SearchProxy(); var inventoryItem = InsertAndGetInventoryItem(); var searchResults = searchProxy.Search(inventoryItem.Code, SearchScope.InventoryItems, 1, 10); Assert.IsNotNull(searchResults.DataObject); Assert.IsTrue(searchResults.DataObject.InventoryItems.Count > 0); var indexedInventoryItem = searchResults.DataObject.InventoryItems.First(x => ReplaceEm(x.Code) == inventoryItem.Code); Assert.IsNotNull(indexedInventoryItem); Assert.AreEqual(inventoryItem.BuyingPrice, indexedInventoryItem.BuyingPrice); Assert.AreEqual(inventoryItem.Description, ReplaceEm(indexedInventoryItem.Description)); Assert.AreEqual(inventoryItem.Type, indexedInventoryItem.Type); Assert.AreEqual("Item", indexedInventoryItem.EntityType); Assert.AreEqual(inventoryItem.Id, indexedInventoryItem.Id); Assert.AreEqual(inventoryItem.SellingPrice, indexedInventoryItem.SellingPrice); Assert.AreEqual(inventoryItem.StockOnHand.HasValue ? inventoryItem.StockOnHand : 0M, indexedInventoryItem.StockOnHand); Assert.AreEqual(inventoryItem.PrimarySupplierItemCode, indexedInventoryItem.SupplierItemCode); }
/// <summary> /// Gets the prod list. /// </summary> /// <returns>The prod list.</returns> /// <param name="rq">Rq.</param> //1.取得商品列表 public static SearchProductModel GetProdList(SearchRQModel rq) { SearchProductModel prod = new SearchProductModel(); List <ProductBaseModel> pLst = new List <ProductBaseModel>(); try { JObject obj = SearchProxy.GetProdList(rq); Metadata md = new Metadata(); DataModel.Discount.DiscountRuleModel disc = null; #region --1.取回傳資料是否成功的訊息、統計用資訊-- md.result = obj["metadata"]["status"].ToString(); md.result_msg = obj["metadata"]["desc"].ToString(); prod.metadata = md; #endregion //如果狀態為0000 表示搜尋沒問題 才繼續滿足商品欄位 if (md.result == "0000") { #region --2.從傑森物件取『商品列表』-- JArray jsonPlst = (JArray)obj["data"]["prods"]; int countBlackProd = 0;//計算黑名單筆數 for (int i = 0; i < jsonPlst.Count; i++) { var model = new ProductBaseModel(); string prod_no = jsonPlst[i]["id"].ToString(); //抓商品是否為黑名單 bool isBlack = DiscountRepository.GetProdBlackWhite(prod_no); //表示該商品為白名單 需要綁入列表中 (黑名單的就不綁了) if (isBlack != true) { model.prod_no = Convert.ToInt32(prod_no); model.prod_name = jsonPlst[i]["name"].ToString(); model.b2d_price = DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jsonPlst[i]["price"], prod_no, jsonPlst[i]["main_cat_key"].ToString(), ref disc); //分銷價 model.b2c_price = (double)jsonPlst[i]["sale_price"]; //直客價 model.display_ref_price = jsonPlst[i]["display_price"].ToString(); model.prod_currency = jsonPlst[i]["currency"].ToString(); model.prod_img_url = jsonPlst[i]["img_url"].ToString(); model.rating_count = (int)jsonPlst[i]["rating_count"]; model.avg_rating_star = (double)jsonPlst[i]["rating_star"]; model.instant_booking = (bool)jsonPlst[i]["instant_booking"]; model.order_count = (int)jsonPlst[i]["order_count"]; model.days = (int)jsonPlst[i]["days"]; model.hours = (int)jsonPlst[i]["hours"]; model.introduction = jsonPlst[i]["introduction"].ToString(); model.duration = (int)jsonPlst[i]["duration"]; //model.display_price_usd = jsonPlst[i]["display_price_usd"].ToString(); //model.price_usd = (double)jsonPlst[i]["price_usd"]; model.prod_type = jsonPlst[i]["main_cat_key"].ToString(); model.tag = jsonPlst[i]["cat_key"].ToObject <string[]>();//把傑森物件轉成字串陣列 //取國家,城市 List <Country> country = ((JArray)jsonPlst[i]["countries"]) .Select(x => new Country { id = (string)x["id"], name = (string)x["name"], cities = x["cities"].ToObject <List <City> >() }).ToList(); model.countries = country; pLst.Add(model); } else { countBlackProd++; } //頁數、筆數統計 md.total_count = (int)obj["metadata"]["pagination"]["total_count"] - countBlackProd; //商品總筆數 扣掉黑名單筆數 md.start = (int)obj["metadata"]["pagination"]["start"]; //從第?筆開始 md.count = (int)obj["metadata"]["pagination"]["count"]; //一頁?筆商品 prod.metadata = md; //stats 金額統計 if (rq.stats != null) { Stats s = new Stats(); s.price = new Price() { min = (int)obj["data"]["stats"]["price"]["min"], max = (int)obj["data"]["stats"]["price"]["max"], count = (int)obj["data"]["stats"]["price"]["count"], currency = obj["data"]["stats"]["price"]["currency"].ToString() }; prod.stats = s; } //facets 大分類 小分類 ...的統計 if (rq.facets != null) { Facets f = new Facets(); //大分 if (rq.facets.Where(x => x.Equals("cat_main")).Count() == 1) { List <CatMain> cm = ((JArray)obj["data"]["facets"]["cat_main"]) .Select(x => new CatMain { id = (string)x["id"], name = (string)x["name"], sort = (string)x["sort"], count = (int)x["count"] }).ToList(); f.cat_main = cm; } //小分 if (rq.facets.Where(x => x.Equals("cat")).Count() == 1) { List <Cat> ca = ((JArray)obj["data"]["facets"]["cat"]) .Select(x => new Cat { id = (string)x["id"], name = (string)x["name"], sort = (string)x["sort"], count = (int)x["count"] }).ToList(); f.cat = ca; } if (rq.facets.Where(x => x.Equals("total_time")).Count() == 1) { List <TotalTime> tt = ((JArray)obj["data"]["facets"]["total_time"]) .Select(x => new TotalTime { time = (int)x["time"], count = (int)x["count"] }).ToList(); f.total_time = tt; } if (rq.facets.Where(x => x.Equals("guide_lang")).Count() == 1) { List <GuideLang> gl = ((JArray)obj["data"]["facets"]["guide_lang"]) .Select(x => new GuideLang { id = (string)x["id"], name = (string)x["name"], count = (int)x["count"] }).ToList(); f.guide_lang = gl; } //可販售日期 if (rq.facets.Where(x => x.Equals("sale_dt")).Count() == 1) { List <SaleDt> sd = ((JArray)obj["data"]["facets"]["sale_dt"]) .Select(x => new SaleDt { id = (int)x["id"], count = (int)x["count"] }).ToList(); f.sale_dt = sd; } prod.facets = f; } } prod.prods = pLst; #endregion } } catch (Exception ex) { Website.Instance.logger.FatalFormat($"getProdLst Error :{ex.Message},{ex.StackTrace}"); throw ex; } return(prod); }
/// <summary> /// Inicjalizuje początkowy stan obiektu /// </summary> protected SearchingViewModelBase() { Service = new SearchProxy(); SearchCommand = new DelegateCommand(async x => await SearchResultAsync()); (App.Current as App).Login += (x, e) => { SearchingResults = null; }; }
private async void StartButton_Click(object sender, EventArgs e) { //var socksList = Helpers.GetIpEndOfFile(@"E:\ProxyList\socks.txt"); //var ipWorks = new List<IPEndPoint>();//Helpers.GetIpEndOfFile(@"E:\ProxyList\socksWork.txt"); //int s5 = 0, s4 = 0; //Parallel.ForEach(socksList, s => //{ // var zxc = Socks.GetTypeSocks(s); // if (zxc != TypeSocks.Error) // { // ipWorks.Add(s); // if (zxc == TypeSocks.Socks5) // s5++; // if (zxc == TypeSocks.Socks4) // s4++; // } //}); var a = new AvJs("123123123"); var tre = a.q_a_bb("{\"a\":{\"af\":1382981724491,\"aa\":1,\"ab\":10,\"ac\":9,\"ae\":\"\",\"ad\":\"BYCR5JHJJDRQZK2VPDDQ\",\"ag\":1382371709662,\"ah\":1382981634346,\"cg\":\"SG0978FE8DF36DE98AC942EC221DCD35404566F861\",\"ai\":\"Win32\",\"aj\":\"http://m.avito.ru/pskov/kvartiry\",\"ak\":1},\"b\":[{\"bd\":\"\",\"be\":\"\",\"bk\":-1,\"bl\":0,\"bj\":\"ru\",\"bo\":[],\"bm\":false,\"bn\":{},\"bv\":[],\"bt\":false,\"bu\":{},\"by\":[],\"cd\":0,\"ba\":1382981634346,\"bb\":90145,\"bc\":36612,\"ch\":\"Etc/GMT-4\"}]}"); //File.WriteAllLines(@"E:\ProxyList\socksWork.txt", ipWorks.Select(x => x.Address + ":" + x.Port)); AvitoHandler aH = new AvitoHandler(); var sa = aH.GetFieldAvito("http://m.avito.ru/sankt-peterburg/avtomobili_s_probegom/toyota_will_2002_227393083"); Helpers.SaveInOnTypeProxy(@"E:\ProxyList\ipMyFind.txt"); var ipRus = File.ReadAllLines(@"E:\ProxyList\GeoipRus1.txt"); List <long> time = new List <long>(); foreach (var str in ipRus) { var rangeIp = Helpers.GetRangeIpOfStr(str); var temp = rangeIp[0].ToString(); var temp1 = rangeIp[1].ToString(); //Перебор {111.111}.111.111 где {p0}.i.j var ip0 = temp.Substring(0, temp.IndexOf(".", temp.IndexOf(".") + 1)); var ip1 = temp1.Substring(0, temp1.IndexOf(".", temp1.IndexOf(".") + 1)); int iEnd, iBegin, zBegin = 0, zEnd = 1; string one = rangeIp[0].ToString().Substring(0, temp.IndexOf(".")); if (ip0.Equals(ip1)) { temp = temp.Replace(ip0 + ".", ""); var iStr = temp.Substring(0, temp.IndexOf(".")); iBegin = Convert.ToInt32(iStr); temp1 = temp1.Replace(ip0 + ".", ""); iStr = temp1.Substring(0, temp1.IndexOf(".")); iEnd = Convert.ToInt32(iStr); } else { //111.{p0}.111.111 ip0 = temp.Substring(temp.IndexOf(".") + 1, temp.IndexOf(".", temp.IndexOf("."))); ip1 = temp1.Substring(temp1.IndexOf(".") + 1, temp1.IndexOf(".", temp1.IndexOf("."))); zBegin = Convert.ToInt32(ip0); zEnd = Convert.ToInt32(ip1); temp = temp.Replace(temp.Substring(0, temp.IndexOf(".", temp.IndexOf(".") + 1)) + ".", ""); var iStr = temp.Substring(0, temp.IndexOf(".")); iBegin = Convert.ToInt32(iStr); temp1 = temp1.Replace(temp1.Substring(0, temp1.IndexOf(".", temp1.IndexOf(".") + 1)) + ".", ""); iStr = temp1.Substring(0, temp1.IndexOf(".")); iEnd = Convert.ToInt32(iStr); } var st = new Stopwatch(); var sad = new List <string>(); sad.Add("--------------------------------------------------------------------------------------------------"); sad.Add("-----------------" + str + " - " + rangeIp[0].ToString() + ":" + rangeIp[1].ToString() + "----------"); sad.Add("--------------------------------------------------------------------------------------------------"); st.Start(); int zx = 0; for (int z = zBegin; z <= zEnd; z++) { List <string> p1080 = new List <string>(); Parallel.For(iBegin, iEnd + 1, /* new ParallelOptions() {MaxDegreeOfParallelism = 10},*/ i => { string ipStr = string.Empty; if (zEnd == 1) { ipStr = string.Format("{0}.{1}.0-255", ip0, i); } else { ipStr = string.Format("{0}.{1}.{2}.0-255", one, z, i); } var res = SearchProxy.GetOpenProxyPorts(ipStr); zx++; if (res.Contains("open")) { sad.Add(res); } if (res.Contains("1080")) { p1080.Add(res); } }); File.AppendAllLines(@"E:\ProxyList\ScanSocks.txt", p1080); if (zEnd == 1) { break; } } st.Stop(); sad.Add("------------------------------------------------------------------------------------------"); File.AppendAllLines(@"E:\ProxyList\Scan.txt", sad); time.Add(st.ElapsedMilliseconds); } var pathProxyList = @"E:\ProxyList\proxy.txt"; Proxy.FormattingProxyFile(@"E:\ProxyList\ProxyListWhiteSpace.txt", pathProxyList); var proxyList = Proxy.ReadIpList(pathProxyList); var error400s = new List <string>(); string[] headerProxies = { "x-via", "cdn-src-ip", "x-bluecoat-via", "mt-proxy-id", "x-real-ip", "x-proxy-id", "x-forwarded-for", "via" , "max-forwards", "x-via", "x-forwarded-server", "x-forwarded-host" }; if (proxyList != null && proxyList.Any()) { var myIp = Proxy.GetIp(null); var ipWork = new List <IpAdr>(); Parallel.ForEach(proxyList, s => { var adr = s.Trim(); var endIp = adr.IndexOf(":"); if (endIp < 1) { endIp = adr.IndexOf(" "); } string ip = adr.Substring(0, endIp); int port = Int32.Parse(adr.Substring(endIp + 1)); var proxy = new Proxy(new WebProxy(ip, port)); if (proxy.IsPing(ip)) { var send = proxy.SocketSendHttp(); if (!string.IsNullOrEmpty(send)) { var status = send.Substring(9, 3); if (status.Substring(0, 1) == "2") { var ipProxy = proxy.GetIp(); if (!ipProxy.Equals("")) { var countryName = proxy.GetGeolocation(); bool visible = ipProxy.Equals(myIp); var ipSecurity = IpSecurity.Transparent; if (!visible) { if (!ipProxy.Equals(ip)) { ipProxy = ip; } foreach (var header in headerProxies) { if (send.IndexOf(header) > 0) { ipSecurity = IpSecurity.Anonymous; break; } } if (ipSecurity == IpSecurity.Transparent) { ipSecurity = IpSecurity.Elite; } } ipWork.Add(new IpAdr() { Ip = ip, Port = port, Security = ipSecurity, TimePing = proxy.TimePing, Country = countryName }); } } else if (status.Equals("400")) { error400s.Add(ip + ":" + port.ToString()); } } } }); File.WriteAllLines(@"E:\ProxyList\proxyElite.txt", ipWork.Where(x => x.Security == IpSecurity.Elite).Select(x => x.Ip + ":" + x.Port)); File.WriteAllLines(@"E:\ProxyList\proxy.txt", ipWork.Select(x => x.Ip + ":" + x.Port)); File.WriteAllLines(@"E:\ProxyList\proxyError400.txt", error400s); WriteCSV(ipWork, @"E:\ProxyList\proxy.csv"); } var ret = 0; }