Exemplo n.º 1
0
        /// <summary>
        /// Imports records from source database to target database/template
        /// </summary>
        /// <param name="selectedNids"></param>
        /// <param name="allSelected">Set true to import all records</param>
        public override void ImportValues(List<string> SelectedNids, bool allSelected)
        {
            AreaBuilder AreaBuilderObj = new AreaBuilder(this._TargetDBConnection, this._TargetDBQueries);
            DI7MetadataCategoryBuilder AreaMetadataCategoryBuilder = null;
            int SelectedCount = SelectedNids.Count;

            try
            {

                // 1. import all area metadata categories
                if (this.IncludeMap)
                {
                    AreaMetadataCategoryBuilder = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
                    AreaMetadataCategoryBuilder.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, MetadataElementType.Area);
                }

                // 2. add event handlers
                AreaBuilderObj.ProcessInfo += new ProcessInfoDelegate(AreaBuilderObj_ProcessInfo);
                AreaBuilderObj.BeforeProcess += new ProcessInfoDelegate(AreaBuilderObj_BeforeProcess);

                // 3. updated selected count variable
                if (allSelected)
                    SelectedCount = -1;

                // 4. import selected areas
                if (this.IncludeArea & this.IncludeMap)
                {
                    // import area and maps

                    AreaBuilderObj.ImportArea(string.Join(",", SelectedNids.ToArray()), SelectedCount, this.SourceDBConnection, this.SourceDBQueries, this.SelectedAreaLevel, true);
                }
                else if (this.IncludeArea)
                {
                    // import area
                    AreaBuilderObj.ImportArea(string.Join(",", SelectedNids.ToArray()), SelectedCount, this.SourceDBConnection, this.SourceDBQueries, this.SelectedAreaLevel);
                }
                else if (this.IncludeMap)
                {
                    // import area maps
                    AreaBuilderObj.ImportAreaMaps(string.Join(",", SelectedNids.ToArray()), SelectedCount, this.SourceDBConnection, this.SourceDBQueries, this.SelectedAreaLevel);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }