/// <summary> /// Delete Notes Classificaton by Classification Nid /// </summary> /// <param name="classificationNids">Comma separated NIDs</param> /// <returns >Count Of Records Updated</returns> public int DeleteNotesClassification(string classificationNids) { int RetVal = 0; string LanguageCode = string.Empty; DITables TableNames; string SqlQuery = string.Empty; string AssociatedNotesNids = string.Empty; NotesBuilder NoteBuilder = new NotesBuilder(this.DBConnection, this.DBQueries); try { foreach (DataRow Row in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows) { LanguageCode = Convert.ToString(Row[Language.LanguageCode]); TableNames = new DITables(this.DBQueries.DataPrefix, "_" + LanguageCode); SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.Notes.Delete.DeleteFrmNotesClassification(TableNames.NotesClassification, classificationNids); RetVal = this.DBConnection.ExecuteNonQuery(SqlQuery); AssociatedNotesNids = DIConnection.GetDelimitedValuesFromDataTable(NoteBuilder.GetNotesByNotesNid(string.Empty, string.Empty, string.Empty, classificationNids, CheckedStatus.All, FieldSelection.Light), Notes.NotesNId); NoteBuilder.DeleteComments(AssociatedNotesNids); } } catch (Exception ex) { throw new ApplicationException(ex.Message); } return(RetVal); }
/// <summary> /// /// Deletes metadata category records from metadata category and metadata report tables /// </summary> /// <param name="categoryNid"></param> public void DeleteMetadataCategory(int categoryNid) { string LanguageCode = string.Empty; DITables TablesName; string CategoryNids = categoryNid.ToString(); DataTable SubCategoriesTable = null; try { // Get sub categories nid SubCategoriesTable = this.DBConnection.ExecuteDataTable(this.DBQueries.Metadata_Category.GetMetadataCategories(FilterFieldType.Search, Metadata_Category.ParentCategoryNId + "=" + categoryNid.ToString())); if (SubCategoriesTable.Rows.Count > 0) { CategoryNids += "," + DIConnection.GetDelimitedValuesFromDataTable(SubCategoriesTable, Metadata_Category.CategoryNId); } foreach (DataRow languageRow in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows) { LanguageCode = languageRow[Language.LanguageCode].ToString(); TablesName = new DITables(this.DBQueries.DataPrefix, LanguageCode); // Delete records from metadata category table this.DBConnection.ExecuteNonQuery(DI_LibDAL.Queries.MetadataCategory.Delete.DeleteMetadataCategory(TablesName.MetadataCategory, CategoryNids)); // Delete records from metadata report table this.DBConnection.ExecuteNonQuery(DI_LibDAL.Queries.MetadataReport.Delete.DeleteMetadataRecordsByCategories(TablesName.MetadataReport, CategoryNids)); } } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } }
/// <summary> /// Import ISDefaultSubgroup from database /// </summary> /// <param name="sourceDatabase"></param> /// <param name="sourceDBQueries"></param> public void ImportDefaultSubgroups(DIConnection sourceDBConnection, DIQueries sourceDBQueries) { string IUSNids = string.Empty; DataTable IUSTable = null; DataTable IUTable = null; IUSInfo IUSInfoObj = new IUSInfo(); //-- Get IUS from Source Database IUSTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.IUS.GetIUS(FilterFieldType.None, string.Empty, FieldSelection.Light, true)); //-- Get Default IUS Values DataRow[] IUSRows = IUSTable.Select(Indicator_Unit_Subgroup.IsDefaultSubgroup + "=1"); foreach (DataRow Row in IUSRows) { IUSInfoObj = new IUSInfo(); IUSInfoObj.IndicatorInfo = new IndicatorInfo(); IUSInfoObj.UnitInfo = new UnitInfo(); IUSInfoObj.SubgroupValInfo = new DI6SubgroupValInfo(); IUSInfoObj.IndicatorInfo.Name = Convert.ToString(Row[Indicator.IndicatorName]); IUSInfoObj.IndicatorInfo.GID = Convert.ToString(Row[Indicator.IndicatorGId]); IUSInfoObj.UnitInfo.Name = Convert.ToString(Row[Unit.UnitName]); IUSInfoObj.UnitInfo.GID = Convert.ToString(Row[Unit.UnitGId]); IUSInfoObj.SubgroupValInfo.Name = Convert.ToString(Row[SubgroupVals.SubgroupVal]); IUSInfoObj.SubgroupValInfo.GID = Convert.ToString(Row[SubgroupVals.SubgroupValGId]); int IUSNid = this.GetIUSNid(IUSInfoObj); //-- Set Default Subgroup if IUS exists if (IUSNid > 0) { IUTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IUS.GetIUSByI_U_S(IUSInfoObj.IndicatorInfo.Nid.ToString(), IUSInfoObj.UnitInfo.Nid.ToString(), string.Empty)); IUSNids = DIConnection.GetDelimitedValuesFromDataTable(IUTable, Indicator_Unit_Subgroup.IUSNId); //-- Make ISDefault false for other subgroupval for current I-U this.UpdateIUSISDefaultSubgroup(IUSNids, false); //-- Set DefaultSubgroupVal for IUSNid this.UpdateIUSISDefaultSubgroup(IUSNid.ToString(), true); } } }