コード例 #1
0
        //private int ImportIndicator(DataRow row)
        //{
        //    int RetVal = -1;

        //    IndicatorInfo IndicatorRecord;
        //    IndicatorBuilder IndicatorBuilderObj;

        //    IndicatorRecord = this.GetIndicatorInfo(row);
        //    IndicatorBuilderObj = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    RetVal = IndicatorBuilderObj.ImportIndicator(IndicatorRecord, IndicatorRecord.Nid, this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private int ImportUnit(DataRow row)
        //{
        //    int RetVal = -1;

        //    UnitInfo UnitRecord;
        //    UnitBuilder UnitBuilderObj;

        //    UnitRecord = this.GetUnitInfo(row);

        //    UnitBuilderObj = new UnitBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    RetVal = UnitBuilderObj.ImportUnit(UnitRecord, UnitRecord.Nid, this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private int ImportSubgroupVal(DataRow row)
        //{
        //    int RetVal = -1;

        //    DI6SubgroupValBuilder SubgroupValBuilderObj = new DI6SubgroupValBuilder(this._TargetDBConnection, this._TargetDBQueries);

        //    //import into target database
        //    RetVal = SubgroupValBuilderObj.ImportSubgroupVal(Convert.ToInt32(row[SubgroupVals.SubgroupValNId]), this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private void ImportIUS(List<string> selectedNids, bool allSelected)
        //{
        //    int ProgressBarValue = 1;
        //    int IndicatorNId = -1;
        //    int UnitNId = -1;
        //    int SGValNId = -1;
        //    int MinValue=0;
        //    int MaxValue=0;

        //    DataRow[] Rows;
        //    DataTable TempTable;

        //    List<string> ImportedIndicatorNIDs = new List<string>();
        //    List<string> ImportedUnitNIDs = new List<string>();
        //    List<string> ImportedSGNIDs = new List<string>();

        //    IUSBuilder IusBuilderObj ;

        //    if (this.ShowIUS)
        //    {
        //        // Get selected rows
        //        if (allSelected)
        //        {
        //            Rows = this.SourceTable.Select("1=1");
        //        }
        //        else
        //        {
        //            Rows = this.SourceTable.Select(this.TagValueColumnName + " IN ( " + string.Join(",", selectedNids.ToArray()) + ")");
        //        }

        //        foreach (DataRow Row in Rows)
        //        {
        //            try
        //            {
        //                //import Indicator
        //                IndicatorNId = Convert.ToInt32(Row[Indicator.IndicatorNId]);
        //                if (!ImportedIndicatorNIDs.Contains(IndicatorNId.ToString()))
        //                {
        //                    ImportedIndicatorNIDs.Add(IndicatorNId.ToString());
        //                    IndicatorNId = this.ImportIndicator(Row);
        //                }


        //                    // import unit
        //                UnitNId = Convert.ToInt32(Row[Unit.UnitNId]);
        //                if (!ImportedIndicatorNIDs.Contains(UnitNId.ToString()))
        //                {
        //                   ImportedUnitNIDs.Add(UnitNId.ToString());
        //                    UnitNId =  this.ImportUnit(Row);
        //                }

        //                // import subgroupval
        //                SGValNId=Convert.ToInt32(Row[SubgroupVals.SubgroupValNId]);
        //                if (!ImportedSGNIDs.Contains(SGValNId.ToString()))
        //                {
        //                    ImportedSGNIDs.Add(SGValNId.ToString());
        //                    SGValNId = this.ImportSubgroupVal(Row);
        //                }

        //                //import IUS
        //                if (IndicatorNId > 0 && UnitNId > 0 && SGValNId > 0)
        //                {
        //                    //if(Convert.ToString(Row[Indicator_Unit_Subgroup.MaxValue]).Length>0)
        //                    //{
        //                    //MaxValue=   Convert.ToInt32(Row[Indicator_Unit_Subgroup.MaxValue]);
        //                    //}
        //                    //else
        //                    //{
        //                    //    MaxValue=0;
        //                    //}

        //                    //if(Convert.ToString(Row[Indicator_Unit_Subgroup.MinValue]).Length>0)
        //                    //{
        //                    //    MinValue= Convert.ToInt32(Row[Indicator_Unit_Subgroup.MinValue]);
        //                    //}
        //                    //else
        //                    //{
        //                    //    MinValue=0;
        //                    //}


        //                    IusBuilderObj = new IUSBuilder( this._TargetDBConnection, this._TargetDBQueries);

        //                    IusBuilderObj.ImportIUS(IndicatorNId, UnitNId, SGValNId,                                                    MinValue, MaxValue , this.SourceDBQueries, this.SourceDBConnection);

        //                }

        //                if (this.ShowSector)
        //                {
        //                    this.ImportSector(Row);
        //                }
        //            }
        //            catch (Exception)
        //            {

        //                throw;
        //            }
        //            this.RaiseIncrementProgessBarEvent(ProgressBarValue);
        //            ProgressBarValue++;
        //        }
        //    }
        //}

        /// <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;
            IndicatorInfo              IndicatorRecord            = null;
            IndicatorBuilder           IndicatorBuilderObj        = null;
            DI7MetadataCategoryBuilder MetadataCategoryBuilderObj = null;
            int ProgressBarValue = 1;

            // import indicator metadata categories
            MetadataCategoryBuilderObj = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
            MetadataCategoryBuilderObj.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, MetadataElementType.Indicator);

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

                    if (this._ShowIUS)
                    {
                        this.ImportForIUS(Row);
                    }
                    else
                    {
                        //import indicator
                        IndicatorRecord     = this.GetIndicatorInfo(Row);
                        IndicatorBuilderObj = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
                        IndicatorBuilderObj.ImportIndicator(IndicatorRecord, Convert.ToInt32(Nid), this.SourceDBQueries, this.SourceDBConnection);

                        if (this._ShowSector)
                        {
                            this.ImportSector(Row);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                ProgressBarValue++;
            }


            if (this._ShowIUS && this._ShowSector)
            {
                this.ImportSectors(selectedNids, allSelected);
            }
        }
コード例 #2
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());
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
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)
        {
            int SelectedCount;

            try
            {
                DI7MetadataCategoryBuilder TargetMetaData     = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
                DI7MetadataCategoryBuilder SrcMetaDataBuilder = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
                if (this.InputFileType != DataSourceType.Database && this.InputFileType != DataSourceType.Template)
                {
                    // Import data from xml or rtf file
                    this.RaiseInitializeProgessBarEvent(1);
                    //if (this.InputFileType == DataSourceType.SDMXWebService)
                    //{
                    // import from database
                    TargetMetaData.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, this.MDElementType);

                    //}
                    this.RaiseIncrementProgessBarEvent(1);
                }
                else
                {
                    //TargetMetaData.ProcessInfo += new ProcessInfoDelegate(MetaData_ProcessInfo);
                    //TargetMetaData.BeforeProcess += new ProcessInfoDelegate(MetaData_BeforeProcess);
                    //improt data from database/template
                    SelectedCount = SelectedNids.Count;

                    if (allSelected)
                    {
                        TargetMetaData.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, this.MDElementType);
                    }
                    else
                    {
                        SrcMetaDataBuilder = new DI7MetadataCategoryBuilder(this.SourceDBConnection, this.SourceDBQueries);
                        foreach (string CategoryNId in SelectedNids)
                        {
                            DI7MetadataCategoryInfo MDCatInfo = SrcMetaDataBuilder.GetMedataCategoryInfo(Convert.ToInt32(CategoryNId));
                            TargetMetaData.CheckNInsertCategory(MDCatInfo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionFacade.ThrowException(ex);
            }
        }
コード例 #5
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());
            }
        }
コード例 #6
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)
        {
            int SelectedCount;
            try
            {
                DI7MetadataCategoryBuilder TargetMetaData = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
                DI7MetadataCategoryBuilder SrcMetaDataBuilder = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
                if (this.InputFileType != DataSourceType.Database && this.InputFileType != DataSourceType.Template)
                {
                    // Import data from xml or rtf file
                    this.RaiseInitializeProgessBarEvent(1);
                    //if (this.InputFileType == DataSourceType.SDMXWebService)
                    //{
                    // import from database
                    TargetMetaData.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, this.MDElementType);

                    //}
                    this.RaiseIncrementProgessBarEvent(1);
                }
                else
                {
                    //TargetMetaData.ProcessInfo += new ProcessInfoDelegate(MetaData_ProcessInfo);
                    //TargetMetaData.BeforeProcess += new ProcessInfoDelegate(MetaData_BeforeProcess);
                    //improt data from database/template
                    SelectedCount = SelectedNids.Count;

                    if (allSelected)
                    {
                        TargetMetaData.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, this.MDElementType);
                    }
                    else
                    {
                        SrcMetaDataBuilder = new DI7MetadataCategoryBuilder(this.SourceDBConnection, this.SourceDBQueries);
                        foreach (string CategoryNId in SelectedNids)
                        {
                            DI7MetadataCategoryInfo MDCatInfo = SrcMetaDataBuilder.GetMedataCategoryInfo(Convert.ToInt32(CategoryNId));
                            TargetMetaData.CheckNInsertCategory(MDCatInfo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionFacade.ThrowException(ex);
            }
        }
コード例 #7
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);
            }
        }
コード例 #8
0
        /// <summary>
        /// Load Data into excel report file
        /// </summary>
        private void LoadData(MetadataElementType elementType, int elementNID)
        {
            string    ParaNodeText             = string.Empty;
            string    ConcatenatedParaNodeText = string.Empty;
            DataTable CategoryTable            = null;
            DataTable MetadataReportTable      = null;
            string    CategoryName             = string.Empty;
            string    CategoryNid       = string.Empty;
            string    MetadataText      = string.Empty;
            string    ReplaceableSymbol = "{{~}}";
            string    CategoryGID       = string.Empty;

            try
            {
                // 1. Get category table from database where ispresentational is false
                CategoryTable = this.GetCategoryDataTable(elementType);

                // rearrange categories
                CategoryTable = DI7MetadataCategoryBuilder.RearrangeCategoryTableByCategoryOrder(CategoryTable);

                // 2. get metadata reports
                MetadataReportTable = this.GetMetadataReportsTableFrmDB(elementNID, elementType);


                // 3. Add Title
                // writes metadata values in excel report.
                this.WriteMetadataField(CategoryIndex, DILanguage.GetLanguageString("CATEGORY"), DILanguage.GetLanguageString("CATEGORY_GID"));
                //Write values to excel
                this.WriteMetadataValueToExcel(CategoryIndex, DILanguage.GetLanguageString("METADATA"));

                this.MetadataSheet.Cells[this._MetadataStartRowIndexInExl + CategoryIndex, 0, this._MetadataStartRowIndexInExl + CategoryIndex, 2].Font.Bold      = true;
                this.MetadataSheet.Cells[this._MetadataStartRowIndexInExl + CategoryIndex, 0, this._MetadataStartRowIndexInExl + CategoryIndex, 2].Interior.Color = SpreadsheetGear.Drawing.Color.FromArgb(System.Drawing.Color.LightGray.ToArgb());
                CategoryIndex++;



                //Iterate through category node
                foreach (DataRow CategoryRow in CategoryTable.Rows)
                {
                    // 4.2 get category label form table
                    CategoryName = Convert.ToString(CategoryRow[Metadata_Category.CategoryName]);
                    CategoryNid  = Convert.ToString(CategoryRow[Metadata_Category.CategoryNId]);
                    CategoryGID  = Convert.ToString(CategoryRow[Metadata_Category.CategoryGId]);

                    // writes metadata values in excel report.
                    this.WriteMetadataField(CategoryIndex, CategoryName, CategoryGID);

                    // Get metadata report from metadata report table for the  current category
                    foreach (DataRow Row in MetadataReportTable.Select(MetadataReport.CategoryNid + "=" + CategoryNid))
                    {
                        MetadataText = Convert.ToString(Row[MetadataReport.Metadata]).Replace(ReplaceableSymbol, Microsoft.VisualBasic.ControlChars.NewLine);

                        //Write values to excel
                        WriteMetadataValueToExcel(CategoryIndex, MetadataText);
                    }


                    CategoryIndex = CategoryIndex + 1;
                }
            }
            catch (Exception ex)
            { ExceptionHandler.ExceptionFacade.ThrowException(ex); }
        }
コード例 #9
0
ファイル: DIDatabase.cs プロジェクト: SDRC-India/sdrcdevinfo
        /// <summary>
        /// Compact the database mainly Access database(.mdb) and save as specified destination file.
        /// </summary>
        ///<param name="sourceDBConnection"> Source database connection</param>
        /// <param name="destFilePath">destination file name with path.</param>
        /// <param name="disposeConnection"> Set true when calling this methods for finish process otherwise false.For only saving the database, pass False and for finish , pass true.  </param>
        /// <returns>true, if success.</returns>
        /// <remarks>Before calling this function,dont dispose source database connection </remarks>
        public static bool CompactDataBase(ref DIConnection sourceDBConnection, DIQueries dbQueries, string destFilePath, bool disposeConnection)
        {
            bool RetVal = false;
            bool IsFileOpen = false;
            DIConnectionDetails SourceDBConnectionDetails;
            DBMetadataTableBuilder DBMetadataTable;
            DIDatabase DBDatabase;
            string SourceDBNameWPath;
            JRO.JetEngine je;
            string DataPrefix = string.Empty;
            DI7MetadataCategoryBuilder DI7MetadataCategory;

            // -- NOTE: USE sDestFile only when sDestFile <> sSourceDB
            try
            {
                if (sourceDBConnection != null && !string.IsNullOrEmpty(destFilePath))
                {
                    //Drop index for ut_data table for IUSNID, areanid column
                    DIDatabase.DropDefaultIndex(sourceDBConnection);

                    // update counts in DBMetadata table( only if database/template is in DI6 format)
                    if (dbQueries == null)
                    {
                        DataPrefix = sourceDBConnection.DIDataSetDefault();

                        dbQueries = new DIQueries(DataPrefix, sourceDBConnection.DILanguageCodeDefault(DataPrefix));
                    }

                    DBMetadataTable = new DBMetadataTableBuilder(sourceDBConnection, dbQueries);
                    if (DBMetadataTable.IsDBMetadataTableExists())
                    {
                        DBMetadataTable.GetNUpdateCounts();
                    }
                    //Updating XSLT from Resourse File into database.
                    DI7MetadataCategory = new DI7MetadataCategoryBuilder(sourceDBConnection, dbQueries);
                    DI7MetadataCategory.UpdateXSLT(dbQueries.DataPrefix);

                    // update database name in DB_Available table
                    sourceDBConnection.InsertNewDBFileName(dbQueries.DataPrefix, DICommon.RemoveQuotes(System.IO.Path.GetFileName(destFilePath)));

                    if (DIDatabase.SeperateDataValueColumn)
                    {
                        // Check orgTextual_Data_value exists or not. If column exists then move textual & numeric values into their respective column.
                        DIDataValueHelper.SeparateTextualandNemericData(sourceDBConnection, dbQueries);
                    }

                    // update indicator unit and subgroup nids in Data table
                    DBDatabase = new DIDatabase(sourceDBConnection, dbQueries);
                    DBDatabase.UpdateIndicatorUnitSubgroupNIDsInData();

                    // remove FootnoteNId inconsistency. (replace 0 or null FootnoteNId by -1 in UT_data table).
                    DBDatabase.RemoveFootnoteNIdsInconsistencyInData();

                    // Update auto calculated columns ( IC table - Publisher, Year & title ,Indicator table- Data_Exists, area table - data_exist, IUS table - subgroup_nids & data_exist) into the database/template
                    DBDatabase.UpdateAutoCalculatedFieldsInTables();

                    // Update auto calculated column of DI7
                    DBDatabase.UpdateAutoCalculatedDI7FieldsInTables();

                    //Update those subgroupVals which is not associated with any subgroup type.Then insert association with others for those subgroup
                    DBDatabase.UpdateSubgroupValsInOthersSGDimensionInTables();

                    //Create index for ut_data table for IUSNID, areanid column
                    DIDatabase.CreateDefaultIndex(sourceDBConnection);

                    // dispose source database connection
                    SourceDBConnectionDetails = sourceDBConnection.ConnectionStringParameters;
                    SourceDBNameWPath = SourceDBConnectionDetails.DbName;
                    sourceDBConnection.Dispose();
                    System.Threading.Thread.Sleep(10);
                    try
                    {
                        if (File.Exists(destFilePath))
                        {
                            File.SetAttributes(destFilePath, FileAttributes.Normal);
                            File.Delete(destFilePath);
                        }
                    }
                    catch { }

                    //-- Copy SourceFile to temp file so that any existing connection on database shall not stop compact database process.
                    //string TempFile = DICommon.GetValidFileName(DateTime.Now.ToString()) + Path.GetExtension(SourceDBNameWPath);
                    //File.Copy(SourceDBNameWPath, TempFile, true);

                    try
                    {
                        // compacting the database
                        je = new JRO.JetEngine();
                        je.CompactDatabase("Data Source=\"" + SourceDBNameWPath + "\";Jet OLEDB:Database Password="******"Data Source=\"" + destFilePath + "\";Jet OLEDB:Database Password="******"Database already exists"))
                            IsFileOpen = true;
                    }

                    // reconnect to source database
                    if (!disposeConnection)
                    {
                        sourceDBConnection = new DIConnection(SourceDBConnectionDetails);
                    }

                    if (IsFileOpen == false)
                        RetVal = true;
                }
            }
            catch (Exception ex)
            {
                RetVal = false;
                ExceptionFacade.ThrowException(ex);
            }
            return RetVal;
        }
コード例 #10
0
        /// <summary>
        /// Imports indicator 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 ImportIndicatorMetadata(string dataPrefix, DIConnection sourceDBConnection, DIQueries sourceDBQueries, string selectedNIDs, int selectionCount, MetaDataType metadataType)
        {
            DataTable TempDataTable;
            int CurrentRecordIndex = 0;
            DI7MetadataCategoryBuilder MetadataCategoryBuilderObj;
            IndicatorInfo SourceIndicatorInfo = new IndicatorInfo();
            IndicatorBuilder IndBuilder = null;

            try
            {
                this.RaiseStartProcessEvent();
                IndBuilder = new IndicatorBuilder(this.DBConnection, this.DBQueries);

                // 1. import metadta categories
                // import indicator metadata categories
                MetadataCategoryBuilderObj = new DI7MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                MetadataCategoryBuilderObj.ImportAllMetadataCategories(sourceDBConnection, sourceDBQueries, MetadataElementType.Indicator);

                // 2. Imort metadata reports
                if (selectionCount == -1)
                {
                    // -- GET ALL
                    TempDataTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.Indicators.GetIndicator(FilterFieldType.None, string.Empty, FieldSelection.Heavy));
                }
                else
                {
                    // -- GET SELECTED
                    TempDataTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.Indicators.GetIndicator(FilterFieldType.NId, selectedNIDs, FieldSelection.Heavy));
                }

                //////// -- Initialize Progress Bar
                this.RaiseBeforeProcessEvent(TempDataTable.Rows.Count);
                foreach (DataRow Row in TempDataTable.Rows)
                {
                    CurrentRecordIndex++;

                    // get source indicator info
                    SourceIndicatorInfo = new IndicatorInfo();
                    SourceIndicatorInfo.Nid = Convert.ToInt32(Row[Indicator.IndicatorNId]);
                    SourceIndicatorInfo.GID = Convert.ToString(Row[Indicator.IndicatorGId]);
                    SourceIndicatorInfo.Name = Convert.ToString(Row[Indicator.IndicatorName]);
                    SourceIndicatorInfo.Global = Convert.ToBoolean(Row[Indicator.IndicatorGlobal]);

                    //import metadata
                    IndBuilder.ImportIndicatorMetadata(SourceIndicatorInfo, SourceIndicatorInfo.Nid, sourceDBQueries, sourceDBConnection);

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

                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
            finally
            {
                this.RaiseEndProcessEvent();
            }
        }
コード例 #11
0
        private void InsertMetadataReportFromXML(int targetNid, bool isNameAttributeExist, DI7MetadataCategoryBuilder MDBuilder, XmlNode ReportNode, string metadataTypeText, int categoryParentNId)
        {
            string MDCategotyID = string.Empty;
            string MDCategotyName = string.Empty;
            DI7MetadataCategoryInfo MDCateInfo = null;
            int CategotyNid = -1;

            foreach (XmlNode ReportAttNode in ReportNode.ChildNodes)
            {
                if (ReportAttNode.Name == ATTRIBUTESET_ELEMENT)
                {
                    this.InsertMetadataReportFromXML(targetNid, isNameAttributeExist, MDBuilder, ReportAttNode, metadataTypeText, categoryParentNId);
                }

                if (ReportAttNode.Name == "ReportedAttribute")
                {

                    MDCategotyID = Convert.ToString(ReportAttNode.Attributes[ID_ATTRIBUTE].Value);

                    if (isNameAttributeExist)
                    {
                        MDCategotyName = Convert.ToString(ReportAttNode.Attributes[NAME_ATTRIBUTE].Value);
                    }
                    else
                    {
                        MDCategotyName = MDCategotyID;
                    }

                    try
                    {
                        if (!string.IsNullOrEmpty(ReportAttNode.InnerXml) && Convert.ToString(ReportAttNode[COMMONTEXT_ELEMENT].Attributes[XMLLANG_ATTRIBUTE].Value).Trim('_') == this.DBQueries.LanguageCode.Trim('_'))
                        {
                            string MetadataReport = Convert.ToString(ReportAttNode[COMMONTEXT_ELEMENT].InnerText);

                            if (!string.IsNullOrEmpty(MetadataReport))
                            {
                                MDCateInfo = new DI7MetadataCategoryInfo();
                                MDCateInfo.CategoryGID = MDCategotyID;
                                MDCateInfo.CategoryName = MDCategotyName;
                                MDCateInfo.CategoryType = metadataTypeText;
                                MDCateInfo.ParentNid = categoryParentNId;

                                CategotyNid = MDBuilder.CheckNInsertCategory(MDCateInfo);
                                //--
                                this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataReport.Insert.InsertMetadataReport(this.DBQueries.TablesName.MetadataReport, targetNid.ToString(), CategotyNid.ToString(), MetadataReport));

                                if (ReportAttNode.ChildNodes.Count > 0)
                                {
                                    this.InsertMetadataReportFromXML(targetNid, isNameAttributeExist, MDBuilder, ReportAttNode, metadataTypeText, CategotyNid);
                                }
                            }
                            else
                            {
                                //this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataReport.Delete.DeleteMetadataReport(this.DBQueries.TablesName.MetadataReport, targetNid.ToString(), CategotyNid.ToString()));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
コード例 #12
0
        private void CheckNInsertMetadataReportXml(XmlDocument XmlDoc, int targetNid, bool isNameAttributeExist, string metadataTypeText)
        {
            XmlNamespaceManager nsManager = new XmlNamespaceManager(XmlDoc.NameTable);
            DI7MetadataCategoryBuilder MDBuilder = new DI7MetadataCategoryBuilder(this.DBConnection, this.DBQueries);

            nsManager.AddNamespace("generic", "http://www.sdmx.org/resources/sdmxml/schemas/v2_1/data/generic");
            nsManager.AddNamespace("message", "http://www.sdmx.org/resources/sdmxml/schemas/v2_1/message");
            XmlNodeList NodeListObj = null;

            try
            {
                //-- this code not wotk due to "name" attribute
                //SDMXObjectModel.Message.GenericMetadataType Obj = new SDMXObjectModel.Message.GenericMetadataType();
                //Obj = (SDMXObjectModel.Message.GenericMetadataType)SDMXObjectModel.Deserializer.LoadFromXmlDocument(typeof(SDMXObjectModel.Message.GenericMetadataType), XmlDoc);

                NodeListObj = XmlDoc.SelectNodes(METADATASET_XPATH, nsManager);
                foreach (XmlNode Node in NodeListObj[0].ChildNodes)
                {
                    if (Node.Name == REPORT_ELEMENT)
                    {
                        foreach (XmlNode ReportNode in Node.ChildNodes)
                        {
                            if (ReportNode.Name == ATTRIBUTESET_ELEMENT)
                            {
                                this.InsertMetadataReportFromXML(targetNid, isNameAttributeExist, MDBuilder, ReportNode, metadataTypeText, -1);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #13
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());
            }
        }
コード例 #14
0
        public bool ImportMetataFromExcel(MetadataElementType categoryType, MetaDataType metadataType, int elementNId, string xlsFileNameWPath, string xsltFldrPath)
        {
            bool RetVal = true;
            string MetadataText = string.Empty;
            string FirstColumnValue = string.Empty;
            string SecondColumnValue = string.Empty;
            string ThirdColumnValue = string.Empty;
            string ElementName = string.Empty;
            string ElementGID = string.Empty;
            DataTable ExcelDataTable = null;
            DataRow Row;

            DI7MetaDataBuilder MDBuilder;
            DI7MetadataCategoryBuilder MDCategoryBuilder;
            DI7MetadataCategoryInfo MetadataCategory;

            DIExcel ExcelFile = null;

            try
            {
                // -- Get data table from excel file
                ExcelFile = new DIExcel(xlsFileNameWPath);
                ExcelDataTable = ExcelFile.GetDataTableFromSheet(ExcelFile.GetSheetName(0));

                // -- create database builder objects
                MDCategoryBuilder = new DI7MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                MDBuilder = new DI7MetaDataBuilder(this.DBConnection, this.DBQueries);

                // -- import metadata reports with category
                for (int RowIndex = 1; RowIndex < ExcelDataTable.Rows.Count; RowIndex++)
                {
                    Row = ExcelDataTable.Rows[RowIndex];
                    FirstColumnValue = Convert.ToString(Row[0]);
                    SecondColumnValue = Convert.ToString(Row[1]);
                    ThirdColumnValue = Convert.ToString(Row[2]);

                    // get element name
                    if (string.IsNullOrEmpty(ElementName))
                    {
                        if (string.IsNullOrEmpty(FirstColumnValue))
                        {
                            break;
                        }
                        else
                        {
                            ElementName = FirstColumnValue;
                            continue;
                        }
                    }

                    // get element gid/id
                    if (string.IsNullOrEmpty(ElementGID))
                    {
                        if (string.IsNullOrEmpty(FirstColumnValue))
                        {
                            break;
                        }
                        else
                        {
                            ElementGID = FirstColumnValue;

                            // get element nid by element gid
                            if (metadataType == MetaDataType.Source)
                            {
                                elementNId = this.GetElementNidByGID(ElementName, metadataType);
                            }
                            else
                            {
                                elementNId = this.GetElementNidByGID(ElementGID, metadataType);
                            }

                            // Skip title row by incrementing  row index
                            RowIndex++;

                            continue;
                        }
                    }

                    // continue if row is blank
                    if (string.IsNullOrEmpty(FirstColumnValue) && string.IsNullOrEmpty(SecondColumnValue) && string.IsNullOrEmpty(ThirdColumnValue))
                    {
                        // reset element  value
                        elementNId = 0;
                        ElementName = string.Empty;
                        ElementGID = string.Empty;
                        continue;
                    }
                    else if (elementNId > 0)
                    {
                        // import metadata report with metadata category

                        // get metadata category and metedata report
                        MetadataCategory = new DI7MetadataCategoryInfo();
                        MetadataCategory.CategoryName = SecondColumnValue;
                        MetadataCategory.CategoryGID = FirstColumnValue;
                        MetadataCategory.CategoryType = DIQueries.MetadataElementTypeText[categoryType];

                        // import metadata category
                        MetadataCategory.CategoryNId = MDCategoryBuilder.CheckNInsertCategory(MetadataCategory);

                        // import metadata report
                        if (MetadataCategory.CategoryNId > 0)
                        {
                            MDBuilder.InsertORUpdateMetadataInfo(metadataType, MetadataCategory.CategoryNId.ToString(), elementNId, this.ReplaceNewLineInMetadataReport(ThirdColumnValue));
                        }
                    }

                }
            }
            catch (Exception)
            {
                RetVal = false;
            }
            finally
            {
                if (ExcelFile != null)
                {
                    ExcelFile.Close();
                }
            }

            return RetVal;
        }
コード例 #15
0
        /// <summary>
        /// Import Metdata report
        /// </summary>
        /// <param name="xmlFileNameWPath"></param>
        /// <param name="mdType"></param>
        /// <param name="selectedNidInTrgDatabase"></param>
        /// <param name="selectedFiles"></param>
        /// <param name="XsltFolderPath"></param>
        public void ImportMetadataFromXML(string xmlString, MetadataElementType metadataElementType, int selectedNidInTrgDatabase, string XsltFolderPath)
        {
            XmlDocument XmlDoc = new XmlDocument();
            DI7MetadataCategoryBuilder MDBuilder = new DI7MetadataCategoryBuilder(this.DBConnection, this.DBQueries);

            XmlDoc.LoadXml(xmlString);
            try
            {
                //--  check that Value/Name attribute exists or not
                if (this.IsMetadataNameAttributeExists(XmlDoc))
                {

                    this.CheckNInsertMetadataReportXml(XmlDoc, selectedNidInTrgDatabase, true, DIQueries.MetadataElementTypeText[metadataElementType]);
                }
                else
                {
                    // if not then use ID for mapping .
                    // If category ID exists in trg database then only import metadata report
                    this.CheckNInsertMetadataReportXml(XmlDoc, selectedNidInTrgDatabase, false, DIQueries.MetadataElementTypeText[metadataElementType]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #16
0
        //private int ImportIndicator(DataRow row)
        //{
        //    int RetVal = -1;
        //    IndicatorInfo IndicatorRecord;
        //    IndicatorBuilder IndicatorBuilderObj;
        //    IndicatorRecord = this.GetIndicatorInfo(row);
        //    IndicatorBuilderObj = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    RetVal = IndicatorBuilderObj.ImportIndicator(IndicatorRecord, IndicatorRecord.Nid, this.SourceDBQueries, this.SourceDBConnection);
        //    return RetVal;
        //}
        //private int ImportUnit(DataRow row)
        //{
        //    int RetVal = -1;
        //    UnitInfo UnitRecord;
        //    UnitBuilder UnitBuilderObj;
        //    UnitRecord = this.GetUnitInfo(row);
        //    UnitBuilderObj = new UnitBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    RetVal = UnitBuilderObj.ImportUnit(UnitRecord, UnitRecord.Nid, this.SourceDBQueries, this.SourceDBConnection);
        //    return RetVal;
        //}
        //private int ImportSubgroupVal(DataRow row)
        //{
        //    int RetVal = -1;
        //    DI6SubgroupValBuilder SubgroupValBuilderObj = new DI6SubgroupValBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    //import into target database
        //    RetVal = SubgroupValBuilderObj.ImportSubgroupVal(Convert.ToInt32(row[SubgroupVals.SubgroupValNId]), this.SourceDBQueries, this.SourceDBConnection);
        //    return RetVal;
        //}
        //private void ImportIUS(List<string> selectedNids, bool allSelected)
        //{
        //    int ProgressBarValue = 1;
        //    int IndicatorNId = -1;
        //    int UnitNId = -1;
        //    int SGValNId = -1;
        //    int MinValue=0;
        //    int MaxValue=0;
        //    DataRow[] Rows;
        //    DataTable TempTable;
        //    List<string> ImportedIndicatorNIDs = new List<string>();
        //    List<string> ImportedUnitNIDs = new List<string>();
        //    List<string> ImportedSGNIDs = new List<string>();
        //    IUSBuilder IusBuilderObj ;
        //    if (this.ShowIUS)
        //    {
        //        // Get selected rows
        //        if (allSelected)
        //        {
        //            Rows = this.SourceTable.Select("1=1");
        //        }
        //        else
        //        {
        //            Rows = this.SourceTable.Select(this.TagValueColumnName + " IN ( " + string.Join(",", selectedNids.ToArray()) + ")");
        //        }
        //        foreach (DataRow Row in Rows)
        //        {
        //            try
        //            {
        //                //import Indicator
        //                IndicatorNId = Convert.ToInt32(Row[Indicator.IndicatorNId]);
        //                if (!ImportedIndicatorNIDs.Contains(IndicatorNId.ToString()))
        //                {
        //                    ImportedIndicatorNIDs.Add(IndicatorNId.ToString());
        //                    IndicatorNId = this.ImportIndicator(Row);
        //                }
        //                    // import unit
        //                UnitNId = Convert.ToInt32(Row[Unit.UnitNId]);
        //                if (!ImportedIndicatorNIDs.Contains(UnitNId.ToString()))
        //                {
        //                   ImportedUnitNIDs.Add(UnitNId.ToString());
        //                    UnitNId =  this.ImportUnit(Row);
        //                }
        //                // import subgroupval
        //                SGValNId=Convert.ToInt32(Row[SubgroupVals.SubgroupValNId]);
        //                if (!ImportedSGNIDs.Contains(SGValNId.ToString()))
        //                {
        //                    ImportedSGNIDs.Add(SGValNId.ToString());
        //                    SGValNId = this.ImportSubgroupVal(Row);
        //                }
        //                //import IUS
        //                if (IndicatorNId > 0 && UnitNId > 0 && SGValNId > 0)
        //                {
        //                    //if(Convert.ToString(Row[Indicator_Unit_Subgroup.MaxValue]).Length>0)
        //                    //{
        //                    //MaxValue=   Convert.ToInt32(Row[Indicator_Unit_Subgroup.MaxValue]);
        //                    //}
        //                    //else
        //                    //{
        //                    //    MaxValue=0;
        //                    //}
        //                    //if(Convert.ToString(Row[Indicator_Unit_Subgroup.MinValue]).Length>0)
        //                    //{
        //                    //    MinValue= Convert.ToInt32(Row[Indicator_Unit_Subgroup.MinValue]);
        //                    //}
        //                    //else
        //                    //{
        //                    //    MinValue=0;
        //                    //}
        //                    IusBuilderObj = new IUSBuilder( this._TargetDBConnection, this._TargetDBQueries);
        //                    IusBuilderObj.ImportIUS(IndicatorNId, UnitNId, SGValNId,                                                    MinValue, MaxValue , this.SourceDBQueries, this.SourceDBConnection);
        //                }
        //                if (this.ShowSector)
        //                {
        //                    this.ImportSector(Row);
        //                }
        //            }
        //            catch (Exception)
        //            {
        //                throw;
        //            }
        //            this.RaiseIncrementProgessBarEvent(ProgressBarValue);
        //            ProgressBarValue++;
        //        }
        //    }
        //}
        /// <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;
            IndicatorInfo IndicatorRecord = null;
            IndicatorBuilder IndicatorBuilderObj = null;
            DI7MetadataCategoryBuilder MetadataCategoryBuilderObj = null;
            int ProgressBarValue = 1;

            // import indicator metadata categories
            MetadataCategoryBuilderObj = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
            MetadataCategoryBuilderObj.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, MetadataElementType.Indicator);

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

                    if (this._ShowIUS)
                    {
                        this.ImportForIUS(Row);
                    }
                    else
                    {

                        //import indicator
                        IndicatorRecord = this.GetIndicatorInfo(Row);
                        IndicatorBuilderObj = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
                        IndicatorBuilderObj.ImportIndicator(IndicatorRecord, Convert.ToInt32(Nid), this.SourceDBQueries, this.SourceDBConnection);

                        if (this._ShowSector)
                        {
                            this.ImportSector(Row);
                        }

                    }

                }
                catch (Exception)
                {

                    throw;
                }
                this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                ProgressBarValue++;
            }

            if (this._ShowIUS && this._ShowSector)
            {
                this.ImportSectors(selectedNids, allSelected);
            }
        }
コード例 #17
0
        /// <summary>
        /// Imports area 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 ImportAreaMetadata(string dataPrefix, DIConnection sourceDBConnection, DIQueries sourceDBQueries, string selectedNIDs, int selectionCount, MetaDataType metadataType)
        {
            DataTable TempDataTable;
            int CurrentRecordIndex = 0;
            DI7MetadataCategoryBuilder AreaMetadataCategoryBuilder;
            DataTable TempTargetTable;

            try
            {
                this.RaiseStartProcessEvent();

                // import area categories
                AreaMetadataCategoryBuilder = new DI7MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                AreaMetadataCategoryBuilder.ImportAllMetadataCategories(sourceDBConnection, sourceDBQueries, MetadataElementType.Area);

                if (selectionCount == -1)
                {
                    // -- GET ALL
                    TempDataTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.Area.GetAreaMapMetadata(string.Empty));
                }
                else
                {
                    // -- GET SELECTED
                    TempDataTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.Area.GetAreaMapMetadata(selectedNIDs));
                }

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

                //import area metadata
                foreach (DataRow Row in TempDataTable.Rows)
                {

                    CurrentRecordIndex++;
                    //-- Get Target table against LayerName
                    TempTargetTable = this.DBConnection.ExecuteDataTable(this.DBQueries.Area.GetAreaMapMetadataByName(
                       Row[Area_Map_Metadata.LayerName].ToString()));

                    foreach (DataRow TrgRow in TempTargetTable.Rows)
                    {
                        this.ImportMetadata(sourceDBConnection, sourceDBQueries, Convert.ToInt32(Row[Area_Map_Layer.LayerNId]), Convert.ToInt32(TrgRow[Area_Map_Layer.LayerNId]), MetadataElementType.Area, MetaDataType.Map, IconElementType.MetadataArea);
                        break;
                    }

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

                }

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
            finally
            {
                this.RaiseEndProcessEvent();
            }
        }