Пример #1
0
        private void btnPutBack_Click(object sender, RoutedEventArgs e)
        {
            List <ZipCityData> cityZipList = new List <ZipCityData>()
            {
                new ZipCityData()
                {
                    ZipCode = "07035", City = "Linkoln Park"
                },
                new ZipCityData()
                {
                    ZipCode = "33030", City = "Homestead"
                },
                new ZipCityData()
                {
                    ZipCode = "90210", City = "Beverly Hills"
                },
                new ZipCityData()
                {
                    ZipCode = "07094", City = "Secaucus"
                }
            };

            lstUpdates.Items.Clear();

            Task.Run(() =>
            {
                try
                {
                    GeoAdminClient proxy = new GeoAdminClient(new InstanceContext(this), "tcpEP");
                    int updated          = proxy.UpdateZipCity(cityZipList);
                    proxy.Close();
                    MessageBox.Show($"Updated {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 =>
            //{
            //    if (result.Exception == null)
            //        MessageBox.Show($"Updated {result.Result}");
            //    else
            //    {
            //        //MessageBox.Show("Error: " + result.Exception.Message + "\n\r" + result.Exception.InnerException.Message);
            //        try
            //        {
            //            throw result.Exception.InnerException;
            //        }
            //        catch (Exception ex)
            //        {
            //            MessageBox.Show("Error: " + ex.Message);
            //        }
            //    }
            //});
        }
Пример #2
0
        static void Main(string[] args)
        {
            System.Console.Write("Enter Zip code:");
            var zip = System.Console.ReadLine();

            System.Console.Write("Enter old state abbrivation:");
            var oldstate = System.Console.ReadLine();

            System.Console.Write("Enter new state abbrivation:");
            var newstate = System.Console.ReadLine();

            GeoClient proxy = new GeoClient();

            try
            {
                var result      = proxy.GetStates(true);
                var zipsByState = proxy.GetZips(new ZipCode()
                {
                    County = "India"
                }, 1);

                var zipcodeByInfo = proxy.GetZipInfo(zip);

                GeoAdminClient adminClient = new GeoAdminClient();
                adminClient.ClientCredentials.UserName.UserName = "******";
                adminClient.ClientCredentials.UserName.Password = "******";

                adminClient.UpdateState(oldstate, newstate);
                //  var allZipCodes = proxy.GetZips(new ZipCode() { }, 1);
                System.Console.Write("State:");
                System.Console.WriteLine(null != zipcodeByInfo.State ? zipcodeByInfo.State.Name : string.Empty);
                System.Console.Write("City:");
                System.Console.WriteLine(null != zipcodeByInfo.City ? zipcodeByInfo.City : string.Empty);
            }
            finally
            {
                //  proxy.Close();
            }

            System.Console.ReadLine();
        }
        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"
                }
            };

            GeoAdminClient proxy = new GeoAdminClient(new InstanceContext(this));

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

            task.ContinueWith(result =>
            {
                if (result.Exception == null)
                {
                    MessageBox.Show(string.Format("Updated {0} items.", result.Result));
                }
                else
                {
                    try
                    {
                        throw result.Exception.InnerException;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: " + ex.Message);
                    }
                }
            });
        }
        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"
                }
            };

            GeoAdminClient proxy = new GeoAdminClient(new InstanceContext(this));

            Task task = proxy.UpdateZipCityAsync(cityZipList);

            task.ContinueWith(result =>
            {
                if (result.Exception == null)
                {
                    MessageBox.Show("Updated.");
                }
                else
                {
                    try
                    {
                        throw result.Exception.InnerException;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: " + ex.Message);
                    }
                }
            });
        }
Пример #5
0
        private async 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"
                }
            };

            lstZips2.Items.Clear();
            await Task.Run(() =>
            {
                try
                {
                    GeoAdminClient proxy = new GeoAdminClient("tcpAdmin");

                    //proxy.ClientCredentials.Windows.ClientCredential.UserName = "******";
                    //proxy.ClientCredentials.Windows.ClientCredential.Password = "******";

                    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 =>
            //{
            //    if (result.Exception == null)
            //    {
            //        MessageBox.Show(string.Format("Updated {0} items.", result.Result));
            //    }
            //    else
            //    {
            //        MessageBox.Show("error: "+result.Exception.Message+"\n\r"+result.Exception.InnerException.Message);

            //    }
            //});
            //MessageBox.Show("Call made");
        }
        private async 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" }
            };

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

                 try
                 {
                     GeoAdminClient proxy = new GeoAdminClient("tcpAdmin");

                     //proxy.ClientCredentials.Windows.ClientCredential.UserName = "******";
                     //proxy.ClientCredentials.Windows.ClientCredential.Password = "******";

                     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 =>
            //{
            //    if (result.Exception == null)
            //    {
            //        MessageBox.Show(string.Format("Updated {0} items.", result.Result));
            //    }
            //    else
            //    {
            //        MessageBox.Show("error: "+result.Exception.Message+"\n\r"+result.Exception.InnerException.Message);

            //    }
            //});
            //MessageBox.Show("Call made");


        }
Пример #7
0
        private void btnUpdateBatch_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"
                },
                new ZipCityData()
                {
                    ZipCode = "90210", City = "Alderan"
                },
                new ZipCityData()
                {
                    ZipCode = "07094", City = "Storybrooke"
                }
            };

            lstUpdates.Items.Clear();

            Task.Run(() =>
            {
                try
                {
                    GeoAdminClient proxy = new GeoAdminClient(new InstanceContext(this), "tcpEP");

                    //proxy.ClientCredentials.Windows.ClientCredential.UserName = "******";
                    //proxy.ClientCredentials.Windows.ClientCredential.Password = "******";

                    int updated = 0;
                    using (TransactionScope scope = new TransactionScope())
                    {
                        updated = proxy.UpdateZipCity(cityZipList);
                        proxy.Close();
                        //throw new ApplicationException("uh oh");
                        scope.Complete();
                    }
                    MessageBox.Show($"Updated {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 =>
            //{
            //    if (result.Exception == null)
            //        MessageBox.Show($"Updated {result.Result}");
            //    else
            //    {
            //        //MessageBox.Show("Error: " + result.Exception.Message + "\n\r" + result.Exception.InnerException.Message);
            //        try
            //        {
            //            throw result.Exception.InnerException;
            //        }
            //        catch (Exception ex)
            //        {
            //            MessageBox.Show("Error: " + ex.Message);
            //        }
            //    }
            //});

            //MessageBox.Show("Call made");
        }