Ejemplo n.º 1
0
        /// <summary>
        /// Check and create IUS
        /// </summary>
        /// <param name="IUSRecord">object of IUS</param>
        /// <returns>IUS Nid</returns>
        public int CheckNCreateIUS(IUSInfo IUSInfo)
        {
            int RetVal = 0;
            try
            {
                //Step 1: check the existence of IUS
                RetVal = this.CheckIUSExists(IUSInfo);

                //Step 2: if doesnt exist , then insert into database
                if (RetVal <= 0)
                {
                    if (this.InsertIUS(IUSInfo))
                    {
                        RetVal = this.GetIUSNid(IUSInfo.IndicatorInfo.Nid, IUSInfo.UnitInfo.Nid, IUSInfo.SubgroupValInfo.Nid);
                    }
                }

                //Step 3: add ius info into collection

                this.AddIUSIntoCollection(IUSInfo);
            }
            catch (Exception)
            {
                RetVal = 0;
            }

            return RetVal;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check and create IUS
        /// </summary>
        /// <param name="IUSRecord">object of IUS</param>
        /// <returns>IUS Nid</returns>
        public int CheckNCreateIUS(IUSInfo IUSInfo)
        {
            int RetVal = 0;

            try
            {
                //Step 1: check the existence of IUS
                RetVal = this.CheckIUSExists(IUSInfo);

                //Step 2: if doesnt exist , then insert into database
                if (RetVal <= 0)
                {
                    if (this.InsertIUS(IUSInfo))
                    {
                        RetVal = this.GetIUSNid(IUSInfo.IndicatorInfo.Nid, IUSInfo.UnitInfo.Nid, IUSInfo.SubgroupValInfo.Nid);
                    }
                }

                //Step 3: add ius info into collection

                this.AddIUSIntoCollection(IUSInfo);
            }
            catch (Exception)
            {
                RetVal = 0;
            }

            return(RetVal);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Add IUS record into collection
 /// </summary>
 /// <param name="IUSRecord">object of IUSInfo </param>
 private void AddIUSIntoCollection(IUSInfo IUSInfo)
 {
     if (!this.IUSCollection.ContainsKey(IUSInfo.Nid.ToString()))
     {
         this.IUSCollection.Add(IUSInfo.Nid.ToString(), IUSInfo);
     }
 }
Ejemplo n.º 4
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)
        {
            DataRow Row;
            IUSInfo IUSInfoObject;
            IUSBuilder IUSBuilderObject;
            int ProgressBarValue = 0;

            foreach (string Nid in selectedNids)
            {
                try
                {
                    Row = this.SourceTable.Select(this.TagValueColumnName + "=" + Nid)[0];

                    IUSInfoObject = new IUSInfo();
                    IUSBuilderObject = new IUSBuilder(this._TargetDBConnection, this._TargetDBQueries);

                    IUSInfoObject.IndicatorInfo = this.GetIndicatorInfo(Row);
                    IUSInfoObject.UnitInfo = this.GetUnitInfo(Row);
                    IUSInfoObject.SubgroupValInfo = this.GetSubgroupValInfo(Row);

                    IUSBuilderObject.ImportIUS(IUSInfoObject, this.SourceDBQueries, this.SourceDBConnection);

                    IUSBuilderObject.UpdateISDefaultSubgroup(IUSInfoObject.IndicatorInfo.Nid, IUSInfoObject.UnitInfo.Nid);

                }
                catch (Exception ex)
                {
                    throw new ApplicationException(ex.ToString());
                }
                this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                ProgressBarValue++;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Check existance of  IUS record in database
        /// </summary>
        /// <param name="IUSRecord">object of IUSInfo</param>
        /// <returns>IUS Nid</returns>
        private int CheckIUSExists(IUSInfo IUSInfo)
        {
            int RetVal         = 0;
            int IndicatorNid   = 0;
            int UnitNid        = 0;
            int SubgroupValNid = 0;

            //get nids
            IndicatorNid   = this.DIIndicator.CheckNCreateIndicator(IUSInfo.IndicatorInfo);
            UnitNid        = this.DIUnit.CheckNCreateUnit(IUSInfo.UnitInfo);
            SubgroupValNid = this.DISubgroupVal.CheckNCreateSubgroupVal(IUSInfo.SubgroupValInfo);

            //udpate  object of IUSInfo
            IUSInfo.IndicatorInfo.Nid   = IndicatorNid;
            IUSInfo.UnitInfo.Nid        = UnitNid;
            IUSInfo.SubgroupValInfo.Nid = SubgroupValNid;

            //check combination of indicator, unit and subgroup exists in the database or not
            if (IndicatorNid > 0 & UnitNid > 0 & SubgroupValNid > 0)
            {
                RetVal = this.GetIUSNid(IndicatorNid, UnitNid, SubgroupValNid);
            }

            return(RetVal);
        }
Ejemplo n.º 6
0
        private void Get_IUS()
        {
            //'Dictionary<string, int> RetVal = new Dictionary<string, int>();
            string Name           = string.Empty;
            string GID            = string.Empty;
            string LanguageCode   = this._LanguageCode;
            int    NID            = 0;
            string IUSGID         = string.Empty;
            string IndicatorGId   = string.Empty;
            string UnitGId        = string.Empty;
            string SGVGId         = string.Empty;
            int    IndicatorNId   = 0;
            int    UnitNId        = 0;
            int    SubgroupValNId = 0;

            //-- Initialize Process
            //  SDMXUtility.Raise_Initilize_Process_Event("Generating Complete DSD...", 1, 1);
            this.IUSDetails = new Dictionary <string, IUSInfo>();

            foreach (SDMXObjectModel.Structure.CodelistType CodeListObj in this.DSDStructure.Structures.Codelists)
            {
                if (CodeListObj.id == SDMXConstants.CodeList.IUS.Id)
                {
                    foreach (SDMXObjectModel.Structure.CodeType IUSCode in CodeListObj.Items)
                    {
                        IUSGID = IUSCode.id;
                        string[] GIDs;
                        GIDs = IUSGID.Split("@".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                        IndicatorGId = GIDs[0];
                        UnitGId      = GIDs[1];
                        SGVGId       = GIDs[2];

                        IUSInfo TableInfoObj = new IUSInfo();
                        TableInfoObj.IndicatorInfo   = new IndicatorInfo();
                        TableInfoObj.UnitInfo        = new UnitInfo();
                        TableInfoObj.SubgroupValInfo = new DI6SubgroupValInfo();

                        TableInfoObj.IndicatorInfo.GID   = IndicatorGId;
                        TableInfoObj.UnitInfo.GID        = UnitGId;
                        TableInfoObj.SubgroupValInfo.GID = SGVGId;

                        if (!this.IUSDetails.ContainsKey(IUSGID))
                        {
                            this.IUSDetails.Add(IUSGID, TableInfoObj);
                        }
                    }
                }
            }

            // return RetVal;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Import ISDefaultSubgroup from database
        /// </summary>
        /// <param name="sourceDatabase"></param>
        /// <param name="sourceDBQueries"></param>
        public void ImportDefaultSubgroups(DIConnection sourceDBConnection, DIQueries sourceDBQueries)
        {
            string IUSNids = string.Empty;

            DataTable IUSTable   = null;
            DataTable IUTable    = null;
            IUSInfo   IUSInfoObj = new IUSInfo();

            //-- Get IUS from Source Database
            IUSTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.IUS.GetIUS(FilterFieldType.None, string.Empty, FieldSelection.Light, true));

            //-- Get Default IUS Values
            DataRow[] IUSRows = IUSTable.Select(Indicator_Unit_Subgroup.IsDefaultSubgroup + "=1");

            foreach (DataRow Row in IUSRows)
            {
                IUSInfoObj = new IUSInfo();
                IUSInfoObj.IndicatorInfo   = new IndicatorInfo();
                IUSInfoObj.UnitInfo        = new UnitInfo();
                IUSInfoObj.SubgroupValInfo = new DI6SubgroupValInfo();

                IUSInfoObj.IndicatorInfo.Name = Convert.ToString(Row[Indicator.IndicatorName]);
                IUSInfoObj.IndicatorInfo.GID  = Convert.ToString(Row[Indicator.IndicatorGId]);

                IUSInfoObj.UnitInfo.Name = Convert.ToString(Row[Unit.UnitName]);
                IUSInfoObj.UnitInfo.GID  = Convert.ToString(Row[Unit.UnitGId]);

                IUSInfoObj.SubgroupValInfo.Name = Convert.ToString(Row[SubgroupVals.SubgroupVal]);
                IUSInfoObj.SubgroupValInfo.GID  = Convert.ToString(Row[SubgroupVals.SubgroupValGId]);

                int IUSNid = this.GetIUSNid(IUSInfoObj);

                //-- Set Default Subgroup if IUS exists
                if (IUSNid > 0)
                {
                    IUTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IUS.GetIUSByI_U_S(IUSInfoObj.IndicatorInfo.Nid.ToString(), IUSInfoObj.UnitInfo.Nid.ToString(), string.Empty));

                    IUSNids = DIConnection.GetDelimitedValuesFromDataTable(IUTable, Indicator_Unit_Subgroup.IUSNId);

                    //-- Make ISDefault false for other subgroupval for current I-U
                    this.UpdateIUSISDefaultSubgroup(IUSNids, false);

                    //-- Set DefaultSubgroupVal for IUSNid
                    this.UpdateIUSISDefaultSubgroup(IUSNid.ToString(), true);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Import indicator, unit and subgroupval.
        /// </summary>
        /// <param name="iusInfo"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns></returns>
        public int ImportIUS(IUSInfo iusInfo, DIQueries sourceQurey, DIConnection sourceDBConnection)
        {
            int RetVal            = 0;
            int NewIndicatorNid   = 0;
            int NewUnitNid        = 0;
            int NewSubgroupValNid = 0;


            try
            {
                //import indicator
                NewIndicatorNid = this.DIIndicator.ImportIndicator(iusInfo.IndicatorInfo, iusInfo.IndicatorInfo.Nid, sourceQurey, sourceDBConnection);

                //import unit
                NewUnitNid = this.DIUnit.ImportUnit(iusInfo.UnitInfo, iusInfo.UnitInfo.Nid, sourceQurey, sourceDBConnection);

                //import subgroupval
                NewSubgroupValNid = this.DISubgroupVal.ImportSubgroupVal(iusInfo.SubgroupValInfo.Nid, sourceQurey, sourceDBConnection);

                //check ius exists or not
                if (NewIndicatorNid > 0 & NewUnitNid > 0 & NewSubgroupValNid > 0)
                {
                    RetVal = this.GetIUSNid(NewIndicatorNid, NewUnitNid, NewSubgroupValNid);

                    //update nids
                    iusInfo.IndicatorInfo.Nid   = NewIndicatorNid;
                    iusInfo.UnitInfo.Nid        = NewUnitNid;
                    iusInfo.SubgroupValInfo.Nid = NewSubgroupValNid;

                    if (RetVal <= 0)
                    {
                        //insert ius combination
                        this.InsertIUS(iusInfo);
                        RetVal = this.GetIUSNid(NewIndicatorNid, NewUnitNid, NewSubgroupValNid);
                    }
                }
            }
            catch (Exception ex)
            {
                RetVal = 0;
                throw new ApplicationException(ex.ToString());
            }

            return(RetVal);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Insert IUS in database
        /// </summary>
        /// <param name="IUSRecord">object of IUSInfo</param>
        /// <returns>Ture/False. Return true after successful insertion otherwise false</returns>
        private bool InsertIUS(IUSInfo IUSInfo)
        {
            bool   RetVal   = false;
            string SqlQuery = string.Empty;

            try
            {
                SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.IUS.Insert.InsertIUS(this.DBQueries.DataPrefix, IUSInfo.IndicatorInfo.Nid,
                                                                              IUSInfo.UnitInfo.Nid, IUSInfo.SubgroupValInfo.Nid,
                                                                              IUSInfo.Maximum, IUSInfo.Minimum);
                this.DBConnection.ExecuteNonQuery(SqlQuery);
                RetVal = true;
            }
            catch (Exception)
            {
                return(RetVal);
            }

            return(RetVal);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Get IUSNId from IUSInfo and also get the IndicatorNid, UnitNid and SubgroupValNid
        /// </summary>
        /// <param name="IUSInfoObj"></param>
        /// <returns></returns>
        public int GetIUSNid(IUSInfo IUSInfoObj)
        {
            int RetVal = 0;

            try
            {
                IUSInfoObj.IndicatorInfo.Nid   = this.DIIndicator.GetIndicatorNid(IUSInfoObj.IndicatorInfo.GID, IUSInfoObj.IndicatorInfo.Name);
                IUSInfoObj.UnitInfo.Nid        = this.DIUnit.GetUnitNid(IUSInfoObj.UnitInfo.GID, IUSInfoObj.UnitInfo.Name);
                IUSInfoObj.SubgroupValInfo.Nid = this.DISubgroupVal.GetSubgroupValNid(IUSInfoObj.SubgroupValInfo.GID, IUSInfoObj.SubgroupValInfo.Name);

                if (IUSInfoObj.IndicatorInfo.Nid > 0 & IUSInfoObj.UnitInfo.Nid > 0 & IUSInfoObj.SubgroupValInfo.Nid > 0)
                {
                    RetVal = this.GetIUSNid(IUSInfoObj.IndicatorInfo.Nid, IUSInfoObj.UnitInfo.Nid, IUSInfoObj.SubgroupValInfo.Nid);
                }
            }
            catch (Exception)
            {
                RetVal = 0;
            }

            return(RetVal);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Insert DevInfo data value  into database.
        /// </summary>
        /// <param name="areaInfo">Object of AreaInfo</param>
        /// <param name="indicatorName">Indicator name</param>
        /// <param name="unitName">unit name</param>
        /// <param name="subgroupValName">SubgroupVal Name</param>
        /// <param name="timeperiod">Time Period </param>
        /// <param name="source">Source Name </param>
        /// <param name="dataValue">data value</param>
        /// <returns></returns>
        public int AddDataPoint(AreaInfo areaInfo, string indicatorName, string unitName, string subgroupValName, string timeperiod, string source, string dataValue)
        {
            int RetVal = 0;
            IUSInfo IUSInfo = new IUSInfo();

            // check and create IUS value
            IUSInfo.IndicatorInfo.Name = indicatorName;
            IUSInfo.UnitInfo.Name = unitName;
            IUSInfo.SubgroupValInfo.Name = subgroupValName;

            //check and create other elements
            RetVal = this.AddDataPoint(areaInfo, IUSInfo, timeperiod, source, dataValue);

            return RetVal;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Import ISDefaultSubgroup from database
        /// </summary>
        /// <param name="sourceDatabase"></param>
        /// <param name="sourceDBQueries"></param>
        public void ImportDefaultSubgroups(DIConnection sourceDBConnection, DIQueries sourceDBQueries)
        {
            string IUSNids = string.Empty;

            DataTable IUSTable = null;
            DataTable IUTable = null;
            IUSInfo IUSInfoObj = new IUSInfo();

            //-- Get IUS from Source Database
            IUSTable = sourceDBConnection.ExecuteDataTable(sourceDBQueries.IUS.GetIUS(FilterFieldType.None, string.Empty, FieldSelection.Light, true));

            //-- Get Default IUS Values
            DataRow[] IUSRows = IUSTable.Select(Indicator_Unit_Subgroup.IsDefaultSubgroup + "=1");

            foreach (DataRow Row in IUSRows)
            {
                IUSInfoObj = new IUSInfo();
                IUSInfoObj.IndicatorInfo = new IndicatorInfo();
                IUSInfoObj.UnitInfo = new UnitInfo();
                IUSInfoObj.SubgroupValInfo = new DI6SubgroupValInfo();

                IUSInfoObj.IndicatorInfo.Name = Convert.ToString(Row[Indicator.IndicatorName]);
                IUSInfoObj.IndicatorInfo.GID = Convert.ToString(Row[Indicator.IndicatorGId]);

                IUSInfoObj.UnitInfo.Name = Convert.ToString(Row[Unit.UnitName]);
                IUSInfoObj.UnitInfo.GID = Convert.ToString(Row[Unit.UnitGId]);

                IUSInfoObj.SubgroupValInfo.Name = Convert.ToString(Row[SubgroupVals.SubgroupVal]);
                IUSInfoObj.SubgroupValInfo.GID = Convert.ToString(Row[SubgroupVals.SubgroupValGId]);

                int IUSNid = this.GetIUSNid(IUSInfoObj);

                //-- Set Default Subgroup if IUS exists
                if (IUSNid > 0)
                {
                    IUTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IUS.GetIUSByI_U_S(IUSInfoObj.IndicatorInfo.Nid.ToString(), IUSInfoObj.UnitInfo.Nid.ToString(), string.Empty));

                    IUSNids = DIConnection.GetDelimitedValuesFromDataTable(IUTable, Indicator_Unit_Subgroup.IUSNId);

                    //-- Make ISDefault false for other subgroupval for current I-U
                    this.UpdateIUSISDefaultSubgroup(IUSNids, false);

                    //-- Set DefaultSubgroupVal for IUSNid
                    this.UpdateIUSISDefaultSubgroup(IUSNid.ToString(), true);
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Import indicator, unit and subgroupval. 
        /// </summary>
        /// <param name="iusInfo"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns></returns>
        public int ImportIUS(IUSInfo iusInfo, DIQueries sourceQurey, DIConnection sourceDBConnection)
        {
            int RetVal = 0;
            int NewIndicatorNid = 0;
            int NewUnitNid = 0;
            int NewSubgroupValNid = 0;

            try
            {
                //import indicator
                NewIndicatorNid = this.DIIndicator.ImportIndicator(iusInfo.IndicatorInfo, iusInfo.IndicatorInfo.Nid, sourceQurey, sourceDBConnection);

                //import unit
                NewUnitNid = this.DIUnit.ImportUnit(iusInfo.UnitInfo, iusInfo.UnitInfo.Nid, sourceQurey, sourceDBConnection);

                //import subgroupval
                NewSubgroupValNid = this.DISubgroupVal.ImportSubgroupVal(iusInfo.SubgroupValInfo.Nid, sourceQurey, sourceDBConnection);

                //check ius exists or not
                if (NewIndicatorNid > 0 & NewUnitNid > 0 & NewSubgroupValNid > 0)
                {
                    RetVal = this.GetIUSNid(NewIndicatorNid, NewUnitNid, NewSubgroupValNid);

                    //update nids
                    iusInfo.IndicatorInfo.Nid = NewIndicatorNid;
                    iusInfo.UnitInfo.Nid = NewUnitNid;
                    iusInfo.SubgroupValInfo.Nid = NewSubgroupValNid;

                    if (RetVal <= 0)
                    {
                        //insert ius combination
                        this.InsertIUS(iusInfo);
                        RetVal = this.GetIUSNid(NewIndicatorNid, NewUnitNid, NewSubgroupValNid);
                    }
                }

            }
            catch (Exception ex)
            {
                RetVal = 0;
                throw new ApplicationException(ex.ToString());
            }

            return RetVal;
        }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Get IUSNId from IUSInfo and also get the IndicatorNid, UnitNid and SubgroupValNid
        /// </summary>
        /// <param name="IUSInfoObj"></param>
        /// <returns></returns>
        public int GetIUSNid(IUSInfo IUSInfoObj)
        {
            int RetVal = 0;

            try
            {
                IUSInfoObj.IndicatorInfo.Nid = this.DIIndicator.GetIndicatorNid(IUSInfoObj.IndicatorInfo.GID, IUSInfoObj.IndicatorInfo.Name);
                IUSInfoObj.UnitInfo.Nid = this.DIUnit.GetUnitNid(IUSInfoObj.UnitInfo.GID, IUSInfoObj.UnitInfo.Name);
                IUSInfoObj.SubgroupValInfo.Nid = this.DISubgroupVal.GetSubgroupValNid(IUSInfoObj.SubgroupValInfo.GID, IUSInfoObj.SubgroupValInfo.Name);

                if (IUSInfoObj.IndicatorInfo.Nid > 0 & IUSInfoObj.UnitInfo.Nid > 0 & IUSInfoObj.SubgroupValInfo.Nid > 0)
                {

                    RetVal = this.GetIUSNid(IUSInfoObj.IndicatorInfo.Nid, IUSInfoObj.UnitInfo.Nid, IUSInfoObj.SubgroupValInfo.Nid);
                }
            }
            catch (Exception)
            {
                RetVal = 0;
            }

            return RetVal;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Insert IUS in database
        /// </summary>
        /// <param name="IUSRecord">object of IUSInfo</param>
        /// <returns>Ture/False. Return true after successful insertion otherwise false</returns>
        private bool InsertIUS(IUSInfo IUSInfo)
        {
            bool RetVal = false;
            string SqlQuery = string.Empty;

            try
            {
                SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.IUS.Insert.InsertIUS(this.DBQueries.DataPrefix, IUSInfo.IndicatorInfo.Nid,
                    IUSInfo.UnitInfo.Nid, IUSInfo.SubgroupValInfo.Nid,
                    IUSInfo.Maximum, IUSInfo.Minimum);
                this.DBConnection.ExecuteNonQuery(SqlQuery);
                RetVal = true;
            }
            catch (Exception)
            {
                return RetVal;
            }

            return RetVal;
        }
Ejemplo n.º 18
0
        private void Get_IUS()
        {
            //'Dictionary<string, int> RetVal = new Dictionary<string, int>();
            string Name = string.Empty;
            string GID = string.Empty;
            string LanguageCode = this._LanguageCode;
            int NID = 0;
            string IUSGID = string.Empty;
            string IndicatorGId = string.Empty;
            string UnitGId = string.Empty;
            string SGVGId = string.Empty;
            int IndicatorNId = 0;
            int UnitNId = 0;
            int SubgroupValNId = 0;

            //-- Initialize Process
            //  SDMXUtility.Raise_Initilize_Process_Event("Generating Complete DSD...", 1, 1);
            this.IUSDetails = new Dictionary<string, IUSInfo>();

            foreach (SDMXObjectModel.Structure.CodelistType CodeListObj in this.DSDStructure.Structures.Codelists)
            {
                if (CodeListObj.id == SDMXConstants.CodeList.IUS.Id)
                {
                    foreach (SDMXObjectModel.Structure.CodeType IUSCode in CodeListObj.Items)
                    {
                        IUSGID = IUSCode.id;
                        string[] GIDs;
                        GIDs = IUSGID.Split("@".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                        IndicatorGId = GIDs[0];
                        UnitGId = GIDs[1];
                        SGVGId = GIDs[2];

                        IUSInfo TableInfoObj = new IUSInfo();
                        TableInfoObj.IndicatorInfo = new IndicatorInfo();
                        TableInfoObj.UnitInfo = new UnitInfo();
                        TableInfoObj.SubgroupValInfo = new DI6SubgroupValInfo();

                        TableInfoObj.IndicatorInfo.GID = IndicatorGId;
                        TableInfoObj.UnitInfo.GID = UnitGId;
                        TableInfoObj.SubgroupValInfo.GID = SGVGId;

                        if (!this.IUSDetails.ContainsKey(IUSGID))
                        {
                            this.IUSDetails.Add(IUSGID, TableInfoObj);
                        }
                    }
                }
            }

            // return RetVal;
        }
Ejemplo n.º 19
0
        private int ImportForIUS(DataRow row)
        {
            int RetVal = 0;
            IUSInfo iusInfo = new IUSInfo();
            IUSBuilder iusBuilder = new IUSBuilder(this._TargetDBConnection, this._TargetDBQueries);

            iusInfo.IndicatorInfo = this.GetIndicatorInfo(row);
            iusInfo.UnitInfo = this.GetUnitInfo(row);
            iusInfo.SubgroupValInfo = this.GetSubgroupValInfo(row);

            RetVal = iusBuilder.ImportIUS(iusInfo, this.SourceDBQueries, this.SourceDBConnection);

            bool ISDefault = false;
            if (!string.IsNullOrEmpty(Convert.ToString(row[Indicator_Unit_Subgroup.IsDefaultSubgroup])))
            {
                ISDefault = Convert.ToBoolean(row[Indicator_Unit_Subgroup.IsDefaultSubgroup]);
            }

            iusBuilder.UpdateIUSISDefaultSubgroup(RetVal.ToString(), ISDefault);

            iusBuilder.UpdateISDefaultSubgroup(iusInfo.IndicatorInfo.Nid, iusInfo.UnitInfo.Nid);

            //if (importSector)
            //{
            //    //create indicator classification
            //    this.ImportSector(row);
            //}

            return RetVal;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Create and add record into database.
        /// </summary>
        /// <param name="areaInfo">object of AreaInfo</param>
        /// <param name="iusInfo">object of IUSInfo</param>
        /// <param name="timeperiod">Timeperiod</param>
        /// <param name="source">Source Name</param>
        /// <param name="dataValue">Data Value</param>
        /// <returns></returns>
        public int AddDataPoint(AreaInfo areaInfo, IUSInfo iusInfo, string timeperiod, string source, string dataValue)
        {
            int RetVal = 0;

            TimeperiodInfo TimeperiodObject = new TimeperiodInfo();
            SourceInfo SourceObject = new SourceInfo();

            if (areaInfo == null | string.IsNullOrEmpty(iusInfo.IndicatorInfo.Name) |
                string.IsNullOrEmpty(iusInfo.UnitInfo.Name) |
                string.IsNullOrEmpty(iusInfo.SubgroupValInfo.Name) |
                string.IsNullOrEmpty(timeperiod) | string.IsNullOrEmpty(source))
            {
                //do nothing

            }
            else
            {
                //set timeperiod info
                TimeperiodObject.Nid = 0;
                TimeperiodObject.TimeperiodValue = timeperiod;

                //set source info
                SourceObject.Nid = 0;
                SourceObject.Name = source;

                //insert data
                RetVal = this.AddDataPoint(areaInfo, iusInfo, TimeperiodObject, SourceObject, dataValue);
            }

            return RetVal;
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Add IUS record into collection
 /// </summary>
 /// <param name="IUSRecord">object of IUSInfo </param>
 private void AddIUSIntoCollection(IUSInfo IUSInfo)
 {
     if (!this.IUSCollection.ContainsKey(IUSInfo.Nid.ToString()))
     {
         this.IUSCollection.Add(IUSInfo.Nid.ToString(), IUSInfo);
     }
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Create and add record into database.
        /// </summary>
        /// <param name="areaInfo"></param>
        /// <param name="iusInfo"></param>
        /// <param name="timeperiodInfo"></param>
        /// <param name="sourceInfo"></param>
        /// <returns></returns>
        public int AddDataPoint(AreaInfo areaInfo, IUSInfo iusInfo, TimeperiodInfo timeperiodInfo, SourceInfo sourceInfo, string dataValue)
        {
            int RetVal = 0;
            int AreaNid = 0;
            int IUSNid = 0;
            int TimeperiodNid = 0;
            int SourceNid = 0;

            // Step 1: Area
            if (areaInfo.Nid <= 0)
            {
                AreaNid = this.DIArea.CheckNCreateArea(areaInfo);
            }
            else
            {
                AreaNid = areaInfo.Nid;
            }

            // Step 2: IUS, check for IUS only if IUSNid is zero.
            if (iusInfo.Nid <= 0)
            {
                IUSNid = this.DIIUS.CheckNCreateIUS(iusInfo);
            }
            else
            {
                IUSNid = iusInfo.Nid;
            }

            // Step 3: Timeperiod
            if (timeperiodInfo.Nid <= 0)
            {
                TimeperiodNid = this.DITimeperiod.CheckNCreateTimeperiod(timeperiodInfo.TimeperiodValue);
            }
            else
            {
                TimeperiodNid = timeperiodInfo.Nid;
            }

            // Step 4: Source
            if (sourceInfo.Nid <= 0)
            {
                SourceNid = this.DISource.CheckNCreateSource(sourceInfo.Name);
            }
            else
            {
                SourceNid = sourceInfo.Nid;
            }

            // Step 5: Insert Data and source , IUSNId & sourceparent ,IUSNID relationship into IC_IUS table
            RetVal = this.CheckNCreateData(AreaNid, IUSNid, SourceNid, TimeperiodNid, dataValue);
            return RetVal;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Check existance of  IUS record in database 
        /// </summary>
        /// <param name="IUSRecord">object of IUSInfo</param>
        /// <returns>IUS Nid</returns>
        private int CheckIUSExists(IUSInfo IUSInfo)
        {
            int RetVal = 0;
            int IndicatorNid = 0;
            int UnitNid = 0;
            int SubgroupValNid = 0;

            //get nids
            IndicatorNid = this.DIIndicator.CheckNCreateIndicator(IUSInfo.IndicatorInfo);
            UnitNid = this.DIUnit.CheckNCreateUnit(IUSInfo.UnitInfo);
            SubgroupValNid = this.DISubgroupVal.CheckNCreateSubgroupVal(IUSInfo.SubgroupValInfo);

            //udpate  object of IUSInfo
            IUSInfo.IndicatorInfo.Nid = IndicatorNid;
            IUSInfo.UnitInfo.Nid = UnitNid;
            IUSInfo.SubgroupValInfo.Nid = SubgroupValNid;

            //check combination of indicator, unit and subgroup exists in the database or not
            if (IndicatorNid > 0 & UnitNid > 0 & SubgroupValNid > 0)
            {
                RetVal = this.GetIUSNid(IndicatorNid, UnitNid, SubgroupValNid);
            }

            return RetVal;
        }
Ejemplo n.º 24
0
        private IUSInfo GetIUSInfo(DataRow row)
        {
            IUSInfo RetVal = new IUSInfo();

            //indicator
            RetVal.IndicatorInfo = new IndicatorInfo();
            RetVal.IndicatorInfo.Name = row[Indicator.IndicatorName].ToString();
            RetVal.IndicatorInfo.GID = row[Indicator.IndicatorGId].ToString();

            //unit
            RetVal.UnitInfo = new UnitInfo();
            RetVal.UnitInfo.Name = row[Unit.UnitName].ToString();
            RetVal.UnitInfo.GID = row[Unit.UnitGId].ToString();

            //subgroup
            RetVal.SubgroupValInfo = new DI6SubgroupValInfo();
            RetVal.SubgroupValInfo.Name = row[SubgroupVals.SubgroupVal].ToString();
            RetVal.SubgroupValInfo.GID = row[SubgroupVals.SubgroupValGId].ToString();

            return RetVal;
        }