private void CheckNCreateMetadataCategoryTable(bool forOnlineDB, DITables tablesName)
        {
            string DataPrefix = string.Empty;
            string LanguageCode = string.Empty;
            MetadataCategoryBuilder MetadataCategoryBuilderObj = null;
            DIQueries TempQueries;

            try
            {
                // check table already exists or not
                TempQueries = new DIQueries(tablesName.CurrentDataPrefix, tablesName.CurrentLanguageCode);
                MetadataCategoryBuilderObj = new MetadataCategoryBuilder(this._DBConnection, TempQueries);

                if (MetadataCategoryBuilderObj.IsMetadataCategoryTableExists() == false)
                {
                    this.AddMissingMetadataCategoryTables(tablesName.MetadataCategory);

                    this._DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Insert.CreateTable(tablesName.MetadataCategory, forOnlineDB, this._DBConnection.ConnectionStringParameters.ServerType));

                }

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
        private void UpdateCategoryTable()
        {
            MetadataCategoryBuilder CategoryBuilder;
            DIQueries TempDBQueries = null;
            string DataPrefix = string.Empty;
            string LanguageCode = string.Empty;
            string CategoryNid = string.Empty;
            string CategoryGID = string.Empty;

            string SourceCategoryTable = string.Empty;
            DataTable CategoryTable;

            try
            {
                // step1: create table for all dataset
                foreach (DataRow DataPrefixRow in this._DBConnection.DIDataSets().Rows)
                {
                    DataPrefix = DataPrefixRow[DBAvailableDatabases.AvlDBPrefix].ToString() + "_";

                    // get language for all available languages
                    foreach (DataRow LanguageRow in this._DBConnection.DILanguages(DataPrefix).Rows)
                    {
                        LanguageCode = "_" + LanguageRow[Language.LanguageCode].ToString();

                        // check table already exists or not
                        TempDBQueries = new DIQueries(DataPrefix, LanguageCode);

                        if (string.IsNullOrEmpty(SourceCategoryTable))
                        {
                            // update GID in only one language table and for other  language tables, use this language table
                            CategoryBuilder = new MetadataCategoryBuilder(this._DBConnection, TempDBQueries);

                            CategoryTable = CategoryBuilder.GetAllRecordsFromMetadataCategory();

                            foreach (DataRow Row in CategoryTable.Rows)
                            {
                                //update metdata category table (set parent_nid to -1 and update gids)
                                //CategoryGID = Convert.ToString(Row[Metadata_Category.CategoryName]).ToUpper().Replace(" ", "_");
                                //CategoryGID = MetaDataBuilder.GetNewMetaDataCategoryGID();

                                CategoryNid = Convert.ToString(Row[Metadata_Category.CategoryNId]);
                                CategoryGID = DICommon.GetValidGIdForSDMXRule(Convert.ToString(Row[Metadata_Category.CategoryName]).ToUpper()) + "_" + CategoryNid;

                                this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Update.UpdateMetadataCategory(TempDBQueries.TablesName.MetadataCategory, Convert.ToInt32(CategoryNid), CategoryGID, "-1", false, false));
                            }

                            SourceCategoryTable = TempDBQueries.TablesName.MetadataCategory;
                        }
                        else
                        {
                            // use first language table  to update other language table
                            this.DBConnection.ExecuteNonQuery("UPDATE " + SourceCategoryTable + " AS src INNER JOIN " + TempDBQueries.TablesName.MetadataCategory + " AS trg ON src." + Metadata_Category.CategoryNId + " = trg." + Metadata_Category.CategoryNId + "  SET trg." + Metadata_Category.CategoryGId + "=src." + Metadata_Category.CategoryGId + " and trg." + Metadata_Category.ParentCategoryNId + "=src." + Metadata_Category.ParentCategoryNId + ";");
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                ExceptionFacade.ThrowException(ex);
            }
        }
        private void CreateMetadataXML(DataRow[] metadataCategoryRows, ref StringBuilder xmlInfo, MetadataCategoryBuilder metadataCategoryBuilder, string categoryType)
        {
            string MetadataCategoryName = string.Empty;
            try
            {
                xmlInfo = new StringBuilder();
                xmlInfo.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                xmlInfo.Append("<metadata>");
                foreach (DataRow metadataCategoryRow in metadataCategoryRows)
                {
                    MetadataCategoryName = Convert.ToString(metadataCategoryRow[Metadata_Category.CategoryName]);

                    //Step 1 Check and create metadata category
                    if (!metadataCategoryBuilder.IsAlreadyExists(MetadataCategoryName, categoryType, -1))
                    {
                        MetadataCategoryInfo metadataCategoryInfo = new MetadataCategoryInfo();
                        metadataCategoryInfo.CategoryName = MetadataCategoryName;
                        metadataCategoryInfo.CategoryType = categoryType;

                        metadataCategoryBuilder.CheckNCreateMetadataCategory(metadataCategoryInfo);
                    }

                    //Step 2 Add category into metadata xml
                    xmlInfo.Append("<Category name=\"" + MetadataCategoryName + "\">");
                    xmlInfo.Append("<para>" + Convert.ToString(metadataCategoryRow[MetadataReport.Metadata]) + "</para></Category>");
                }

                xmlInfo.Append("</metadata>");
            }
            catch (Exception ex)
            {

            }
        }
        private void UpdateMetadataInfoByCategoryType(MetadataElementType categoryType, MetadataCategoryBuilder metadataCategoryBuilder, DIQueries queries)
        {
            List<string> TargetNids;
            DataTable SrcCategoryTable = null;
            StringBuilder Metadata_Category_Info = new StringBuilder();

            SrcCategoryTable = this._DBConnection.ExecuteDataTable(queries.MetadataReport.GetAllMetadataReportsByCategoryType(categoryType));
            TargetNids = DICommon.GetCommaSeperatedListOfGivenColumn(SrcCategoryTable, MetadataReport.TargetNid, false, string.Empty);

            //for every target like for indicator one there is many metadata category may be definition, Classification, Method of Computation
            foreach (string targetNid in TargetNids)
            {
                Metadata_Category_Info.Remove(0, Metadata_Category_Info.Length);

                //Step 1 Create metadata Info in xml format
                this.CreateMetadataXML(SrcCategoryTable.Select(MetadataReport.TargetNid + "='" + targetNid + "'"), ref Metadata_Category_Info, metadataCategoryBuilder, DIQueries.MetadataElementTypeText[categoryType].Trim("'".ToCharArray()));

                //Step 2 Update metadata Info in xml format
                this.UpdateMetadataInfo(queries, targetNid, categoryType, Metadata_Category_Info.ToString());
            }
        }
        private string GetElementMetadata(MetaDataType elementType, string elementGId, int elementNId, DIExcel diExcel, int startRowIndex)
        {
            string RetVal = string.Empty;
            MetadataCategoryBuilder MDCatBuilder;
            MetadataCategoryInfo MDCatInfo;
            XmlDocument MetadataXmlDoc = new XmlDocument();
            XmlElement CategoryNode;
            XmlElement ParaNode;
            XmlText CategoryText;
            string Category = string.Empty;
            string CategoryValue = string.Empty;
            string ElementMetadataXml = string.Empty;
            int CategoryNId = 0;

            //-- Get Metadata Info for Element
            ElementMetadataXml = this.GetElementInfo(elementType, elementGId);

            if (string.IsNullOrEmpty(ElementMetadataXml))
            {
                MetadataConverter.InsertRootNode(MetadataXmlDoc);
            }
            else
            {
                MetadataXmlDoc.LoadXml(ElementMetadataXml);
            }

            MDCatBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);

            //foreach (IRange Row in DiExcel.GetUsedRange(0).Rows )
            for (int Index = startRowIndex; Index < diExcel.GetUsedRange(0).Rows.RowCount; Index++)
            {
                Category = Convert.ToString(diExcel.GetUsedRange(0).Rows[Index, 0].Value);
                CategoryValue = Convert.ToString(diExcel.GetUsedRange(0).Rows[Index, 1].Value);

                if (!string.IsNullOrEmpty(Category))
                {
                    //-- Get Metadata CategoryInfo
                    MDCatInfo = MDCatBuilder.GetMetadataCategoryInfo(FilterFieldType.Name, "'" + DICommon.RemoveQuotes(Category) + "'");
                    //-- If Metadata not category exists
                    if (MDCatInfo != null && string.IsNullOrEmpty(MDCatInfo.CategoryName))
                    {
                        MDCatInfo.CategoryName = Category;
                        MDCatInfo.CategoryType = this.GetCategoryTypeText(elementType);

                        //Create new xmlelement as Category
                        CategoryNode = MetadataXmlDoc.CreateElement(MetaDataConstants.CategoryTagName);

                        //Set attribute values of category element.
                        CategoryNode.SetAttribute(MetaDataConstants.NameAttribute, Category);
                        // create para element
                        ParaNode = MetadataXmlDoc.CreateElement(MetaDataConstants.ParaTagName);
                        //Append as para node under category node
                        CategoryNode.AppendChild(ParaNode);
                        // create text node
                        CategoryText = MetadataXmlDoc.CreateTextNode(this.ReplaceInvalidString(CategoryValue));
                        //Append category text in paraNode
                        ParaNode.AppendChild(CategoryText);
                        //Append it under metadata node
                        MetadataXmlDoc.DocumentElement.AppendChild(CategoryNode);
                    }
                    //-- Get CategoryNId
                    CategoryNId = MDCatBuilder.CheckNCreateMetadataCategory(MDCatInfo);
                    this.UpdateMetadataCategory(MetadataXmlDoc, Category, CategoryValue);
                }
                else
                {
                    //-- Exit for Next Metadata
                    break;
                }

            }

            RetVal = MetadataXmlDoc.InnerXml;

            return RetVal;
        }
        private void ConvertDI7MetadataIntoDI6Metadata()
        {
            MetadataCategoryBuilder metadataCategoryBuilder;
            DIQueries queries;

            foreach (string LanguageCode in AllLanguageCodes)
            {
                queries = new DIQueries(this.DBQueries.DataPrefix, LanguageCode);
                metadataCategoryBuilder = new MetadataCategoryBuilder(this._DBConnection, queries);

                //for Indicator, Area, Source
                this.UpdateMetadataInfoByCategoryType(MetadataElementType.Indicator, metadataCategoryBuilder, queries);

                this.UpdateMetadataInfoByCategoryType(MetadataElementType.Area, metadataCategoryBuilder, queries);

                this.UpdateMetadataInfoByCategoryType(MetadataElementType.Source, metadataCategoryBuilder, queries);
            }
        }
        /// <summary>
        /// To Import metadata information 
        /// </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 InsertImportValues(string dataPrefix, DIConnection sourceDBConnection, DIQueries sourceDBQueries, string selectedNIDs, int selectionCount, MetaDataType metadataType)
        {
            int Index;
            string MetadataInfo = string.Empty;
            DataTable TempDataTable;
            DataTable TempTargetIdTable = new DataTable();
            ICType ClassificationType;
            Dictionary<string, string> OldIconNId_NewIconNId = new Dictionary<string, string>();
            int CurrentRecordIndex = 0;
            MetadataCategoryBuilder MDCategoryBuilder = null;
            int IndicatorNid = 0;

            this.RaiseStartProcessEvent();

            switch (metadataType)
            {
                case MetaDataType.Indicator:
                    // -- INDICATORS
                    try
                    {
                        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);

                        for (Index = 0; Index <= TempDataTable.Rows.Count - 1; Index++)
                        {
                            CurrentRecordIndex++;

                            if (!Information.IsDBNull(TempDataTable.Rows[Index][Indicator.IndicatorInfo]))
                            {
                                if (!string.IsNullOrEmpty(TempDataTable.Rows[Index][Indicator.IndicatorInfo].ToString()))
                                {
                                    OldIconNId_NewIconNId = new Dictionary<string, string>();

                                    //-- Get Target IndicatorNId against IndicatorGId
                                    TempTargetIdTable = this.DBConnection.ExecuteDataTable(this.DBQueries.Indicators.GetIndicator(FilterFieldType.GId, "'" + DICommon.RemoveQuotes(TempDataTable.Rows[Index][Indicator.IndicatorGId].ToString()) + "'", FieldSelection.Heavy));

                                    if (TempTargetIdTable.Rows.Count == 0)
                                    {
                                        TempTargetIdTable = this.DBConnection.ExecuteDataTable(this.DBQueries.Indicators.GetIndicator(FilterFieldType.Name, "'" + DICommon.RemoveQuotes(TempDataTable.Rows[Index][Indicator.IndicatorName].ToString()) + "'", FieldSelection.Heavy));
                                    }

                                    IndicatorNid = -1;

                                    if (TempTargetIdTable.Rows.Count > 0)
                                    {
                                        IndicatorNid = Convert.ToInt32(TempTargetIdTable.Rows[0][Indicator.IndicatorNId]);

                                        //-- Update Icons in Icon Table
                                        OldIconNId_NewIconNId = DIIcons.ImportElement(
                                           Convert.ToInt32(TempDataTable.Rows[Index][Indicator.IndicatorNId]),
                                           Convert.ToInt32(TempTargetIdTable.Rows[0][Indicator.IndicatorNId]),
                                           IconElementType.Indicator, sourceDBQueries, sourceDBConnection,
                                           this.DBQueries, this.DBConnection);
                                    }

                                    //-- Retrieve Metadata Information
                                    MetadataInfo = TempDataTable.Rows[Index][Indicator.IndicatorInfo].ToString();

                                    //-- Convert Metdata into latest format
                                    MetadataInfo = DICommon.CheckNConvertMetadataXml(MetadataInfo);

                                    //-- Update Metadata Category from XML File
                                    MDCategoryBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);

                                    MDCategoryBuilder.ReadXmlAndUpdateCategoryTable(MetadataInfo, this.GetCategoryTypeText(metadataType));
                                    //-- Update IconNids in xml if it exists
                                    foreach (KeyValuePair<string, string> kvp in OldIconNId_NewIconNId)
                                    {
                                        MetadataInfo = MetadataInfo.Replace(kvp.Key, kvp.Value);
                                    }

                                    //-- Update Metadata
                                    this.UpdateMetadataInfo(metadataType, string.Empty, IndicatorNid, MetadataInfo);

                                }
                            }

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

                        }

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

                    break;

                case MetaDataType.Map:
                    // -- MAP
                    try
                    {
                        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;

                        for (Index = 0; Index <= TempDataTable.Rows.Count - 1; Index++)
                        {
                            CurrentRecordIndex++;

                            if (!Information.IsDBNull(TempDataTable.Rows[Index][Area_Map_Metadata.MetadataText]))
                            {
                                if (!(TempDataTable.Rows[Index][Area_Map_Metadata.MetadataText].ToString().Length == 0))
                                {

                                    OldIconNId_NewIconNId = new Dictionary<string, string>();
                                    //-- Update Icons in Icon Table
                                    //-- Get Target LayerNId against LayerName
                                    TempTargetIdTable = this.DBConnection.ExecuteDataTable(
                                        this.DBQueries.Area.GetAreaMapMetadataByName(
                                        TempDataTable.Rows[Index][Area_Map_Metadata.LayerName].ToString()));

                                    if (TempTargetIdTable.Rows.Count > 0)
                                    {
                                        OldIconNId_NewIconNId = DIIcons.ImportElement(
                                           Convert.ToInt32(TempDataTable.Rows[Index][Area_Map_Metadata.LayerNId]),
                                           Convert.ToInt32(TempTargetIdTable.Rows[0][Area_Map_Metadata.LayerNId]),
                                           IconElementType.MetadataArea,
                                           sourceDBQueries, sourceDBConnection,
                                           this.DBQueries, this.DBConnection);
                                    }

                                    //-- Retrieve Metadata Information
                                    MetadataInfo = TempDataTable.Rows[Index][Area_Map_Metadata.MetadataText].ToString();
                                    //-- Convert Metdata into latest format
                                    MetadataInfo = DICommon.CheckNConvertMetadataXml(MetadataInfo);

                                    //-- Update Metadata Category from XML File
                                    MDCategoryBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                                    MDCategoryBuilder.ReadXmlAndUpdateCategoryTable(MetadataInfo, this.GetCategoryTypeText(metadataType));
                                    //-- Update IconNids in xml if it exists
                                    foreach (KeyValuePair<string, string> kvp in OldIconNId_NewIconNId)
                                    {
                                        MetadataInfo = MetadataInfo.Replace(kvp.Key, kvp.Value);
                                    }

                                    //-- Update Metadata
                                    this.UpdateMetadataInfo(metadataType, TempDataTable.Rows[Index][Area_Map_Metadata.LayerName].ToString(), -1, MetadataInfo);
                                }
                            }

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

                        }

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

                    break;
                default:
                    //AppGeneral.MetadataType.Source
                    // -- SOURCE
                    ClassificationType = ICType.Sector;
                    switch (metadataType)
                    {
                        case MetaDataType.Sector:
                            ClassificationType = ICType.Sector;
                            break;
                        case MetaDataType.Goal:
                            ClassificationType = ICType.Goal;
                            break;
                        case MetaDataType.CF:
                            ClassificationType = ICType.CF;
                            break;
                        case MetaDataType.Theme:
                            ClassificationType = ICType.Theme;
                            break;
                        case MetaDataType.Source:
                            ClassificationType = ICType.Source;
                            break;
                        case MetaDataType.Institution:
                            ClassificationType = ICType.Institution;
                            break;
                        case MetaDataType.Convention:
                            ClassificationType = ICType.Convention;
                            break;
                    }
                    try
                    {
                        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;

                        for (Index = 0; Index <= TempDataTable.Rows.Count - 1; Index++)
                        {
                            CurrentRecordIndex++;

                            if (!Information.IsDBNull(TempDataTable.Rows[Index][IndicatorClassifications.ICInfo]))
                            {
                                if (!(TempDataTable.Rows[Index][IndicatorClassifications.ICInfo].ToString().Length == 0))
                                {

                                    //-- Retrieve Metadata Information
                                    MetadataInfo = TempDataTable.Rows[Index][IndicatorClassifications.ICInfo].ToString();

                                    if (ClassificationType == ICType.Source)
                                    {
                                        //Only for Source which has xml Metadata
                                        OldIconNId_NewIconNId = new Dictionary<string, string>();
                                        //-- Update Icons in Icon Table
                                        //-- Get Target LayerNId against LayerName
                                        TempTargetIdTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.Name, "'" + DICommon.RemoveQuotes(Convert.ToString(TempDataTable.Rows[Index][IndicatorClassifications.ICName])) + "'", ClassificationType, FieldSelection.Heavy));

                                        if (TempTargetIdTable.Rows.Count > 0)
                                        {
                                            OldIconNId_NewIconNId = DIIcons.ImportElement(
                                               Convert.ToInt32(TempDataTable.Rows[Index][IndicatorClassifications.ICNId]),
                                              Convert.ToInt32(TempTargetIdTable.Rows[0][IndicatorClassifications.ICNId]),
                                              IconElementType.MetadataSource,
                                              sourceDBQueries, sourceDBConnection,
                                              this.DBQueries, this.DBConnection);
                                        }

                                        //-- Convert Metdata into latest format
                                        MetadataInfo = DICommon.CheckNConvertMetadataXml(MetadataInfo);

                                        //-- Update IconNids in xml if it exists
                                        foreach (KeyValuePair<string, string> kvp in OldIconNId_NewIconNId)
                                        {
                                            MetadataInfo = MetadataInfo.Replace(kvp.Key, kvp.Value);
                                        }
                                        //-- Update Metadata Category from XML File
                                        MDCategoryBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                                        MDCategoryBuilder.ReadXmlAndUpdateCategoryTable(MetadataInfo, this.GetCategoryTypeText(metadataType));
                                    }
                                    //-- Update Metadata
                                    this.UpdateMetadataInfo(metadataType, Convert.ToString(TempDataTable.Rows[Index][IndicatorClassifications.ICGId]), -1, MetadataInfo);
                                }
                            }

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

                        }

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

                    break;
            }
        }
        private void CheckNUpdateMetadataCategory(string metadataXml)
        {
            string CategoryName = string.Empty;
            string CategoryValue = string.Empty;
            XmlDocument XmlDoc = new XmlDocument();
            MetadataCategoryBuilder MDCatBuilder;
            MetadataCategoryInfo MDCatInfo;
            XmlDoc.LoadXml(metadataXml);

            try
            {

                MDCatBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                XmlNodeList XmlList = XmlDoc.SelectNodes(METADATA_CATEGORYTAG);

                for (int i = 0; i < XmlList.Count; i++)
                {
                    CategoryName = XmlList[i].Attributes["name"].Value;

                    MDCatInfo = MDCatBuilder.GetMetadataCategoryInfo(FilterFieldType.Name, "'" + DICommon.RemoveQuotes(CategoryName) + "'");

                    MDCatBuilder.CheckNCreateMetadataCategory(MDCatInfo);

                }

            }
            catch (Exception)
            {
            }
        }
        private bool ISMetadataXmlForCategory(string metadataXml, MetaDataType elementType)
        {
            bool RetVal = false;
            string CategoryName = string.Empty;
            string CategoryValue = string.Empty;
            XmlDocument XmlDoc = new XmlDocument();
            MetadataCategoryBuilder MDCatBuilder;
            MetadataCategoryInfo MDCatInfo;
            XmlDoc.LoadXml(metadataXml);

            try
            {

                MDCatBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                XmlNodeList XmlList = XmlDoc.SelectNodes(METADATA_CATEGORYTAG);

                for (int i = 0; i < XmlList.Count; i++)
                {
                    CategoryName = XmlList[i].Attributes["name"].Value;

                    MDCatInfo = MDCatBuilder.GetMetadataCategoryInfo(FilterFieldType.Name, "'" + DICommon.RemoveQuotes(CategoryName) + "'");

                    if (MDCatInfo.CategoryType == this.GetCategoryTypeText(elementType))
                    {
                        MDCatBuilder.CheckNCreateMetadataCategory(MDCatInfo);
                        RetVal = true;
                    }

                }

            }
            catch (Exception)
            {
            }

            return RetVal;
        }
        private void CreateMetadatCategoryTable(bool forOnlineDB)
        {
            string DataPrefix = string.Empty;
            string LanguageCode = string.Empty;
            DITables TableNames;
            MetadataCategoryBuilder MetadataCategoryBuilderObj = null;
            DIQueries TempQueries;

            try
            {
                // step1: create table for all dataset
                foreach (DataRow DataPrefixRow in this._DBConnection.DIDataSets().Rows)
                {
                    DataPrefix = DataPrefixRow[DBAvailableDatabases.AvlDBPrefix].ToString() + "_";

                    // create table for all available langauges
                    foreach (DataRow LanguageRow in this._DBConnection.DILanguages(DataPrefix).Rows)
                    {
                        LanguageCode = "_" + LanguageRow[Language.LanguageCode].ToString();

                        // check table already exists or not
                        TempQueries = new DIQueries(DataPrefix, LanguageCode);
                        MetadataCategoryBuilderObj = new MetadataCategoryBuilder(this._DBConnection, TempQueries);

                        if (MetadataCategoryBuilderObj.IsMetadataCategoryTableExists() == false)
                        {
                            TableNames = new DITables(DataPrefix, LanguageCode);

                            this._DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Insert.CreateTable(TableNames.MetadataCategory,
                                forOnlineDB, this._DBConnection.ConnectionStringParameters.ServerType));

                        }

                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
        private void ConvertMetataCategoryIntoDatabase()
        {
            MetadataCategoryBuilder MetadataCatBuilder = new MetadataCategoryBuilder(this._DBConnection, this._DBQueries);
            DIQueries TempDBQueries = null;
            string DataPrefix = string.Empty;
            string LanguageCode = string.Empty;
            try
            {
                // step1: create table for all dataset
                foreach (DataRow DataPrefixRow in this._DBConnection.DIDataSets().Rows)
                {
                    DataPrefix = DataPrefixRow[DBAvailableDatabases.AvlDBPrefix].ToString() + "_";

                    // get language for all available langauges
                    foreach (DataRow LanguageRow in this._DBConnection.DILanguages(DataPrefix).Rows)
                    {
                        LanguageCode = "_" + LanguageRow[Language.LanguageCode].ToString();

                        // check table already exists or not
                        TempDBQueries = new DIQueries(DataPrefix, LanguageCode);
                        MetadataCatBuilder = new MetadataCategoryBuilder(this._DBConnection, TempDBQueries);

                        // Populate Metadata_Category Table from mask file or default values
                        MetadataCatBuilder.UpdateMetadataCategoryTableFromMaskFile();
                    }
                }

            }
            catch
            {
            }
        }
        private void ConvertMetadataXmlIntoDatabse()
        {
            MetadataCategoryBuilder MetadataCatBuilder = new MetadataCategoryBuilder(this._DBConnection, this._DBQueries);
            DIQueries TempDBQueries = null;
            string DataPrefix = string.Empty;
            string LanguageCode = string.Empty;
            try
            {
                // step1: create table for all dataset
                foreach (DataRow DataPrefixRow in this._DBConnection.DIDataSets().Rows)
                {
                    DataPrefix = DataPrefixRow[DBAvailableDatabases.AvlDBPrefix].ToString() + "_";

                    // get language for all available langauges
                    foreach (DataRow LanguageRow in this._DBConnection.DILanguages(DataPrefix).Rows)
                    {
                        LanguageCode = "_" + LanguageRow[Language.LanguageCode].ToString();

                        // check table already exists or not
                        TempDBQueries = new DIQueries(DataPrefix, LanguageCode);

                        MetadataCatBuilder = new MetadataCategoryBuilder(this._DBConnection, TempDBQueries);

                        // convert Indicator,Map and Source Info
                        MetadataCatBuilder.ConvertIndicatorMapICAndXsltMetadataIntoNewFormat();
                    }
                }

            }
            catch (Exception)
            {
            }
        }
Beispiel #13
0
        private void ImportAreaMetadataCategories(DIConnection srcDBConn, DIQueries srcDBQueries)
        {
            MetadataCategoryInfo MDCatInfo = null;
            MetadataCategoryBuilder MDCatBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
            MetadataCategoryBuilder SrcMDCatBuilder = new MetadataCategoryBuilder(srcDBConn, srcDBQueries);
            //-- Get Categories from Source Table
            DataTable Table = SrcMDCatBuilder.GetAllRecordsFromMetadataCategory();

            DataRow[] Rows = Table.Select(Metadata_Category.CategoryType + "=" + "'A'");

            foreach (DataRow Row in Rows)
            {
                MDCatInfo = new MetadataCategoryInfo();
                MDCatInfo.CategoryName = Convert.ToString(Row[Metadata_Category.CategoryName]);
                MDCatInfo.CategoryType = Convert.ToString(Row[Metadata_Category.CategoryType]);
                // Add MetadataCategory Into all metdata category language tables
                MDCatBuilder.CheckNCreateMetadataCategory(MDCatInfo);
            }
        }