/// <summary> /// Imports records from source database to target database/template /// </summary> /// <param name="selectedNids"></param> /// <param name="allSelected">Set true to import all records</param> public override void ImportValues(List <string> SelectedNids, bool allSelected) { DI7MetaDataBuilder MetaData = new DI7MetaDataBuilder(this._TargetDBConnection, this._TargetDBQueries); MetaData.BeforeProcess += new ProcessInfoDelegate(MetaData_BeforeProcess); MetaData.ProcessInfo += new ProcessInfoDelegate(MetaData_ProcessInfo); if (this.InputFileType != DataSourceType.Database && this.InputFileType != DataSourceType.Template) { // Import data from xml file this.RaiseInitializeProgessBarEvent(1); if (System.IO.Path.GetExtension(this._SelectedFiles[0]).ToUpper() == DICommon.FileExtension.Excel.ToUpper()) { // import from excel MetaData.ImportMetataFromExcel(MetadataElementType.Area, MetaDataType.Map, this.SelectedNidInTrgDatabase, this._SelectedFiles[0].ToString(), this.XsltFolderPath); } else { ////MetaData.ImportMetadataFromXML(this.GetFileText(this._SelectedFiles[0]), MetaDataType.Map, this.SelectedNidInTrgDatabase, this.XsltFolderPath); MetaData.ImportMetadataFromXML(this.GetFileText(this._SelectedFiles[0]), MetadataElementType.Area, this.SelectedNidInTrgDatabase, this.XsltFolderPath); } this.RaiseIncrementProgessBarEvent(1); } else { int SelectedCount = SelectedNids.Count; if (allSelected) { SelectedCount = -1; } MetaData.ImportAreaMetadata(this._TargetDBQueries.DataPrefix, this.SourceDBConnection, this.SourceDBQueries, string.Join(",", SelectedNids.ToArray()), SelectedCount, MetaDataType.Map); } }
/// <summary> /// Returns the metadata text from database /// </summary> /// <param name="elementNid"></param> /// <returns></returns> public override string GetMetadataTextFrmDB(int elementNid) { string RetVal = string.Empty; string ElementGID = string.Empty; DataTable Table; DI7MetaDataBuilder MDBuilder = null; try { Table = this.DBConnection.ExecuteDataTable(this.DBQueries.Area.GetAreaByLayer(elementNid.ToString())); foreach (DataRow Row in Table.Rows) { ElementGID = Convert.ToString(Row[Area.AreaID]); // get xml file from SDMX library RetVal = DevInfo.Lib.DI_LibSDMX.SDMXUtility.Get_MetadataReport(DI_LibSDMX.SDMXSchemaType.Two_One, ElementGID, DevInfo.Lib.DI_LibSDMX.MetadataTypes.Area, "MDAgency", this.DBQueries.LanguageCode.Replace("_", ""), this.DBConnection, this.DBQueries).InnerXml; MDBuilder = new DI7MetaDataBuilder(this.DBConnection, this.DBQueries); RetVal = MDBuilder.GetMetadataReportWCategoryName(RetVal, MetadataElementType.Area).InnerXml; break; } } catch (Exception) { RetVal = string.Empty; } return(RetVal); }
/// <summary> /// Returns the metadata text from database /// </summary> /// <param name="elementNid"></param> /// <returns></returns> public override string GetMetadataTextFrmDB(int elementNid) { string RetVal = string.Empty; string ElementGID = string.Empty; IndicatorBuilder Indicators; DI7MetaDataBuilder MDBuilder = null; try { Indicators = new IndicatorBuilder(this.DBConnection, this.DBQueries); ElementGID = Indicators.GetIndicatorInfo(FilterFieldType.NId, elementNid.ToString(), FieldSelection.Light).GID; // get xml file from SDMX library RetVal = DevInfo.Lib.DI_LibSDMX.SDMXUtility.Get_MetadataReport(DI_LibSDMX.SDMXSchemaType.Two_One, ElementGID, DevInfo.Lib.DI_LibSDMX.MetadataTypes.Indicator, "MDAgency", this.DBQueries.LanguageCode.Replace("_", ""), this.DBConnection, this.DBQueries).InnerXml; MDBuilder = new DI7MetaDataBuilder(this.DBConnection, this.DBQueries); RetVal = MDBuilder.GetMetadataReportWCategoryName(RetVal, MetadataElementType.Indicator).InnerXml; } catch (Exception) { RetVal = string.Empty; } return(RetVal); }
/// <summary> /// Imports records from source database to target database/template /// </summary> /// <param name="selectedNids"></param> /// <param name="allSelected">Set true to import all records</param> public override void ImportValues(List <string> SelectedNids, bool allSelected) { DI7MetaDataBuilder MetaData = new DI7MetaDataBuilder(this._TargetDBConnection, this._TargetDBQueries); MetaDataType MetaDataType = MetaDataType.Sector; switch (this._IndicatorClassificationType) { case ICType.Sector: MetaDataType = MetaDataType.Sector; break; case ICType.Goal: MetaDataType = MetaDataType.Goal; break; case ICType.CF: MetaDataType = MetaDataType.CF; break; case ICType.Theme: MetaDataType = MetaDataType.Theme; break; case ICType.Source: MetaDataType = MetaDataType.Source; break; case ICType.Institution: MetaDataType = MetaDataType.Institution; break; case ICType.Convention: MetaDataType = MetaDataType.Convention; break; default: break; } if (this.InputFileType != DataSourceType.Database && this.InputFileType != DataSourceType.Template) { this.RaiseInitializeProgessBarEvent(1); if (MetaDataType == MetaDataType.Source) { if (System.IO.Path.GetExtension(this._SelectedFiles[0]).ToUpper() == DICommon.FileExtension.Excel.ToUpper()) { // import from excel MetaData.ImportMetataFromExcel(MetadataElementType.Source, MetaDataType.Source, this.SelectedNidInTrgDatabase, this._SelectedFiles[0].ToString(), this.XsltFolderPath); } else { // Import data from xml file ////MetaData.ImportMetadataFromXML(this.GetFileText(this._SelectedFiles[0]), MetaDataType, this.SelectedNidInTrgDatabase, this.XsltFolderPath); MetaData.ImportMetadataFromXML(this.GetFileText(this._SelectedFiles[0]), MetadataElementType.Source, this.SelectedNidInTrgDatabase, this.XsltFolderPath); } } else { // Import data from rtf file MetaData.ImportMetadataFromRTFFile(this.GetFileText(this._SelectedFiles[0]), MetaDataType, this.SelectedNidInTrgDatabase); } this.RaiseIncrementProgessBarEvent(1); } else { //improt data from database/template MetaData.BeforeProcess += new ProcessInfoDelegate(MetaData_BeforeProcess); MetaData.ProcessInfo += new ProcessInfoDelegate(MetaData_ProcessInfo); if (MetaDataType == MetaDataType.Source) { MetaData.ImportSourceMetadata(this._TargetDBQueries.DataPrefix, this.SourceDBConnection, this.SourceDBQueries, string.Join(",", SelectedNids.ToArray()), SelectedNids.Count, MetaDataType); } else { MetaData.ImportICMetadata(this._TargetDBQueries.DataPrefix, this.SourceDBConnection, this.SourceDBQueries, string.Join(",", SelectedNids.ToArray()), SelectedNids.Count, MetaDataType, this._IndicatorClassificationType); } } }