Ejemplo n.º 1
0
        private void run()
        {
            var client = new Model.WDSFAPI_Client(_context);

            client.ProgressChanged += new Model.ProgressChangedEvent(ProgressChanged);

            try
            {
                client.DownloadCouples(AppSettings.Default.API_User,
                                       AppSettings.Default.API_Password,
                                       AppSettings.Default.API_ProductionSystem);
            }
            catch (Wdsf.Api.Client.Exceptions.ApiException ex)
            {
                if (ex.InnerException.GetType() == typeof(System.Threading.ThreadAbortException))
                {
                    client.Abort();
                }
                else
                {
                    MessageBox.Show("Could not download couples, please check the internet connection (Message: " + ex.Message + " - " + (ex.InnerException != null ? ex.InnerException.Message : "") + ")", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                return;
            }

            // Now we save this data
            _context.SaveWDSFCouples(AppSettings.Default.CoupleFile);

            // we are done ... exit
            this.Dispatcher.Invoke(new System.Threading.ThreadStart(delegate()
            {
                this.Close();
                MessageBox.Show("Downloaded all couples from WDSF.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                this.OnComplete(this, new EventArgs());
            }));
        }