public bool SetOptionValue(string option, string value) { if (option.Equals("Locale", StringComparison.CurrentCultureIgnoreCase)) { _locale = AmazonLocale.FromString(value.ToUpper()); Properties.Settings.Default.AmazonLocale = _locale.FriendlyName; Properties.Settings.Default.Save(); return(true); } else { return(false); } }
public bool Initialize(string provider, Dictionary <string, string> parameters) { _locale = AmazonLocale.FromString(Properties.Settings.Default.AmazonLocale); if (parameters != null) { if (parameters.ContainsKey("Locale")) { string localeParam = parameters["Locale"]; _locale = AmazonLocale.FromString(localeParam); } } return(true); }
public bool SearchForMovie(string movieName, int maxResults) { _locale = AmazonLocale.FromString(Properties.Settings.Default.AmazonLocale); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.MaxReceivedMessageSize = int.MaxValue; client = new AWSECommerceServicePortTypeClient( binding, new EndpointAddress(_locale.URL) ); client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior()); try { ItemSearchRequest req = new ItemSearchRequest(); req.SearchIndex = Properties.Settings.Default.AmazonSearchMode; req.Title = movieName; req.ItemPage = @"1"; req.ResponseGroup = new string[] { "Medium", "Subjects" }; ItemSearch iSearch = new ItemSearch(); iSearch.Request = new ItemSearchRequest[] { req }; iSearch.AWSAccessKeyId = Properties.Settings.Default.AWEAccessKeyId; ItemSearchResponse res = client.ItemSearch(iSearch); if (res.Items[0].Item.Length > 0) { Item[] amazonItems = res.Items[0].Item; int itemsToProcess = Math.Min(amazonItems.Length, maxResults); if (amazonItems != null) { // convert Amazon Items to generic collection of DVDs OMLSDKTitle[] searchResults = new OMLSDKTitle[itemsToProcess]; for (int i = 0; i < itemsToProcess; i++) { searchResults[i] = AmazonToOML.TitleFromAmazonItem(amazonItems[i]); } int totalPages = 0; int totalItems = 0; if (res.Items[0].TotalPages != null) { totalPages = Convert.ToInt32(res.Items[0].TotalPages); } if (res.Items[0].TotalResults != null) { totalItems = Convert.ToInt32(res.Items[0].TotalResults); } _searchResult = (new AmazonSearchResult(searchResults, totalPages, totalItems)); } else { _searchResult = (new AmazonSearchResult(null, 0, 0)); } return(true); } } catch { _searchResult = (new AmazonSearchResult(null, 0, 0)); } return(false); }
public bool SetOptionValue(string option, string value) { if (option.Equals("Locale", StringComparison.CurrentCultureIgnoreCase)) { _locale = AmazonLocale.FromString(value.ToUpper()); Properties.Settings.Default.AmazonLocale = _locale.FriendlyName; Properties.Settings.Default.Save(); return true; } else { return false; } }
public bool SearchForMovie(string movieName, int maxResults) { _locale = AmazonLocale.FromString(Properties.Settings.Default.AmazonLocale); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.MaxReceivedMessageSize = int.MaxValue; client = new AWSECommerceServicePortTypeClient( binding, new EndpointAddress(_locale.URL) ); client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior()); try { ItemSearchRequest req = new ItemSearchRequest(); req.SearchIndex = Properties.Settings.Default.AmazonSearchMode; req.Title = movieName; req.ItemPage = @"1"; req.ResponseGroup = new string[] { "Medium", "Subjects" }; ItemSearch iSearch = new ItemSearch(); iSearch.Request = new ItemSearchRequest[] { req }; iSearch.AWSAccessKeyId = Properties.Settings.Default.AWEAccessKeyId; ItemSearchResponse res = client.ItemSearch(iSearch); if (res.Items[0].Item.Length > 0) { Item[] amazonItems = res.Items[0].Item; int itemsToProcess = Math.Min(amazonItems.Length, maxResults); if (amazonItems != null) { // convert Amazon Items to generic collection of DVDs OMLSDKTitle[] searchResults = new OMLSDKTitle[itemsToProcess]; for (int i = 0; i < itemsToProcess; i++) { searchResults[i] = AmazonToOML.TitleFromAmazonItem(amazonItems[i]); } int totalPages = 0; int totalItems = 0; if (res.Items[0].TotalPages != null) totalPages = Convert.ToInt32(res.Items[0].TotalPages); if (res.Items[0].TotalResults != null) totalItems = Convert.ToInt32(res.Items[0].TotalResults); _searchResult = (new AmazonSearchResult(searchResults, totalPages, totalItems)); } else { _searchResult = (new AmazonSearchResult(null, 0, 0)); } return true; } } catch { _searchResult = (new AmazonSearchResult(null, 0, 0)); } return false; }
public bool Initialize(string provider, Dictionary<string, string> parameters) { _locale = AmazonLocale.FromString(Properties.Settings.Default.AmazonLocale); if (parameters != null) { if (parameters.ContainsKey("Locale")) { string localeParam = parameters["Locale"]; _locale = AmazonLocale.FromString(localeParam); } } return true; }