/// <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)
        {
            UnitBuilder UnitBuilderObj = new UnitBuilder(this._TargetDBConnection, this._TargetDBQueries);
            UnitInfo SourceDBUnit;
            DataRow Row;
            int ProgressBarValue = 0;

            foreach (string Nid in selectedNids)
            {
                try
                {
                    //get unit from source table
                    Row = this.SourceTable.Select(Unit.UnitNId + "=" + Nid)[0];
                    SourceDBUnit = new UnitInfo();
                    SourceDBUnit.Name = DICommon.RemoveQuotes( Row[Unit.UnitName].ToString());
                    SourceDBUnit.GID = Row[Unit.UnitGId].ToString();
                   SourceDBUnit.Global = Convert.ToBoolean(Row[Unit.UnitGlobal]);
                    SourceDBUnit.Nid=Convert.ToInt32(Row[Unit.UnitNId]);
                    //import into target database
                   UnitBuilderObj.ImportUnit(SourceDBUnit, SourceDBUnit.Nid, this.SourceDBQueries, this.SourceDBConnection);
                }
                catch (Exception ex)
                {
                    ExceptionFacade.ThrowException(ex);
                }

                this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                ProgressBarValue++;
            }
        }
Beispiel #2
0
 public IUSBuilder(DIConnection connection, DIQueries queries)
 {
     this.DBConnection = connection;
     this.DBQueries = queries;
     this.DIIndicator = new IndicatorBuilder(connection, queries);
     this.DIUnit = new UnitBuilder(connection, queries);
     this.DISubgroupVal = new DI6SubgroupValBuilder(connection, queries);
     DIConnection.ConnectionType = this.DBConnection.ConnectionStringParameters.ServerType;
 }
        internal AssistantImporter(DIConnection targetConnection, DIQueries targetQueries, List<string> sourceDatabaseFileNamesWPath)
        {
            this._TargetDBConnection = targetConnection;
            this._TargetDBQueries = targetQueries;

            this.SourceDatabaseFileNamesWPath = sourceDatabaseFileNamesWPath;

            this.AvailableIndicators = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
            this.AvailableUnit= new UnitBuilder(this._TargetDBConnection, this._TargetDBQueries);
            this.AvailableSubgroupVal= new DI6SubgroupValBuilder(this._TargetDBConnection, this._TargetDBQueries);
        }
Beispiel #4
0
        /// <summary>
        /// Generates blank DES 
        /// </summary>
        /// <param name="singleWorkbook"></param>
        /// <param name="dBConnection"></param>
        /// <param name="dBQueries"></param>
        /// <param name="userSelection"></param>
        /// <param name="sortedFields"></param>
        /// <param name="xlsFileNameWPath"></param>
        /// <param name="includeGUID"></param>
        /// <param name="languageFileNameWPath"></param>
        /// <returns></returns>
        private DataView GetBlankDESDataView(DataView blankDESDataView, string indicatorNId, string unitNId, bool singleWorkbook, DIConnection dBConnection, DIQueries dBQueries, UserSelection userSelection, bool includeGUID)
        {
            DataView RetVal = null;
            string SqlQuery = string.Empty;
            string OriginalSubgroupNIds = string.Empty;
            DataTable AutoSubgroupValsTable = null;
            IndicatorInfo IndicatorInfoObj;
            IndicatorBuilder IndicatorBuilderObj;
            UnitInfo UnitInfoObj;
            UnitBuilder UnitBuilderObj;
            DI6SubgroupValBuilder SGValBuilder;
            DI6SubgroupValInfo SGValINfo;
            DataTable DT;

            try
            {
                // 1. Get blank DES dataview only if it is null
                if (blankDESDataView == null)
                {
                    blankDESDataView = GetBlankDESDataViewWithoutIUS(userSelection, dBConnection, dBQueries);
                }

                // 2. get dAtaview for the given Indicator + Unit.

                try
                {
                    // 3.  Preserve original SubgroupNIds into a temp
                    OriginalSubgroupNIds = userSelection.SubgroupValNIds;

                    // 4.  If SubgroupVal is blank, then get all subgroups for which given IU are combined as IUS.
                    if (userSelection.SubgroupValNIds.Length == 0)
                    {
                        if (userSelection.ShowIUS & userSelection.IndicatorNIds.Length > 0)
                        {
                            // 4.1  Get SubgroupNIDs for given IUSNId as userSelection.IndicatorNId
                            AutoSubgroupValsTable = dBConnection.ExecuteDataTable(dBQueries.IUS.GetIUS(FilterFieldType.NId, userSelection.IndicatorNIds, FieldSelection.Light));

                            // 4.2 Set filter for given I, U
                            AutoSubgroupValsTable.DefaultView.RowFilter = Indicator.IndicatorNId + " = " + indicatorNId + " AND " + Unit.UnitNId + " = " + unitNId;

                            AutoSubgroupValsTable = AutoSubgroupValsTable.DefaultView.ToTable();
                        }
                        else
                        {
                            // 4.3 Get SubgroupNIDs for given Indicator + Unit
                            AutoSubgroupValsTable = dBConnection.ExecuteDataTable(dBQueries.IUS.GetIUSNIdByI_U_S(indicatorNId, unitNId, string.Empty));
                        }

                        // 4.4 Set those SubgroupNIds into userSelection
                        userSelection.SubgroupValNIds = DIExport.DataColumnValuesToString(AutoSubgroupValsTable, SubgroupVals.SubgroupValNId);
                    }

                    //////// get IUSNIds on the basis of IndicatorsNId,UnitsNId and subgroupValSNId

                    //////SqlQuery = dBQueries.IUS.GetIUSByI_U_S(indicatorNId, unitNId, userSelection.SubgroupValNIds);

                    //////IUSTable = dBConnection.ExecuteDataTable(SqlQuery);

                    //////IUSNIds = DIConnection.GetDelimitedValuesFromDataTable(IUSTable, Indicator_Unit_Subgroup.IUSNId);

                    //  **************************************************************************
                    // get indicator,unit and subgroup info
                    IndicatorBuilderObj = new IndicatorBuilder(dBConnection, dBQueries);
                    IndicatorInfoObj = IndicatorBuilderObj.GetIndicatorInfo(FilterFieldType.NId, indicatorNId, FieldSelection.Light);

                    UnitBuilderObj = new UnitBuilder(dBConnection, dBQueries);
                    UnitInfoObj = UnitBuilderObj.GetUnitInfo(FilterFieldType.NId, unitNId);

                    SGValBuilder = new DI6SubgroupValBuilder(dBConnection, dBQueries);

                    // 5. process and update filteredDataview  for all subgroup nids

                    if (RetVal == null)
                    {
                        RetVal = new DataView(blankDESDataView.Table.Copy());
                        RetVal.Table.Clear();
                        // add subgroup columns
                        if (includeGUID)
                        {
                            RetVal.Table.Columns.Add(SubgroupVals.SubgroupValGId);
                        }

                        RetVal.Table.Columns.Add(SubgroupVals.SubgroupVal);

                        // check and insert columns for indicator & unit
                        if (!(RetVal.Table.Columns.Contains(Indicator.IndicatorName)))
                        {
                            RetVal.Table.Columns.Add(Indicator.IndicatorName);
                        }
                        if (!(RetVal.Table.Columns.Contains(Indicator.IndicatorGId)))
                        {
                            RetVal.Table.Columns.Add(Indicator.IndicatorGId);
                        }
                        if (!(RetVal.Table.Columns.Contains(Unit.UnitName)))
                        {
                            RetVal.Table.Columns.Add(Unit.UnitName);
                        }
                        if (!(RetVal.Table.Columns.Contains(Unit.UnitGId)))
                        {
                            RetVal.Table.Columns.Add(Unit.UnitGId);
                        }

                        // set indicator and unit values
                        RetVal.Table.Columns[Indicator.IndicatorGId].DefaultValue = IndicatorInfoObj.GID;
                        RetVal.Table.Columns[Indicator.IndicatorName].DefaultValue = IndicatorInfoObj.Name;
                        RetVal.Table.Columns[Unit.UnitGId].DefaultValue = UnitInfoObj.GID;
                        RetVal.Table.Columns[Unit.UnitName].DefaultValue = UnitInfoObj.Name;
                    }
                    else
                    {
                        RetVal.Table.Clear();
                    }

                    foreach (string SGNid in DICommon.SplitString(userSelection.SubgroupValNIds, ","))
                    {
                        //////// 5.1 if rows are morethan 65500 then dont add more rows
                        //////if (RetVal.Table.Rows.Count > 65500)
                        //////{
                        //////    break;
                        //////}
                        // 5.2 get subgroup val info
                        SGValINfo = SGValBuilder.GetSubgroupValInfo(FilterFieldType.NId, SGNid);

                        DT = blankDESDataView.Table.Copy();
                        DT.Clear();

                        // 5.3 add subgroup columns
                        if (includeGUID)
                        {
                            DT.Columns.Add(SubgroupVals.SubgroupValGId);
                            DT.Columns[SubgroupVals.SubgroupValGId].DefaultValue = SGValINfo.GID;
                        }

                        DT.Columns.Add(SubgroupVals.SubgroupVal);
                        DT.Columns[SubgroupVals.SubgroupVal].DefaultValue = SGValINfo.Name;

                        // 5.4 merge blank DES data view
                        DT.Merge(blankDESDataView.Table);

                        // 5.5 update Subgroup in BlankDESDataView
                        RetVal.Table.Merge(DT);

                    }

                    //  **************************************************************************

                    //////// 5.6 Limit DataRows to 65,536 as Excels sheet has 65,536 rows limit.
                    //////if (RetVal.Table.Rows.Count > 65500)
                    //////{
                    //////    for (int i = RetVal.Table.Rows.Count - 1; i > 65500; i--)
                    //////    {
                    //////        RetVal.Table.Rows[i].Delete();
                    //////    }
                    //////}
                    //////RetVal.Table.AcceptChanges();

                    // 5.7 Set original SubgroupNIDs back into userSelection
                    userSelection.SubgroupValNIds = OriginalSubgroupNIds;

                    ////////// 5.9 Rename GID columns if not required.
                    ////////if (!(includeGUID))
                    ////////{
                    ////////    FilteredDataView.Table.Columns[Indicator.IndicatorGId].ColumnName = "I_GID";
                    ////////    FilteredDataView.Table.Columns[Unit.UnitGId].ColumnName = "U_GID";
                    ////////    if (FilteredDataView.Table.Columns.Contains(SubgroupVals.SubgroupValGId))
                    ////////    {
                    ////////        FilteredDataView.Table.Columns[SubgroupVals.SubgroupValGId].ColumnName = "S_GID";
                    ////////    }
                    ////////}

                    ////////// 5.10 Update Sector , Class in DataView
                    ////////DIExport.AddSectorClassInDataView(ref FilteredDataView, dBConnection, dBQueries, indicatorNId, unitNId);
                    ////////FilteredDataView.Table.AcceptChanges();

                }
                catch (Exception ex)
                {

                }
                finally
                {
                    if (RetVal == null)
                    {
                        RetVal = (new DataTable()).DefaultView;
                    }
                }

            }
            catch (Exception ex)
            {

            }
            finally
            {
                if (RetVal == null)
                {
                    RetVal = (new DataTable()).DefaultView;
                }
            }
            return RetVal;
        }
Beispiel #5
0
        /// <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;
        }
Beispiel #6
0
        /// <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;
        }
Beispiel #7
0
        /// <summary>
        /// Returns instance of IUSInfo.
        /// </summary>
        /// <param name="filterClause"></param>
        /// <param name="filterText"></param>
        /// <param name="selectionType"></param>
        /// <returns></returns>
        public IUSInfo GetIUSInfo(FilterFieldType filterClause, string filterText, FieldSelection selectionType)
        {
            string Query = string.Empty;

            IUSInfo RetVal = new IUSInfo();
            IndicatorInfo IndicatorObject = new IndicatorInfo();
            UnitInfo UnitObject = new UnitInfo();
            IndicatorBuilder IndicatorBuilderObj = null;
            UnitBuilder UnitBuilderObj = null;
            DI6SubgroupValBuilder SubgroupValBuilderObj = null;
            DI6SubgroupValInfo SubgroupValObject = new DI6SubgroupValInfo();

            int IndicatorNid = 0;
            int UnitNid = 0;
            int SGNid = 0;
            int MinVal = 0;
            int MaxVal = 0;
            DataTable Table = null;
            try
            {

                //get IUS information
                Query = this.DBQueries.IUS.GetIUS(filterClause, filterText, selectionType);
                Table = this.DBConnection.ExecuteDataTable(Query);

                //set IUS info
                if (Table != null)
                {
                    if (Table.Rows.Count > 0)
                    {
                        MinVal = 0;
                        MaxVal = 0;

                        // initialize builder objects
                        IndicatorBuilderObj = new IndicatorBuilder(this.DBConnection, this.DBQueries);
                        UnitBuilderObj = new UnitBuilder(this.DBConnection, this.DBQueries);
                        SubgroupValBuilderObj = new DI6SubgroupValBuilder(this.DBConnection, this.DBQueries);

                        // set IUS properties
                        //-- set maximum value
                        if (!string.IsNullOrEmpty(Convert.ToString(Table.Rows[0][Indicator_Unit_Subgroup.MaxValue])))
                        {
                            MaxVal = Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.MaxValue]);
                        }
                        //-- Set Minmum Value
                        if (!string.IsNullOrEmpty(Convert.ToString(Table.Rows[0][Indicator_Unit_Subgroup.MinValue])))
                        {
                            MinVal = Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.MinValue]);
                        }

                        RetVal.Maximum = MaxVal;    // Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.MaxValue]);
                        RetVal.Minimum = MinVal;    // Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.MinValue]);

                        RetVal.Nid = Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.IUSNId]);

                        // set indicator, unit and subgroup info
                        IndicatorNid = Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.IndicatorNId]);
                        UnitNid = Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.UnitNId]);
                        SGNid = Convert.ToInt32(Table.Rows[0][Indicator_Unit_Subgroup.SubgroupValNId]);

                        RetVal.IndicatorInfo = IndicatorBuilderObj.GetIndicatorInfo(FilterFieldType.NId, IndicatorNid.ToString(), FieldSelection.Light);
                        RetVal.UnitInfo = UnitBuilderObj.GetUnitInfo(FilterFieldType.NId, UnitNid.ToString());
                        RetVal.SubgroupValInfo = SubgroupValBuilderObj.GetSubgroupValInfo(FilterFieldType.NId, SGNid.ToString());

                    }
                }
            }
            catch (Exception)
            {
                RetVal = null;
            }

            return RetVal;
        }
        private void ProcessMappedUnits()
        {
            DIConnection SrcDBConnection = null;
            DIQueries SrcDBQueries = null;

            UnitBuilder TrgUnitBilder = null;
            UnitInfo SrcUnitInfoObj = null;
            UnitBuilder SrcUnitBuilderObj = null;
            DataTable Table = null;
            string SourceFileWPath = string.Empty;
            int TrgUnitNid = 0;

            if (this.MappedTables.ContainsKey(TemplateMergeControlType.Unit))
            {
                TrgUnitBilder = new UnitBuilder(this.DBConnection, this.DBQueries);

                foreach (DataRow Row in this.MappedTables[TemplateMergeControlType.Unit].MappedTable.MappedTable.Rows)
                {
                    Table = this.DBConnection.ExecuteDataTable(TemplateQueries.GetImportUnits(Convert.ToString(Row[MergetTemplateConstants.Columns.UNMATCHED_COL_Prefix + Unit.UnitNId])));

                    TrgUnitNid = Convert.ToInt32(Row[MergetTemplateConstants.Columns.AVAILABLE_COL_Prefix + Unit.UnitNId]);

                    if (Table != null && Table.Rows.Count > 0)
                    {

                        SourceFileWPath = Convert.ToString(Table.Rows[0][MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]);

                        SrcDBConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, SourceFileWPath, string.Empty, string.Empty);
                        SrcDBQueries = DataExchange.GetDBQueries(SrcDBConnection);

                        // get unit info
                        SrcUnitBuilderObj = new UnitBuilder(SrcDBConnection, SrcDBQueries);
                        SrcUnitInfoObj = SrcUnitBuilderObj.GetUnitInfo(FilterFieldType.NId, Convert.ToString(Table.Rows[0][MergetTemplateConstants.Columns.COLUMN_SRCNID]));

                        // Import Mapped Unit Values
                        TrgUnitBilder.ImportMappedUnitInformation(SrcUnitInfoObj, SrcUnitInfoObj.Nid, TrgUnitNid, SrcDBQueries, SrcDBConnection);

                        SrcDBConnection.Dispose();
                    }

                }
            }
        }
        /// <summary>
        /// Process Target Units which matched with Source Units
        /// </summary>
        public void ProcessMatchedUnits()
        {
            DataTable Table = null;

            UnitBuilder UnitBuilderObj = null;
            UnitBuilder SrcUnitBuilderObj = null;
            UnitInfo SrcUnitInfoObj = null;
            Dictionary<string, DataRow> FileWithNids = new Dictionary<string, DataRow>();

            DIConnection SourceDBConnection = null;
            DIQueries SourceDBQueries = null;

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this.DBConnection.ExecuteDataTable(this.TemplateQueries.GetMatchedUnit());

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            UnitBuilderObj = new UnitBuilder(this.DBConnection, this.DBQueries);

            //-- Step 3: Import Nids for each SourceFile
            foreach (DataRow Row in Table.Copy().Rows)
            {
                try
                {
                    string SourceFileWPath = Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]);

                    SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, SourceFileWPath, String.Empty, MergetTemplateConstants.DBPassword);
                    SourceDBQueries = DataExchange.GetDBQueries(SourceDBConnection);

                    // get unit info
                    SrcUnitBuilderObj = new UnitBuilder(SourceDBConnection, SourceDBQueries);
                    SrcUnitInfoObj = SrcUnitBuilderObj.GetUnitInfo(FilterFieldType.NId, Convert.ToString(Row[Unit.UnitNId]));
                    // import unit
                    UnitBuilderObj.ImportUnit(SrcUnitInfoObj, Convert.ToInt32(Row[Unit.UnitNId]), SourceDBQueries, SourceDBConnection);

                }
                catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
                finally
                {
                    if (SourceDBConnection != null)
                        SourceDBConnection.Dispose();
                    if (SourceDBQueries != null)
                        SourceDBQueries.Dispose();
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Generate SDMX Files from DES
        /// </summary>
        /// <param name="DESFileNameWithPath"></param>
        /// <param name="DSDFileNameWPath"></param>
        /// <param name="outputFolder"></param>
        /// <returns></returns>
        public static bool Generate_SDMXML_Data(string DESFileNameWithPath, string DSDFileNameWPath, string outputFolder)
        {
            bool RetVal = false;
            DIConnection DBConnection = null;
            DIQueries DBQueries = null;
            int count = 0;

            //  Utility.TemporaryFileNamePath
            DataTable Table = DevInfo.Lib.DI_LibBAL.Import.DAImport.DES.DataEntrySpreadsheets.GetDataTableForAllDESSheets(DESFileNameWithPath);

            string TempDatabaseName = string.Empty;
            string TempDatabaseNameCompact = string.Empty;
            TempDatabaseName = Path.Combine(Path.GetDirectoryName(DESFileNameWithPath), DICommon.GetValidFileName(DateTime.Now.Ticks.ToString() + DICommon.FileExtension.Template));

            Dictionary<string, int> IndicatorList = new Dictionary<string, int>();
            Dictionary<string, int> UnitList = new Dictionary<string, int>();
            Dictionary<string, int> AreaList = new Dictionary<string, int>();
            Dictionary<string, int> SgValList = new Dictionary<string, int>();
            Dictionary<string, int> TimepeirodList = new Dictionary<string, int>();
            Dictionary<string, int> SourceList = new Dictionary<string, int>();

            try
            {

                DevInfo.Lib.DI_LibDAL.Resources.Resource.GetBlankDevInfoDBFile(TempDatabaseName);

                DBConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, TempDatabaseName, string.Empty, string.Empty);
                DBQueries = new DIQueries(DBConnection.DIDataSetDefault(), DBConnection.DILanguageCodeDefault(DBConnection.DIDataSetDefault()));

                DIDataValueHelper.MergeTextualandNumericDataValueColumn(DBConnection, DBQueries);

                IndicatorBuilder IndBuilder = new IndicatorBuilder(DBConnection, DBQueries);
                UnitBuilder UBuilder = new UnitBuilder(DBConnection, DBQueries);
                DI6SubgroupValBuilder SGBuilder = new DI6SubgroupValBuilder(DBConnection, DBQueries);
                AreaBuilder AreaBuilderObj = new AreaBuilder(DBConnection, DBQueries);
                IndicatorClassificationBuilder ICBuilder = new IndicatorClassificationBuilder(DBConnection, DBQueries);
                TimeperiodBuilder TBuilder = new TimeperiodBuilder(DBConnection, DBQueries);
                SourceBuilder SrcBuilder = new SourceBuilder(DBConnection, DBQueries);
                DIDatabase DatabaseObj = new DIDatabase(DBConnection, DBQueries);
                IUSBuilder IUSBuilderObj = new IUSBuilder(DBConnection, DBQueries);

                foreach (DataRow Row in Table.Rows)
                {
                    int IndicatorNId = 0;
                    int UnitNId = 0;
                    int SGValNId = 0;
                    int AreaNId = 0;
                    int TimeperiodNId = 0;
                    int SourceNid = 0;
                    int IUSNID = 0;

                    //-- Import Indicator
                    if (IndicatorList.ContainsKey(Convert.ToString(Row[Indicator.IndicatorGId])))
                    {
                        IndicatorNId = IndicatorList[Convert.ToString(Row[Indicator.IndicatorGId])];
                    }
                    else
                    {
                        IndicatorNId = IndBuilder.ImportIndicator(Convert.ToString(Row[Indicator.IndicatorName]), Convert.ToString(Row[Indicator.IndicatorGId]), false);
                        IndicatorList.Add(Convert.ToString(Row[Indicator.IndicatorGId]), IndicatorNId);
                    }

                    //-- Import Unit
                    if (UnitList.ContainsKey(Convert.ToString(Row[Unit.UnitGId])))
                    {
                        UnitNId = UnitList[Convert.ToString(Row[Unit.UnitGId])];
                    }
                    else
                    {
                        UnitNId = UBuilder.ImportUnit(Convert.ToString(Row[Unit.UnitGId]), Convert.ToString(Row[Unit.UnitName]).Trim(), false);
                        UnitList.Add(Convert.ToString(Row[Unit.UnitGId]), UnitNId);
                    }

                    //-- Import SubgroupVal
                    if (!string.IsNullOrEmpty(Convert.ToString(Row[SubgroupVals.SubgroupVal])))
                    {
                        if (SgValList.ContainsKey(Convert.ToString(Row[SubgroupVals.SubgroupValGId])))
                        {
                            SGValNId = SgValList[Convert.ToString(Row[SubgroupVals.SubgroupValGId])];
                        }
                        else
                        {
                            SGValNId = SGBuilder.ImportSubgroupVal(Convert.ToString(Row[SubgroupVals.SubgroupVal]), Convert.ToString(Row[SubgroupVals.SubgroupValGId]), false);
                            SgValList.Add(Convert.ToString(Row[SubgroupVals.SubgroupValGId]), SGValNId);
                        }
                    }

                    //-- Import Area
                    if (AreaList.ContainsKey(Convert.ToString(Row[Area.AreaID])))
                    {
                        AreaNId = AreaList[Convert.ToString(Row[Area.AreaID])];
                    }
                    else
                    {
                        AreaNId = AreaBuilderObj.ImportArea(Convert.ToString(Row[Area.AreaName]), Convert.ToString(Row[Area.AreaID]), String.Empty, false);
                        AreaList.Add(Convert.ToString(Row[Area.AreaID]), AreaNId);
                    }

                    //-- Import Timeperiod
                    if (TimepeirodList.ContainsKey(Convert.ToString(Row[Timeperiods.TimePeriod])))
                    {
                        TimeperiodNId = TimepeirodList[Convert.ToString(Row[Timeperiods.TimePeriod])];
                    }
                    else
                    {
                        TimeperiodNId = TBuilder.CheckNCreateTimeperiod(Convert.ToString(Row[Timeperiods.TimePeriod]));
                        TimepeirodList.Add(Convert.ToString(Row[Timeperiods.TimePeriod]), TimeperiodNId);
                    }

                    //-- Import Source
                    if (SourceList.ContainsKey(Convert.ToString(Row[IndicatorClassifications.ICName])))
                    {
                        SourceNid = SourceList[Convert.ToString(Row[IndicatorClassifications.ICName])];
                    }
                    else
                    {
                        SourceNid = SrcBuilder.CheckNCreateSource(Convert.ToString(Row[IndicatorClassifications.ICName]));
                        SourceList.Add(Convert.ToString(Row[IndicatorClassifications.ICName]), SourceNid);
                    }

                    IUSNID = IUSBuilderObj.ImportIUS(IndicatorNId, UnitNId, SGValNId, 0, 0, DBQueries, DBConnection);

                    if (IUSNID > 0 && AreaNId > 0 && TimeperiodNId > 0 && !string.IsNullOrEmpty(Convert.ToString(Row[Data.DataValue])))
                    {
                        DatabaseObj.CheckNCreateData(AreaNId, IUSNID, SourceNid, TimeperiodNId, Convert.ToString(Row[Data.DataValue]));
                    }
                }

                DatabaseObj.UpdateIndicatorUnitSubgroupNIDsInData();

                //-- Compact Database into TempFile
                TempDatabaseNameCompact = Path.Combine(Path.GetDirectoryName(DESFileNameWithPath), DICommon.GetValidFileName(DateTime.Now.Ticks.ToString() + DICommon.FileExtension.Template));

                DIDatabase.CompactDataBase(ref DBConnection, DBQueries, TempDatabaseNameCompact, true);

                DBConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, TempDatabaseNameCompact, string.Empty, string.Empty);
                DBQueries = new DIQueries(DBConnection.DIDataSetDefault(), DBConnection.DILanguageCodeDefault(DBConnection.DIDataSetDefault()));

                if (!Directory.Exists(Path.Combine(outputFolder, DBQueries.LanguageCode.Trim('_'))))
                {
                    Directory.CreateDirectory(Path.Combine(outputFolder, DBQueries.LanguageCode.Trim('_')));
                }

                System.Xml.XmlDocument XmlDoc = SDMXUtility.Get_Query(SDMXSchemaType.Two_One, null, QueryFormats.StructureSpecificTS, DataReturnDetailTypes.Full, Guid.NewGuid().ToString().Replace("-", "").Replace("_", ""), DBConnection, DBQueries);

                RetVal = SDMXUtility.Generate_Data(SDMXSchemaType.Two_One, XmlDoc, DevInfo.Lib.DI_LibSDMX.DataFormats.StructureSpecificTS, DBConnection, DBQueries, outputFolder);

            }
            catch (Exception ex)
            {
                ExceptionFacade.ThrowException(ex);
            }

            return RetVal;
        }