private async void doSearch_Click(object sender, RoutedEventArgs e) { try { prog.Text = "working..."; ServiceReference1.Service1Client service = new ServiceReference1.Service1Client(); service.ClientCredentials.UserName.UserName = "******"; service.ClientCredentials.UserName.Password = "******"; ServiceReference1.HotelSearchRequest hr = new HotelSearchRequest(); hr.destination = destination.Text; hr.date = DateTime.Now.AddDays(2); ServiceReference1.hotelsummary[] hotels = await service.GetHotelsAsync(hr); text.Text = ""; foreach (var h in hotels) { text.Text += String.Format("{0},{1},{2}", h.name, h.address1, h.city) + "\n"; } if (searchResultCollectionList == null) { searchResultCollectionList = new SearchResultCollectionList(); } SearchResultCollectionList.ItemsSource = hotels.ToList(); prog.Text = ""; } catch (Exception exp) { prog.Text = ""; if (exp.InnerException != null) { text.Text = exp.InnerException.Message; } else if (exp != null) { text.Text = exp.Message; } else { text.Text = "unknow error"; } } }
private async void dorun2_Click(object sender, RoutedEventArgs e) { try { if (searchResultCollectionList == null) { searchResultCollectionList = new SearchResultCollectionList(); } SearchResultCollectionList.ItemsSource = searchResultCollectionList.Items; prog.Text = "working..."; ServiceReference1.Service1Client service = new ServiceReference1.Service1Client(); service.ClientCredentials.UserName.UserName = "******"; service.ClientCredentials.UserName.Password = "******"; ServiceReference1.AuthorResponse auth = await service.GetInfoAsync(adddata.Text); text.Text = auth.auhther.FirstName; prog.Text = ""; } catch (Exception exp) { prog.Text = ""; if (exp.InnerException != null) { text.Text = exp.InnerException.Message; } else if (exp != null) { text.Text = exp.Message; } else { text.Text = "unknow error"; } } }