コード例 #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
        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");
        }
コード例 #3
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");


        }
コード例 #4
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");
        }