コード例 #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();
            }
        }
コード例 #2
0
            /// <summary>
            /// Creates a new instance of the <c>ProcessParams</c> class.
            /// </summary>
            /// <param name="profile">Import profile to importing.</param>
            /// <param name="defaultDate">Default date for default initialize imported objects.</param>
            /// <param name="dataProvider">Data provider.</param>
            /// <param name="cancelChecker">Cancellation checker.</param>
            /// <param name="informer">Progress informer.</param>
            public ProcessParams(ImportProfile profile,
                                 DateTime defaultDate,
                                 IDataProvider dataProvider,
                                 ICancellationChecker cancelChecker,
                                 IProgressInformer informer)
            {
                Debug.Assert(null != profile);       // created
                Debug.Assert(null != dataProvider);  // creatde
                Debug.Assert(null != cancelChecker); // created
                Debug.Assert(null != informer);      // created

                Profile       = profile;
                DefaultDate   = defaultDate;
                DataProvider  = dataProvider;
                CancelChecker = cancelChecker;
                Informer      = informer;
            }
コード例 #3
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();
        }
コード例 #4
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Geocodes objects
        /// </summary>
        /// <param name="objects">Objects to geocoding.</param>
        /// <param name="type">Geocoding type.</param>
        /// <param name="checker">Cancellation checker.</param>
        public void Geocode(IList <AppData.DataObject> objects,
                            GeocodeType type,
                            ICancellationChecker checker)
        {
            Debug.Assert(null != objects);                    // created
            Debug.Assert(0 < objects.Count);                  // not empty
            Debug.Assert(null != _GetGeocodable(objects[0])); // valid call
            Debug.Assert(null != checker);                    // created

            // reset internal state first
            _detectedException = null;
            _geocodedCount     = 0;
            _details.Clear();

            // store checker
            _checker = checker;

            // start geocode
            _Geocode(objects, type);
        }
コード例 #5
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Importes objects from source.
        /// </summary>
        /// <param name="profile">Import source settings.</param>
        /// <param name="provider">Data provider.</param>
        /// <param name="defaultDate">Default date for default initialize imported objects.</param>
        /// <param name="projectData">Project data.</param>
        /// <param name="checker">Cancellation checker.</param>
        public void Import(ImportProfile profile,
                           IDataProvider provider,
                           DateTime defaultDate,
                           IProjectDataContext projectData,
                           ICancellationChecker checker)
        {
            Debug.Assert(null != profile);     // created
            Debug.Assert(null != provider);    // created
            Debug.Assert(null != projectData); // created
            Debug.Assert(null != checker);     // created

            // reset internal state first
            _Reset();

            // store contects
            _profile     = profile;
            _provider    = provider;
            _defaultDate = defaultDate;
            _projectData = projectData;

            // start process
            _Import(checker);
        }
コード例 #6
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Geocodes objects
        /// </summary>
        /// <param name="objects">Objects to geocoding.</param>
        /// <param name="type">Geocoding type.</param>
        /// <param name="checker">Cancellation checker.</param>
        public void Geocode(IList<AppData.DataObject> objects,
                            GeocodeType type,
                            ICancellationChecker checker)
        {
            Debug.Assert(null != objects); // created
            Debug.Assert(0 < objects.Count); // not empty
            Debug.Assert(null != _GetGeocodable(objects[0])); // valid call
            Debug.Assert(null != checker); // created

            // reset internal state first
            _detectedException = null;
            _geocodedCount = 0;
            _details.Clear();

            // store checker
            _checker = checker;

            // start geocode
            _Geocode(objects, type);
        }
コード例 #7
0
            /// <summary>
            /// Creates a new instance of the <c>ProcessParams</c> class.
            /// </summary>
            /// <param name="profile">Import profile to importing.</param>
            /// <param name="defaultDate">Default date for default initialize imported objects.</param>
            /// <param name="dataProvider">Data provider.</param>
            /// <param name="cancelChecker">Cancellation checker.</param>
            /// <param name="informer">Progress informer.</param>
            public ProcessParams(ImportProfile profile,
                                 DateTime defaultDate,
                                 IDataProvider dataProvider,
                                 ICancellationChecker cancelChecker,
                                 IProgressInformer informer)
            {
                Debug.Assert(null != profile); // created
                Debug.Assert(null != dataProvider); // creatde
                Debug.Assert(null != cancelChecker); // created
                Debug.Assert(null != informer); // created

                Profile = profile;
                DefaultDate = defaultDate;
                DataProvider = dataProvider;
                CancelChecker = cancelChecker;
                Informer = informer;
            }