コード例 #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)
        {
            DataRow       Row;
            SourceInfo    SourceRecord     = null;
            SourceBuilder SourceBuilderObj = null;
            DI7MetadataCategoryBuilder SourceMetadataCategoryBuilder = null;
            int ProgressBarValue = 0;

            try
            {
                // import source metadata categories from source dadtabase
                SourceMetadataCategoryBuilder = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
                SourceMetadataCategoryBuilder.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, MetadataElementType.Source);

                //import selected sources
                foreach (string Nid in selectedNids)
                {
                    try
                    {
                        Row = this.SourceTable.Select(this.TagValueColumnName + "=" + Nid)[0];

                        //import indicator
                        SourceRecord        = new SourceInfo();
                        SourceRecord.Name   = Row[IndicatorClassifications.ICName].ToString();
                        SourceRecord.Info   = Row[IndicatorClassifications.ICInfo].ToString();
                        SourceRecord.ISBN   = Row[IndicatorClassifications.ISBN].ToString();
                        SourceRecord.Nature = Row[IndicatorClassifications.Nature].ToString();

                        SourceBuilderObj = new SourceBuilder(this._TargetDBConnection, this._TargetDBQueries);
                        SourceBuilderObj.ImportSource(SourceRecord, Convert.ToInt32(Nid), this.SourceDBQueries, this.SourceDBConnection);
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException(ex.ToString());
                    }

                    this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                    ProgressBarValue++;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.ExceptionFacade.ThrowException(ex);
            }
        }