Ejemplo n.º 1
0
        /// <summary>
        /// Worker completed event handler.
        /// Parses results.
        /// </summary>
        /// <param name="sender">Background worker.</param>
        /// <param name="e">Run worker completed event arguments.</param>
        private void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var bw = sender as BackgroundWorker;

            Debug.Assert(null != bw); // supported object

            // stop events
            bw.DoWork             -= _worker_DoWork;
            bw.ProgressChanged    -= _worker_ProgressChanged;
            bw.RunWorkerCompleted -= _worker_RunWorkerCompleted;

            // free resources
            bw.Dispose();
            _worker = null;

            // parse operation results
            Storage storage = _ParseResults(e.Error, e.Cancelled);

            // fire import completed
            if (null != ImportCompleted)
            {
                Debug.Assert(null != storage); // inited
                var events = new ImportCompletedEventArgs(storage.UpdatedObjects, e.Cancelled);
                ImportCompleted(this, events);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Worker completed event handler.
        /// Parses results.
        /// </summary>
        /// <param name="sender">Background worker.</param>
        /// <param name="e">Run worker completed event arguments.</param>
        private void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var bw = sender as BackgroundWorker;
            Debug.Assert(null != bw); // supported object

            // stop events
            bw.DoWork -= _worker_DoWork;
            bw.ProgressChanged -= _worker_ProgressChanged;
            bw.RunWorkerCompleted -= _worker_RunWorkerCompleted;

            // free resources
            bw.Dispose();
            _worker = null;

            // parse operation results
            Storage storage = _ParseResults(e.Error, e.Cancelled);

            // fire import completed
            if (null != ImportCompleted)
            {
                Debug.Assert(null != storage); // inited
                var events = new ImportCompletedEventArgs(storage.UpdatedObjects, e.Cancelled);
                ImportCompleted(this, events);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// React on import completed.
        /// </summary>
        /// <param name="sender">Importer.</param>
        /// <param name="e">Ignored.</param>
        private void _ImportCompleted(object sender, ImportCompletedEventArgs e)
        {
            var manager = sender as ImportManager;
            Debug.Assert(manager != null);
            manager.ImportCompleted -= _ImportCompleted;
            manager.Dispose();

            // Special logic for Optimize and edit page.
            if (ParentPage is AppPages.OptimizeAndEditPage)
            {
                // Get ungeocoded orders collection.
                var ungeocodedOrders = new List<Order>();
                foreach (Order order in e.ImportedObjects)
                {
                    if (!order.IsGeocoded)
                    {
                        Debug.Assert(!ungeocodedOrders.Contains(order));
                        ungeocodedOrders.Add(order);
                    }
                }

                // If at least one ungeocoded order present on current day -
                // show ungeocoded orders page.
                if (ungeocodedOrders.Count > 0)
                {
                    var ordersPage =
                        new FleetSetupWizardUngeocodedOrdersPage(ungeocodedOrders);

                    // React on page load and unload.
                    ordersPage.Loaded +=
                        new RoutedEventHandler(_UngeocodedOrdersPageLoaded);
                    ordersPage.Unloaded +=
                        new RoutedEventHandler(_UngeocodedOrdersPageUnloaded);

                    ordersPage.NextRequired += new EventHandler(_OrdersPageNextRequired);
                    // Show orders geocoding page.
                    App.Current.MainWindow.PageFrame.Navigate(ordersPage);
                }
            }
        }