/// <summary> /// Check existance of Metadata Category record into database if false then create MetadataCategory record /// </summary> /// <param name="metadataCategoryInfo">object of MetadataCategoryInfo</param> /// <returns>MetadataCategoryNid</returns> public int CheckNCreateMetadataCategoryForCurrentLanguageOnly(MetadataCategoryInfo metadataCategoryInfo) { int RetVal = 0; try { // check Metadata Category exists or not RetVal = this.GetNidByName(metadataCategoryInfo.CategoryName, metadataCategoryInfo.CategoryType); // if Metadata Category does not exist then create it. if (RetVal <= 0) { // insert Metadata Category if (this.InsertIntoDatabaseForCurrLangOnly(metadataCategoryInfo)) { RetVal = this.GetNidByName(metadataCategoryInfo.CategoryName, metadataCategoryInfo.CategoryType); } } // add indicator information metadataCategoryInfo.CategoryNId = RetVal; } catch (Exception) { RetVal = 0; } return(RetVal); }
/// <summary> /// Check existance of Metadata Category record into database if false then create MetadataCategory record /// </summary> /// <param name="metadataCategoryInfo">object of MetadataCategoryInfo</param> /// <returns>MetadataCategoryNid</returns> public int CheckNCreateMetadataCategory(MetadataCategoryInfo metadataCategoryInfo) { int RetVal = 0; try { // check Metadata Category exists or not RetVal = this.GetNidByName(metadataCategoryInfo.CategoryName, metadataCategoryInfo.CategoryType); // if Metadata Category does not exist then create it. if (RetVal <= 0) { // insert Metadata Category if (this.InsertIntoDatabase(metadataCategoryInfo)) { RetVal = this.GetNidByName(metadataCategoryInfo.CategoryName, metadataCategoryInfo.CategoryType); } } // add indicator information metadataCategoryInfo.CategoryNId = RetVal; } catch (Exception) { RetVal = 0; } return RetVal; }
/// <summary> /// Returns instance of MetadataCategoryInfo details for filerText. /// </summary> /// <param name="filterClause"></param> /// <param name="filterText"></param> /// <returns></returns> public MetadataCategoryInfo GetMetadataCategoryInfo(FilterFieldType filterClause, string filterText) { string Query = string.Empty; MetadataCategoryInfo RetVal = new MetadataCategoryInfo(); DataTable MetadataCategoryTable; try { //get Metadata_Category information Query = this.DBQueries.Metadata_Category.GetMetadataCategories(filterClause, filterText); MetadataCategoryTable = this.DBConnection.ExecuteDataTable(Query); //set Metadata Category info if (MetadataCategoryTable != null) { if (MetadataCategoryTable.Rows.Count > 0) { RetVal.CategoryName = MetadataCategoryTable.Rows[0][Metadata_Category.CategoryName].ToString(); RetVal.CategoryType = Convert.ToString(MetadataCategoryTable.Rows[0][Metadata_Category.CategoryType]); RetVal.CategoryOrder = Convert.ToInt32(MetadataCategoryTable.Rows[0][Metadata_Category.CategoryOrder]); RetVal.CategoryNId = Convert.ToInt32(MetadataCategoryTable.Rows[0][Metadata_Category.CategoryNId]); } } } catch (Exception) { RetVal = null; } return(RetVal); }
/// <summary> /// Insert MetadataCategory record into database /// </summary> /// <param name="MetadataCategoryInfo">object of IndicatorInfo</param> /// <returns>Ture/False. Return true after successful insertion otherwise false</returns> private bool InsertIntoDatabase(MetadataCategoryInfo MetadataCategoryInfo) { bool RetVal = false; string MetadataCategoryName = MetadataCategoryInfo.CategoryName; string LanguageCode = string.Empty; string DefaultLanguageCode = string.Empty; string MetadataCategoryForDatabase = string.Empty; DITables TablesName; int LastOrder = 0; try { DefaultLanguageCode = this.DBQueries.LanguageCode; //get and set category order // get max category order from database/template try { LastOrder = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(this.DBQueries.Metadata_Category.GetMaxMetadataCategoryOrder(MetadataCategoryInfo.CategoryType))); } catch (Exception) { } LastOrder += 1; MetadataCategoryInfo.CategoryOrder = LastOrder; // insert metadata category into database/template foreach (DataRow languageRow in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows) { LanguageCode = languageRow[Language.LanguageCode].ToString(); TablesName = new DITables(this.DBQueries.DataPrefix, LanguageCode); //if (LanguageCode == DefaultLanguageCode.Replace("_", String.Empty)) //{ MetadataCategoryForDatabase = MetadataCategoryName; //} //else //{ // MetadataCategoryForDatabase = Constants.PrefixForNewValue + MetadataCategoryName; //} this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Insert.InsertMetadataCategory(TablesName.MetadataCategory, MetadataCategoryForDatabase, MetadataCategoryInfo.CategoryType, MetadataCategoryInfo.CategoryOrder)); } RetVal = true; } catch (Exception) { RetVal = false; } return(RetVal); }
private bool InsertXmlMetadataIntoCategoryTable(List <string> categoryList, CategoryType categoryType) { bool RetVal = false; int CategoryOrder = 0; MetadataCategoryInfo MetadataInfo; string CategoryTypeText = this.GetCategoryTypeText(categoryType); foreach (string CategoryItem in categoryList) { CategoryOrder++; MetadataInfo = new MetadataCategoryInfo(); MetadataInfo.CategoryName = CategoryItem; MetadataInfo.CategoryType = CategoryTypeText; MetadataInfo.CategoryOrder = CategoryOrder; // Add MetadataCategory Into all metdata category language tables this.CheckNCreateMetadataCategoryForCurrentLanguageOnly(MetadataInfo); RetVal = true; } return(RetVal); }
private bool InsertIntoDatabaseForCurrLangOnly(MetadataCategoryInfo MetadataCategoryInfo) { bool RetVal = false; string MetadataCategoryName = MetadataCategoryInfo.CategoryName; string LanguageCode = string.Empty; string DefaultLanguageCode = string.Empty; string MetadataCategoryForDatabase = string.Empty; DITables TablesName; int LastOrder = 0; try { DefaultLanguageCode = this.DBQueries.LanguageCode; //get and set category order // get max category order from database/template try { LastOrder = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(this.DBQueries.Metadata_Category.GetMaxMetadataCategoryOrder(MetadataCategoryInfo.CategoryType))); } catch (Exception) { } LastOrder += 1; MetadataCategoryInfo.CategoryOrder = LastOrder; // insert metadata category into database/template MetadataCategoryForDatabase = MetadataCategoryName; this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Insert.InsertMetadataCategory(this.DBQueries.TablesName.MetadataCategory, MetadataCategoryForDatabase, MetadataCategoryInfo.CategoryType, MetadataCategoryInfo.CategoryOrder)); RetVal = true; } catch (Exception) { RetVal = false; } return(RetVal); }
public void ReadXmlAndUpdateCategoryTable(string metadataXmlInfo, string metadataTypeText) { int CategoryOrder = 0; XmlDocument XmlDoc = new XmlDocument(); XmlNodeList RootNodeList; string DefaultCategoryLanguageValue = string.Empty; MetadataCategoryInfo MetadataInfo; string CategoryForDatabase = string.Empty; DITables Tables = null; DIQueries TempDBQueries = null; if (!string.IsNullOrEmpty(metadataXmlInfo.Trim())) { XmlDoc.LoadXml(metadataXmlInfo); // Get "Metadata" Root Element NodeList RootNodeList = XmlDoc.SelectNodes(Constants.MetadataCategory.MetadataCategoryNodePath); // Get first recrod from "metadata/Category" Node and insert into all available Metadata_Category language table // Check Category In each "metadata/Category" Node for (int Index = 0; Index < RootNodeList.Count; Index++)//reach (XmlElement InputNodeList in RootNodeList.Count) { MetadataInfo = new MetadataCategoryInfo(); // Set MetadataCategoryInfo Value MetadataInfo.CategoryName = DICommon.RemoveQuotes(Convert.ToString(RootNodeList[Index].Attributes["name"].Value)); //-- Get Max Category Order CategoryOrder = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(this.DBQueries.Metadata_Category.GetMaxMetadataCategoryOrder(metadataTypeText))); MetadataInfo.CategoryOrder = CategoryOrder; MetadataInfo.CategoryType = metadataTypeText; // Add MetadataCategory Into all metdata category language tables this.CheckNCreateMetadataCategory(MetadataInfo); } } }
private int CheckNUpdateMetadataCategoryInLangTable(MetadataCategoryInfo metadataCategoryInfo, string languageCode, string defaultLanguageCategoryName) { int RetVal = 0; DITables TablesName; DIQueries NewDBQueries = null; string SqlQuery = string.Empty; try { NewDBQueries = new DIQueries(this.DBQueries.DataPrefix, languageCode); TablesName = new DITables(this.DBQueries.DataPrefix, languageCode); // check Metadata Category exists or not RetVal = this.GetNidByName(metadataCategoryInfo.CategoryName, NewDBQueries); metadataCategoryInfo.CategoryNId = this.GetNidByName(defaultLanguageCategoryName, NewDBQueries); // if Metadata Category does not exist then create it. if (RetVal <= 0 && metadataCategoryInfo.CategoryNId > 0) { SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Update.UpdateMetadataCategory(TablesName.MetadataCategory, metadataCategoryInfo.CategoryNId, DICommon.RemoveQuotes(metadataCategoryInfo.CategoryName), metadataCategoryInfo.CategoryType, metadataCategoryInfo.CategoryOrder); this.DBConnection.ExecuteNonQuery(SqlQuery); RetVal = this.GetNidByName(metadataCategoryInfo.CategoryName, metadataCategoryInfo.CategoryType); } // add indicator information metadataCategoryInfo.CategoryNId = RetVal; } catch (Exception) { RetVal = 0; } return(RetVal); }
private void ReadMaskMetadataNInsertIntoCategoryTable(XmlDocument XmlDoc, CategoryType categoryType) { int CategoryOrder = 0; XmlNodeList RootNodeList; string DefaultCategoryLanguageValue = string.Empty; MetadataCategoryInfo MetadataInfo; string CategoryTypeText = string.Empty; // Get Mask Type like "I" for Indicator, "A" for Map and "S" for Source CategoryTypeText = this.GetCategoryTypeText(categoryType); // Get Root Element NodeList RootNodeList = XmlDoc.SelectNodes(Constants.MetadataCategory.RootElementName); // Get first recrod from "root/Input<n>" Node and insert into all available Metadata_Category language table // Check Category In each "root/Input<n>" Node foreach (XmlElement InputNodeList in RootNodeList.Item(0).ChildNodes) { CategoryOrder++; // Check category In Input Node and insert metdata category language value into all metadata category language tables for (int i = 0; i < InputNodeList.ChildNodes.Count; i++) { if (InputNodeList.ChildNodes[i].Name == Constants.MetadataCategory.CaptionElementName) { // set category value into default category langauge value DefaultCategoryLanguageValue = InputNodeList.ChildNodes[i].InnerText; // check xml languagecode is default language if (InputNodeList.ChildNodes[i].Attributes[Constants.MetadataCategory.LangAttributeName].Value.ToUpper() == this.DBQueries.LanguageCode.Replace("_", "").ToUpper()) { MetadataInfo = new MetadataCategoryInfo(); // Set MetadataCategoryInfo Value MetadataInfo.CategoryName = InputNodeList.ChildNodes[i].InnerText; MetadataInfo.CategoryType = CategoryTypeText; MetadataInfo.CategoryOrder = CategoryOrder; // Add MetadataCategory Into all metdata category language tables this.CheckNCreateMetadataCategoryForCurrentLanguageOnly(MetadataInfo); break; } } } // update metadata category language value into their respective metadata category language table for (int i = 0; i < InputNodeList.ChildNodes.Count; i++) { if (InputNodeList.ChildNodes[i].Name == Constants.MetadataCategory.CaptionElementName) { // Check lang attribute is valid language or not if (this.DBConnection.IsValidDILanguage(this.DBQueries.DataPrefix, InputNodeList.ChildNodes[i].Attributes[Constants.MetadataCategory.LangAttributeName].Value)) { MetadataInfo = new MetadataCategoryInfo(); // Set MetadataCategoryInfo Value MetadataInfo.CategoryName = InputNodeList.ChildNodes[i].InnerText; MetadataInfo.CategoryType = CategoryTypeText; MetadataInfo.CategoryOrder = CategoryOrder; if (MetadataInfo.CategoryName != DefaultCategoryLanguageValue) { // update MetadataCategory Into database this.CheckNUpdateMetadataCategoryInLangTable(MetadataInfo, "_" + InputNodeList.ChildNodes[i].Attributes[Constants.MetadataCategory.LangAttributeName].Value, DefaultCategoryLanguageValue); } } } } } }
/// <summary> /// Returns instance of MetadataCategoryInfo details for filerText. /// </summary> /// <param name="filterClause"></param> /// <param name="filterText"></param> /// <returns></returns> public MetadataCategoryInfo GetMetadataCategoryInfo(FilterFieldType filterClause, string filterText) { string Query = string.Empty; MetadataCategoryInfo RetVal = new MetadataCategoryInfo(); DataTable MetadataCategoryTable; try { //get Metadata_Category information Query = this.DBQueries.Metadata_Category.GetMetadataCategories(filterClause, filterText); MetadataCategoryTable = this.DBConnection.ExecuteDataTable(Query); //set Metadata Category info if (MetadataCategoryTable != null) { if (MetadataCategoryTable.Rows.Count > 0) { RetVal.CategoryName = MetadataCategoryTable.Rows[0][Metadata_Category.CategoryName].ToString(); RetVal.CategoryType = Convert.ToString(MetadataCategoryTable.Rows[0][Metadata_Category.CategoryType]); RetVal.CategoryOrder = Convert.ToInt32(MetadataCategoryTable.Rows[0][Metadata_Category.CategoryOrder]); RetVal.CategoryNId = Convert.ToInt32(MetadataCategoryTable.Rows[0][Metadata_Category.CategoryNId]); } } } catch (Exception) { RetVal = null; } return RetVal; }
private bool InsertXmlMetadataIntoCategoryTable(List<string> categoryList, CategoryType categoryType) { bool RetVal = false; int CategoryOrder = 0; MetadataCategoryInfo MetadataInfo; string CategoryTypeText = this.GetCategoryTypeText(categoryType); foreach (string CategoryItem in categoryList) { CategoryOrder++; MetadataInfo = new MetadataCategoryInfo(); MetadataInfo.CategoryName = CategoryItem; MetadataInfo.CategoryType = CategoryTypeText; MetadataInfo.CategoryOrder = CategoryOrder; // Add MetadataCategory Into all metdata category language tables this.CheckNCreateMetadataCategoryForCurrentLanguageOnly(MetadataInfo); RetVal = true; } return RetVal; }
private bool InsertIntoDatabaseForCurrLangOnly(MetadataCategoryInfo MetadataCategoryInfo) { bool RetVal = false; string MetadataCategoryName = MetadataCategoryInfo.CategoryName; string LanguageCode = string.Empty; string DefaultLanguageCode = string.Empty; string MetadataCategoryForDatabase = string.Empty; DITables TablesName; int LastOrder = 0; try { DefaultLanguageCode = this.DBQueries.LanguageCode; //get and set category order // get max category order from database/template try { LastOrder = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(this.DBQueries.Metadata_Category.GetMaxMetadataCategoryOrder(MetadataCategoryInfo.CategoryType))); } catch (Exception) { } LastOrder += 1; MetadataCategoryInfo.CategoryOrder = LastOrder; // insert metadata category into database/template MetadataCategoryForDatabase = MetadataCategoryName; this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Insert.InsertMetadataCategory(this.DBQueries.TablesName.MetadataCategory, MetadataCategoryForDatabase, MetadataCategoryInfo.CategoryType, MetadataCategoryInfo.CategoryOrder)); RetVal = true; } catch (Exception) { RetVal = false; } return RetVal; }
/// <summary> /// Insert MetadataCategory record into database /// </summary> /// <param name="MetadataCategoryInfo">object of IndicatorInfo</param> /// <returns>Ture/False. Return true after successful insertion otherwise false</returns> private bool InsertIntoDatabase(MetadataCategoryInfo MetadataCategoryInfo) { bool RetVal = false; string MetadataCategoryName = MetadataCategoryInfo.CategoryName; string LanguageCode = string.Empty; string DefaultLanguageCode = string.Empty; string MetadataCategoryForDatabase = string.Empty; DITables TablesName; int LastOrder = 0; try { DefaultLanguageCode = this.DBQueries.LanguageCode; //get and set category order // get max category order from database/template try { LastOrder = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(this.DBQueries.Metadata_Category.GetMaxMetadataCategoryOrder(MetadataCategoryInfo.CategoryType))); } catch (Exception) { } LastOrder += 1; MetadataCategoryInfo.CategoryOrder = LastOrder; // insert metadata category into database/template foreach (DataRow languageRow in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows) { LanguageCode = languageRow[Language.LanguageCode].ToString(); TablesName = new DITables(this.DBQueries.DataPrefix, LanguageCode); //if (LanguageCode == DefaultLanguageCode.Replace("_", String.Empty)) //{ MetadataCategoryForDatabase = MetadataCategoryName; //} //else //{ // MetadataCategoryForDatabase = Constants.PrefixForNewValue + MetadataCategoryName; //} this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Insert.InsertMetadataCategory(TablesName.MetadataCategory, MetadataCategoryForDatabase, MetadataCategoryInfo.CategoryType, MetadataCategoryInfo.CategoryOrder)); } RetVal = true; } catch (Exception) { RetVal = false; } return RetVal; }
private int CheckNUpdateMetadataCategoryInLangTable(MetadataCategoryInfo metadataCategoryInfo, string languageCode, string defaultLanguageCategoryName) { int RetVal = 0; DITables TablesName; DIQueries NewDBQueries = null; string SqlQuery = string.Empty; try { NewDBQueries = new DIQueries(this.DBQueries.DataPrefix, languageCode); TablesName = new DITables(this.DBQueries.DataPrefix, languageCode); // check Metadata Category exists or not RetVal = this.GetNidByName(metadataCategoryInfo.CategoryName, NewDBQueries); metadataCategoryInfo.CategoryNId = this.GetNidByName(defaultLanguageCategoryName, NewDBQueries); // if Metadata Category does not exist then create it. if (RetVal <= 0 && metadataCategoryInfo.CategoryNId > 0) { SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.MetadataCategory.Update.UpdateMetadataCategory(TablesName.MetadataCategory, metadataCategoryInfo.CategoryNId, DICommon.RemoveQuotes(metadataCategoryInfo.CategoryName), metadataCategoryInfo.CategoryType, metadataCategoryInfo.CategoryOrder); this.DBConnection.ExecuteNonQuery(SqlQuery); RetVal = this.GetNidByName(metadataCategoryInfo.CategoryName, metadataCategoryInfo.CategoryType); } // add indicator information metadataCategoryInfo.CategoryNId = RetVal; } catch (Exception) { RetVal = 0; } return RetVal; }
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 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); } }