Exemplo n.º 1
0
        /// <summary>
        /// Imports source metadata from template/database
        /// </summary>
        /// <param name="dataPrefix"></param>
        /// <param name="sourceDBConnection"></param>
        /// <param name="sourceDBQueries"></param>
        /// <param name="selectedNIDs"></param>
        /// <param name="selectionCount"></param>
        /// <param name="metadataType"></param>
        public void ImportSourceMetadata(string dataPrefix, DIConnection sourceDBConnection, DIQueries sourceDBQueries, string selectedNIDs, int selectionCount, MetaDataType metadataType)
        {
            DataTable TempDataTable;
            ICType    ClassificationType;
            int       CurrentRecordIndex = 0;
            int       SrcElementNid;
            int       TrgElementNid;
            DI7MetadataCategoryBuilder SourceMetadataCategoryBuilder;

            SourceBuilder ICBuilder;

            try
            {
                this.RaiseStartProcessEvent();


                ICBuilder = new SourceBuilder(this.DBConnection, this.DBQueries);

                // import source categories
                SourceMetadataCategoryBuilder = new DI7MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                SourceMetadataCategoryBuilder.ImportAllMetadataCategories(sourceDBConnection, sourceDBQueries, MetadataElementType.Source);


                ClassificationType = ICType.Source;
                if (selectionCount == -1)
                {
                    // -- GET ALL
                    TempDataTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.IndicatorClassification.GetIC(FilterFieldType.None, string.Empty, ClassificationType, FieldSelection.Heavy));
                }
                else
                {
                    // -- GET SELECTED
                    TempDataTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, selectedNIDs, ClassificationType, FieldSelection.Heavy));
                }



                ////// -- Initialize Progress Bar
                this.RaiseBeforeProcessEvent(TempDataTable.Rows.Count);
                CurrentRecordIndex = 0;

                foreach (DataRow Row in TempDataTable.Rows)
                {
                    CurrentRecordIndex++;
                    SrcElementNid = Convert.ToInt32(Row[IndicatorClassifications.ICNId]);
                    TrgElementNid = ICBuilder.CheckSourceExists(Convert.ToString(Row[IndicatorClassifications.ICName]));

                    // import source metadadta
                    if (TrgElementNid > 0)
                    {
                        this.ImportMetadata(sourceDBConnection, sourceDBQueries, SrcElementNid, TrgElementNid, MetadataElementType.Source, MetaDataType.Source, IconElementType.MetadataSource);
                    }

                    ////// -- Increemnt the Progress Bar Value
                    this.RaiseProcessInfoEvent(CurrentRecordIndex);
                }
                // -- Dispose the Data Table object
                TempDataTable.Dispose();
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Imports source metadata from template/database
        /// </summary>
        /// <param name="dataPrefix"></param>
        /// <param name="sourceDBConnection"></param>
        /// <param name="sourceDBQueries"></param>
        /// <param name="selectedNIDs"></param>
        /// <param name="selectionCount"></param>
        /// <param name="metadataType"></param>
        public void ImportSourceMetadata(string dataPrefix, DIConnection sourceDBConnection, DIQueries sourceDBQueries, string selectedNIDs, int selectionCount, MetaDataType metadataType)
        {
            DataTable TempDataTable;
            ICType ClassificationType;
            int CurrentRecordIndex = 0;
            int SrcElementNid;
            int TrgElementNid;
            DI7MetadataCategoryBuilder SourceMetadataCategoryBuilder;

            SourceBuilder ICBuilder;

            try
            {
                this.RaiseStartProcessEvent();

                ICBuilder = new SourceBuilder(this.DBConnection, this.DBQueries);

                // import source categories
                SourceMetadataCategoryBuilder = new DI7MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                SourceMetadataCategoryBuilder.ImportAllMetadataCategories(sourceDBConnection, sourceDBQueries, MetadataElementType.Source);

                ClassificationType = ICType.Source;
                if (selectionCount == -1)
                {
                    // -- GET ALL
                    TempDataTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.IndicatorClassification.GetIC(FilterFieldType.None, string.Empty, ClassificationType, FieldSelection.Heavy));
                }
                else
                {
                    // -- GET SELECTED
                    TempDataTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, selectedNIDs, ClassificationType, FieldSelection.Heavy));
                }

                ////// -- Initialize Progress Bar
                this.RaiseBeforeProcessEvent(TempDataTable.Rows.Count);
                CurrentRecordIndex = 0;

                foreach (DataRow Row in TempDataTable.Rows)
                {
                    CurrentRecordIndex++;
                    SrcElementNid = Convert.ToInt32(Row[IndicatorClassifications.ICNId]);
                    TrgElementNid = ICBuilder.CheckSourceExists(Convert.ToString(Row[IndicatorClassifications.ICName]));

                    // import source metadadta
                    if (TrgElementNid > 0)
                    {
                        this.ImportMetadata(sourceDBConnection, sourceDBQueries, SrcElementNid, TrgElementNid, MetadataElementType.Source, MetaDataType.Source, IconElementType.MetadataSource);

                    }

                    ////// -- Increemnt the Progress Bar Value
                    this.RaiseProcessInfoEvent(CurrentRecordIndex);

                }
                // -- Dispose the Data Table object
                TempDataTable.Dispose();
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }