Ejemplo n.º 1
0
        /// <summary>
        /// Starts import process.
        /// </summary>
        /// <param name="checker">Cancellation checker.</param>
        private void _Import(ICancellationChecker checker)
        {
            Debug.Assert(null != _profile);  // inited
            Debug.Assert(null != _provider); // inited
            Debug.Assert(null != checker);   // created

            // store records count
            _readCount = _GetNotEmptyRecordNumber();

            Dictionary <string, int> references =
                PropertyHelpers.CreateImportMap(_profile.Settings.FieldsMap, _provider);

            // read source
            _provider.MoveFirst();

            int index = 0;

            while (!_provider.IsEnd())
            {   // do import process
                checker.ThrowIfCancellationRequested();

                if (!_provider.IsRecordEmpty)
                {
                    _ImportObject(references, index);

                    ++index;
                }

                _provider.MoveNext();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Import procedure.
        /// </summary>
        /// <param name="parameters">Process parameters.</param>
        private void _Import(ProcessParams parameters)
        {
            Debug.Assert(null != _informer);  // inited
            Debug.Assert(null != parameters); // created

            ImportProfile        profile       = parameters.Profile;
            ICancellationChecker cancelChecker = parameters.CancelChecker;

            // do import operation from source
            var projectData = new ProjectDataContext(App.Current.Project);

            _importer.Import(profile,
                             parameters.DataProvider,
                             parameters.DefaultDate,
                             projectData,
                             cancelChecker);

            cancelChecker.ThrowIfCancellationRequested();

            IList <AppData.DataObject> importedObjects = _importer.ImportedObjects;

            // do geocode imported objects
            if ((null != _geocoder) &&
                (0 < importedObjects.Count))
            {
                Geocoder.GeocodeType type = _GetGeocodeType(profile.Settings);
                _geocoder.Geocode(importedObjects, type, cancelChecker);
            }

            _AddObjectsToFeatureServiceIfNeeded(importedObjects);

            cancelChecker.ThrowIfCancellationRequested();

            // commit additions of related objects
            _informer.ParentPage.Dispatcher.BeginInvoke(new Action(() =>
            {
                projectData.Commit();
                projectData.Dispose();
            }), System.Windows.Threading.DispatcherPriority.Send);

            cancelChecker.ThrowIfCancellationRequested();
        }