|
|
I am trying to use the amazon web services in my c# program but I kept getting a http 410:gone error.
I did some research and found webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl is suppose to be the correct web reference. In any event, the following appears to be obsolete and I can not find it replacement. What I am wanting to do is query amazon based on a title and return the price.
I thought AmazonSearchService srchrequest = new AmazonSearchService(); would work but that appears to have been replaced and i haven't a clue with what. I thought maybe AWSECommerceService srch = new AWSECommerceService();
Then also the KeywordRequest kr = new KeywordRequest(); has been removed. so I guess how do you do keyword searches now?
I was hoping to do something like this
ProductInfo pi = srch.KeywordSearchRequest(kr);
Details[] allDetails = pi.Details;
allDetails no longer exist either
Am I going about this all wrong or what? I can't seem to figure it out..
The closest I see are two things in the object brower. Price and then itemsearchrequest but I can't seem to figure out how one would use that to get the price of the item.
any help or a reference to a working tutorial or something would be great.
thanks
|
|
|
|
|
This documentation[^] may be of some help.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Thanks for that link..
Here is something I came up with but for some reason It keeps throwing an exception.
The assembly with display name 'book list project.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1.
The cause of the failure was: System.IO.FileNotFoundException:
Could not load file or assembly 'book list project.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
The system cannot find the file specified.The assembly with display name 'book list project.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1.
The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'book list project.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
here is the code I'm calling:
private void btn_GetPrice_Click(object sender, EventArgs e)
{
AWSECommerceService aws = new AWSECommerceService();
ItemSearchRequest request = new ItemSearchRequest();
request.SearchIndex = "Books";
request.Power = "title:" + titleTextBox.Text;
request.ResponseGroup = new string[] { "Small" };
request.Sort = "salesrank";
ItemSearchRequest[] requests = new ItemSearchRequest[] { request };
ItemSearch itemSearch = new ItemSearch();
itemSearch.AssociateTag = "XXXXXX";
itemSearch.SubscriptionId = "XXXX";
itemSearch.Request = requests;
try
{
ItemSearchResponse response = aws.ItemSearch(itemSearch);
Items info = response.Items[0];
Item[] items = info.Item;
for (int i = 0; i < items.Length; i++)
{
Item item = items[i];
priceTextBox.Text = item.ItemAttributes.ListPrice.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
|
|
|
|
|
how to convert string like 0.5555 to rounded double value of 0.6 in this case? Because when i use Convert.ToDouble("0.555555") the result is 55555555..
Thanks
|
|
|
|
|
Hi,
the Convert class (or the Parse methods of several classes) will turn a string into a numeric value that matches the string as good as it can. There is no way around that.
You can change the result by adding another statement that operates on the numeric variable, something like double d=Math.Round(d,1); . AFAIK there isn't a single statement that will do both at once.
read up on the Math.Round() method.
|
|
|
|
|
Still..you can't convert string 0.555 to double value 0.555? Always removes 0 from first place..i used another more complicated way..i separate string..i get second decimal..check if it is greater than 5..if yes i inc first decimal and at the end i put numbers converted to string back together.
|
|
|
|
|
Aljaz111 wrote: you can't convert string 0.555 to double value 0.555
Of course you can, just use double.Parse or better still TryParse
double d = double.Parse("0.555");
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Aljaz111 wrote: Always removes 0 from first place..
Is the decimal separator in your country by any chance a comma? How about this for verification;
string s = "0.55555";
double d = Convert.ToDouble(s, System.Globalization.CultureInfo.InvariantCulture);
string s2 = d.ToString("#,#0.0");
Console.WriteLine(s2);
I are Troll
|
|
|
|
|
|
Good thinking
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks
I are Troll
|
|
|
|
|
Ok it doesn't work without System.Globalization.CultureInfo.InvariantCulture but with it in Convert.Double(s, System.Globalization.CultureInfo.InvariantCulture) works just fine. Can you explain me please what does this have to do with rounding numbers?
Thx
|
|
|
|
|
It interprets the decimal point wrong, if you replace the point with a comma then all goes well. There's also a System.Globalization.CultureInfo.CurrentCulture .
The invariant culture will use the decimal-point, no matter what's been set currently by the user. If you convert the double "2.0" from invariant to your CurrentCulture[^], then you'd probably get "2,0"
I are Troll
|
|
|
|
|
I'm not quite sure how you're approching this but it's quite simple
public static double StringToRoundedDouble(string s, int decimals)
{
double result;
if (double.TryParse(s, out result))
result = Math.Round(result, decimals, MidpointRounding.AwayFromZero);
return result;
} Useage
double d =(StringToRoundedDouble("0.5555", 1);
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
hi im coding c# sockets in Asynchronous mode.
my app is running but i need to limit the number clients to one. so if a connection already exists i want the server to refuse any new connection. but using async methods i cant stop it from listening.
the server will have to be restarted everytime the unique connection is terminated, so i dont need it to serve next new connection.
how could i refuse new connections when async does not support it?
thank you very much.
|
|
|
|
|
Whether you're using synchronous or asynchronous methods you have to explicitly tell the TcpListener or Socket to accept a new connection using one of the BeginAccept or Accept methods. If you don't want more than one client connected then don't call those methods more than once.
|
|
|
|
|
perfect! i understand it now. thanks.
|
|
|
|
|
are you sure you still want asynchronous operation if all that is going on is a single connection?
seems to me you're paying the bills but not getting the goods.
|
|
|
|
|
|
I will answer them only if you can answer yes to any of the following:
Have you gone to class once this semester?
Are you looking forward to bagging my groceries next year?
Do you know how annoying it is to have kids come here before mid-terms and ask basic questions they should have known by class #3?
Do you understand that this series of mock questions is your last call to go see your teacher and get a tutor before you flunk out of your program?
Seriously, this is your last chance.
|
|
|
|
|
I did think of giving him single word, truthfull but unhelpfull answers, but decided he would probably talk to me if I did. Perhaps Google has stopped working for him?
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
This could be a take home interview and he is a senior .NET consultant with 20 years experience charging $7 an hour.
|
|
|
|
|
Yes and no. You decide which questions these apply to.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I have a groupBox that has N PictureBox controls on it.
Each PictureBox is named thmb1-N e.g thmb26.
I have a list of paths, of thumbnail images, which I want to iterate through and set PictureBox control ImageLocation properties for each PictureBox .
The code I have written below is a first rather messy and quick attempt - which is cumbersome and I really don't want to be iterating through every object.
Is there a better way of doing this?
If I could do something like thmb + N.ImageLocation = ... but i realise I cannot do this in C# so any help in directing me towards how to do this would be much appreciated.
Guy
for (int i = 0; i < bubble.thumbs.Count; i++)
{
foreach (Control ctrl in this.groupBox8.Controls)
{
if (ctrl is PictureBox)
{
if (LeftRightMid.Left(ctrl.Name.ToString(), 4) == "thmb"
&& Convert.ToInt32(LeftRightMid.Right(ctrl.Name.ToString(), 1)) == i)
{
((PictureBox)(ctrl)).ImageLocation = bubble.thumbs[i];
}
}
}
}
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|