public IntegratedCircuit(int numPins) { Id = Guid.NewGuid(); IcType = ICType.unknown; ModelName = "Unknown"; OverwriteObjText = true; WriteToNodes = true; PinNames = new string[] { }; PinNamesDisplayed = false; isEditable = false; Pins = numPins; Vdd = numPins - 1; Gnd = (numPins / 2) - 1; PinIndex = Enumerable.Repeat(-1, Pins).ToArray(); PinNodes = Enumerable.Repeat("", Pins).ToArray(); PinState = Enumerable.Repeat(State.OFF, Pins).ToArray(); PinModes = Enumerable.Repeat(PinMode.Input, Pins).ToArray(); DefaultState = Enumerable.Repeat(State.LOW, Pins).ToArray(); if (Pins > 3) { DefaultState[Vdd] = 0; DefaultState[Gnd] = 0; } }
/// <summary> /// Delete IC & IUS relation by IUS/Indicator /// </summary> /// <param name="icType"></param> /// <param name="ICNid"></param> /// <param name="IUSNid"></param> /// <param name="isIUS"></param> public void DeleteICIUSRelationUptoRootlevel(ICType icType, int ICNid, int IUSNid, bool isIUS) { string IUSNIds = string.Empty; DataTable Table = null; try { if (!isIUS) { Table = this.DBConnection.ExecuteDataTable(this.DBQueries.IUS.GetIUSByI_U_S(IUSNid.ToString(), string.Empty, string.Empty)); //IUSNIds = DIConnection.GetDelimitedValuesFromDataTable(Table, Indicator.IndicatorNId); foreach (DataRow Row in Table.Rows) { this.DeleteICIUSRelationUptoRootlevel(icType, ICNid, Convert.ToInt32(Row[Indicator_Unit_Subgroup.IUSNId])); } } else { this.DeleteICIUSRelationUptoRootlevel(icType, ICNid, IUSNid); } } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } }
/// <summary> /// Get AreaBy ICNid or AreaNids /// </summary> /// <param name="selectedICType"></param> /// <param name="userSelections"></param> /// <returns></returns> public string GetAutoDistinctArea(ICType selectedICType, UserSelection.UserSelection userSelections) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); sbQuery.Append("SELECT A." + DIColumns.Data.AreaNId + ", A." + DIColumns.Area.AreaGlobal + ", A." + DIColumns.Area.AreaName); sbQuery.Append(" FROM " + this.TablesName.Area + " AS A "); sbQuery.Append(" WHERE EXISTS ( Select * FROM " + this.TablesName.Data + " AS D "); if (userSelections.ICNIds.Length > 0 && string.IsNullOrEmpty(userSelections.IndicatorNIds)) { sbQuery.Append("," + this.TablesName.IndicatorClassifications + " AS IC"); sbQuery.Append("," + this.TablesName.IndicatorClassificationsIUS + " AS ICIUS"); } sbQuery.Append(" WHERE D." + DIColumns.Data.AreaNId + " = A." + DIColumns.Area.AreaNId); if (userSelections.AreaNIds.Length > 0) { sbQuery.Append(" AND D." + DIColumns.Data.AreaNId + " IN(" + userSelections.AreaNIds + ")"); } if (userSelections.TimePeriodNIds.Length > 0) { sbQuery.Append(" AND D." + DIColumns.Data.TimePeriodNId + " IN(" + userSelections.TimePeriodNIds + ")"); } if (userSelections.SourceNIds.Length > 0) { sbQuery.Append(" AND D." + DIColumns.Data.SourceNId + " IN(" + userSelections.SourceNIds + ")"); } if (userSelections.ShowIUS & userSelections.IndicatorNIds.Length > 0) { sbQuery.Append(" AND D." + DIColumns.Data.IUSNId + " IN(" + userSelections.IndicatorNIds + ")"); } else if (userSelections.IndicatorNIds.Length > 0) { sbQuery.Append(" AND D." + DIColumns.Data.IndicatorNId + " IN(" + userSelections.IndicatorNIds + ")"); } if (userSelections.ICNIds.Length > 0 && string.IsNullOrEmpty(userSelections.IndicatorNIds)) { sbQuery.Append(" AND ICIUS." + DIColumns.IndicatorClassificationsIUS.ICNId + " =IC." + DIColumns.IndicatorClassifications.ICNId); sbQuery.Append(" AND ICIUS." + DIColumns.IndicatorClassificationsIUS.IUSNId + " =D." + DIColumns.Data.IUSNId); if (userSelections.ICNIds != "-1") { sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICNId + " IN(" + userSelections.ICNIds + ")"); } sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICType + "=" + DIQueries.ICTypeText[selectedICType]); } sbQuery.Append(") ORDER BY A." + DIColumns.Area.AreaName + " DESC "); RetVal = sbQuery.ToString(); return RetVal; }
private string GetSqlQueryForIC(string searchString, ICType classificationType) { string RetVal = string.Empty; RetVal = this.SourceDBQueries.IndicatorClassification.GetIC(FilterFieldType.None, string.Empty, classificationType, FieldSelection.Heavy); return(RetVal); }
public IndicatorClassificationInfo(string name, ICType type, bool isGlobal, int parentNid) { this._Parent = new IndicatorClassificationInfo(); this._Name = name; this._Type = type; this._IsGlobal = isGlobal; this._Parent.Nid = parentNid; }
public string GetAllIUSByIC(ICType ICType, string ICNId, FieldSelection fieldSelection) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); // SELECT Clause sbQuery.Append("SELECT IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + ",IUS." + DIColumns.Indicator_Unit_Subgroup.IndicatorNId + ",IUS." + DIColumns.Indicator_Unit_Subgroup.UnitNId + ",IUS." + DIColumns.Indicator_Unit_Subgroup.SubgroupValNId); if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append(",I." + DIColumns.Indicator.IndicatorName + ",I." + DIColumns.Indicator.IndicatorGId + ",I." + DIColumns.Indicator.IndicatorGlobal); sbQuery.Append(",U." + DIColumns.Unit.UnitName + ",U." + DIColumns.Unit.UnitGId + ",U." + DIColumns.Unit.UnitGlobal); sbQuery.Append(",SGV." + DIColumns.SubgroupVals.SubgroupVal + ",SGV." + DIColumns.SubgroupVals.SubgroupValGId + ",SGV." + DIColumns.SubgroupVals.SubgroupValGlobal); sbQuery.Append(",ICIUS." + DIColumns.IndicatorClassifications.ICNId + ", ICIUS." + DIColumns.IndicatorClassificationsIUS.RecommendedSource); sbQuery.Append(",ICIUS." + DIColumns.IndicatorClassificationsIUS.ICIUSOrder); } if (fieldSelection == FieldSelection.Heavy) { sbQuery.Append(",I." + DIColumns.Indicator.IndicatorInfo); } // FROM Clause sbQuery.Append(" FROM " + this.TablesName.IndicatorUnitSubgroup + " AS IUS"); if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append("," + this.TablesName.Indicator + " AS I"); sbQuery.Append("," + this.TablesName.Unit + " AS U"); sbQuery.Append("," + this.TablesName.SubgroupVals + " AS SGV"); } sbQuery.Append("," + this.TablesName.IndicatorClassificationsIUS + " AS ICIUS"); sbQuery.Append("," + this.TablesName.IndicatorClassifications + " AS IC"); // WHERE Clause sbQuery.Append(" WHERE 1=1 "); if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.IndicatorNId + " = I." + DIColumns.Indicator.IndicatorNId); sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.UnitNId + " = U." + DIColumns.Unit.UnitNId); sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.SubgroupValNId + " = SGV." + DIColumns.SubgroupVals.SubgroupValNId); } sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + " = ICIUS." + DIColumns.IndicatorClassificationsIUS.IUSNId); sbQuery.Append(" AND ICIUS." + DIColumns.IndicatorClassificationsIUS.ICNId + " = IC." + DIColumns.IndicatorClassifications.ICNId); sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICType + " = " + DIQueries.ICTypeText[ICType]); if (ICNId.Length > 0) { sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICNId + " IN (" + ICNId + ")"); } // ORDER BY Clause if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append(" ORDER BY I." + DIColumns.Indicator.IndicatorName); } RetVal = sbQuery.ToString(); return RetVal; }
/// <summary> /// Rerturns sql query to get recommended sources for the given Nids.Any NIds can be empty. /// </summary> /// <param name="IUSNIds"></param> /// <param name="areaNIds"></param> /// <param name="timeperiodNIds"></param> /// <param name="sourceNIds"></param> /// <param name="ICNIds"></param> /// <param name="selectedICType"></param> /// <returns></returns> public string GetAllRecordsByIUSTimeperiodAreaNSource(string IUSNIds, string areaNIds, string timeperiodNIds, string sourceNIds,string ICNIds ,ICType selectedICType) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); sbQuery.Append("SELECT D." + DIColumns.Data.DataNId + ",D." + DIColumns.Data.IUSNId + ",D." + DIColumns.Indicator.IndicatorNId + ",I." + DIColumns.Indicator.IndicatorGlobal + ",I." + DIColumns.Indicator.IndicatorName + ",D." + DIColumns.Unit.UnitNId + ",U." + DIColumns.Unit.UnitGlobal + ",U." + DIColumns.Unit.UnitName + ",D." + DIColumns.SubgroupVals.SubgroupValNId + ",SGV." + DIColumns.SubgroupVals.SubgroupValGlobal + ",SGV." + DIColumns.SubgroupVals.SubgroupVal + ",D." + DIColumns.Area.AreaNId + ",A." + DIColumns.Area.AreaGlobal + ",A." + DIColumns.Area.AreaName + ",T." + DIColumns.Timeperiods.TimePeriodNId + ",T." + DIColumns.Timeperiods.TimePeriod + ",D." + DIColumns.Data.SourceNId + ",IC." + DIColumns.IndicatorClassifications.ICGlobal + ",IC." + DIColumns.IndicatorClassifications.ICName + ",D." + DIColumns.Data.ICIUSOrder); sbQuery.Append(this.GetGenericFromClause()); if (ICNIds.Length > 0 && string.IsNullOrEmpty(IUSNIds)) { sbQuery.Append("," + this.TablesName.IndicatorClassifications + " AS IC1 "); sbQuery.Append("," + this.TablesName.IndicatorClassificationsIUS + " AS ICIUS "); } sbQuery.Append(" WHERE "); sbQuery.Append(" D." + DIColumns.Indicator_Unit_Subgroup.IndicatorNId + " = I." + DIColumns.Indicator.IndicatorNId); sbQuery.Append(" AND D." + DIColumns.Indicator_Unit_Subgroup.UnitNId + " = U." + DIColumns.Unit.UnitNId); sbQuery.Append(" AND D." + DIColumns.Indicator_Unit_Subgroup.SubgroupValNId + " = SGV." + DIColumns.SubgroupVals.SubgroupValNId); sbQuery.Append(" AND D." + DIColumns.Data.TimePeriodNId + " = T." + DIColumns.Timeperiods.TimePeriodNId); sbQuery.Append(" AND D." + DIColumns.Data.AreaNId + " = A." + DIColumns.Area.AreaNId); sbQuery.Append(" AND D." + DIColumns.Data.SourceNId + " = IC." + DIColumns.IndicatorClassifications.ICNId); if (!string.IsNullOrEmpty(IUSNIds)) { sbQuery.Append(" AND D." + DIColumns.Data.IUSNId + " IN(" + IUSNIds + ")"); } if (!string.IsNullOrEmpty(areaNIds)) { sbQuery.Append(" AND D." + DIColumns.Data.AreaNId + " IN(" + areaNIds + ")"); } if (!string.IsNullOrEmpty(timeperiodNIds)) { sbQuery.Append(" AND D." + DIColumns.Data.TimePeriodNId + " IN(" + timeperiodNIds + ")"); } if (!string.IsNullOrEmpty(sourceNIds)) { sbQuery.Append(" AND D." + DIColumns.Data.SourceNId + " IN(" + sourceNIds + ")"); } if (ICNIds.Length > 0 && string.IsNullOrEmpty(IUSNIds)) { sbQuery.Append(" AND ICIUS." + DIColumns.IndicatorClassifications.ICNId + " =IC1." + DIColumns.IndicatorClassifications.ICNId); sbQuery.Append(" AND ICIUS." + DIColumns.IndicatorClassificationsIUS.IUSNId + " =D." + DIColumns.Data.IUSNId); if (ICNIds != "-1") { sbQuery.Append(" AND IC1." + DIColumns.IndicatorClassifications.ICNId + " IN(" + ICNIds + ")"); } sbQuery.Append(" AND IC1." + DIColumns.IndicatorClassifications.ICType + "=" + DIQueries.ICTypeText[selectedICType]); } RetVal = sbQuery.ToString(); return RetVal; }
private void Get_ICChain(string parentICGID, ICType icICType, SDMXObjectModel.Structure.CategoryType CatTypeCode) { string Name = string.Empty; string GID = string.Empty; string LanguageCode = this._LanguageCode; int NID = 0; bool ISGlobal = false; // Read each child IC for current IC foreach (SDMXObjectModel.Structure.CategoryType SubCateType in CatTypeCode.Items) { GID = SubCateType.id; Name = string.Empty; ISGlobal = false; foreach (TextType IndTextType in SubCateType.Name) { if (IndTextType.lang.Trim('_') == this._LanguageCode) { Name = IndTextType.Value; break; } } foreach (AnnotationType AnnType in SubCateType.Annotations) { if (AnnType.AnnotationTitle == SDMXConstants.Annotations.IsGlobal) { foreach (TextType AnnTextType in AnnType.AnnotationText) { ISGlobal = Convert.ToBoolean(AnnTextType.Value); break; } } } if (!this.ICDetails.ContainsKey(GID)) { IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo(); TableInfoObj.GID = GID; TableInfoObj.Name = Name; TableInfoObj.Type = icICType; TableInfoObj.Parent = new IndicatorClassificationInfo(); TableInfoObj.Parent.GID = parentICGID; this.ICDetails.Add(GID, TableInfoObj); } this.Get_ICChain(GID, icICType, SubCateType); } }
/// <summary> /// Delete IC and IUS relation upto root level. /// </summary> public void DeleteICIUSRelationUptoRootlevel(ICType icType, int ICNid, int IUSNid) { string SqlQuery = string.Empty; DataView ICTable = null; int ICParentNid = ICNid; int ChildICNId; DataView IUSTable = null; bool IUSFound = false; try { if ((ICParentNid != -1)) { // add ic and ius relationship this.DeleteClassificationIUSRelation(ICNid.ToString(), IUSNid.ToString()); SqlQuery = this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, ICParentNid.ToString(), FieldSelection.NId); ICTable = this.DBConnection.ExecuteDataTable(SqlQuery).DefaultView; if (ICTable.Count > 0) { ICParentNid = (int)ICTable[0][IndicatorClassifications.ICParent_NId]; SqlQuery = this.DBQueries.IndicatorClassification.GetICForParentNIdAndICType(icType, ICParentNid); ICTable = this.DBConnection.ExecuteDataTable(SqlQuery).DefaultView; foreach (DataRowView Row in ICTable) { ChildICNId = Convert.ToInt32(Row[IndicatorClassifications.ICNId]); SqlQuery = this.DBQueries.IUS.GetIUSByIC(icType, ChildICNId, FieldSelection.NId); IUSTable = this.DBConnection.ExecuteDataTable(SqlQuery).DefaultView; IUSTable.RowFilter = Indicator_Unit_Subgroup.IUSNId + "=" + IUSNid; //-- Delete Relation if IUS not associated with other siblings if (IUSTable.Count > 0) { IUSFound = true; } } if (!IUSFound) { this.DeleteICIUSRelationUptoRootlevel(icType, ICParentNid, IUSNid); } } } } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } }
/// <summary> /// Retruns nid only if GID exists in the database /// </summary> /// <returns></returns> public int GetNidByGID(string GID, ICType type) { string SqlQuery = string.Empty; int RetVal = 0; try { SqlQuery = this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.GId, "'" + GID + "'", type, FieldSelection.NId); RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(SqlQuery)); } catch (Exception) { RetVal = 0; } return(RetVal); }
public DataTable GetDataTable(string searchString, ICType classificationType, bool isMetadataRequired, bool includeOnlyName) { string SqlQuery = string.Empty; DataTable SourceTable = null; try { //Step1: Get sqlquery SqlQuery = this.GetSqlQueryForIC(searchString, classificationType); //Step2: Execute query and get datatable SourceTable = this.SourceDBConnection.ExecuteDataTable(SqlQuery); this.ProcessDataTable(ref SourceTable, classificationType, isMetadataRequired, includeOnlyName); } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return SourceTable; }
/// <summary> /// Get NId, Name, GID, Global from Indicator table based on Indicator Classification Type /// </summary> /// <param name="ICType">Indicator Classification Type with which associated indicator are to be retrieved</param> /// <param name="ICNId">ICNId which may be -1 if only ICType is to be considered</param> /// <param name="fieldSelection">Use heavy for all fields or use light to exclude IndicatorInfo field</param> /// <returns>Sql query string</returns> public string GetAllIndicatorByIC(ICType ICType, string ICNId, FieldSelection fieldSelection) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); // SELECT clause sbQuery.Append("SELECT I." + DIColumns.Indicator.IndicatorNId); //FieldSelection.NId if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append(",I." + DIColumns.Indicator.IndicatorName + ",I." + DIColumns.Indicator.IndicatorGId + ",I." + DIColumns.Indicator.IndicatorGlobal); } if (fieldSelection == FieldSelection.Heavy) { sbQuery.Append(",I." + DIColumns.Indicator.IndicatorInfo); } // FROM Clause sbQuery.Append(" FROM " + this.TablesName.Indicator + " AS I"); sbQuery.Append("," + this.TablesName.IndicatorUnitSubgroup + " AS IUS"); sbQuery.Append("," + this.TablesName.IndicatorClassificationsIUS + " AS ICIUS"); sbQuery.Append("," + this.TablesName.IndicatorClassifications + " AS IC"); // WHERE Clause sbQuery.Append(" WHERE I." + DIColumns.Indicator.IndicatorNId + " = IUS." + DIColumns.Indicator_Unit_Subgroup.IndicatorNId); sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + " = ICIUS." + DIColumns.IndicatorClassificationsIUS.IUSNId); sbQuery.Append(" AND ICIUS." + DIColumns.IndicatorClassificationsIUS.ICNId + " = IC." + DIColumns.IndicatorClassifications.ICNId); sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICType + " = " + DIQueries.ICTypeText[ICType]); if (!string.IsNullOrEmpty(ICNId) && ICNId != "-1") { sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICNId + " IN (" + ICNId + ")"); } // ORDER BY Clause sbQuery.Append(" ORDER BY " + DIColumns.Indicator.IndicatorName); RetVal = sbQuery.ToString(); return RetVal; }
/// <summary> /// Retruns nid only if name exists in the database /// </summary> /// <param name="name"></param> /// <param name="parentNid"></param> /// <param name="type"></param> /// <returns></returns> private int GetNidByName(string name, int parentNid, ICType type) { int RetVal = 0; string SqlQuery = string.Empty; DataTable TempTable; DataRow[] Rows; try { SqlQuery = this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.Name, "'" + name + "'", type, FieldSelection.NId); TempTable = this.DBConnection.ExecuteDataTable(SqlQuery); if (TempTable.Rows.Count > 0) { Rows = TempTable.Select(IndicatorClassifications.ICParent_NId + "=" + parentNid); RetVal = Convert.ToInt32(Rows[0][IndicatorClassifications.ICNId]); } } catch (Exception) { RetVal = 0; } return(RetVal); }
public bool NodeHasICType(string nodeId, ICType iCType) { if (nodes.ContainsKey(nodeId)) { Node node = nodes[nodeId]; foreach (Connection connection in node.connections.Values) { if (!connection.IsNode) { Guid id = Guid.Parse(connection.ID); if (!connection.IsNode && components.ContainsKey(id)) { IntegratedCircuit c = components[id]; if (c.IcType == iCType) { return(true); } } } } } return(false); }
public DataTable GetDataTable(string searchString, ICType classificationType, bool isMetadataRequired, bool includeOnlyName) { string SqlQuery = string.Empty; DataTable SourceTable = null; try { //Step1: Get sqlquery SqlQuery = this.GetSqlQueryForIC(searchString, classificationType); //Step2: Execute query and get datatable SourceTable = this.SourceDBConnection.ExecuteDataTable(SqlQuery); this.ProcessDataTable(ref SourceTable, classificationType, isMetadataRequired, includeOnlyName); } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return(SourceTable); }
/// <summary> /// Getting MetaData and writing them to Rtf file. /// </summary> public static string ExtractRtfMetadata(ICType ICType, int ICNId, DIConnection DIConnection, DIQueries DIQueries, String outputFolder, String outputFileName) { string RetVal = string.Empty; string RtfFilePath = System.IO.Path.Combine(outputFolder, outputFileName + ".rtf"); DataTable RtfDataTable = new DataTable(); try { if (System.IO.File.Exists(RtfFilePath)) { System.IO.File.Delete(RtfFilePath); } // getting metadata informationn from Database into DataTable RtfDataTable string sSql = DIQueries.IndicatorClassification.GetIC(FilterFieldType.NId, ICNId.ToString(), ICType, FieldSelection.Heavy); RtfDataTable = DIConnection.ExecuteDataTable(sSql); if (RtfDataTable != null & RtfDataTable.Rows.Count > 0) { RetVal = RtfDataTable.Rows[0][IndicatorClassifications.ICName].ToString(); if (!Convert.IsDBNull(RtfDataTable.Rows[0][IndicatorClassifications.ICInfo])) { string RtfString = RtfDataTable.Rows[0][IndicatorClassifications.ICInfo].ToString(); // Writng metadata into a rtf file in output directory if (RtfString.Trim().Length > 0) { WriteToFile(RtfString, RtfFilePath); } } } } catch (Exception) { //throw ex; } return RetVal; }
/// <summary> /// Getting MetaData and writing them to Rtf file. /// </summary> public static string ExtractRtfMetadata(ICType ICType, int ICNId, DIConnection DIConnection, DIQueries DIQueries, String outputFolder, String outputFileName) { string RetVal = string.Empty; string RtfFilePath = System.IO.Path.Combine(outputFolder, outputFileName + ".rtf"); DataTable RtfDataTable = new DataTable(); try { if (System.IO.File.Exists(RtfFilePath)) { System.IO.File.Delete(RtfFilePath); } // getting metadata informationn from Database into DataTable RtfDataTable string sSql = DIQueries.IndicatorClassification.GetIC(FilterFieldType.NId, ICNId.ToString(), ICType, FieldSelection.Heavy); RtfDataTable = DIConnection.ExecuteDataTable(sSql); if (RtfDataTable != null & RtfDataTable.Rows.Count > 0) { RetVal = RtfDataTable.Rows[0][IndicatorClassifications.ICName].ToString(); if (!Convert.IsDBNull(RtfDataTable.Rows[0][IndicatorClassifications.ICInfo])) { string RtfString = RtfDataTable.Rows[0][IndicatorClassifications.ICInfo].ToString(); // Writng metadata into a rtf file in output directory if (RtfString.Trim().Length > 0) { WriteToFile(RtfString, RtfFilePath); } } } } catch (Exception) { //throw ex; } return(RetVal); }
private DataTable AutoSelectIndicatorOrIUS(int icNId, ICType icType) { DataTable RetVal = new DataTable(); string Sql = string.Empty; DataTable IUSTable; string[] DistinctColumns = new string[1]; StringBuilder StringBuilderIUSNIds = new StringBuilder(); string IUSNIDs = string.Empty; string SelectedTimeperiodNIds = this.UserPrefences.UserSelection.TimePeriodNIds; string SelectedAreaNIds = this.UserPrefences.UserSelection.AreaNIds; string SelectedSourceNIds = this.UserPrefences.UserSelection.SourceNIds; IDataReader IUSDataReader; // -- Get All Comma seperated IUSNIDs for the selected IC Type from the Available list DataTable IUSFromICTypes; try { //'-- Get the IUS NIds on the basis of IC types if (icNId > -1) { // -- When IC Element is slected Sql = this.SqlQueries.Indicators.GetIUSNIdFromICType(icType, icNId.ToString()); IUSFromICTypes = this._DBConnection.ExecuteDataTable(Sql); } // -- This will return Distinct IUS always under a given IC Element else { // -- When IC Element is NOT slected (IUS on the basis of the ICType) Sql = this.SqlQueries.Indicators.GetIUSNIdFromICType(icType, ""); IUSFromICTypes = this._DBConnection.ExecuteDataTable(Sql); // -- This will NOT return DISTINCT IUS under a given IC Type // -- Get DISTINCT IUS RetVal = IUSFromICTypes; DistinctColumns[0] = IndicatorClassificationsIUS.IUSNId; //-- Distinct IUS NIds IUSFromICTypes = RetVal.DefaultView.ToTable(true, DistinctColumns); } // -- Loop and get the comma seperated IUS NIDs foreach (DataRow IUSNId in IUSFromICTypes.Rows) { StringBuilderIUSNIds.Append("," + IUSNId[IndicatorClassificationsIUS.IUSNId]); } // -- Remove extra Comma if (StringBuilderIUSNIds.Length > 0) { IUSNIDs = StringBuilderIUSNIds.ToString().Substring(1); } // -- AUTO SELECT the DISTINCT IUSNIDs on the basis of the selected Time, Area and Available IUS/I in the Available list if (!this.UseArea) SelectedAreaNIds = string.Empty; if (!this.UseTime) SelectedTimeperiodNIds = string.Empty; if (!this.UseSource) SelectedSourceNIds = string.Empty; if (string.IsNullOrEmpty(IUSNIDs)) { IUSNIDs = "0"; } Sql = this.SqlQueries.Indicators.GetAutoSelectByTimePeriodAreaSource(SelectedTimeperiodNIds, SelectedAreaNIds, IUSNIDs.ToString(), SelectedSourceNIds); IUSDataReader = this._DBConnection.ExecuteReader(Sql); StringBuilderIUSNIds.Length = 0; while ((IUSDataReader.Read())) { StringBuilderIUSNIds.Append(","); StringBuilderIUSNIds.Append(IUSDataReader[Indicator_Unit_Subgroup.IUSNId]); } IUSNIDs = string.Empty; if (StringBuilderIUSNIds.Length > 0) { IUSNIDs = StringBuilderIUSNIds.ToString().Substring(1); } IUSDataReader.Close(); if (this.UserPrefences.Indicator.ShowIUS) { Sql = this.SqlQueries.Indicators.GetIndicators(IUSNIDs.ToString(), this.UserPrefences.Indicator.ShowIUS); } else { Sql = this.SqlQueries.IUS.GetDistinctIndicatorUnit(IUSNIDs.ToString(), this.UserPrefences.Indicator.ShowIUS); } //Sql = this.SqlQueries.Indicators.GetIndicators(sIUSNIDs.ToString(), this.UserPrefences.Indicator.ShowIUS); RetVal = this._DBConnection.ExecuteDataTable(Sql); } catch (Exception) { RetVal = null; } return RetVal; }
/// <summary> /// Get ICs on the basis of parent NId and Ic Type /// </summary> /// <param name="icType"> Indicator Classifcation type </param> /// <param name="parentNId"> Parent Nid </param> /// <returns></returns> public string GetICForParentNIdAndICType(ICType icType, int parentNId) { StringBuilder RetVal = new StringBuilder(); try { RetVal.Append("SELECT IC." + DIColumns.IndicatorClassifications.ICNId + " ,IC." + DIColumns.IndicatorClassifications.ICName + " ,IC." + DIColumns.IndicatorClassifications.ICGId); RetVal.Append(" ,IC." + DIColumns.IndicatorClassifications.ICGlobal + " ,IC." + DIColumns.IndicatorClassifications.ICType + " ,IC." + DIColumns.IndicatorClassifications.ICParent_NId); RetVal.Append(" ,IC." + DIColumns.IndicatorClassifications.ICOrder); RetVal.Append(" FROM " + TablesName.IndicatorClassifications + " IC"); RetVal.Append(" WHERE IC." + DIColumns.IndicatorClassifications.ICType + " = " + DIQueries.ICTypeText[icType]); RetVal.Append(" AND IC." + DIColumns.IndicatorClassifications.ICParent_NId + " = " + parentNId); RetVal.Append(" ORDER BY IC." + DIColumns.IndicatorClassifications.ICName); } catch (Exception ex) { RetVal.Length = 0; } return RetVal.ToString(); }
/// <summary> /// Get Indicator Classification records for a given IC Type and IndicatorNids /// </summary> /// <param name="classificationType">ICType enum value</param> /// <param name="IndicatorNIds">Comma delimited Indicator NIds</param> /// <param name="fieldSelection">LIGHT: Returns - ICNId, ICParent_NId, ICName, ICGId, ICGlobal,IndicatorNId /// <para>HEAVY: Returns - NId, PArentNId, Name, GID, Global, Info</para> /// </param> /// <returns> /// </returns> public string GetICForIndicators(ICType classificationType, string IndicatorNIds, FieldSelection fieldSelection) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); // SELECT Clause sbQuery.Append("SELECT DISTINCT IC." + DIColumns.IndicatorClassifications.ICNId + ",IC." + DIColumns.IndicatorClassifications.ICParent_NId + ",IC." + DIColumns.IndicatorClassifications.ICName + ",IC." + DIColumns.IndicatorClassifications.ICGId + ",IC." + DIColumns.IndicatorClassifications.ICGlobal); sbQuery.Append(",IUS." + DIColumns.Indicator_Unit_Subgroup.IndicatorNId + ",IC." + DIColumns.IndicatorClassifications.ICOrder); if (fieldSelection == FieldSelection.Heavy) { sbQuery.Append("," + DIColumns.IndicatorClassifications.ICInfo); } // FROM Clause sbQuery.Append(" FROM " + this.TablesName.IndicatorClassifications + " AS IC," + this.TablesName.IndicatorClassificationsIUS + " AS ICIUS," + this.TablesName.IndicatorUnitSubgroup + " AS IUS"); // WHERE Clause sbQuery.Append(" WHERE "); sbQuery.Append(" IC." + DIColumns.IndicatorClassifications.ICNId + "= ICIUS." + DIColumns.IndicatorClassificationsIUS.ICNId + " AND ICIUS." + DIColumns.IndicatorClassificationsIUS.IUSNId + "= IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId); sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICType + "=" + DIQueries.ICTypeText[classificationType]); if (IndicatorNIds.Trim().Length > 0) { sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.IndicatorNId + " IN (" + IndicatorNIds + ")"); } RetVal = sbQuery.ToString(); return RetVal; }
/// <summary> /// It exports the Indicator Classifications of specified ICType, present in Database. <para>Exported ICs will be in format: ICLevel 1, ICLevel 2, ...ICLevel n , Indicator, Unit, Subgroup. </para> /// </summary> /// <param name="ICElementType">ICType enum value</param> /// <param name="dBConnection">DIConnection object of source Database,</param> /// <param name="dBQueries">DIQueries object of source Database.</param> /// <param name="exportOutputType">Output format type.</param> /// <param name="outputFileNameWPath">Output fileName With path.</param> /// <param name="languageFileNameWPath">language xml file name path.</param> /// <returns></returns> public static bool ExportIC(ICType ICElementType, DIConnection dBConnection, DIQueries dBQueries, DIExportOutputType exportOutputType, string outputFileNameWPath, string languageFileNameWPath) { bool RetVal = false; DataView ICDataView = null; try { // Get Distinct IndicatorClassification labels for N levels and Indicator, Unit, Subgroup in a DataView. ICDataView = DIExport.GetDataViewForICExport(ICElementType, dBConnection, dBQueries).DefaultView; // Export Indicator Entry Spreadsheet using DataView. RetVal = DIExport.ExportIC(ICElementType, ICDataView, exportOutputType, outputFileNameWPath); } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } return RetVal; }
/// <summary> /// It generates DataTable for specified ICType. DataTable will have all n-levels of IC in one row for each IUS. /// <para>Eg: there are 3 levels of Goals in UT_IndicatorClassification_en, then fields will be : Goal Label 1, Goal Label 2, Goal Label 3, Indicator_Name, Unit_Name, Subgroup_Name</para> /// </summary> /// <param name="iCType">IC type</param> /// <param name="dbConnection">source Database DIconnection object</param> /// <param name="dbQueries">source database DIQueries object</param> /// <returns></returns> private static DataTable GetDataViewForICExport(ICType iCType, DIConnection dbConnection, DIQueries dbQueries) { DataTable RetVal = new DataTable(); // Final DataTable contaning data for IC spreadsheet DataRow ICRow = null; DataTable TempTable = null; DataView DataViewIUS = null; DataRow[] objRow; DataRow NewRow; int MaxLevel = 0; // Max levels present in database for specified ICType. string[] _Temp; int cc = 0; int TotalCols = 0; try { DataTable ICTable = new DataTable(); DataColumn[] _PK = new DataColumn[1]; { _PK[0] = ICTable.Columns.Add("ID", typeof(int)); _PK[0].Unique = true; ICTable.PrimaryKey = _PK; ICTable.Columns.Add("Parent_ID", typeof(int)); ICTable.Columns.Add("LABEL", typeof(string)); ICTable.Columns.Add("ACT_LABEL", typeof(string)); } // Get IC info (IC_Nid, IC_Name, IC_Parent_Nid) from Database, filtering ICType. TempTable = dbConnection.ExecuteDataTable(dbQueries.IndicatorClassification.GetIC(FilterFieldType.None, "", iCType, FieldSelection.Light)); TempTable.DefaultView.Sort = IndicatorClassifications.ICParent_NId + " ASC"; TempTable = TempTable.DefaultView.ToTable(); foreach (DataRow Dr in TempTable.Rows) { NewRow = ICTable.NewRow(); objRow = ICTable.Select("ID=" + Dr["IC_Parent_NID"].ToString()); NewRow["ID"] = Dr["IC_Nid"]; NewRow["Parent_ID"] = Dr["IC_Parent_NID"]; NewRow["ACT_LABEL"] = Dr["IC_Name"].ToString(); if (objRow.Length > 0) { _Temp = Strings.Split(objRow[0]["LABEL"].ToString(), "{[~-~]}", -1, CompareMethod.Text); if (MaxLevel < _Temp.Length) MaxLevel = _Temp.Length; NewRow["LABEL"] = objRow[0]["LABEL"].ToString() + "{[~-~]}" + Dr["IC_Name"].ToString(); } else { NewRow["LABEL"] = Dr["IC_Name"].ToString(); } ICTable.Rows.Add(NewRow); } ICTable.AcceptChanges(); // Calculating total required columns in DataTable. TotalCols = MaxLevel + 1 + 3; // -- Fill IUS int jj; object[] ArrTemp = new object[TotalCols]; // Adding Columns for IC levels string sHeadVal = string.Empty; switch (iCType) { case ICType.Sector: sHeadVal = "SECTOR"; break; case ICType.Goal: sHeadVal = "GOAL"; break; case ICType.CF: sHeadVal = "CF"; break; case ICType.Institution: sHeadVal = "INSTITUTION"; break; case ICType.Theme: sHeadVal = "THEME"; break; case ICType.Convention: sHeadVal = "CONVENTION"; break; case ICType.Source: sHeadVal = "SOURCE"; break; } // -- Columns headings for (jj = 0; jj <= MaxLevel; jj++) { int t = jj + 1; RetVal.Columns.Add(sHeadVal + " Label " + t); } RetVal.Columns.Add("INDICATOR"); // GetLngStringValue(oXmlLngFile, "INDICATOR") RetVal.Columns.Add("UNIT"); // GetLngStringValue(oXmlLngFile, "UNIT") RetVal.Columns.Add("SUBGROUP"); for (cc = 0; cc <= ICTable.Rows.Count - 1; cc++) { // -- if the Number of Elements in the DataRow is same as MaxLevel then get the IUS combination for this level _Temp = Strings.Split(ICTable.Rows[cc]["LABEL"].ToString(), "{[~-~]}", -1, CompareMethod.Text); if ((_Temp.Length - 1) == MaxLevel) { // -- get the IUS for this DataRow try { //string sqlString = "SELECT UT_Indicator_Unit_Subgroup.IUSNId, UT_Indicator_en.Indicator_Name, UT_Unit_en.Unit_Name, UT_Subgroup_Vals_en.Subgroup_Val " + // " FROM UT_Subgroup_Vals_en INNER JOIN (UT_Unit_en INNER JOIN ((UT_Indicator_en INNER JOIN UT_Indicator_Unit_Subgroup ON UT_Indicator_en.Indicator_NId = UT_Indicator_Unit_Subgroup.Indicator_NId) INNER JOIN UT_Indicator_Classifications_IUS ON UT_Indicator_Unit_Subgroup.IUSNId = UT_Indicator_Classifications_IUS.IUSNId) ON UT_Unit_en.Unit_NId = UT_Indicator_Unit_Subgroup.Unit_NId) ON UT_Subgroup_Vals_en.Subgroup_Val_NId = UT_Indicator_Unit_Subgroup.Subgroup_Val_NId " + // " WHERE UT_Indicator_Classifications_IUS.IC_NId = " + ICTable.Rows[cc]["ID"].ToString(); //DataViewIUS = dbConnection.ExecuteDataTable(sqlString).DefaultView; DataViewIUS = dbConnection.ExecuteDataTable(dbQueries.IUS.GetIUSByIC(iCType, ICTable.Rows[cc]["ID"].ToString(), FieldSelection.Light)).DefaultView; } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } if (DataViewIUS.Count > 0) { foreach (DataRowView DVRow in DataViewIUS) { ICRow = RetVal.NewRow(); for (jj = 0; jj <= _Temp.Length - 1; jj++) { //ArrTemp(jj) = _Temp(jj); ICRow[jj] = _Temp[jj]; } ICRow[jj] = DVRow[Indicator.IndicatorName].ToString(); ICRow[jj + 1] = DVRow[Unit.UnitName].ToString(); ICRow[jj + 2] = DVRow[SubgroupVals.SubgroupVal].ToString(); //oColl.Add(ArrTemp); RetVal.Rows.Add(ICRow); } } else { ICRow = RetVal.NewRow(); for (jj = 0; jj <= _Temp.Length - 1; jj++) { ICRow[jj] = _Temp[jj]; } ICRow[jj] = ""; ICRow[jj + 1] = ""; ICRow[jj + 2] = ""; RetVal.Rows.Add(ICRow); } } } } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } return RetVal; }
/// <summary> /// Get distinct NId, Name, GID, Global from IUS - Indicator - Unit - SubgroupVal table based on Indicator Classification Type /// </summary> /// <param name="ICType">Indicator Classification Type</param> /// <param name="ICNId">ICNId which may be blank if only ICType is to be considered</param> /// <param name="fieldSelection">Use Light for NId + Name + GId + Global fields use heavy to include IndicatorInfo field</param> /// <returns>Sql query string</returns> public string GetDistinctIUSByIC(ICType ICType, string ICNId, FieldSelection fieldSelection) { string sortOrderString = "I." + DIColumns.Indicator.IndicatorName + ", U." + DIColumns.Unit.UnitName + ", SGV." + DIColumns.SubgroupVals.SubgroupVal; return this.GetDistinctIUSByIC(ICType, ICNId, fieldSelection, sortOrderString); }
public BType(ICType dummyReference) { DummyReference = dummyReference; }
/// <summary> /// To Import indicator classification into database or template /// </summary> /// <param name="ICInfo">Instance of IndicatorClassificationInfo</param> /// <param name="NidInSourceDB"></param> /// <param name="sourceQurey"></param> /// <param name="sourceDBConnection"></param> /// <returns>new indicator classification nid</returns> public int ImportIndicatorClassification(ICType icType, string icName, string icGId, string parentICGId, bool isGlobal) { int RetVal = -1; bool ISTrgICGlobal = false; DataTable TempTable; IndicatorClassificationInfo ICInfo = new IndicatorClassificationInfo(icName, icType, isGlobal, 0); ICInfo.GID = icGId; string LangCode = this.DBQueries.LanguageCode; try { ICInfo.Parent = new IndicatorClassificationInfo(); if (parentICGId == "-1") { ICInfo.Parent.Nid = -1; } else { ICInfo.Parent.GID = parentICGId; ICInfo.Parent.Nid = this.GetNidByGID(parentICGId, icType); } //check item is already exist in database or not RetVal = this.GetIndicatorClassificationNid(ICInfo.GID, ICInfo.Name, ICInfo.Parent.Nid, ICInfo.Type); if (RetVal > 0) { if (!this.DBQueries.LanguageCode.StartsWith("_")) { LangCode = "_" + LangCode; } // check target ic is global TempTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, RetVal.ToString(), FieldSelection.Light)); if (TempTable.Rows.Count > 0) { ISTrgICGlobal = Convert.ToBoolean(TempTable.Rows[0][IndicatorClassifications.ICGlobal]); } // if target item is not global if (!ISTrgICGlobal) { //update the gid,name and global on the basis of nid this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Update.UpdateIC(this.DBQueries.DataPrefix, LangCode, ICInfo.Name, ICInfo.GID, ICInfo.IsGlobal, ICInfo.Parent.Nid, ICInfo.ClassificationInfo, ICInfo.Type, RetVal)); } } else { if (this.InsertIntoDatabase(ICInfo)) { //get nid RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY")); } } // update UT_CF_FLOWCHART table if (ICInfo.Type == ICType.CF) { //-- } } catch (Exception ex) { throw new ApplicationException(ex.Message); } return(RetVal); }
private void Get_Source() { //'Dictionary<string, int> RetVal = new Dictionary<string, int>(); SourceBuilder SrcBuilderObj = null; string Name = string.Empty; string GID = string.Empty; string LanguageCode = this._LanguageCode; int NID = 0; string ParentID = string.Empty; ICType icICType = ICType.Sector; this.SourceDetails = new Dictionary <string, CommonInfo>(); //SrcBuilderObj = new SourceBuilder(this.DBConnection, this.DBQueries); foreach (SDMXObjectModel.Structure.CategorySchemeType CodeListObj in this._DSDStructure.Structures.CategorySchemes) { icICType = (ICType)DIQueries.ICTypeText.Values.IndexOf("'" + CodeListObj.id.Substring(3) + "'"); if (icICType == ICType.Source) { foreach (SDMXObjectModel.Structure.CategoryType CatTypeCode in CodeListObj.Items) { GID = CatTypeCode.id; string ParentName = string.Empty; foreach (TextType IndTextType in CatTypeCode.Name) { if (IndTextType.lang.Trim('_') == this._LanguageCode) { ParentName = IndTextType.Value; } } foreach (SDMXObjectModel.Structure.CategoryType SubCatTypeCode in CatTypeCode.Items) { GID = CatTypeCode.id; Name = string.Empty; foreach (TextType IndTextType in SubCatTypeCode.Name) { if (IndTextType.lang.Trim('_') == this._LanguageCode) { Name = IndTextType.Value; break; } } } ParentID = "-1"; //NID = SrcBuilderObj.CheckNCreateSource(Name); //if (!RetVal.ContainsKey(GID) && NID > 0) //{ // RetVal.Add(GID, NID); //} if (!this.SourceDetails.ContainsKey(Name)) { CommonInfo TableInfoObj = new CommonInfo(); TableInfoObj.GID = GID; TableInfoObj.Name = Name; this.SourceDetails.Add(Name, TableInfoObj); } } } } }
/// <summary> /// Get_IC_Collection method.. /// </summary> /// <param name="this._DSDStructure"></param> /// <returns></returns> private void Get_IC() { //'Dictionary<string, int> RetVal = new Dictionary<string, int>(); // IndicatorClassificationBuilder BuilderObj = new IndicatorClassificationBuilder(this.DBConnection, this.DBQueries); //SourceBuilder SrcBuilderObj = new SourceBuilder(this.DBConnection, this.DBQueries); string Name = string.Empty; string GID = string.Empty; string LanguageCode = this._LanguageCode; int NID = 0; string ParentID = string.Empty; ICType icICType = ICType.Sector; //Dictionary<string, string> CParent = new Dictionary<string, string>(); bool ISGlobal = false; this.ICDetails = new Dictionary <string, IndicatorClassificationInfo>(); foreach (SDMXObjectModel.Structure.CategorySchemeType CodeListObj in this._DSDStructure.Structures.CategorySchemes) { icICType = (ICType)DIQueries.ICTypeText.Values.IndexOf("'" + CodeListObj.id.Substring(3) + "'"); if (icICType != ICType.Source) { foreach (SDMXObjectModel.Structure.CategoryType CatTypeCode in CodeListObj.Items) { GID = CatTypeCode.id; Name = string.Empty; ISGlobal = false; foreach (TextType IndTextType in CatTypeCode.Name) { if (IndTextType.lang.Trim('_') == this._LanguageCode) { Name = IndTextType.Value; break; } } foreach (AnnotationType AnnType in CatTypeCode.Annotations) { if (AnnType.AnnotationTitle == SDMXConstants.Annotations.IsGlobal) { foreach (TextType AnnTextType in AnnType.AnnotationText) { ISGlobal = Convert.ToBoolean(AnnTextType.Value); break; } } } ParentID = "-1"; if (!this.ICDetails.ContainsKey(GID)) { IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo(); TableInfoObj.GID = GID; TableInfoObj.Name = Name; TableInfoObj.Type = icICType; TableInfoObj.Parent = new IndicatorClassificationInfo(); TableInfoObj.Parent.GID = ParentID; this.ICDetails.Add(GID, TableInfoObj); } // Read each child IC for current IC this.Get_ICChain(GID, icICType, CatTypeCode); } } } }
internal int CreateClassificationChainFromExtDB(int srcICNId, int srcParentNId, string srcICGid, string srcICName, ICType srcICType, string srcICInfo, bool isGlobal, DIQueries srcQueries, DIConnection srcDBConnection, DIQueries targetDBQueries, DIConnection targetDBConnection) { int RetVal; //int TrgParentNId; //string TrgParentName; int NewParentNId; DataTable TempTable; IndicatorClassificationInfo ICInfo; IndicatorClassificationBuilder ClassificationBuilder = new IndicatorClassificationBuilder(targetDBConnection, targetDBQueries); // -- STEP 1: If the Parent NID is -1 then create the Classification at the root if (srcParentNId == -1) { // -- Create the Classification // -------------------------------------------------------------- // While importing the Classifications, if the NId of the Source Classification is _ // the same as that of the one created, then the Duplicate check fails and a duplicate // classification getscreated. PASS -99 as the first parameter to the calling function // -------------------------------------------------------------- ICInfo = new IndicatorClassificationInfo(); ICInfo.Parent = new IndicatorClassificationInfo(); ICInfo.Parent.Nid = srcParentNId; ICInfo.Nid = srcICNId; ICInfo.Name = srcICName; ICInfo.ClassificationInfo = srcICInfo; ICInfo.GID = srcICGid; ICInfo.IsGlobal = isGlobal; ICInfo.Type = srcICType; RetVal = ClassificationBuilder.ImportIndicatorClassification(ICInfo, srcICNId, srcQueries, srcDBConnection); } else { // -- STEP 2: If the Parent is not -1 then check for the existence of the Parent and then create the Classification // Classification can only be created if the parent exists // -- STEP 2.1: If the Parent Exists then create the Classification under that parent // -- STEP 2.2: If the Parent does not Exist then create the Parent first and then the Classification under that parent // -- STEP 2: Check the existence of the Parent in the Target Database // -- get the parent from the source database TempTable = srcDBConnection.ExecuteDataTable(srcQueries.IndicatorClassification.GetIC(FilterFieldType.NId, srcParentNId.ToString(), srcICType, FieldSelection.Heavy)); { // -------------------------------------------------------------- // While importing the Classifications, if the NId of the Source Classification is _ // the same as that of the one created, then the Duplicate check fails and a duplicate // classification getscreated. PASS -99 as the first parameter to the calling function // -------------------------------------------------------------- DataRow Row; string ClassificationInfo = string.Empty; Row = TempTable.Rows[0]; ClassificationInfo = Convert.ToString(Row[IndicatorClassifications.ICInfo]); NewParentNId = CreateClassificationChainFromExtDB( Convert.ToInt32(Row[IndicatorClassifications.ICNId]), Convert.ToInt32(Row[IndicatorClassifications.ICParent_NId]), Row[IndicatorClassifications.ICGId].ToString(), Row[IndicatorClassifications.ICName].ToString(), srcICType, ClassificationInfo, Convert.ToBoolean(Row[IndicatorClassifications.ICGlobal]), srcQueries, srcDBConnection, targetDBQueries, targetDBConnection);; } // -- Create the Child Now ICInfo = new IndicatorClassificationInfo(); ICInfo.Parent = new IndicatorClassificationInfo(); ICInfo.Parent.Nid = NewParentNId; // set new parent nid ICInfo.Nid = srcICNId; ICInfo.Name = srcICName; ICInfo.ClassificationInfo = srcICInfo; ICInfo.GID = srcICGid; ICInfo.IsGlobal = isGlobal; ICInfo.Type = srcICType; RetVal = ClassificationBuilder.ImportIndicatorClassification(ICInfo, srcICNId, srcQueries, srcDBConnection); } //import ic and ius relationship into indicator_classification_IUS table ClassificationBuilder.ImportICAndIUSRelations(srcICNId, RetVal, ICInfo.Type, srcQueries, srcDBConnection); return(RetVal); }
/// <summary> /// Returns indicator classification nid. /// </summary> /// <param name="Gid">Indicator classification GID </param> /// <param name="name">Name of the Indicator classification</param> /// <param name="parentNid"></param> /// <param name="classificationType">Indicator classification type</param> /// <returns></returns> public int GetIndicatorClassificationNid(string Gid, string name, int parentNid, ICType classificationType) { int RetVal = 0; string SqlQuery = string.Empty; //--step1:Get Nid by GID if GID is not empty if (!string.IsNullOrEmpty(Gid)) { RetVal = this.GetNidByGID(Gid, classificationType); } //--step2:Get Nid by Name if name is not empty if (RetVal <= 0) { if (!string.IsNullOrEmpty(name)) { RetVal = this.GetNidByName(name, parentNid, classificationType); } } return(RetVal); }
/// <summary> /// To import IC and IUS realtionship into Indicator_Classification_IUS table /// </summary> /// <param name="NidInSourceDB"></param> /// <param name="NidinTargetDB"></param> /// <param name="classificationType"></param> /// <param name="srcQueries"></param> /// <param name="srcDBConnection"></param> public void ImportICAndIUSRelations(int NidInSourceDB, int NidinTargetDB, ICType classificationType, DIQueries srcQueries, DIConnection srcDBConnection) { // -- Create the IUS Links // -- STEP 1: Get the Indicator, Unit and Subgroup Names from the Source Database // -- STEP 2: Get IUSNIds from the Target Database against the I-U-S from the Source Database int TempIUSNId; int ClassificationNId; string IndicatorName; string UnitName; string SGVal; string IndicatorGID; string UnitGID; string SGValGID; bool RecommendedSource; DataTable TempTable = null; DataTable Table = null; // -- STEP 1: Get the Indicator, Unit and Subgroup Names from the Source Database TempTable = srcDBConnection.ExecuteDataTable(srcQueries.IUS.GetIUSByIC(classificationType, NidInSourceDB, FieldSelection.Light)); for (int Index = 0; Index <= TempTable.Rows.Count - 1; Index++) { try { // -- STEP 2: Get IUSNIds from the Target Database against the I-U-S from the Source Database IndicatorName = DICommon.RemoveQuotes(TempTable.Rows[Index][Indicator.IndicatorName].ToString()); UnitName = DICommon.RemoveQuotes(TempTable.Rows[Index][Unit.UnitName].ToString()); SGVal = DICommon.RemoveQuotes(TempTable.Rows[Index][SubgroupVals.SubgroupVal].ToString()); RecommendedSource = Convert.ToBoolean(TempTable.Rows[Index][IndicatorClassificationsIUS.RecommendedSource]); IndicatorGID = DICommon.RemoveQuotes(TempTable.Rows[Index][Indicator.IndicatorGId].ToString()); UnitGID = DICommon.RemoveQuotes(TempTable.Rows[Index][Unit.UnitGId].ToString()); SGValGID = DICommon.RemoveQuotes(TempTable.Rows[Index][SubgroupVals.SubgroupValGId].ToString()); // get records it by GID try { Table = this.DBConnection.ExecuteDataTable(this.DBQueries.IUS.GetIUSNIdsByGID( IndicatorGID, UnitGID, SGValGID)); } catch (Exception) { } // if records not found then get it by Name if (Table == null || Table.Rows.Count == 0) { Table = this.DBConnection.ExecuteDataTable(this.DBQueries.IUS.GetIUSByI_U_S_Name(IndicatorName, UnitName, SGVal, FieldSelection.Light)); } if (Table.Rows.Count > 0) { TempIUSNId = Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.IUSNId]); //create relationship for parent_IC_NID also try { ClassificationNId = NidinTargetDB; while (true) { // -- Create IUS Relationship this.AddNUpdateICIUSRelation(ClassificationNId, TempIUSNId, RecommendedSource); //-- find parent IC_NId DataTable ICTable; try { ICTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, ClassificationNId.ToString(), classificationType, FieldSelection.Light)); if (ICTable.Rows.Count > 0) { ClassificationNId = Convert.ToInt32(ICTable.Rows[0][IndicatorClassifications.ICParent_NId]); } else { ClassificationNId = -1; } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } finally { if ((Table != null)) { Table.Dispose(); } Table = null; } if (ClassificationNId == -1) { break; } } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } } }
public ICLookInSource(ICType indicatorClassificationType) { this._IndicatorClassificationType = indicatorClassificationType; }
/// <summary> /// Constructor to Initialize Sheet Variables /// </summary> internal ICSheetSource(ICType icType, string sheetName) { this.InitializeSheetVariables(); this.EICType = icType; this.SheetName = sheetName; }
public MetaDataICLookInSource(ICType indicatorClassificationType) { this._IndicatorClassificationType = indicatorClassificationType; this.ShowDESButton = true; }
/// <summary> /// Get distinct NId, Name, GID, Global from IUS - Indicator - Unit - SubgroupVal table based on Indicator Classification Type /// </summary> /// <param name="ICType">Indicator Classification Type</param> /// <param name="ICNId">ICNId which may be -1 if only ICType is to be considered</param> /// <param name="fieldSelection">Use Light for NId + Name + GId + Global fields use heavy to include IndicatorInfo field</param> /// <returns>Sql query string</returns> public string GetDistinctIUSByIC(ICType ICType, int ICNId, FieldSelection fieldSelection) { if (ICNId == -1) { return GetDistinctIUSByIC(ICType, string.Empty, fieldSelection); } else { return GetDistinctIUSByIC(ICType, ICNId.ToString(), fieldSelection); } }
private void ProcessIC(ICType icType, DataTable ICTable) { ElementImportType ICElementType = ElementImportType.Sector; string ICNIds = string.Empty; switch (icType) { case ICType.Goal: ICElementType = ElementImportType.Goal; ICTable.DefaultView.RowFilter = IndicatorClassifications.ICType + " IN (" + DIQueries.ICTypeText[icType] + ")"; break; case ICType.Sector: ICElementType = ElementImportType.Sector; ICTable.DefaultView.RowFilter = IndicatorClassifications.ICType + " IN (" + DIQueries.ICTypeText[icType] + ")"; break; case ICType.CF: ICTable.DefaultView.RowFilter = IndicatorClassifications.ICType + " IN (" + DIQueries.ICTypeText[icType] + ")"; ICElementType = ElementImportType.Framework; break; case ICType.Theme: ICElementType = ElementImportType.Theme; ICTable.DefaultView.RowFilter = IndicatorClassifications.ICType + " IN (" + DIQueries.ICTypeText[icType] + ")"; break; case ICType.Source: ICElementType = ElementImportType.Source; ICTable.DefaultView.RowFilter = IndicatorClassifications.ICType + " IN (" + DIQueries.ICTypeText[icType] + ") AND " + IndicatorClassifications.ICParent_NId + " NOT IN (-1)"; break; case ICType.Institution: ICElementType = ElementImportType.Institution; ICTable.DefaultView.RowFilter = IndicatorClassifications.ICType + " IN (" + DIQueries.ICTypeText[icType] + ")"; break; case ICType.Convention: ICElementType = ElementImportType.Convention; ICTable.DefaultView.RowFilter = IndicatorClassifications.ICType + " IN (" + DIQueries.ICTypeText[icType] + ")"; break; } // Get ICNId on the basis of ICType ICNIds = DIConnection.GetDelimitedValuesFromDataView(ICTable.DefaultView, IndicatorClassifications.ICNId); if (string.IsNullOrEmpty(ICNIds) == false) { //- Initialize LookInImport object (used to export ICs into another database) this.LookInSource = this.GetLookInImporterObject(ICElementType); //- Export ICs associated with IUSNId. List<string> IC_List = new List<string>(ICNIds.Split(',')); this.LookInSource.ImportValues(IC_List, false); } }
/// <summary> /// Constructor /// </summary> /// <param name="indicatorClassificationType"></param> /// <param name="displayString"></param> /// <param name="databaseString"></param> public IndicatorClassificationInfo(ICType indicatorClassificationType, string displayString, string databaseString) { this._IndicatorClassificationType = indicatorClassificationType; this._DatabaseString = databaseString; this._DisplayString = displayString; }
private void ProcessDataTable(ref System.Data.DataTable table, ICType classificationType, bool isMetadataRequired, bool includeOnlyName) { string SqlQuery = string.Empty; DataTable NewTable; DataTable TempTable; DataTable SectorTable; DataRow NewRow; int Level = 0; //Step 1: Get IC table with levels SectorTable = this.GetICTableWLevel(ref table); //Step 2: Create New Data Table to fill the list view NewTable = new DataTable(); //insert columns for IC level information. for (Level = 1; Level <= this.MaxLevel; Level++) { NewTable.Columns.Add(LanguageKeys.Level + " " + Level); } NewTable.Columns.Add(IndicatorClassifications.ICNId, System.Type.GetType("System.Int32")); NewTable.Columns.Add(IndicatorClassifications.ICParent_NId, System.Type.GetType("System.Int32")); NewTable.Columns.Add(IndicatorClassifications.ICGlobal, System.Type.GetType("System.Boolean")); NewTable.Columns.Add(IndicatorClassifications.ICGId); NewTable.Columns.Add(Indicator.IndicatorNId, System.Type.GetType("System.Int32")); NewTable.Columns.Add(Indicator.IndicatorGId); NewTable.Columns.Add(Indicator.IndicatorGlobal); if (isMetadataRequired) { NewTable.Columns.Add(IndicatorClassifications.ICInfo); NewTable.Columns.Add(Indicator.IndicatorInfo); } NewTable.Columns.Add(LanguageKeys.Level, System.Type.GetType("System.Int32")); NewTable.Columns.Add(IndicatorClassifications.ICName); NewTable.Columns.Add(Indicator.IndicatorName); //add unit and subgroup columns only if show IUS is true. if (this._ShowIUS) { NewTable.Columns.Add(Unit.UnitNId, System.Type.GetType("System.Int32")); NewTable.Columns.Add(Unit.UnitGId); NewTable.Columns.Add(Unit.UnitGlobal); NewTable.Columns.Add(SubgroupVals.SubgroupValNId, System.Type.GetType("System.Int32")); NewTable.Columns.Add(SubgroupVals.SubgroupValGId); NewTable.Columns.Add(SubgroupVals.SubgroupValGlobal); NewTable.Columns.Add(Indicator_Unit_Subgroup.IUSNId, System.Type.GetType("System.Int32")); NewTable.Columns.Add(Unit.UnitName); NewTable.Columns.Add(SubgroupVals.SubgroupVal); } //insert rows into new table foreach (DataRow Row in SectorTable.Rows)//.Select( LanguageKeys.Level + "=" + this.MaxLevel)) { //get Indicator or IUS on the basis of IC_ICNid if (this._ShowIUS) { SqlQuery = this.SourceDBQueries.IUS.GetAllIUSByIC(classificationType, Row[IndicatorClassifications.ICNId].ToString(), FieldSelection.Heavy); } else { SqlQuery = this.SourceDBQueries.Indicators.GetAllIndicatorByIC(classificationType, Convert.ToString(Row[IndicatorClassifications.ICNId]), FieldSelection.Heavy); } TempTable = this.SourceDBConnection.ExecuteDataTable(SqlQuery); string[] ColArr = new string[TempTable.Columns.Count]; int Index = 0; foreach (DataColumn Col in TempTable.Columns) { ColArr[Index++] = Col.ColumnName; } TempTable = TempTable.DefaultView.ToTable(true, ColArr); foreach (DataRow IndicatorRow in TempTable.Rows) { NewRow = NewTable.NewRow(); NewRow[IndicatorClassifications.ICNId] = Row[IndicatorClassifications.ICNId]; NewRow[IndicatorClassifications.ICParent_NId] = Row[IndicatorClassifications.ICParent_NId]; NewRow[IndicatorClassifications.ICGlobal] = Convert.ToBoolean(Row[IndicatorClassifications.ICGlobal]); NewRow[IndicatorClassifications.ICGId] = Row[IndicatorClassifications.ICGId]; if (isMetadataRequired) { NewRow[IndicatorClassifications.ICInfo] = Row[IndicatorClassifications.ICInfo]; } NewRow[IndicatorClassifications.ICName] = Row[IndicatorClassifications.ICName].ToString(); NewRow[LanguageKeys.Level] = Row[LanguageKeys.Level]; for (Level = 1; Level < Convert.ToInt32(Row[LanguageKeys.Level]); Level++) { NewRow[LanguageKeys.Level + " " + Level] = Row[LanguageKeys.Level + " " + Level].ToString(); } NewRow[LanguageKeys.Level + " " + Level] = Row[IndicatorClassifications.ICName].ToString(); //add indicator, unit and subgroup NewRow[Indicator.IndicatorName] = IndicatorRow[Indicator.IndicatorName]; NewRow[Indicator.IndicatorNId] = IndicatorRow[Indicator.IndicatorNId]; NewRow[Indicator.IndicatorGId] = IndicatorRow[Indicator.IndicatorGId]; NewRow[Indicator.IndicatorGlobal] = IndicatorRow[Indicator.IndicatorGlobal]; //get indicatorinfo from indicator table if (isMetadataRequired) { DataRow IndicatorInfoRow = this.SourceDBConnection.ExecuteDataTable(this.SourceDBQueries.Indicators.GetIndicator(FilterFieldType.NId, IndicatorRow[Indicator.IndicatorNId].ToString(), FieldSelection.Heavy)).Rows[0]; NewRow[Indicator.IndicatorInfo] = IndicatorInfoRow[Indicator.IndicatorInfo]; } if (this._ShowIUS) { NewRow[Unit.UnitName] = IndicatorRow[Unit.UnitName]; NewRow[SubgroupVals.SubgroupVal] = IndicatorRow[SubgroupVals.SubgroupVal]; NewRow[Unit.UnitNId] = IndicatorRow[Unit.UnitNId]; NewRow[Unit.UnitGId] = IndicatorRow[Unit.UnitGId]; NewRow[Unit.UnitGlobal] = IndicatorRow[Unit.UnitGlobal]; NewRow[SubgroupVals.SubgroupValNId] = IndicatorRow[SubgroupVals.SubgroupValNId]; NewRow[SubgroupVals.SubgroupValGId] = IndicatorRow[SubgroupVals.SubgroupValGId]; NewRow[SubgroupVals.SubgroupValGlobal] = IndicatorRow[SubgroupVals.SubgroupValGlobal]; NewRow[Indicator_Unit_Subgroup.IUSNId] = IndicatorRow[Indicator_Unit_Subgroup.IUSNId]; } NewTable.Rows.Add(NewRow); } } NewTable.AcceptChanges(); //remove extra rows from table NewTable = this.DeleteExtraRows(NewTable); ////////Step 4: If search string is not empty then filter data table //////if (!string.IsNullOrEmpty(this.SearchString)) //////{ ////// NewTable.DefaultView.RowFilter = Indicator.IndicatorName + " LIKE '%" + this.SearchString + "%'"; ////// NewTable = NewTable.DefaultView.ToTable(); //////} //Step 5: set sorting NewTable.DefaultView.Sort = this.GetSortingString(); //Step 6: Replace the referenced table with the new data table table = NewTable.DefaultView.ToTable(); if (includeOnlyName) { table.Columns.Remove(IndicatorClassifications.ICNId); table.Columns.Remove(IndicatorClassifications.ICParent_NId); table.Columns.Remove(IndicatorClassifications.ICGlobal); table.Columns.Remove(IndicatorClassifications.ICGId); table.Columns.Remove(Indicator.IndicatorNId); table.Columns.Remove(Indicator.IndicatorGId); table.Columns.Remove(Indicator.IndicatorGlobal); table.Columns.Remove(LanguageKeys.Level); if (this._ShowIUS) { table.Columns.Remove(Unit.UnitNId); table.Columns.Remove(Unit.UnitGId); table.Columns.Remove(Unit.UnitGlobal); table.Columns.Remove(SubgroupVals.SubgroupValNId); table.Columns.Remove(SubgroupVals.SubgroupValGId); table.Columns.Remove(SubgroupVals.SubgroupValGlobal); table.Columns.Remove(Indicator_Unit_Subgroup.IUSNId); } } }
/// <summary> /// It exports the Indicator Classifications of specified ICType, present in DataView. <para>Exported ICs will be in format: ICLevel 1, ICLevel 2, ...ICLevel n , Indicator, Unit, Subgroup. </para> /// </summary> /// <param name="ICElementType">ICType enum value </param> /// <param name="ICDataView">DataView having IC Data in format: ICLevel 1, ICLevel 2, ...ICLevel n , Indicator, Unit, Subgroup. </param> /// <param name="outputType">Output format type.</param> /// <param name="outputFileNameWPath">Output fileName With path.</param> /// <returns></returns> public static bool ExportIC(ICType ICElementType, DataView ICDataView, DIExportOutputType outputType, string outputFileNameWPath) { bool RetVal = false; try { switch (outputType) { case DIExportOutputType.DES: case DIExportOutputType.Spreadsheet: RetVal = ExportDES.ExportICFromDataView(ICDataView, ICElementType, outputFileNameWPath); break; case DIExportOutputType.PDF: RetVal = ExportPDF.ExportICFromDataView(ICDataView, ICElementType, outputFileNameWPath); break; case DIExportOutputType.HTML: RetVal = ExportHTML.ExportICFromDataView(ICDataView, ICElementType, outputFileNameWPath); break; default: break; } } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } return RetVal; }
public bool CanPlace(ICType iCType, int pins, string nodeId, int index) { bool rotated = Helper.CircuitHelper.IsNodeRotated(nodeId); switch (iCType) { case ICType.solo: return(CanPlaceSinglePin(nodeId, index)); case ICType.dual: return(CanPlaceSinglePin(nodeId, index)); case ICType.wire: return(CanPlaceSinglePin(nodeId, index)); case ICType.ic4: if (index != 4) { return(false); } string[] id = nodeId.Split('x'); int a = int.Parse(id[0]); int b = int.Parse(id[1]); int c = int.Parse(id[2]); int d = int.Parse(id[3]); if (a != 1) { return(false); } if (d > 64 - (pins / 2)) { return(false); } for (int i = 0; i < 2; i++) { int indexT = i == 0 ? 4 : 0; for (int j = 0; j < pins / 2; j++) { string nodeIdT; if (rotated) { nodeIdT = $"{a + i}x{b + (i * 7)}x{c}x{d + j}x{id[4]}"; } else { nodeIdT = $"{a + i}x{b}x{c + (i * 7)}x{d + j}x{id[4]}"; } if (!CanPlaceSinglePin(nodeIdT, indexT)) { return(false); } if (breadBoard.NodeHasICType(nodeIdT, ICType.ic6)) { return(false); } } } return(true); case ICType.ic6: if (index == 0) { return(false); } id = nodeId.Split('x'); a = int.Parse(id[0]); b = int.Parse(id[1]); c = int.Parse(id[2]); d = int.Parse(id[3]); if (a != 1) { return(false); } if (d > 64 - (pins / 2)) { return(false); } for (int k = 0; k < pins / 2; k++) { string nodeIdT = $"1x{id[1]}x{id[2]}x{d + k}x{id[4]}"; for (int i = index; i < 5; i++) { if (!CanPlaceSinglePin(nodeIdT, i)) { return(false); } } } for (int k = 0; k < pins / 2; k++) { string nodeIdT = $"2x{(rotated ? (b + 7).ToString() : id[1])}x{(rotated ? id[2] : (c + 7).ToString())}x{d + k}x{id[4]}"; for (int i = 0; i < index; i++) { if (!CanPlaceSinglePin(nodeIdT, i)) { return(false); } } } return(true); default: return(false); } }
/// <summary> /// Get IC Records for a given IC Type and Filter Criteria /// </summary> /// <param name="filterFieldType"> /// <para>Applicable for NId, GId, Name, Search, ParentNId, NIdNotIn, NameNotIn, Type</para> /// </param> /// <param name="filterText"> /// <para>For FilterFieldType "Search" include wild characters. e.g. '%UNSD%' or '%UNSD'</para> /// </param> /// <param name="classificationType"></param> /// <param name="fieldSelection">LIGHT: Returns - NId, PArentNId, Name, GID, Global /// <para>HEAVY: Returns - NId, PArentNId, Name, GID, Global, Info</para> /// </param> /// <returns> /// </returns> public string GetIC(FilterFieldType filterFieldType, string filterText, ICType classificationType, FieldSelection fieldSelection, bool includeISBNNature) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); string WhereClause = string.Empty; sbQuery.Append(this.GetICSelectFromClause(fieldSelection, includeISBNNature)); sbQuery.Append(" WHERE "); sbQuery.Append("IC." + DIColumns.IndicatorClassifications.ICType + "=" + DIQueries.ICTypeText[classificationType]); WhereClause = this.GetICWhereClause(filterFieldType, filterText); if (WhereClause.Length > 0) { sbQuery.Append(" AND " + WhereClause); } if (classificationType == ICType.Source) { sbQuery.Append(" ORDER BY IC." + DIColumns.IndicatorClassifications.ICName); } else { sbQuery.Append(" ORDER BY IC." + DIColumns.IndicatorClassifications.ICOrder); } RetVal = sbQuery.ToString(); return RetVal; }
/// <summary> /// Get NId, Name, GID, Global from IUS - Indicator - Unit - SubgroupVal table based on Indicator Classification Type /// </summary> /// <param name="ICType"></param> /// <param name="ICNId"></param> /// <param name="fieldSelection"></param> /// <param name="includeDI7Columns"></param> /// <returns></returns> public string GetIUSByIC(ICType ICType, int ICNId, FieldSelection fieldSelection, bool includeDI7Columns) { if (ICNId == -1) { return GetIUSByIC(ICType, string.Empty, fieldSelection, includeDI7Columns); } else { return GetIUSByIC(ICType, ICNId.ToString(), fieldSelection, includeDI7Columns); } }
/// <summary> /// Get Indicator Classification records for a given IC Type and IUSNId /// </summary> /// <param name="filterFieldType">Applicable for NId, GId, Name, Search, ParentNId, NIdNotIn, NameNotIn, Type</param> /// <param name="filterText"> /// <para>For FilterFieldType "Search" include wild characters. e.g. '%UNSD%' or '%UNSD'</para> /// </param> /// <param name="IUSNIds">Comma delimited IUSNIds </param> /// <param name="classificationType">ICType enum value</param> /// <param name="fieldSelection">LIGHT: Returns - ICNId, ICParent_NId, ICName, ICGId, ICGlobal, ICType, IUSNId /// <para>HEAVY: Returns - ICNId, ICParent_NId, ICName, ICGId, ICGlobal, ICType, ICInfo, IUSNId</para> /// </param> /// <returns> /// </returns> public string GetICForIUSNId(FilterFieldType filterFieldType, string filterText, string IUSNIds, ICType classificationType, FieldSelection fieldSelection) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); sbQuery.Append(this.GetICIUSSelectFromClause(fieldSelection)); // WHERE Clause sbQuery.Append(" WHERE "); sbQuery.Append(" IC." + DIColumns.IndicatorClassifications.ICNId + " = ICIUS." + DIColumns.IndicatorClassificationsIUS.ICNId); sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICType + "=" + DIQueries.ICTypeText[classificationType]); if (IUSNIds.Trim().Length > 0) { sbQuery.Append(" AND ICIUS." + DIColumns.IndicatorClassificationsIUS.IUSNId + " IN (" + IUSNIds + ")"); } string WhereClause = this.GetICWhereClause(filterFieldType, filterText); if (WhereClause.Length > 0) { sbQuery.Append(" AND " + WhereClause); } RetVal = sbQuery.ToString(); return RetVal; }
/// <summary> /// Get NId, Name, GID, Global from IUS - Indicator - Unit - SubgroupVal table for a given Filter Criteria /// </summary> /// <param name="filterFieldType">Applicable for NId</param> /// <param name="filterText"></param> /// <param name="fieldSelection">Use Light for NId + Name + GId + Global fields use heavy to include IndicatorInfo field</param> /// <returns>Sql query string</returns> public string GetIUSByParentOrder(FilterFieldType filterFieldType, string filterText, ICType ICType, FieldSelection fieldSelection, string icNIds) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); // SELECT Clause sbQuery.Append("SELECT DISTINCT IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + ",IUS." + DIColumns.Indicator_Unit_Subgroup.IndicatorNId + ",IUS." + DIColumns.Indicator_Unit_Subgroup.UnitNId + ",IUS." + DIColumns.Indicator_Unit_Subgroup.SubgroupValNId); if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append(",I." + DIColumns.Indicator.IndicatorName + ",I." + DIColumns.Indicator.IndicatorGId + ",I." + DIColumns.Indicator.IndicatorGlobal); sbQuery.Append(",U." + DIColumns.Unit.UnitName + ",U." + DIColumns.Unit.UnitGId + ",U." + DIColumns.Unit.UnitGlobal); sbQuery.Append(",SGV." + DIColumns.SubgroupVals.SubgroupVal + ",SGV." + DIColumns.SubgroupVals.SubgroupValGId + ",SGV." + DIColumns.SubgroupVals.SubgroupValGlobal); sbQuery.Append(",IUS." + DIColumns.Indicator_Unit_Subgroup.MinValue + ",IUS." + DIColumns.Indicator_Unit_Subgroup.MaxValue); sbQuery.Append(",ICIUS." + DIColumns.IndicatorClassificationsIUS.ICIUSOrder); } if (fieldSelection == FieldSelection.Heavy) { sbQuery.Append(",I." + DIColumns.Indicator.IndicatorInfo); } // FROM Clause sbQuery.Append(" FROM " + this.TablesName.IndicatorUnitSubgroup + " AS IUS"); if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append("," + this.TablesName.Indicator + " AS I"); sbQuery.Append("," + this.TablesName.Unit + " AS U"); sbQuery.Append("," + this.TablesName.SubgroupVals + " AS SGV"); sbQuery.Append("," + this.TablesName.IndicatorClassifications + " AS IC"); sbQuery.Append("," + this.TablesName.IndicatorClassificationsIUS + " AS ICIUS"); } // WHERE Clause sbQuery.Append(" WHERE 1=1 "); if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.IndicatorNId + " = I." + DIColumns.Indicator.IndicatorNId); sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.UnitNId + " = U." + DIColumns.Unit.UnitNId); sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.SubgroupValNId + " = SGV." + DIColumns.SubgroupVals.SubgroupValNId); sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + " = ICIUS." + DIColumns.IndicatorClassificationsIUS.IUSNId); sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICNId + " = ICIUS." + DIColumns.IndicatorClassificationsIUS.ICNId); sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICType + " = " + DIQueries.ICTypeText[ICType]); if (!string.IsNullOrEmpty(icNIds)) { sbQuery.Append(" AND IC." + DIColumns.IndicatorClassifications.ICParent_NId + " IN (" + icNIds + ")"); } } if (filterFieldType != FilterFieldType.None && filterText.Length > 0) { switch (filterFieldType) { case FilterFieldType.None: break; case FilterFieldType.NId: sbQuery.Append(" AND IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + " IN (" + filterText + ")"); break; case FilterFieldType.ParentNId: break; case FilterFieldType.ID: break; case FilterFieldType.GId: break; case FilterFieldType.Name: break; case FilterFieldType.Search: sbQuery.Append(filterText); break; case FilterFieldType.Global: break; case FilterFieldType.NIdNotIn: break; case FilterFieldType.NameNotIn: break; default: break; } } // ORDER BY Clause if (fieldSelection == FieldSelection.Light || fieldSelection == FieldSelection.Heavy) { sbQuery.Append(" ORDER BY ICIUS." + DIColumns.IndicatorClassificationsIUS.ICIUSOrder); } RetVal = sbQuery.ToString(); return RetVal; }
/// <summary> /// Get IC Records for root parents (-1) for a given IC Type and Filter Criteria /// </summary> /// <param name="filterFieldType">None = get all top level Classifications with ParentNId=-1. /// <para>Applicable for NId, Search, NameNotIn</para> /// </param> /// <param name="filterText"><para>blank will Filter only for ICParentNId=-1</para> /// <para>For FilterFieldType "Search" include wild characters. e.g. '%UNSD%' or '%UNSD'</para> /// </param> /// <param name="classificationType"></param> /// <returns> /// <para>NId, Name, GID, Global</para> /// </returns> public string GetICTopParents(FilterFieldType filterFieldType, string filterText, ICType classificationType) { string RetVal = string.Empty; StringBuilder sbQuery = new StringBuilder(); // SELECT Clause sbQuery.Append("SELECT " + DIColumns.IndicatorClassifications.ICNId + "," + DIColumns.IndicatorClassifications.ICName + "," + DIColumns.IndicatorClassifications.ICGId + "," + DIColumns.IndicatorClassifications.ICGlobal); // FROM Clause sbQuery.Append(" FROM " + this.TablesName.IndicatorClassifications); // WHERE Clause sbQuery.Append(" WHERE " + DIColumns.IndicatorClassifications.ICParent_NId + " = -1 "); sbQuery.Append(" AND " + DIColumns.IndicatorClassifications.ICType + "=" + DIQueries.ICTypeText[classificationType]); if (filterText.Length > 0) { switch (filterFieldType) { case FilterFieldType.NId: // Filter on NID sbQuery.Append(" AND " + DIColumns.IndicatorClassifications.ICNId + " IN(" + filterText + ")"); break; case FilterFieldType.GId: break; case FilterFieldType.Name: sbQuery.Append(" AND " + DIColumns.IndicatorClassifications.ICName + " IN (" + filterText + ")"); break; case FilterFieldType.Search: sbQuery.Append(" AND " + DIColumns.IndicatorClassifications.ICName + " LIKE " + filterText); break; case FilterFieldType.Global: break; case FilterFieldType.NIdNotIn: break; case FilterFieldType.NameNotIn: sbQuery.Append(" AND " + DIColumns.IndicatorClassifications.ICName + " NOT IN (" + filterText + ")"); break; default: break; } } // ORDER BY Clause sbQuery.Append(" ORDER BY " + DIColumns.IndicatorClassifications.ICName); RetVal = sbQuery.ToString(); return RetVal; }
/// <summary> /// AutoSelect IUS based on TimePeriod and Area selection /// </summary> /// <param name="timePeriodNIds">commma delimited Timeperiod NIds which may be blank</param> /// <param name="areaNIds">commma delimited Area NIds which may be blank</param> /// <param name="ICType">Indicator Classification Type</param> /// <param name="fieldSelection">NId or Light</param> /// <returns>Sql query string</returns> public string GetAutoSelectByTimePeriodArea(string timePeriodNIds, string areaNIds, ICType ICType, FieldSelection fieldSelection) { string RetVal = String.Empty; // Get basic Sql clause from overloaded function RetVal = GetAutoSelectByTimePeriodArea(timePeriodNIds, areaNIds, -1, fieldSelection); // Append additional clause for ICType RetVal += " AND IC." + DIColumns.IndicatorClassifications.ICType + " = " + DIQueries.ICTypeText[ICType]; return RetVal; }
private DataTable AutoSelectIndicatorOrIUS(bool isForTree, ICType icType) { DataTable RetVal = new DataTable(); string Sql = string.Empty; string SelectedAreaNIds = this.UserPrefences.UserSelection.AreaNIds; string SelectedTimeperiodNIds = this.UserPrefences.UserSelection.TimePeriodNIds; string SelectedSourceNIds = this.UserPrefences.UserSelection.SourceNIds; try { // -- AUTO SELECT the source nids on the basis of the selected Time,Area & Source if (!this._UseArea) SelectedAreaNIds = string.Empty; if (!this._UseTime) SelectedTimeperiodNIds = string.Empty; if (!this._UseSource) SelectedSourceNIds = string.Empty; if (isForTree) { if (this._UserPrefences.Indicator.ShowIUS) { Sql = this.SqlQueries.IUS.GetAutoSelectIUS(SelectedTimeperiodNIds, SelectedAreaNIds, SelectedSourceNIds, 0, icType); } else { Sql = this.SqlQueries.Indicators.GetAutoSelectIndicator(SelectedTimeperiodNIds, SelectedAreaNIds, SelectedSourceNIds, 0, icType); } } else { if (this._UserPrefences.Indicator.ShowIUS) { Sql = this.SqlQueries.IUS.GetAutoSelectIUS(SelectedTimeperiodNIds, SelectedAreaNIds, SelectedSourceNIds, this._SelectedNid, icType); } else { Sql = this.SqlQueries.Indicators.GetAutoSelectIndicator(SelectedTimeperiodNIds, SelectedAreaNIds, SelectedSourceNIds, this._SelectedNid, icType); } } RetVal = this._DBConnection.ExecuteDataTable(Sql); } catch (Exception) { RetVal = null; } return RetVal; }
/// <summary> /// AutoSelect Indiactor,Unit & SubgroupVal based on TimePeriod, Area and source selection /// </summary> /// <param name="timePeriodNIds">commma delimited Timeperiod NIds which may be blank</param> /// <param name="areaNIds">commma delimited Area NIds which may be blank</param> /// <param name="sourceNids">Source Nids which may be blank </param> /// <param name="ICParentNId">Set IC_Parent_NID to get records against the given NID otherwise set 0 to get all auto select records</param> /// <param name="ICType"></param> /// <returns>Sql query string</returns> public string GetAutoSelectIUS(string timePeriodNIds, string areaNIds, string sourceNids, int ICParentNId, ICType ICType) { string RetVal = string.Empty; RetVal = "SELECT I." + DIColumns.Indicator.IndicatorNId + ", I." + DIColumns.Indicator.IndicatorName + ", I." + DIColumns.Indicator.IndicatorGId + ", I." + DIColumns.Indicator.IndicatorGlobal + ", U." + DIColumns.Unit.UnitNId + ", U." + DIColumns.Unit.UnitName + ", U." + DIColumns.Unit.UnitGId + ", U." + DIColumns.Unit.UnitGlobal + ", SG." + DIColumns.SubgroupVals.SubgroupValNId + ", SG." + DIColumns.SubgroupVals.SubgroupVal + ", SG." + DIColumns.SubgroupVals.SubgroupValGId + ", SG." + DIColumns.SubgroupVals.SubgroupValGlobal + ", IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + " FROM " + this.TablesName.Indicator + " AS I ," + this.TablesName.Unit + " AS U ," + this.TablesName.SubgroupVals + " AS SG, " + this.TablesName.IndicatorUnitSubgroup + " AS IUS WHERE I." + DIColumns.Indicator.IndicatorNId + "= IUS." + DIColumns.Indicator.IndicatorNId + " AND U." + DIColumns.Unit.UnitNId + "=IUS." + DIColumns.Unit.UnitNId + " AND SG." + DIColumns.SubgroupVals.SubgroupValNId + "=IUS." + DIColumns.SubgroupVals.SubgroupValNId + " AND EXISTS ( SELECT * FROM " + this.TablesName.Data + " as D WHERE IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + "= D." + DIColumns.Data.IUSNId; if (!string.IsNullOrEmpty(timePeriodNIds)) { RetVal += " AND D." + DIColumns.Data.TimePeriodNId + " IN( " + timePeriodNIds + " ) "; } if (!string.IsNullOrEmpty(areaNIds)) { RetVal += " AND D." + DIColumns.Data.AreaNId + " IN( " + areaNIds + " ) "; } if (!string.IsNullOrEmpty(sourceNids)) { RetVal += " AND D." + DIColumns.Data.SourceNId + " IN( " + sourceNids + " ) "; } RetVal += " )"; RetVal += " AND EXISTS ( SELECT * FROM " + this.TablesName.IndicatorClassificationsIUS + " ICIUS WHERE IUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + " = ICIUS." + DIColumns.Indicator_Unit_Subgroup.IUSNId + " AND EXISTS ( SELECT * FROM " + this.TablesName.IndicatorClassifications + " IC WHERE ICIUS." + DIColumns.IndicatorClassifications.ICNId + " =IC." + DIColumns.IndicatorClassifications.ICNId; if (ICParentNId > 0) { RetVal += " AND IC." + DIColumns.IndicatorClassifications.ICParent_NId + " =" + ICParentNId + " "; } RetVal += " AND IC." + DIColumns.IndicatorClassifications.ICType + "=" + DIQueries.ICTypeText[ICType] + " )) "; RetVal += " ORDER BY I." + DIColumns.Indicator.IndicatorName + ""; return RetVal; }
internal int CreateClassificationChainFromExtDB(int srcICNId, int srcParentNId, string srcICGid, string srcICName, ICType srcICType, string srcICInfo, bool isGlobal, DIQueries srcQueries, DIConnection srcDBConnection, DIQueries targetDBQueries, DIConnection targetDBConnection) { int RetVal; //int TrgParentNId; //string TrgParentName; int NewParentNId; DataTable TempTable; IndicatorClassificationInfo ICInfo; IndicatorClassificationBuilder ClassificationBuilder = new IndicatorClassificationBuilder(targetDBConnection, targetDBQueries); // -- STEP 1: If the Parent NID is -1 then create the Classification at the root if (srcParentNId == -1) { // -- Create the Classification // -------------------------------------------------------------- // While importing the Classifications, if the NId of the Source Classification is _ // the same as that of the one created, then the Duplicate check fails and a duplicate // classification getscreated. PASS -99 as the first parameter to the calling function // -------------------------------------------------------------- ICInfo = new IndicatorClassificationInfo(); ICInfo.Parent = new IndicatorClassificationInfo(); ICInfo.Parent.Nid = srcParentNId; ICInfo.Nid = srcICNId; ICInfo.Name = srcICName; ICInfo.ClassificationInfo = srcICInfo; ICInfo.GID = srcICGid; ICInfo.IsGlobal = isGlobal; ICInfo.Type = srcICType; RetVal = ClassificationBuilder.ImportIndicatorClassification(ICInfo, srcICNId, srcQueries, srcDBConnection); } else { // -- STEP 2: If the Parent is not -1 then check for the existence of the Parent and then create the Classification // Classification can only be created if the parent exists // -- STEP 2.1: If the Parent Exists then create the Classification under that parent // -- STEP 2.2: If the Parent does not Exist then create the Parent first and then the Classification under that parent // -- STEP 2: Check the existence of the Parent in the Target Database // -- get the parent from the source database TempTable = srcDBConnection.ExecuteDataTable(srcQueries.IndicatorClassification.GetIC(FilterFieldType.NId, srcParentNId.ToString(), srcICType, FieldSelection.Heavy)); { // -------------------------------------------------------------- // While importing the Classifications, if the NId of the Source Classification is _ // the same as that of the one created, then the Duplicate check fails and a duplicate // classification getscreated. PASS -99 as the first parameter to the calling function // -------------------------------------------------------------- DataRow Row; string ClassificationInfo = string.Empty; Row = TempTable.Rows[0]; ClassificationInfo = Convert.ToString(Row[IndicatorClassifications.ICInfo]); NewParentNId = CreateClassificationChainFromExtDB( Convert.ToInt32(Row[IndicatorClassifications.ICNId]), Convert.ToInt32(Row[IndicatorClassifications.ICParent_NId]), Row[IndicatorClassifications.ICGId].ToString(), Row[IndicatorClassifications.ICName].ToString(), srcICType, ClassificationInfo, Convert.ToBoolean(Row[IndicatorClassifications.ICGlobal]), srcQueries, srcDBConnection, targetDBQueries, targetDBConnection); ; } // -- Create the Child Now ICInfo = new IndicatorClassificationInfo(); ICInfo.Parent = new IndicatorClassificationInfo(); ICInfo.Parent.Nid = NewParentNId; // set new parent nid ICInfo.Nid = srcICNId; ICInfo.Name = srcICName; ICInfo.ClassificationInfo = srcICInfo; ICInfo.GID = srcICGid; ICInfo.IsGlobal = isGlobal; ICInfo.Type = srcICType; RetVal = ClassificationBuilder.ImportIndicatorClassification(ICInfo, srcICNId, srcQueries, srcDBConnection); } //import ic and ius relationship into indicator_classification_IUS table ClassificationBuilder.ImportICAndIUSRelations(srcICNId, RetVal, ICInfo.Type, srcQueries, srcDBConnection); return RetVal; }
/// <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 ImportICMetadata(string dataPrefix, DIConnection sourceDBConnection, DIQueries sourceDBQueries, string selectedNIDs, int selectionCount, MetaDataType metadataType, ICType classificationType) { string MetadataInfo = string.Empty; DataTable TempDataTable; DataTable TempTargetIdTable = new DataTable(); IndicatorClassificationBuilder ICBuilder; int TargetICNid = 0; int CurrentRecordIndex = 0; this.RaiseStartProcessEvent(); try { ICBuilder = new IndicatorClassificationBuilder(this.DBConnection, this.DBQueries); 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 (int 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(); // Get Target IC NID by Source IC GID TargetICNid = ICBuilder.GetNidByGID(Convert.ToString(TempDataTable.Rows[Index][IndicatorClassifications.ICGId]), classificationType); if (TargetICNid > 0) { //-- Update Metadata ICBuilder.UpdateICInfo(TargetICNid, MetadataInfo); } } } // -- Increemnt the Progress Bar Value this.RaiseProcessInfoEvent(CurrentRecordIndex); } // -- Dispose the Data Table object TempDataTable.Dispose(); } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } }
/// <summary> /// Get distinct NId, Name, GID, Global from IUS - Indicator - Unit - SubgroupVal table based on Indicator Classification Type and order on the basis of ICIUS order /// </summary> /// <param name="ICType">Indicator Classification Type</param> /// <param name="ICNId">ICNId which may be blank if only ICType is to be considered</param> /// <param name="fieldSelection">Use Light for NId + Name + GId + Global fields use heavy to include IndicatorInfo field</param> /// <returns>Sql query string</returns> public string GetDistinctOrderedIUSByIC(ICType ICType, string ICNId, FieldSelection fieldSelection) { string sortOrderString = "ICIUS." + DIColumns.IndicatorClassificationsIUS.ICIUSOrder; return this.GetDistinctIUSByIC(ICType, ICNId, fieldSelection, sortOrderString); }
private DataTable AutoSelectIndicatorOrIUS(int icNId, ICType icType) { DataTable RetVal = new DataTable(); try { string Sql = string.Empty; DataTable IUSDt; string[] DistinctColumns = new string[1]; StringBuilder sbIUSNIds = new StringBuilder(); string sIUSNIDs = string.Empty; string SelectedTimeperiodNIds = this.UserPrefences.UserSelection.TimePeriodNIds; string SelectedAreaNIds = this.UserPrefences.UserSelection.AreaNIds; string SelectedSourceNIds = this.UserPrefences.UserSelection.SourceNIds; // -- Get All Comma seperated IUSNIDs for the selected IC Type from the Available list DataTable IUSFromICTypes; //'-- Get the IUS NIds on the basis of IC types if (icNId > -1) { // -- When IC Element is slected Sql = this.SqlQueries.Indicators.GetIUSNIdFromICType(icType, icNId.ToString()); IUSFromICTypes = this._DBConnection.ExecuteDataTable(Sql); } // -- This will return Distinct IUS always under a given IC Element else { // -- When IC Element is NOT slected (IUS on the basis of the ICType) Sql = this.SqlQueries.Indicators.GetIUSNIdFromICType(icType, ""); IUSFromICTypes = this._DBConnection.ExecuteDataTable(Sql); // -- This will NOT return DISTINCT IUS under a given IC Type // -- Get DISTINCT IUS RetVal = IUSFromICTypes; DistinctColumns[0] = IndicatorClassificationsIUS.IUSNId; //-- Distinct IUS NIds IUSFromICTypes = RetVal.DefaultView.ToTable(true, DistinctColumns); } // -- Loop and get the comma seperated IUS NIDs foreach (DataRow IUSNId in IUSFromICTypes.Rows) { sbIUSNIds.Append("," + IUSNId[IndicatorClassificationsIUS.IUSNId]); } // -- Remove extra Comma if (sbIUSNIds.Length > 0) { sIUSNIDs = sbIUSNIds.ToString().Substring(1); } // -- AUTO SELECT the DISTINCT IUSNIDs on the basis of the selected Time, Area and Available IUS/I in the Available list if (!this.UseArea) { SelectedAreaNIds = string.Empty; } if (!this.UseTime) { SelectedTimeperiodNIds = string.Empty; } if (!this.UseSource) { SelectedSourceNIds = string.Empty; } if (string.IsNullOrEmpty(sIUSNIDs)) { sIUSNIDs = "0"; } Sql = this.SqlQueries.Indicators.GetAutoSelectByTimePeriodAreaSource(SelectedTimeperiodNIds, SelectedAreaNIds, sIUSNIDs.ToString(), SelectedSourceNIds); IDataReader rdIUS; rdIUS = this._DBConnection.ExecuteReader(Sql); sbIUSNIds.Length = 0; while ((rdIUS.Read())) { sbIUSNIds.Append(","); sbIUSNIds.Append(rdIUS[Indicator_Unit_Subgroup.IUSNId]); } sIUSNIDs = string.Empty; if (sbIUSNIds.Length > 0) { sIUSNIDs = sbIUSNIds.ToString().Substring(1); } rdIUS.Close(); if (this.UserPrefences.Indicator.ShowIUS) { Sql = this.SqlQueries.Indicators.GetIndicators(sIUSNIDs.ToString(), this.UserPrefences.Indicator.ShowIUS); } else { Sql = this.SqlQueries.IUS.GetDistinctIndicatorUnit(sIUSNIDs.ToString(), this.UserPrefences.Indicator.ShowIUS); } //Sql = this.SqlQueries.Indicators.GetIndicators(sIUSNIDs.ToString(), this.UserPrefences.Indicator.ShowIUS); RetVal = this._DBConnection.ExecuteDataTable(Sql); } catch (Exception) { RetVal = null; } return(RetVal); }
/// <summary> /// Update indicator classification information /// </summary> /// <param name="dataPrefix"></param> /// <param name="languageCode"></param> /// <param name="name">Name which may be empty</param> /// <param name="GId">GID which may be empty</param> /// <param name="isGlobal"></param> /// <param name="parentNid"></param> /// <param name="ICInfo">ICInfo which may be empty</param> /// <param name="classificationType"></param> /// <param name="ICNid"></param> /// <returns></returns> public static string UpdateICInfo(string dataPrefix, string languageCode, string ICInfo, ICType classificationType, int ICNid) { string RetVal = string.Empty; RetVal = RetVal = "UPDATE " + dataPrefix + Update.TableName + languageCode + " SET "; RetVal += DIColumns.IndicatorClassifications.ICInfo + "='" + ICInfo + "'"; RetVal += "," + DIColumns.IndicatorClassifications.ICType + "=" + DIQueries.ICTypeText[classificationType] + " WHERE " + DIColumns.IndicatorClassifications.ICNId + "=" + ICNid; return RetVal; }