private void updateBatchBtn_Click(object sender, RoutedEventArgs e) { List <ZipCityData> cityZipList = new List <ZipCityData>() { new ZipCityData() { ZipCode = "07035", City = "Bedrock" }, new ZipCityData() { ZipCode = "33030", City = "End of the World" } }; try { GeoClient proxy = new GeoClient("tcpEP"); using (TransactionScope scope = new TransactionScope()) { proxy.UpdateZipCity(cityZipList); proxy.Close(); throw new ApplicationException("uh oh"); scope.Complete(); } proxy.Close(); MessageBox.Show("Updated."); } catch (Exception ex) { MessageBox.Show("Exception: " + ex.Message); } }
private void btnGetZipCodes_Click(object sender, RoutedEventArgs e) { //This call, in the way it's configured, will only work with ConsoleHost if (!string.IsNullOrWhiteSpace(txtSearchState.Text)) { //As commented in the module, it's possible to set values in the config file or programmatically. //Here it was set programmatically, to change this, you just need to comment the next lines, //and make the constructor passing the tcpEP string as parameter. EndpointAddress address = new EndpointAddress("net.tcp://localhost:8009/GeoService"); Binding binding = new NetTcpBinding() { MaxReceivedMessageSize = 2000000, SendTimeout = new TimeSpan(0, 0, 5) }; GeoClient proxy = new GeoClient(binding, address); IEnumerable <ZipCodeData> data = proxy.GetZips(txtSearchState.Text); if (data != null) { lstZips.ItemsSource = data; } proxy.Close(); } }
private void btnGetInfo_Click(object sender, RoutedEventArgs e) { if (txtZipCode.Text != "") { GeoClient proxy = new GeoClient(); try { ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } proxy.Close(); } catch (Exception ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + ex.GetType().Name + "\n\r" + "Message: " + ex.Message + "\n\r" + "Proxy state: " + proxy.State.ToString()); } } }
private void btnUpdateBatch_Click(object sender, RoutedEventArgs e) { List <ZipCityData> cityZipList = new List <ZipCityData>() { new ZipCityData() { ZipCode = "07035", City = "Bedrock" }, new ZipCityData() { ZipCode = "33033", City = "End of the World" } }; try { GeoClient proxy = new GeoClient(); proxy.UpdateZipCity(cityZipList); proxy.Close(); MessageBox.Show("Updated"); } catch (Exception ex) { MessageBox.Show("Error"); } }
private void btnPutBack_Click(object sender, RoutedEventArgs e) { List <ZipCityData> cityZipList = new List <ZipCityData>() { new ZipCityData() { ZipCode = "07035", City = "Linkin Park" }, new ZipCityData() { ZipCode = "33033", City = "Homestead" } }; try { GeoClient proxy = new GeoClient(); proxy.UpdateZipCity(cityZipList); proxy.Close(); MessageBox.Show("Updated"); } catch (Exception ex) { MessageBox.Show("Error"); } }
private void BtnGetZipCodes_Click(object sender, RoutedEventArgs e) { try { if (!string.IsNullOrWhiteSpace(txtState.Text)) { var address = new EndpointAddress("net.tcp://localhost/GeoLib.WebHost/GeoService.svc"); var binding = new NetTcpBinding(); GeoClient proxy = new GeoClient(binding, address); IEnumerable <ZipCodeData> data = proxy.GetZips(txtState.Text); if (data != null) { lstZips.ItemsSource = data; } proxy.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnGetInfo_Click(object sender, RoutedEventArgs e) { if (txtZipCode.Text != "") { GeoClient proxy = new GeoClient(); try { ZipCode data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State.Name; } proxy.Close(); } catch (FaultException ex) { MessageBox.Show("Fault Exception: " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void GetInfoBtn_OnClick(object sender, RoutedEventArgs e) { var proxy = new GeoClient(); ZipCodeData data = proxy.GetZipInfo(""); GetInfoTextBlock.Text = $"{data.City} \r\n {data.State} \r\n {data.ZipCode}"; proxy.Close(); }
private void btnGetInfo_Click(object sender, RoutedEventArgs e) { if (txtZipCode.Text != "") { GeoClient proxy = new GeoClient(new InstanceContext(this), "tcpEp"); try { ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } else { lblCity.Content = "N/A"; lblState.Content = "N/A"; } proxy.Close(); } catch (FaultException <ExceptionDetail> ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + "FaultException<ExceptionDetail>" + "\n\r" + "Message: " + ex.Detail.Message + "\n\r" + "Proxy state: " + proxy.State); } catch (FaultException <ApplicationException> ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + "FaultException<ApplicationException>" + "\n\r" + "Reason: " + ex.Message + "\n\r" + "Message: " + ex.Detail.Message + "\n\r" + "Proxy state: " + proxy.State); } catch (FaultException <NotFoundData> ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + "FaultException<NotFoundData>" + "\n\r" + "Reason: " + ex.Message + "\n\r" + "Message: " + ex.Detail.Message + "\n\r" + "Proxy state: " + proxy.State); } catch (FaultException ex) { MessageBox.Show("Faultxception thrown by service.\n\rException type: " + "FaultException" + "\n\r" + "Message: " + ex.Message + "\n\r" + "Proxy state: " + proxy.State); } catch (Exception ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + ex.GetType().Name + "\n\r" + "Message: " + ex.Message + "\n\r" + "Proxy state: " + proxy.State); } } }
private void btnGetInfo_Click(object sender, RoutedEventArgs e) { if (txtZipCode.Text != "") { GeoClient proxy = new GeoClient(new InstanceContext(this), "tcpEp"); try { ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } else { lblCity.Content = "N/A"; lblState.Content = "N/A"; } proxy.Close(); } catch (FaultException<ExceptionDetail> ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + "FaultException<ExceptionDetail>" + "\n\r" + "Message: " + ex.Detail.Message + "\n\r" + "Proxy state: " + proxy.State); } catch (FaultException<ApplicationException> ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + "FaultException<ApplicationException>" + "\n\r" + "Reason: " + ex.Message + "\n\r" + "Message: " + ex.Detail.Message + "\n\r" + "Proxy state: " + proxy.State); } catch (FaultException<NotFoundData> ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + "FaultException<NotFoundData>" + "\n\r" + "Reason: " + ex.Message + "\n\r" + "Message: " + ex.Detail.Message + "\n\r" + "Proxy state: " + proxy.State); } catch (FaultException ex) { MessageBox.Show("Faultxception thrown by service.\n\rException type: " + "FaultException" + "\n\r" + "Message: " + ex.Message + "\n\r" + "Proxy state: " + proxy.State); } catch (Exception ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + ex.GetType().Name + "\n\r" + "Message: " + ex.Message + "\n\r" + "Proxy state: " + proxy.State); } } }
private void btnOneWay_Click(object sender, RoutedEventArgs e) { GeoClient proxy = new GeoClient(new InstanceContext(this)); proxy.OneWayExample(); MessageBox.Show("Oneway Example called. Back at client."); proxy.Close(); MessageBox.Show("Proxy is closed"); }
private void btnOneWay_Click(object sender, RoutedEventArgs e) { GeoClient proxy = new GeoClient("tcpEP"); proxy.OneWayExample(); MessageBox.Show("Oneway example called. Back at client."); proxy.Close(); MessageBox.Show("Proxy is now close."); }
private void btnOneWay_Click(object sender, RoutedEventArgs e) { GeoClient proxy = new GeoClient(new InstanceContext(this), "tcpEp"); proxy.OneWayExample(); MessageBox.Show("Oneway example. Back at client"); proxy.Close(); MessageBox.Show("Proxy close"); }
private void btnGetInfo_Click(object sender, RoutedEventArgs e) { if (txtZipCode.Text != "") { GeoClient proxy = new GeoClient(); ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } proxy.Close(); } }
private void btnGetZipCodes_Click(object sender, RoutedEventArgs e) { if (txtState.Text != null) { GeoClient proxy = new GeoClient(); IEnumerable <ZipCode> data = proxy.GetZips(txtState.Text); if (data != null) { lstZips.ItemsSource = data; } proxy.Close(); } }
private void BtnGetInfo_OnClick(object sender, RoutedEventArgs e) { if (txtZipCode.Text != null) { var proxy = new GeoClient("httpEP"); var data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } proxy.Close(); } }
private void btnGetInfo_Click( object sender, RoutedEventArgs e ) { if (txtZipCode.Text != "") { GeoClient proxy = new GeoClient("webEP"); ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } proxy.Close(); } }
public void GetZipCodes() { var tempProxy = new GeoClient("tcpEP"); if (string.IsNullOrEmpty(State)) return; var data = tempProxy.GetZips(State); this.ZipCodes.Clear(); foreach (var zipCodeData in data) { this.ZipCodes.Add(zipCodeData); } tempProxy.Close(); }
private void btnGetZipCodes_Click(object sender, RoutedEventArgs e) { if (txtState.Text != "") { EndpointAddress address = new EndpointAddress("net.tcp://localhost:8009/GeoService"); Binding binding = new NetTcpBinding(); GeoClient proxy = new GeoClient(binding, address); IEnumerable <ZipCodeData> data = proxy.GetZips(txtState.Text); if (data != null) { lstZipCodes.ItemsSource = data; } proxy.Close(); } }
private void btnGetInfo_Click(object sender, RoutedEventArgs e) { if (txtZipCode.Text == "") { return; } var proxy = new GeoClient("webEP"); var data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } proxy.Close(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(txtState.Text)) { EndpointAddress address = new EndpointAddress("net.tcp://localhost:8009/GeoService"); System.ServiceModel.Channels.Binding bind = new NetTcpBinding(); GeoClient client = new GeoClient(bind, address); var result = client.GetZips(txtState.Text); if (result != null) { lstZips.ItemsSource = result; } client.Close(); } }
private void buttonInfo_Click(object sender, RoutedEventArgs e) { if (textBoxInfo.Text != "") { GeoClient geoClientProxy = new GeoClient(); ZipCodeData zipCodeData = geoClientProxy.GetZipInfo(textBoxInfo.Text); if (zipCodeData != null) { lblCity.Content = zipCodeData.City; lblState.Content = zipCodeData.State; } geoClientProxy.Close(); } }
private void btnPutBack_Click(object sender, RoutedEventArgs e) { List <ZipCityData> cityZipList = new List <ZipCityData>() { new ZipCityData() { ZipCode = "07035", City = "Lincoln Park" }, new ZipCityData() { ZipCode = "33033", City = "Homestead" }, new ZipCityData() { ZipCode = "90210", City = "Beverly Hills" }, new ZipCityData() { ZipCode = "07094", City = "Secaucus" } }; lstUpdates.Items.Clear(); Thread thread = new Thread(() => { try { GeoClient proxy = new GeoClient(new InstanceContext(this)); proxy.Open(); proxy.UpdateZipCity(cityZipList); proxy.Close(); MessageBox.Show("Updated."); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }); thread.Start(); }
private void BtnGetInfo_OnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.TxtZipCode.Text)) { return; } var proxy = new GeoClient("httpEP"); var data = proxy.GetZipInfo(this.TxtZipCode.Text); if (data != null) { LblCity.Content = data.City; LblState.Content = data.State; } proxy.Close(); }
private void GetZipCodesBtn_OnClick(object sender, RoutedEventArgs e) { var address = new EndpointAddress("net.tcp://localhost:8009/GeoService"); var binding = new NetTcpBinding(); var proxy = new GeoClient(binding, address); ZipCodeData[] data = proxy.GetZips(""); var sb = new StringBuilder(); foreach (var zipCodeData in data) { sb.AppendLine($"State: {zipCodeData.State} City: {zipCodeData.City} ZipCode: {zipCodeData.ZipCode}"); } GetZipsTextBLock.Text = sb.ToString(); proxy.Close(); }
private void btnGetZipCodes_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtState.Text)) { return; } var endpointAddress = new EndpointAddress("net.tcp://localhost:8009/GeoService"); Binding binding = new NetTcpBinding(); var proxy = new GeoClient(binding, endpointAddress); var data = proxy.GetZips(txtState.Text); if (data != null) { lstZips.ItemsSource = data; } proxy.Close(); }
private void GetZipCodesButton_Click(object sender, RoutedEventArgs e) { ZipCodesListBox.ItemsSource = null; ZipCodesListBox.Items.Clear(); ErrorMessage2TextBox.Text = ""; string state = StateTextBox.Text; // ReSharper disable once InvertIf if (state != "") { // Alternate constructor //EndpointAddress endpointAddress = new EndpointAddress("net.tcp://localhost:8009/GeoService"); //Binding binding = new NetTcpBinding(); //GeoClient geoClient = new GeoClient(binding, endpointAddress); List <ZipCodeData> zipCodeDataList = null; WcfBindingType wcfBindingType = GetBindingTypeFromRadioButtons(); GeoClient geoClient = GetGeoClientWithBinding(wcfBindingType); try { zipCodeDataList = geoClient.GetZipCodes(state); } catch (FaultException exception) { string message = "Exception: \r\n" + $"Message = {exception.Message} \r\n" + $"Proxy state = {geoClient.State.ToString()}"; ErrorMessage2TextBox.Text = message; } if (zipCodeDataList == null || zipCodeDataList.Count == 0) { ErrorMessage2TextBox.Text = $"No zip code data found for state {state}"; } ZipCodesListBox.ItemsSource = zipCodeDataList; geoClient.Close(); } }
private void bthGetZipCodes_Click( object sender, RoutedEventArgs e ) { if (txtState.Text != "") { //GeoClient proxy = new GeoClient("httpEP"); EndpointAddress address = new EndpointAddress("net.tcp://localhost:8009/GeoService"); System.ServiceModel.Channels.Binding binding = new NetTcpBinding(); GeoClient proxy = new GeoClient(binding, address); IEnumerable<ZipCodeData> data = proxy.GetZips(txtState.Text); if (data != null) { lstZips.ItemsSource = data; } proxy.Close(); } }
private void btnGetZipCodes_Click(object sender, RoutedEventArgs e) { if (txtState.Text != null) { EndpointAddress address = new EndpointAddress("net.tcp://localhost:8009/GeoService"); Binding binding = new NetTcpBinding(); binding.SendTimeout = new TimeSpan(0, 0, 0, 5); ((NetTcpBinding)binding).MaxReceivedMessageSize = 2000000; GeoClient proxy = new GeoClient(binding, address); IEnumerable <ZipCodeData> data = proxy.GetZips(txtState.Text); if (data != null) { lbxResponse.ItemsSource = data; } proxy.Close(); } }
private void btnUpdateBatch_Click(object sender, RoutedEventArgs e) { List <ZipCityData> cityZipList = new List <ZipCityData>() { new ZipCityData() { ZipCode = "07035", City = "Bedrock" }, new ZipCityData() { ZipCode = "33033", City = "End of the World" }, new ZipCityData() { ZipCode = "90210", City = "Alderan" }, new ZipCityData() { ZipCode = "07094", City = "Storybrooke" } }; lstUpdates.Items.Clear(); try { GeoClient proxy = new GeoClient(new InstanceContext(this)); proxy.UpdateZipCity(cityZipList); proxy.Close(); MessageBox.Show("Updated."); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private async void btnPutBack_Click(object sender, RoutedEventArgs e) { var cityZipList = new List <ZipCityData> { new ZipCityData { ZipCode = "07035", City = "Lincoln Park" }, new ZipCityData { ZipCode = "33033", City = "Homestead" }, new ZipCityData { ZipCode = "90210", City = "Beverly Hills" }, new ZipCityData { ZipCode = "07094", City = "Secaucus" } }; lstUpdates.Items.Clear(); await Task.Run(() => { try { var proxy = new GeoClient(new InstanceContext(this), "tcpEP"); proxy.UpdateZipCity(cityZipList); proxy.Close(); MessageBox.Show("Updated."); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }); }
private void GetZipCodeInfoButton_Click(object sender, RoutedEventArgs e) { CityOutputTextBox.Text = ""; StateOutputTextBox.Text = ""; ErrorMessage1TextBox.Text = ""; string zipCode = ZipCodeTextBox.Text; // ReSharper disable once InvertIf if (zipCode != "") { WcfBindingType wcfBindingType = GetBindingTypeFromRadioButtons(); GeoClient geoClient = GetGeoClientWithBinding(wcfBindingType); ZipCodeData zipCodeData = null; try { zipCodeData = geoClient.GetZipCodeInfo(zipCode); } catch (FaultException exception) { string message = "Exception: \r\n" + $"Message = {exception.Message} \r\n" + $"Proxy state = {geoClient.State.ToString()}"; CityOutputTextBox.Text = ""; StateOutputTextBox.Text = ""; ErrorMessage1TextBox.Text = message; } if (zipCodeData != null) { CityOutputTextBox.Text = zipCodeData.City; StateOutputTextBox.Text = zipCodeData.State; } geoClient.Close(); } }
private void BtnGetInfo_Click(object sender, RoutedEventArgs e) { try { if (!string.IsNullOrWhiteSpace(txtZipCode.Text)) { GeoClient proxy = new GeoClient("httpEP"); ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } proxy.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btnGetZipCodes_Click(object sender, RoutedEventArgs e) { if(txtState.Text != "") { GeoClient proxy = new GeoClient(endpointName); IEnumerable<ZipCodeData> zipCodeData = proxy.GetZips(txtState.Text); if (zipCodeData != null) { lstZips.ItemsSource = zipCodeData; } proxy.Close(); //EndpointAddress endpointAddress = new EndpointAddress("net.tcp://localhost:11001/GeoService"); //System.ServiceModel.Channels.Binding binding = new NetTcpBinding(); //GeoClient proxy = new GeoClient(binding, endpointAddress); //IEnumerable<ZipCodeData> zipCodeData = proxy.GetZips(txtState.Text); //if(zipCodeData!=null) //{ // lstZips.ItemsSource = zipCodeData; //} //proxy.Close(); } }
private void btnUpdateBatch_Click(object sender, RoutedEventArgs e) { List <ZipCityData> cityZipList = new List <ZipCityData>() { new ZipCityData() { Zip = "07035", City = "Bedrock" }, new ZipCityData() { Zip = "33030", City = "End of the World" } }; try { #region Controlling Transaction in the service //Way to do with transaction controlled by the service. //Must use TransactionScope in the service implementation. //GeoClient proxy = new GeoClient("tcpEP"); //proxy.UpdateZipCity(cityZipList); //proxy.Close(); #endregion #region Controlling Transactions PerCall at the client ////Way to do with transaction controlled by the client. //GeoClient proxy = new GeoClient("tcpEP"); ////In the service, if the ReleaseServiceInstanceOnTransactionComplete = false is set, //using (TransactionScope scope = new TransactionScope()) // { // //this method must have the [OperationBehavior(TransactionScopeRequired = true)] also set. // proxy.UpdateZipCity(cityZipList); // scope.Complete(); // } // proxy.Close(); #endregion #region Controlling Transaction PerSession failing at client, to make sure the propagation. //Way to do with transaction controlled by the client. GeoClient proxy = new GeoClient("tcpEP"); //In the service, if the ReleaseServiceInstanceOnTransactionComplete = false is set, using (TransactionScope scope = new TransactionScope()) { //this method must have the [OperationBehavior(TransactionScopeRequired = true)] also set. proxy.UpdateZipCity(cityZipList); //If the service is PerSession, it's necessary to close the proxy inside the transaction scope. proxy.Close(); throw new ApplicationException("uh oh."); scope.Complete(); } #endregion MessageBox.Show("Updated"); } catch (Exception ex) { MessageBox.Show("Error"); } }
private async void btnGetInfo_Click(object sender, RoutedEventArgs e) { if (txtZipCode.Text == "") { txtZipCode.Text = "07035"; } if (txtZipCode.Text != "") { //GeoClient proxy = new GeoClient("tcpEP"); GeoClient proxy = _Proxy; string zipCode = txtZipCode.Text; try { ZipCodeData data = await Task.Run(() => proxy.GetZipInfo(zipCode)); if (data != null) { lblCity.Content = data.City; lblState.Content = data.State; } } catch (FaultException <ExceptionDetail> ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + ex.GetType().Name + "\n\r" + "Message: " + ex.Message + "\r\n" + "Detailed message: " + ex.Detail.Message + "\r\n" + "Proxy state: " + proxy.State.ToString()); } catch (FaultException <NotFoundData> ex) { MessageBox.Show("FaultException<NotFoundData> thrown by service.\n\rException type: " + ex.GetType().Name + "\n\r" + "Message: " + ex.Message + "\r\n" + "Detailed message: " + ex.Detail.Message + "\r\n" + "When: " + ex.Detail.When + "\r\n" + "User: "******"\r\n" + "Proxy state: " + proxy.State.ToString()); } catch (FaultException <ApplicationException> ex) { MessageBox.Show("FaultException<ApplicationException> thrown by service.\n\rException type: " + ex.GetType().Name + "\n\r" + "Message: " + ex.Message + "\r\n" + "Detailed message: " + ex.Detail.Message + "\r\n" + "Proxy state: " + proxy.State.ToString()); } catch (FaultException ex) { MessageBox.Show("FaultException thrown by service.\n\rException type: " + ex.GetType().Name + "\n\r" + "Message: " + ex.Message + "\r\n" + "Proxy state: " + proxy.State.ToString()); } catch (Exception ex) { MessageBox.Show("Exception thrown by service.\n\rException type: " + ex.GetType().Name + "\n\r" + "Message: " + ex.Message + "\r\n" + "Proxy state: " + proxy.State.ToString()); } if (proxy != _Proxy) { proxy.Close(); } } }
private void btnGetZipCodes_Click(object sender, RoutedEventArgs e) { //Here we will do no config for proxy //the client little more knowledge of wcf becuase proxy need this programattic end point //config info and this is fed through ctor overload. if (txtState.Text != null) { //EndpointAddress address = new EndpointAddress("net.tcp://localhost:8009/GeoService"); //NetTcpBinding binding = new NetTcpBinding(); //binding.Name = "dynamic"; //binding.MaxReceivedMessageSize = 2000000; //GeoClient proxy = new GeoClient(binding, address); GeoClient proxy = new GeoClient("tcpEP"); IEnumerable<ZipCodeData> data = proxy.GetZips(txtState.Text); if (data != null) lstZips.ItemsSource = data; proxy.Close(); } }