Esempio n. 1
0
        public async Task PostDouble()
        {
            //// Arrange

            // The nl-NL culture is one of the cultures that uses a comma as the decimal separator.
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-NL");
            var geoClient = new GeoClient(new HttpClient())
            {
                BaseUrl = "http://localhost:13452"
            };
            const double value = 0.5d;

            //// Act
            try
            {
                // This tests whether the value is encoded in the client using the invariant culture. If not, API method will receive the value as null (since it is optional).
                var result = await geoClient.PostDoubleAsync(value);

                //// Assert
                Assert.AreEqual(value, result.Result);
            }
            catch (GeoClientException exception)
            {
                Assert.IsTrue(exception.InnerException is ArgumentException);
                Assert.IsTrue(exception.InnerException.StackTrace.Contains("NSwag.Integration.WebAPI.Controllers.GeoController.SaveItems"));
            }
        }
Esempio n. 2
0
        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 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());
            }
        }
Esempio n. 4
0
        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"
                }
            };

            try
            {
                GeoClient proxy = new GeoClient();

                proxy.UpdateZipCity(cityZipList);

                proxy.Close();

                MessageBox.Show("Updated.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error");
            }
        }
Esempio n. 5
0
        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 (FaultException ex)
                {
                    MessageBox.Show("Fault Exception: " + ex.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            _Proxy = new GeoClient(new InstanceContext(this), "tcpEp");
            _Proxy2 = new StatefulGeoClient();
            _SyncContext = SynchronizationContext.Current;

        }
Esempio n. 7
0
 //GeoClient _Proxy = null;
 public MainWindow()
 {
     InitializeComponent();
     this.Title = "UI Running on Thread" + Thread.CurrentThread.ManagedThreadId +
         " | Process" + Process.GetCurrentProcess().Id.ToString();
     _Proxy = new GeoClient("tcpEP");
     _StateFulProxy = new StateFulGeoClient();
 }
Esempio n. 8
0
        public MainWindow()
        {
            InitializeComponent();

            _Proxy = new GeoClient("");
            _Proxy.Open();
            _SyncContext = SynchronizationContext.Current;
        }
 public MainWindow()
 {
     InitializeComponent();
     this.Title = "UI Running on Thread " + Thread.CurrentThread.ManagedThreadId
         + " | Process " + Process.GetCurrentProcess().Id.ToString();
     LoadComboBox();
     endpointName = cbEndpoint.SelectedValue.ToString();
     _proxy = new GeoClient(endpointName);
 }
Esempio n. 10
0
        public MainWindow()
        {
            InitializeComponent();

            this.Title = "UI Running on Thread " + Thread.CurrentThread.ManagedThreadId +
                         " | Process " + Process.GetCurrentProcess().Id.ToString();
            _proxy = new GeoClient();
            _proxy.Open();
            _proxy2 = new StatefulGeoClient();
        }
Esempio n. 11
0
        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);
                }
            }
        }
Esempio n. 13
0
        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);
                }
            }
        }
Esempio n. 14
0
        public async Task UploadFile()
        {
            //// Arrange
            var geoClient = new GeoClient("http://localhost:13452");

            //// Act
            var result = await geoClient.UploadFileAsync(new FileParameter(new MemoryStream(new byte[] { 1, 2 })));

            //// Assert
            Assert.IsTrue(result);
        }
Esempio n. 15
0
        public async Task UploadFile()
        {
            //// Arrange
            var geoClient = new GeoClient { BaseUrl = "http://localhost:13452" };

            //// Act
            var result = await geoClient.UploadFileAsync(new FileParameter(new MemoryStream(new byte[] { 1, 2 })));

            //// Assert
            Assert.IsTrue(result);
        }
Esempio n. 16
0
        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");
        }
Esempio n. 17
0
        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");
        }
Esempio n. 18
0
        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.");
        }
Esempio n. 19
0
        private async 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"
                }
            };

            lstZips2.Items.Clear();
            //await Task.Run(() =>
            //{

            //    try
            //    {
            //        GeoClient proxy = new GeoClient(new InstanceContext(this), "tcpEp");

            //        proxy.UpdateZipCity(cityZipList);

            //        proxy.Close();

            //        MessageBox.Show("Updated.");
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show("Error: " + ex.Message);
            //    }
            //});
            GeoClient proxy = new GeoClient(new InstanceContext(this), "tcpEp");

            Task <int> task = proxy.UpdateZipCityAsync(cityZipList);

            task.ContinueWith(result =>
            {
                MessageBox.Show(string.Format("Updated {0} items.", result.Result));
            });
            // MessageBox.Show("Call made");
        }
Esempio n. 20
0
        private void btnGetInfo_Click(object sender, RoutedEventArgs e)
        {
            if (txtZipCode.Text != "")
            {
                GeoClient proxy = new GeoClient("tcpEP");                       //Pass tcpEP or httpEP

                ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text);
                if (data != null)
                {
                    lblCity.Content  = data.City;
                    lblState.Content = data.State;
                }
            }
        }
        private void btnGetInfo_Click(object sender, RoutedEventArgs e)
        {
            if (txtZipCode.Text == "") return;

            using (GeoClient proxy = new GeoClient("httpEP"))
            {
                ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text);

                if (data == null) return;

                lblCity.Content = data.City;
                lblState.Content = data.State;
            }
        }
Esempio n. 22
0
        public MainWindow()
        {
            InitializeComponent();

            _Proxy = new GeoClient("tcpEP");
            _Proxy.Open();
            _ProxyStateful = new StatefulGeoClient();

            _SyncContext   = SynchronizationContext.Current;
            _TaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();

            this.Title = "UI Running on Thread " + Thread.CurrentThread.ManagedThreadId +
                         " | Process " + Process.GetCurrentProcess().Id.ToString();
        }
        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();
            }
        }
Esempio n. 24
0
        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();

            }
        }
        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();
            }
        }
Esempio n. 26
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(zipCode.Text))
            {
                client = new GeoClient("tcpEP");
                var result = client.GetZipcodeInfo(zipCode.Text);
                if (result != null)
                {
                    lblCity.Content  = result.City;
                    lblState.Content = result.State;
                }

                //client.Close();
            }
        }
Esempio n. 27
0
        public MainWindow()
        {
            InitializeComponent();

            //This string sent to GeoClient constructor will define which configuration will be used. Very flexible. Check App.Config.
            //This call, in the way it's configured, will only work with WindowsHost. For WebHost, use webEP.
            _Proxy = new GeoClient("tcpEP");

            //Sleeping to have the chance to click Start Service on WindowsHost.
            Thread.Sleep(3000);
            _Proxy.Open();

            _ProxyStateful = new StatefulGeoClient();
            _SyncContext   = SynchronizationContext.Current;
        }
Esempio n. 28
0
        private async void btnUpdateBatch_Click(object sender, RoutedEventArgs e)
        {
            var 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();

            //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);
            //    }
            //});

            GeoClient  proxy = new GeoClient(new InstanceContext(this), "tcpEP");
            Task <int> task  = proxy.UpdateZipCityAsync(cityZipList);

            task.ContinueWith(x =>
            {
                MessageBox.Show(string.Format("Service returned {0} items.", x.Result));
            });

            MessageBox.Show("Call made.");
        }
        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();
            }
        }
        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();
        }
Esempio n. 31
0
        public async Task QueryStringParameters()
        {
            //// Arrange
            var geoClient = new GeoClient(new HttpClient())
            {
                BaseUrl = "http://localhost:13452"
            };

            //// Act
            var result = await geoClient.ReverseAsync(new string[] { "foo", "bar" });

            //// Assert
            Assert.AreEqual(2, result.Result.Count);
            Assert.AreEqual("foo", result.Result[1]);
            Assert.AreEqual("bar", result.Result[0]);
        }
Esempio n. 32
0
        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 btnGetInfo_Click(object sender, RoutedEventArgs e)
        {
            if (txtZipCode.Text != "")
            {
                GeoClient proxy = new GeoClient("GeoLibRouter");

                ZipCodeData data = proxy.GetZipInfo(txtZipCode.Text);
                if (data != null)
                {
                    lblCity.Content  = data.City;
                    lblState.Content = data.State;
                }

                proxy.Close();
            }
        }
Esempio n. 34
0
        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();
        }
Esempio n. 35
0
        public async Task FileDownload()
        {
            //// Arrange
            var geoClient = new GeoClient(new HttpClient())
            {
                BaseUrl = "http://localhost:13452"
            };

            //// Act
            using (var response = await geoClient.GetUploadedFileAsync(1, true))
            {
                //// Assert
                Assert.AreEqual(1, response.Stream.ReadByte());
                Assert.AreEqual(2, response.Stream.ReadByte());
                Assert.AreEqual(3, response.Stream.ReadByte());
            }
        }
        private void BtnGetZipCodes_OnClick(object sender, RoutedEventArgs e)
        {
            if (txtState != null)
            {
                EndpointAddress address = new EndpointAddress("net.tcp://localhost:8009/GeoService");
                Binding binding = new NetTcpBinding();

                GeoClient proxy = new GeoClient(binding, address);

                var datas = proxy.GetZips(txtState.Text);

                if (datas != null)
                {
                    lstZips.ItemsSource = datas;
                }
            }
        }
Esempio n. 37
0
        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();
            }
        }
Esempio n. 38
0
        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();
        }
Esempio n. 39
0
        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 (txtState.Text != null)
            {
                //GeoClient proxy = new GeoClient();
                //IGeoService proxy = CreateProxy();
                GeoClient proxy = new GeoClient("dynamicGeoService");

                IEnumerable <ZipCodeData> data = proxy.GetZips(txtState.Text);
                if (data != null)
                {
                    lstZips.ItemsSource = data;
                }

                ((IDisposable)proxy).Dispose();
                //proxy.Close();
            }
        }
        private void btnGetZipCodes_Click(object sender, RoutedEventArgs e)
        {
            if (txtState.Text == "") return;

            EndpointAddress address = new EndpointAddress("net.tcp://localhost:8009/GeoService");
            NetTcpBinding binding = new NetTcpBinding();
            binding.MaxReceivedMessageSize = 2097152;

            using (GeoClient client = new GeoClient(binding, address))
            {
                IEnumerable<ZipCodeData> data = client.GetZips(txtState.Text);

                if (data == null) return;

                lstZips.ItemsSource = data;

            }
        }
        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();
        }
Esempio n. 43
0
        public async Task SaveItems()
        {
            //// Arrange
            var geoClient = new GeoClient { BaseUrl = "http://localhost:13452" };

            //// Act
            try
            {
                await geoClient.SaveItemsAsync(null);

                //// Assert
                Assert.Fail();
            }
            catch (GeoClientException exception)
            {
                Assert.IsTrue(exception.InnerException is ArgumentException);
                Assert.IsTrue(exception.InnerException.StackTrace.Contains("NSwag.Integration.WebAPI.Controllers.GeoController.SaveItems"));
            }
        }
Esempio n. 44
0
        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();
            }
        }
Esempio n. 45
0
        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 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 async 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" }
            };

            lstZips2.Items.Clear();
            //await Task.Run(() =>
            //{

            //    try
            //    {
            //        GeoClient proxy = new GeoClient(new InstanceContext(this), "tcpEp");

            //        proxy.UpdateZipCity(cityZipList);

            //        proxy.Close();

            //        MessageBox.Show("Updated.");
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show("Error: " + ex.Message);
            //    }
            //});
            GeoClient proxy = new GeoClient(new InstanceContext(this), "tcpEp");

            Task<int> task = proxy.UpdateZipCityAsync(cityZipList);

            task.ContinueWith(result =>
            {
                MessageBox.Show(string.Format("Updated {0} items.", result.Result));
            });
           // MessageBox.Show("Call made");

        }
Esempio n. 48
0
        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();
            }
        }