/// <summary> /// Inserts IUS into database /// </summary> /// <param name="indicatorGId"></param> /// <param name="unitGId"></param> /// <param name="subgroupGId"></param> /// <returns></returns> public int InsertIUSIntoDB(string indicatorGId, string unitGId, string subgroupGId) { int RetVal = -1; IndicatorBuilder IndicatorBuilderObj = new IndicatorBuilder(this.DBConnection, this.DBQueries); UnitBuilder UnitBuilderObj = new UnitBuilder(this.DBConnection, this.DBQueries); DI6SubgroupValBuilder SGBuilder = new DI6SubgroupValBuilder(this.DBConnection, this.DBQueries); IUSBuilder IUSObj = new IUSBuilder(this.DBConnection, this.DBQueries); int IndicatorNID = -1; int UnitNID = -1; int SubgroupValNID = -1; try { IndicatorNID = IndicatorBuilderObj.GetIndicatorNid(indicatorGId, string.Empty); UnitNID = UnitBuilderObj.GetUnitNid(unitGId, string.Empty); SubgroupValNID = SGBuilder.GetSubgroupValNid(subgroupGId, string.Empty); if (IndicatorNID > 0 & UnitNID > 0 & SubgroupValNID > 0) { RetVal = IUSObj.InsertIUS(IndicatorNID, UnitNID, SubgroupValNID, 0, 0); } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return(RetVal); }
/// <summary> /// Inserts or updates IUS into database /// </summary> /// <param name="indicatorGId"></param> /// <param name="unitGId"></param> /// <param name="subgroupGId"></param> /// <param name="minValue"></param> /// <param name="maxValue"></param> /// <returns></returns> public int InsertOrUpdateIUSIntoDBByName(string indicatorName, string unitName, string subgroupval, int minValue, int maxValue) { int RetVal = -1; IndicatorBuilder IndicatorBuilderObj = new IndicatorBuilder(this.DBConnection, this.DBQueries); UnitBuilder UnitBuilderObj = new UnitBuilder(this.DBConnection, this.DBQueries); DI6SubgroupValBuilder SGBuilder = new DI6SubgroupValBuilder(this.DBConnection, this.DBQueries); IUSBuilder IUSObj = new IUSBuilder(this.DBConnection, this.DBQueries); int IndicatorNID = -1; int UnitNID = -1; int SubgroupValNID = -1; try { IndicatorNID = IndicatorBuilderObj.GetIndicatorNid(string.Empty, indicatorName); UnitNID = UnitBuilderObj.GetUnitNid(string.Empty, unitName); SubgroupValNID = SGBuilder.GetSubgroupValNid(string.Empty, subgroupval); if (IndicatorNID > 0 & UnitNID > 0 & SubgroupValNID > 0) { // check IUS combination already exists or not RetVal = this.GetIUSNid(IndicatorNID, UnitNID, SubgroupValNID); if (RetVal > 0) { //update record this.UpdateIUS(IndicatorNID, UnitNID, SubgroupValNID, maxValue.ToString(), minValue.ToString(), RetVal); } else { // insert record RetVal = IUSObj.InsertIUS(IndicatorNID, UnitNID, SubgroupValNID, minValue, maxValue); } } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return(RetVal); }
/// <summary> /// Inserts or updates IUS into database /// </summary> /// <param name="indicatorGId"></param> /// <param name="unitGId"></param> /// <param name="subgroupGId"></param> /// <param name="minValue"></param> /// <param name="maxValue"></param> /// <returns></returns> public int InsertOrUpdateIUSIntoDBByName(string indicatorName, string unitName, string subgroupval, int minValue, int maxValue) { int RetVal = -1; IndicatorBuilder IndicatorBuilderObj = new IndicatorBuilder(this.DBConnection, this.DBQueries); UnitBuilder UnitBuilderObj = new UnitBuilder(this.DBConnection, this.DBQueries); DI6SubgroupValBuilder SGBuilder = new DI6SubgroupValBuilder(this.DBConnection, this.DBQueries); IUSBuilder IUSObj = new IUSBuilder(this.DBConnection, this.DBQueries); int IndicatorNID = -1; int UnitNID = -1; int SubgroupValNID = -1; try { IndicatorNID = IndicatorBuilderObj.GetIndicatorNid(string.Empty, indicatorName); UnitNID = UnitBuilderObj.GetUnitNid(string.Empty, unitName); SubgroupValNID = SGBuilder.GetSubgroupValNid(string.Empty, subgroupval); if (IndicatorNID > 0 & UnitNID > 0 & SubgroupValNID > 0) { // check IUS combination already exists or not RetVal = this.GetIUSNid(IndicatorNID, UnitNID, SubgroupValNID); if (RetVal > 0) { //update record this.UpdateIUS(IndicatorNID, UnitNID, SubgroupValNID, maxValue.ToString(), minValue.ToString(), RetVal); } else { // insert record RetVal = IUSObj.InsertIUS(IndicatorNID, UnitNID, SubgroupValNID, minValue, maxValue); } } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return RetVal; }
/// <summary> /// Inserts IUS into database /// </summary> /// <param name="indicatorGId"></param> /// <param name="unitGId"></param> /// <param name="subgroupGId"></param> /// <returns></returns> public int InsertIUSIntoDB(string indicatorGId, string unitGId, string subgroupGId) { int RetVal = -1; IndicatorBuilder IndicatorBuilderObj = new IndicatorBuilder(this.DBConnection, this.DBQueries); UnitBuilder UnitBuilderObj = new UnitBuilder(this.DBConnection, this.DBQueries); DI6SubgroupValBuilder SGBuilder = new DI6SubgroupValBuilder(this.DBConnection, this.DBQueries); IUSBuilder IUSObj = new IUSBuilder(this.DBConnection, this.DBQueries); int IndicatorNID = -1; int UnitNID = -1; int SubgroupValNID = -1; try { IndicatorNID = IndicatorBuilderObj.GetIndicatorNid(indicatorGId, string.Empty); UnitNID = UnitBuilderObj.GetUnitNid(unitGId, string.Empty); SubgroupValNID = SGBuilder.GetSubgroupValNid(subgroupGId, string.Empty); if (IndicatorNID > 0 & UnitNID > 0 & SubgroupValNID > 0) { RetVal = IUSObj.InsertIUS(IndicatorNID, UnitNID, SubgroupValNID, 0, 0); } } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return RetVal; }
private int GetElementNId(string excelFilePath, MetaDataType elementType, int elementNameRowIndex) { int RetVal = 0; string ElementName = string.Empty; string ElementGId = string.Empty; SpreadsheetGear.IWorksheet MetadataSheet; IndicatorBuilder IndBuilder = null; IndicatorInfo IndInfo = new IndicatorInfo(); DataTable Table = null; int GIdRowIndex = elementNameRowIndex + 1; //-- Open excel File and get first worksheet DIExcel DiExcel = new DIExcel(excelFilePath); MetadataSheet = DiExcel.GetWorksheet(0); //-- Get Element GId ElementGId = DiExcel.GetCellValue(ElementSheetIndex, GIdRowIndex, ElementGIdColumnIndex, GIdRowIndex, ElementGIdColumnIndex); //-- Get Element Name ElementName = DiExcel.GetCellValue(ElementSheetIndex, elementNameRowIndex, ElementNameColumnIndex, elementNameRowIndex, ElementNameColumnIndex); //-- Get GId By Name if GID is blank in Excel File if (!string.IsNullOrEmpty(ElementGId) || !string.IsNullOrEmpty(ElementName)) { switch (elementType) { case MetaDataType.Indicator: IndBuilder = new IndicatorBuilder(this.DBConnection, this.DBQueries); RetVal = IndBuilder.GetIndicatorNid(ElementGId, ElementName); break; case MetaDataType.Map: Table = this.DBConnection.ExecuteDataTable(this.DBQueries.Area.GetAreaMapMetadataByName(string.IsNullOrEmpty(ElementGId) ? ElementName : ElementGId)); if (Table.Rows.Count > 0) { RetVal = Convert.ToInt32(Table.Rows[0][Area_Map_Metadata.LayerNId]); } break; case MetaDataType.Source: case MetaDataType.Sector: case MetaDataType.Goal: case MetaDataType.CF: case MetaDataType.Theme: case MetaDataType.Institution: case MetaDataType.Convention: case MetaDataType.IndicatorClassification: Table = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.GId, "'" + ElementGId + "'", FieldSelection.Heavy)); if (Table.Rows.Count > 0) { RetVal = Convert.ToInt32(Table.Rows[0][IndicatorClassifications.ICNId]); } break; default: break; } } return RetVal; }