예제 #1
0
        /// <summary>
        /// Deletes subgroup and associated records from SubgroupVal, SubgroupValSubgroup, Indicator_Unit_Subgroup and
        /// </summary>
        /// <param name="NIds"></param>
        public void DeleteSubgroup(string NIds)
        {
            string   SqlQuery = string.Empty;
            DITables TablesName;
            DI6SubgroupValBuilder SGValBuilder;
            string AssociatedSubgroupValNIds = string.Empty;

            try
            {
                // Step 1: Delete subgroup
                foreach (DataRow Row in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows)
                {
                    TablesName = new DITables(this.DBQueries.DataPrefix, "_" + Row[Language.LanguageCode].ToString());

                    SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.Subgroup.Delete.DeleteSubgroups(TablesName.Subgroup, NIds);
                    this.DBConnection.ExecuteNonQuery(SqlQuery);
                }

                // Step 2: Delete associated SubgroupVal which will automatically delete associated records from SubgroupValSubgroup, IUS and IC_IUS
                SGValBuilder = new DI6SubgroupValBuilder(this.DBConnection, this.DBQueries);
                AssociatedSubgroupValNIds = SGValBuilder.GetAllAssociatedSubgroupValNIds(NIds);

                if (!string.IsNullOrEmpty(AssociatedSubgroupValNIds))
                {
                    SGValBuilder.DeleteSubgroupVals(AssociatedSubgroupValNIds);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
예제 #2
0
        public override void Import(string selectedNids)
        {
            DataTable                    Table           = null;
            int                          ProgressCounter = 0;
            DI6SubgroupValBuilder        SGBuilderObj    = null;
            DI6SubgroupValInfo           SGInfoObj       = null;
            Dictionary <string, DataRow> FileWithNids    = new Dictionary <string, DataRow>();

            DIConnection          SourceDBConnection = null;
            DIQueries             SourceDBQueries    = null;
            DI6SubgroupValBuilder SourceSGValBuilder = null;

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportSubgroupVals(selectedNids));

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            SGBuilderObj = new DI6SubgroupValBuilder(this.TargetDBConnection, this.TargetDBQueries);

            // Initialize progress bar
            this.RaiseProgressBarInitialize(selectedNids.Split(',').GetUpperBound(0) + 1);


            //-- 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 subgroupval info from source file
                    SourceSGValBuilder = new DI6SubgroupValBuilder(SourceDBConnection, SourceDBQueries);
                    SGInfoObj          = SourceSGValBuilder.GetSubgroupValInfo(FilterFieldType.NId, Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]));



                    SGBuilderObj.ImportSubgroupVal(Convert.ToInt32(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]), SourceDBQueries, SourceDBConnection);
                    ProgressCounter += 1;
                    this.RaiseProgressBarIncrement(ProgressCounter);
                }
                catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
                finally
                {
                    if (SourceDBConnection != null)
                    {
                        SourceDBConnection.Dispose();
                    }
                    if (SourceDBQueries != null)
                    {
                        SourceDBQueries.Dispose();
                    }
                }
            }
            this._AvailableTable = this.GetAvailableTable();
            this._UnmatchedTable = this.GetUnmatchedTable();
            // Close ProgressBar
            this.RaiseProgressBarClose();
        }
예제 #3
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);
        }
예제 #4
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;
 }
예제 #5
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;
 }
예제 #6
0
        public override void Import(string selectedNids)
        {
            DataTable Table = null;
            int ProgressCounter = 0;
            DI6SubgroupValBuilder SGBuilderObj = null;
            DI6SubgroupValInfo SGInfoObj = null;
            Dictionary<string, DataRow> FileWithNids = new Dictionary<string, DataRow>();

            DIConnection SourceDBConnection = null;
            DIQueries SourceDBQueries = null;
            DI6SubgroupValBuilder SourceSGValBuilder = null;

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportSubgroupVals(selectedNids));

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            SGBuilderObj = new DI6SubgroupValBuilder(this.TargetDBConnection, this.TargetDBQueries);

            // Initialize progress bar
            this.RaiseProgressBarInitialize(selectedNids.Split(',').GetUpperBound(0) + 1);

            //-- 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 subgroupval info from source file
                    SourceSGValBuilder = new DI6SubgroupValBuilder(SourceDBConnection, SourceDBQueries);
                 SGInfoObj =SourceSGValBuilder.GetSubgroupValInfo(FilterFieldType.NId,   Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]));

                    SGBuilderObj.ImportSubgroupVal(Convert.ToInt32(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]), SourceDBQueries, SourceDBConnection);
                    ProgressCounter += 1;
                    this.RaiseProgressBarIncrement(ProgressCounter);

                }
                catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
                finally
                {
                    if (SourceDBConnection != null)
                        SourceDBConnection.Dispose();
                    if (SourceDBQueries != null)
                        SourceDBQueries.Dispose();
                }
            }
            this._AvailableTable = this.GetAvailableTable();
            this._UnmatchedTable = this.GetUnmatchedTable();
            // Close ProgressBar
            this.RaiseProgressBarClose();
        }
예제 #7
0
        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);
        }
예제 #8
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);
        }
예제 #9
0
        /// <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)
        {
            DI6SubgroupValBuilder SubgroupValBuilderObj = new DI6SubgroupValBuilder(this._TargetDBConnection, this._TargetDBQueries);
            int ProgressBarValue = 0;

            foreach (string Nid in selectedNids)
            {
                try
                {
                    //import into target database
                    SubgroupValBuilderObj.ImportSubgroupVal(Convert.ToInt32(Nid), this.SourceDBQueries, this.SourceDBConnection);
                }
                catch (Exception ex)
                {
                    ExceptionFacade.ThrowException(ex);
                }

                this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                ProgressBarValue++;
            }
        }
        /// <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)
        {
            DI6SubgroupValBuilder SubgroupValBuilderObj = new DI6SubgroupValBuilder(this._TargetDBConnection, this._TargetDBQueries);
            int ProgressBarValue = 0;

               foreach (string Nid in selectedNids)
               {
               try
               {
                   //import into target database
                   SubgroupValBuilderObj.ImportSubgroupVal(Convert.ToInt32(Nid),this.SourceDBQueries, this.SourceDBConnection);
               }
               catch (Exception ex)
               {
                   ExceptionFacade.ThrowException(ex);
               }

               this.RaiseIncrementProgessBarEvent(ProgressBarValue);
               ProgressBarValue++;
               }
        }
예제 #11
0
        private void UpdateSubgroupValText()
        {
            string SqlQuery = string.Empty;
            DI6SubgroupValBuilder SGValBuilder;
            DIQueries             TempQueries;

            try
            {
                // get all subgroup val
                SqlQuery     = this._DBQueries.SubgroupVals.GetSubgroupVals();
                SGValBuilder = new DI6SubgroupValBuilder(this._DBConnection, this._DBQueries);

                // run this process (update subgroup val text) only for default langauge
                foreach (DataRow Row in this._DBConnection.ExecuteDataTable(SqlQuery).Rows)
                {
                    // run this process (update subgroup val text) only for default langauge


                    //    // for available language update subgroup val text
                    //    foreach (DataRow LangaugeRow in this._DBConnection.DILanguages(this._DBQueries.DataPrefix).Rows)
                    //    {
                    // create subgroup val builder instance
                    //TempQueries = new DIQueries(this._DBQueries.DataPrefix, "_" + LangaugeRow[Language.LanguageCode].ToString());

                    // SGValBuilder = new DI6SubgroupValBuilder(this._DBConnection, TempQueries);

                    //        this.CheckNUpdateSubgroupValText(Convert.ToInt32(Row[SubgroupVals.SubgroupValNId]), SGValBuilder, TempQueries);
                    //    }


                    this.CheckNUpdateSubgroupValText(Convert.ToInt32(Row[SubgroupVals.SubgroupValNId]), SGValBuilder, this._DBQueries);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
예제 #12
0
        /// <summary>
        /// Returns cell mapping values
        /// </summary>
        /// <param name="selectedTableInfo"></param>
        /// <param name="rowIndex"></param>
        /// <param name="colIndex"></param>
        /// <returns></returns>
        public Mapping GetCellMapping(int rowIndex, int colIndex, Database dbDatabase)
        {
            Mapping RetVal = null;

            Mapping            ColumnMapping;
            Mapping            RowMapping;
            int                SGValNID = -1;
            List <string>      SGNIds   = new List <string>();
            DI6SubgroupBuilder DI6SGBuilder;

            try
            {
                // Get mapping information

                if (rowIndex >= 0 && colIndex >= 0)
                {
                    ColumnMapping = this.ColumnsMapping[colIndex].Mappings.CellMap;
                    RowMapping    = this.RowsMapping[rowIndex].Mappings.CellMap;

                    // Step1: copy column mapping
                    RetVal = ColumnMapping.Copy();

                    // Step2: set the blank mapping value with the values available in row's mapping
                    RetVal.ReplaceEmptyValues(RowMapping);

                    // Step3: IF SubgoupVal is empty then get subgroupval on the basis of column's subgroups NID + row's subgroups NID
                    if (string.IsNullOrEmpty(RetVal.SubgroupVal))
                    {
                        DI6SGBuilder = new DI6SubgroupBuilder(dbDatabase.DBConnection, dbDatabase.DBQueries);

                        // Step 3a: get subgroup nids(dimensionvalues nid)
                        this.AddSubgroupNIds(DI6SGBuilder, RetVal.Subgroups, SGNIds);
                        this.AddSubgroupNIds(DI6SGBuilder, RowMapping.Subgroups, SGNIds);

                        if (SGNIds.Count > 0)
                        {
                            // Step 3b: get subgroupval for the selected dimensions
                            DI6SubgroupValBuilder SGValBuilder = new DI6SubgroupValBuilder(dbDatabase.DBConnection, dbDatabase.DBQueries);
                            DI6SubgroupValInfo    SGValInfo;

                            SGValNID = SGValBuilder.GetSubgroupValNIdBySugbroups(SGNIds);

                            if (SGValNID > 0)
                            {
                                SGValInfo             = SGValBuilder.GetSubgroupValInfo(FilterFieldType.NId, SGValNID.ToString());
                                RetVal.SubgroupVal    = SGValInfo.Name;
                                RetVal.SubgroupValGID = SGValInfo.GID;
                            }
                        }
                    }

                    // Step 4: set the blank mapping value with the values available in Default mapping
                    RetVal.ReplaceEmptyValues(this._DefaultMapping);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }

            return(RetVal);
        }
예제 #13
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;
        }
예제 #14
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;
        }
예제 #15
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;
        }
예제 #16
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;
        }
예제 #17
0
        /// <summary>
        /// Deletes subgroup and associated records from SubgroupVal, SubgroupValSubgroup, Indicator_Unit_Subgroup and 
        /// </summary>
        /// <param name="NIds"></param>
        public void DeleteSubgroup(string NIds)
        {
            string SqlQuery = string.Empty;
            DITables TablesName;
            DI6SubgroupValBuilder SGValBuilder;
            string AssociatedSubgroupValNIds = string.Empty;

            try
            {

                // Step 1: Delete subgroup
                foreach (DataRow Row in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows)
                {
                    TablesName = new DITables(this.DBQueries.DataPrefix, "_" + Row[Language.LanguageCode].ToString());

                    SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.Subgroup.Delete.DeleteSubgroups(TablesName.Subgroup, NIds);
                    this.DBConnection.ExecuteNonQuery(SqlQuery);
                }

                // Step 2: Delete associated SubgroupVal which will automatically delete associated records from SubgroupValSubgroup, IUS and IC_IUS
                SGValBuilder = new DI6SubgroupValBuilder(this.DBConnection, this.DBQueries);
                AssociatedSubgroupValNIds = SGValBuilder.GetAllAssociatedSubgroupValNIds(NIds);

                if (!string.IsNullOrEmpty(AssociatedSubgroupValNIds))
                {
                    SGValBuilder.DeleteSubgroupVals(AssociatedSubgroupValNIds);
                }

            }
            catch (Exception ex)
            {

                throw new ApplicationException(ex.ToString());
            }
        }
        /// <summary>
        /// Process Matched Target Subgroupvals
        /// </summary>
        public void ProcessSubgroupVals()
        {
            DataTable Table = null;

            DI6SubgroupValBuilder SGBuilderObj = null;
            DI6SubgroupValInfo SourceSGInfoObj = null;
            Dictionary<string, DataRow> FileWithNids = new Dictionary<string, DataRow>();

            DIConnection SourceDBConnection = null;
            DIQueries SourceDBQueries = null;

            DI6SubgroupValBuilder SourceSGValBuilder = null;

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

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            SGBuilderObj = new DI6SubgroupValBuilder(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 subgroupval info
                    SourceSGValBuilder = new DI6SubgroupValBuilder(SourceDBConnection, SourceDBQueries);
                    SourceSGInfoObj = SourceSGValBuilder.GetSubgroupValInfo(FilterFieldType.NId, Convert.ToString(Row[SubgroupVals.SubgroupValNId]));

                    // import subgroup val
                    SGBuilderObj.ImportSubgroupVal(Convert.ToInt32(Row[SubgroupVals.SubgroupValNId]), SourceDBQueries, SourceDBConnection);

                }
                catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
                finally
                {
                    if (SourceDBConnection != null)
                        SourceDBConnection.Dispose();
                    if (SourceDBQueries != null)
                        SourceDBQueries.Dispose();
                }
            }
        }
예제 #19
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);
        }
예제 #20
0
        /// <summary>
        /// Imports mapped values into database and returns unmatched elements info
        /// </summary>
        /// <param name="mappedValues"></param>
        /// <param name="dataValue"></param>
        /// <param name="denominator"></param>
        /// <returns></returns>
        public UnMatchedElementInfo ImportMappedValuesIntoDB(DIConnection dbConnection, DIQueries dbQueries, string dataValue, string denominator)
        {
            UnMatchedElementInfo RetVal = new UnMatchedElementInfo();

            int IndicatorNId = -1;
            int UnitNId      = -1;
            int SGNId        = -1;
            int IUSNId       = -1;

            int AreaNId       = -1;
            int SourceNId     = -1;
            int TimeperiodNId = -1;
            int DataNId       = -1;

            Dictionary <string, int> IUSNIds        = new Dictionary <string, int>();
            Dictionary <string, int> AreaNIds       = new Dictionary <string, int>();
            Dictionary <string, int> SourceNIds     = new Dictionary <string, int>();
            Dictionary <string, int> TimeperiodNIds = new Dictionary <string, int>();

            IndicatorBuilder      IndicatorBuilderObj;
            UnitBuilder           UnitBuilderObj;
            DI6SubgroupValBuilder SGValBuilderObj;
            IUSBuilder            IUSBuilderObj;

            AreaBuilder       AreaBuilderObj;
            SourceBuilder     SourceBuilderObj;
            TimeperiodBuilder TimeperiodBuilderObj;
            DIDatabase        TargetDatabase;

            try
            {
                IndicatorBuilderObj = new IndicatorBuilder(dbConnection, dbQueries);
                UnitBuilderObj      = new UnitBuilder(dbConnection, dbQueries);
                SGValBuilderObj     = new DI6SubgroupValBuilder(dbConnection, dbQueries);
                IUSBuilderObj       = new IUSBuilder(dbConnection, dbQueries);

                AreaBuilderObj       = new AreaBuilder(dbConnection, dbQueries);
                SourceBuilderObj     = new SourceBuilder(dbConnection, dbQueries);
                TimeperiodBuilderObj = new TimeperiodBuilder(dbConnection, dbQueries);
                TargetDatabase       = new DIDatabase(dbConnection, dbQueries);

                // import value
                if (this.IsVaildMappedValues())
                {
                    // check IUSNId in IUSNIDs list
                    if (IUSNIds.ContainsKey(this._IndicatorGID + this._UnitGID + this._SubgroupValGID))
                    {
                        IUSNId = IUSNIds[this._IndicatorGID + this._UnitGID + this._SubgroupValGID];
                    }

                    else
                    {
// indicator Nid
                        IndicatorNId = IndicatorBuilderObj.GetIndicatorNid(this._IndicatorGID, this._IndicatorName);

                        // UnitNId
                        UnitNId = UnitBuilderObj.GetUnitNid(this._UnitGID, this._UnitName);

                        // SG Val NID
                        SGNId = SGValBuilderObj.GetSubgroupValNid(this._SubgroupValGID, this._SubgroupVal);

                        //IUSNID
                        IUSNId = IUSBuilderObj.GetIUSNid(IndicatorNId, UnitNId, SGNId);

                        // if IUSNID <=0 then create the given IUS combinator into database
                        if (IUSNId <= 0)
                        {
                            IUSNId = IUSBuilderObj.InsertIUSIntoDB(this._IndicatorGID, this._UnitGID, this._SubgroupValGID);
                        }

                        IUSNIds.Add((this._IndicatorGID + this._UnitGID + this._SubgroupValGID), IUSNId);
                    }


                    if (IUSNId > 0)
                    {
                        // get AREANID
                        if (AreaNIds.ContainsKey(this._AreaID))
                        {
                            AreaNId = AreaNIds[this._AreaID];
                        }
                        else
                        {
                            AreaNId = AreaBuilderObj.GetAreaNidByAreaID(this._AreaID);
                            AreaNIds.Add(this._AreaID, AreaNId);
                        }

                        // get sourcenid
                        if (SourceNIds.ContainsKey(this._Source))
                        {
                            SourceNId = SourceNIds[this._Source];
                        }
                        else
                        {
                            SourceNId = SourceBuilderObj.CheckNCreateSource(this._Source);
                            SourceNIds.Add(this._Source, SourceNId);
                        }

                        // get timeperiodNId
                        if (TimeperiodNIds.ContainsKey(this._Timeperiod))
                        {
                            TimeperiodNId = TimeperiodNIds[this._Timeperiod];
                        }
                        else
                        {
                            TimeperiodNId = TimeperiodBuilderObj.CheckNCreateTimeperiod(this._Timeperiod);
                            TimeperiodNIds.Add(this._Timeperiod, TimeperiodNId);
                        }

                        if (AreaNId > 0 && IUSNId > 0 && SourceNId > 0 && TimeperiodNId > 0 && !string.IsNullOrEmpty(dataValue))
                        {
                            DataNId = TargetDatabase.CheckNCreateData(AreaNId, IUSNId, SourceNId, TimeperiodNId, dataValue);
                        }


                        // denominator value
                        if (!string.IsNullOrEmpty(denominator) && DataNId > 0)
                        {
                            try
                            {
                                TargetDatabase.UpdateDenominatorValue(DataNId, Convert.ToInt32(Convert.ToDecimal(denominator)));
                            }
                            catch (Exception ex)
                            {
                                throw new ApplicationException(ex.ToString());
                            }
                        }
                    }
                }

                // for log file
                if (!string.IsNullOrEmpty(dataValue))
                {
                    if (AreaNId <= 0 || IUSNId <= 0 || SourceNId <= 0 || TimeperiodNId <= 0)
                    {
                        // for log file
                        if (AreaNId <= 0)
                        {
                            RetVal.Areas.Add(this._AreaID, this._Area);
                        }
                        if (IndicatorNId <= 0)
                        {
                            RetVal.Indicators.Add(this._IndicatorGID, this._IndicatorName);
                        }
                        if (UnitNId <= 0)
                        {
                            RetVal.Units.Add(this._UnitGID, this._UnitName);
                        }
                        if (SGNId <= 0)
                        {
                            RetVal.Subgroups.Add(this._SubgroupValGID, this._SubgroupVal);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }

            return(RetVal);
        }
예제 #21
0
        /// <summary>
        /// Checks and updates the SubgroupVal text for the given SubgroupValNIds
        /// </summary>
        /// <param name="SubgroupValNIds"></param>
        public void CheckNUpdateSubgroupValText(int SubgroupValNId, DI6SubgroupValBuilder SGValBuilder, DIQueries TempQueries)
        {
            string SqlQuery                        = string.Empty;
            string SubgroupNids                    = string.Empty;
            string DI5SubgroupValText              = string.Empty;
            string NewSubgroupValText              = string.Empty;
            string NewSubgroupValTextWTotal        = string.Empty;
            string NewSubgroupValTextWTotalNPrefix = string.Empty;

            string TotalTextValue = string.Empty;

            int  TotalNId             = 0;
            bool IsTotalSGFound       = false;
            bool IsSubgroupValInvalid = true;

            DI6SubgroupValInfo SGValInfo;

            DI6SubgroupBuilder SGBuilder;
            DI6SubgroupInfo    SGInfo = new DI6SubgroupInfo();



            bool   IsLocationSubgroupExistsInSubgroup = false;
            string LocationSubgroupName = string.Empty;
            int    LocationSubgroupNId  = 0;
            int    NewSubgroupNId       = 0;

            try
            {
                // get total text value for the curent langauge
                TotalTextValue = this.GetTotalTextString(TempQueries.LanguageCode);


                SGBuilder = new DI6SubgroupBuilder(this.DBConnection, TempQueries);

                // Step1: get SubgroupVal info
                SGValInfo = SGValBuilder.GetSubgroupValInfo(FilterFieldType.NId, SubgroupValNId.ToString());
                //NewSubgroupValText

                if (SGValInfo != null)
                {
                    DI5SubgroupValText = DICommon.RemoveQuotes(Convert.ToString(SGValInfo.Name));


                    // Get subgroup Nids and check location subgroup exists in the template/databse.
                    foreach (DI6SubgroupInfo DimensionValue in SGValInfo.Dimensions)
                    {
                        if (!string.IsNullOrEmpty(SubgroupNids))
                        {
                            SubgroupNids += ",";
                        }
                        SubgroupNids += DimensionValue.Nid;

                        if (DimensionValue.Nid == 0 || DimensionValue.DISubgroupType == null)
                        {
                            // subgroup missing in DI5 but relationship of that subgroup exists in Subgroup_VAls table
                        }
                        else
                        {
                            if (DimensionValue.DISubgroupType.Order == 1) // 1 order is for location in DI5 DB
                            {
                                IsLocationSubgroupExistsInSubgroup = true;
                                LocationSubgroupName = DimensionValue.Name;
                                LocationSubgroupNId  = DimensionValue.Nid;
                            }
                        }
                    }
                }
                // Step3: Check and update SubgroupVal text
                if (!string.IsNullOrEmpty(SubgroupNids))
                {
                    // Step 3.1: Get New subgroup val text
                    NewSubgroupValText = DICommon.RemoveQuotes(SGValBuilder.CreateSubgroupValTextBySubgroupNids(SubgroupNids));
                }
                // step 3.2: compare New subgroup Val text with DI5SubgroupVal text
                // step 3.2.1: compare Normal text value
                if (NewSubgroupValText.ToLower() != DI5SubgroupValText.ToLower())
                {
                    // step 3.2.2: if text doesnot match then compare the subgroup val with Total
                    NewSubgroupValTextWTotal = TotalTextValue + " " + NewSubgroupValText;

                    if (NewSubgroupValTextWTotal.ToLower() == DI5SubgroupValText.ToLower())
                    {
                        IsTotalSGFound = true;
                    }
                    else
                    {
                        // step 3.2.3: if text still doesnot match then compare the subgroup val with Total and prefix (#)
                        NewSubgroupValTextWTotalNPrefix = Constants.PrefixForNewValue + TotalTextValue + " " + NewSubgroupValText;

                        if (NewSubgroupValTextWTotalNPrefix.ToLower() == DI5SubgroupValText.ToLower())
                        {
                            TotalTextValue = Constants.PrefixForNewValue + TotalTextValue;
                            IsTotalSGFound = true;
                        }
                    }



                    // if New subgroup text matched with DI5 subgroup text
                    if (IsTotalSGFound)
                    {
                        // Check New DI6 subgrop text has Location subgroup
                        //      If location subgroup dimension exists,
                        if (IsLocationSubgroupExistsInSubgroup)
                        {
                            //          Delete the relationship of subgroup with the location subgroup
                            SGValBuilder.DeleteSubgroupValRelations(SubgroupValNId, LocationSubgroupNId.ToString());

                            //          Create new subgroup under location where subgroup value is equal to "Total" + available value of location subgroup dimension
                            SGInfo = new DI6SubgroupInfo();
                            SGInfo.DISubgroupType = this.LocationTypeInfo;
                            SGInfo.Type           = this.LocationTypeInfo.Nid;
                            SGInfo.Name           = TotalTextValue + " " + LocationSubgroupName;

                            NewSubgroupNId = SGBuilder.CheckNCreateSubgroup(SGInfo);

                            //          Create relationship with new subgoup
                            SGValBuilder.InsertSubgroupValRelations(SubgroupValNId, NewSubgroupNId);
                        }
                        else
                        {
                            //      And If not
                            //          Check TOTAL is available under location or not
                            //              If not then create it under location
                            TotalNId = this.CheckNCreateTotalSubgroupUnderLocation(TotalTextValue);
                            //          Create relationship with Total
                            SGValBuilder.InsertSubgroupValRelations(SubgroupValNId, TotalNId);
                        }

                        IsSubgroupValInvalid = false;
                    }
                }
                else
                {
                    IsSubgroupValInvalid = false;
                }

                // Step 4.1: Get New subgroup val text
                NewSubgroupValText = DICommon.RemoveQuotes(SGValBuilder.CreateSubgroupValTextBySubgroupNids(string.Join(",", SGValBuilder.GetAssocaitedSubgroupsNId(SubgroupValNId).ToArray())));

                // Step 4.2: Update Subgroup Val text
                // SGValBuilder.UpdateSubgroupVals(SubgroupValNId, NewSubgroupValText, SGValInfo.Global, SGValInfo.GID);

                if (IsSubgroupValInvalid)
                {
                    // 4.2.1 create new subgorup under others dimension
                    SGInfo = new DI6SubgroupInfo();

                    // if subgorup val is equal to "total" only and no relationship found, then create total subgroup under location otherwise create it under others

                    if (string.IsNullOrEmpty(NewSubgroupValText) && (DI5SubgroupValText.Trim().ToLower() == TotalTextValue.Trim().ToLower() || DI5SubgroupValText.Trim().ToLower() == Constants.PrefixForNewValue.Trim().ToLower() + TotalTextValue.Trim().ToLower()))
                    {
                        SGInfo.DISubgroupType = this.LocationTypeInfo;
                        SGInfo.Type           = this.LocationTypeInfo.Nid;
                    }
                    else
                    {
                        SGInfo.DISubgroupType = this.OthersTypeInfo;
                        SGInfo.Type           = this.OthersTypeInfo.Nid;
                    }

                    SGInfo.Name = DI5SubgroupValText;

                    // check it is already exist or not. If not then only show it under log file
                    NewSubgroupNId = SGBuilder.GetSubgroupNid(string.Empty, DI5SubgroupValText);

                    if (NewSubgroupNId <= 0)
                    {
                        NewSubgroupNId = SGBuilder.CheckNCreateSubgroup(SGInfo);

                        if (SGInfo.Type != this.LocationTypeInfo.Nid)
                        {
                            // add subgorup into mismatch list
                            this.MismatchSubgroups.Add(DI5SubgroupValText);
                        }
                    }


                    // 4.2.2 delete relationship of subgroup val nid from subgroup_val_subgroup table
                    SGValBuilder.DeleteSubgroupValRelations(SubgroupValNId);

                    // 4.2.3 create subgroupval relationship with new subgroup
                    SGValBuilder.InsertSubgroupValRelations(SubgroupValNId, NewSubgroupNId);
                }
                else
                {
                    if (IsTotalSGFound)
                    {
                        if (IsLocationSubgroupExistsInSubgroup)
                        {
                            this.SubgroupsAddedWNewSubgorup.Add(NewSubgroupValText, SGInfo.Name);
                        }
                        else
                        {
                            this.SubgroupsAddedWithTotal.Add(NewSubgroupValText);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }
예제 #22
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);
        }
예제 #23
0
        /// <summary>
        /// Returns cell mapping values
        /// </summary>
        /// <param name="selectedTableInfo"></param>
        /// <param name="rowIndex"></param>
        /// <param name="colIndex"></param>
        /// <returns></returns>
        public Mapping GetCellMapping(int rowIndex, int colIndex, Database dbDatabase)
        {
            Mapping RetVal = null;

            Mapping ColumnMapping;
            Mapping RowMapping;
            int SGValNID = -1;
            List<string> SGNIds = new List<string>();
            DI6SubgroupBuilder DI6SGBuilder;

            try
            {
                // Get mapping information

                if (rowIndex >= 0 && colIndex >= 0)
                {
                    ColumnMapping = this.ColumnsMapping[colIndex].Mappings.CellMap;
                    RowMapping = this.RowsMapping[rowIndex].Mappings.CellMap;

                    // Step1: copy column mapping
                    RetVal = ColumnMapping.Copy();

                    // Step2: set the blank mapping value with the values available in row's mapping
                    RetVal.ReplaceEmptyValues(RowMapping);

                    // Step3: IF SubgoupVal is empty then get subgroupval on the basis of column's subgroups NID + row's subgroups NID
                    if (string.IsNullOrEmpty(RetVal.SubgroupVal))
                    {
                        DI6SGBuilder = new DI6SubgroupBuilder(dbDatabase.DBConnection, dbDatabase.DBQueries);

                        // Step 3a: get subgroup nids(dimensionvalues nid)
                        this.AddSubgroupNIds(DI6SGBuilder, RetVal.Subgroups, SGNIds);
                        this.AddSubgroupNIds(DI6SGBuilder, RowMapping.Subgroups, SGNIds);

                        if (SGNIds.Count > 0)
                        {
                            // Step 3b: get subgroupval for the selected dimensions
                            DI6SubgroupValBuilder SGValBuilder = new DI6SubgroupValBuilder(dbDatabase.DBConnection, dbDatabase.DBQueries);
                            DI6SubgroupValInfo SGValInfo;

                            SGValNID = SGValBuilder.GetSubgroupValNIdBySugbroups(SGNIds);

                            if (SGValNID > 0)
                            {
                                SGValInfo = SGValBuilder.GetSubgroupValInfo(FilterFieldType.NId, SGValNID.ToString());
                                RetVal.SubgroupVal = SGValInfo.Name;
                                RetVal.SubgroupValGID = SGValInfo.GID;
                            }
                        }

                    }

                    // Step 4: set the blank mapping value with the values available in Default mapping
                    RetVal.ReplaceEmptyValues(this._DefaultMapping);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }

            return RetVal;
        }
예제 #24
0
        private void ProcessMappedSubgroupVals()
        {
            DIConnection SrcDBConnection = null;
            DIQueries SrcDBQueries = null;

            DI6SubgroupValBuilder TrgSubgroupValBuilder = null;
            DI6SubgroupValBuilder SrcSubgroupBuilder = null;
            DI6SubgroupValInfo SrcSubgroupValInfo = null;

            DataTable Table = null;
            string SourceFileWPath = string.Empty;
            int TrgSGNid = 0;

            if (this.MappedTables.ContainsKey(TemplateMergeControlType.Subgroups))
            {
                TrgSubgroupValBuilder = new DI6SubgroupValBuilder(this.DBConnection, this.DBQueries);

                foreach (DataRow Row in this.MappedTables[TemplateMergeControlType.Subgroups].MappedTable.MappedTable.Rows)
                {
                    Table = this.DBConnection.ExecuteDataTable(TemplateQueries.GetImportSubgroupVals(Convert.ToString(Row[MergetTemplateConstants.Columns.UNMATCHED_COL_Prefix + SubgroupVals.SubgroupValNId])));

                    TrgSGNid = Convert.ToInt32(Row[MergetTemplateConstants.Columns.AVAILABLE_COL_Prefix + SubgroupVals.SubgroupValNId]);

                    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 SubgroupVal Info
                        SrcSubgroupBuilder = new DI6SubgroupValBuilder(SrcDBConnection, SrcDBQueries);
                        SrcSubgroupValInfo= SrcSubgroupBuilder.GetSubgroupValInfo(FilterFieldType.NId, Convert.ToString(Table.Rows[0][MergetTemplateConstants.Columns.COLUMN_SRCNID]));

                        // Import Mapped SubgroupVals
                        TrgSubgroupValBuilder.ImportSubgroupValFrmMappedSubgroupVal(SrcSubgroupValInfo.Nid, TrgSGNid, SrcDBQueries, SrcDBConnection);
                        SrcDBConnection.Dispose();
                    }

                }
            }
        }
예제 #25
0
        /// <summary>
        /// Get the IUSNIds for the indicator and unit NId
        /// </summary>
        /// <param name="subgroupNIds"></param>
        /// <param name="exactMatch"></param>
        /// <param name="indicatorNId"></param>
        /// <param name="unitNId"></param>
        /// <returns></returns>
        public string GetIUSNIds(OrderedDictionary subgroupNIds, int indicatorNId, int unitNId)
        {
            string RetVal = string.Empty;
            try
            {
                DataView dvIUS;
                DataRow[] Rows = new DataRow[0];
                string SubgroupVal = string.Empty;
                string[] SelSubgroupVals = new string[subgroupNIds.Count];
                bool exactMatch = true;

                dtIUS = this.DbConnection.ExecuteDataTable(this.DbQueries.IUS.GetAutoSelectIUS(FilterFieldType.None, "", FieldSelection.Light));
                dvIUS = this.dtIUS.DefaultView;
                dvIUS.RowFilter = Indicator.IndicatorNId + " = " + indicatorNId + " AND " + Unit.UnitNId + " = " + unitNId;
                this.dtIUS = dvIUS.ToTable();
                this._SubgroupValCount = dtIUS.Rows.Count;

                this.SelectedSubgroups = subgroupNIds;

                this.SubgroupValBuilder = new DI6SubgroupValBuilder(this.DbConnection, this.DbQueries);

                this.IntializeSubgroupVal(ref SelSubgroupVals, exactMatch);
                this.GetSubgroupValsFromNIds(SelSubgroupVals, 0, this.SelectedSubgroups.Count - 1, 0, exactMatch);

                if (exactMatch && this.SelSubgroupVals.Length > 0)
                {
                    this.SelSubgroupVals.Insert(0, SubgroupVals.SubgroupVal + " IN (");
                    this.SelSubgroupVals.Append(")");
                }

                if (this.SelSubgroupVals.Length > 0)
                {
                    Rows = dtIUS.Select(this.SelSubgroupVals.ToString());
                    this._SelectedSubgroupValCount = Rows.Length;

                    foreach (DataRow Row in Rows)
                    {
                        RetVal += "," + Row[Indicator_Unit_Subgroup.IUSNId].ToString();
                        this._TrimedSubgroupVal += "," + Row[SubgroupVals.SubgroupVal].ToString();
                    }
                }

                if (!string.IsNullOrEmpty(RetVal))
                {
                    RetVal = RetVal.Substring(1);
                    this._TrimedSubgroupVal = this._TrimedSubgroupVal.Substring(1);
                    this._TrimedSubgroupVal = this._TrimedSubgroupVal.Substring(0, SubgroupValLength - 3) + "...";
                }
                else
                {
                    RetVal = "-1";
                }
            }
            catch (Exception)
            {
            }
            return RetVal;
        }
예제 #26
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;
        }