/// <summary>
        /// Get_Attributes
        /// </summary>
        /// <param name="idset">ID of Structure</param>
        /// <returns>return list of attributes form specific structure</returns>
        public static List<ISTAT.ENTITY.Attribute> Get_Attributes(int idset)
        {
            DataWrapper dtw = new DataWrapper(DataWrapper.ECONNECTIONTYPE.SQL, DataAccess.SQLConnString_DB.ConnectionString);

            if (dtw.TestConnection())
            {
                dtw.DBConnection.Open();
                try
                {

                    ////////////////////////

                    List<ISTAT.ENTITY.Attribute> atts = new List<ISTAT.ENTITY.Attribute>();

                    System.Data.IDbCommand cmd = dtw.DBConnection.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "dbo.proc_GET_ATTRIBUTES";

                    System.Data.IDbDataParameter _idset = cmd.CreateParameter();
                    _idset.DbType = System.Data.DbType.Int32;
                    _idset.ParameterName = "IDSet";
                    _idset.Value = idset;
                    cmd.Parameters.Add(_idset);

                    System.Data.IDbDataParameter _twoLetterISO = cmd.CreateParameter();
                    _twoLetterISO.DbType = System.Data.DbType.String;
                    _twoLetterISO.ParameterName = "TwoLetterISO";
                    _twoLetterISO.Value = DataAccess.TwoLetterIso;
                    cmd.Parameters.Add(_twoLetterISO);

                    System.Data.IDataReader _reader = cmd.ExecuteReader();
                    while (_reader.Read())
                    {
                        ISTAT.ENTITY.Attribute att = new ISTAT.ENTITY.Attribute();
                        att.Id = _reader.GetString(_reader.GetOrdinal("Code"));
                        att.IsCodelist = _reader.GetBoolean(_reader.GetOrdinal("IsCodelist"));

                        List<TextTypeWrapper> names = DataAccess.Get_LocalisedStrings(_reader.GetInt32(_reader.GetOrdinal("IDAtt")), "CatAtt");
                        att.Names.Add(names[TextTypeWrapper.GetIndexLocale(names, DataAccess.TwoLetterIso)]);

                        atts.Add(att);
                    }
                    _reader.Close();

                    foreach (ISTAT.ENTITY.Attribute att in atts)
                    {
                        System.Data.IDbCommand cmd_attach = dtw.DBConnection.CreateCommand();
                        cmd_attach.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd_attach.CommandText = "dbo.proc_GET_ATT_ATTACH";

                        System.Data.IDbDataParameter _idSetAttach = cmd_attach.CreateParameter();
                        _idSetAttach.DbType = System.Data.DbType.Int32;
                        _idSetAttach.ParameterName = "IDSet";
                        _idSetAttach.Value = idset;
                        cmd_attach.Parameters.Add(_idSetAttach);

                        System.Data.IDbDataParameter _codeAttAttach = cmd_attach.CreateParameter();
                        _codeAttAttach.DbType = System.Data.DbType.String;
                        _codeAttAttach.ParameterName = "AttCode";
                        _codeAttAttach.Value = att.Id;
                        cmd_attach.Parameters.Add(_codeAttAttach);

                        System.Data.IDataReader _readerAttach = cmd_attach.ExecuteReader();

                        bool isTimeDimension = false;
                        att.DimensionReferences = new List<string>();
                        while (_readerAttach.Read())
                        {
                            string dimCode = _readerAttach.GetString(_readerAttach.GetOrdinal("Code"));
                            isTimeDimension = _readerAttach.GetBoolean(_readerAttach.GetOrdinal("IsTimeSeriesDim"));
                            att.DimensionReferences.Add(dimCode);
                        }
                        _readerAttach.Close();

                        if (att.DimensionReferences.Count == 0)
                        {
                            att.AttachmentLevel = Org.Sdmxsource.Sdmx.Api.Constants.AttributeAttachmentLevel.DataSet.ToString();
                        }
                        else if (att.DimensionReferences.Count == 1 && isTimeDimension)
                        {
                            att.AttachmentLevel = Org.Sdmxsource.Sdmx.Api.Constants.AttributeAttachmentLevel.Observation.ToString();
                        }
                        else
                        {
                            att.AttachmentLevel = Org.Sdmxsource.Sdmx.Api.Constants.AttributeAttachmentLevel.DimensionGroup.ToString();
                        }

                    }

                    ////////////////////////

                    dtw.DBConnection.Close();
                    return atts;
                }
                catch
                {
                    dtw.DBConnection.Close();
                    return null;
                }
            } return null;
        }
Пример #2
0
        public DataStructure Get_DSD(ISTAT.ENTITY.SDMXIdentifier sdmxIdentity)
        {
            DataStructure _ds = new ISTAT.ENTITY.DataStructure();
            Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IDataStructureObject dsd = ISTAT.DBDAL.DataSDMX.GetDSD(sdmxIdentity);

            #region Get Dimension
            List<Dimension> dims = new List<Dimension>();
            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IDimension dim in dsd.DimensionList.Dimensions)
            {
                Dimension _dim = new Dimension(dim);
                dims.Add(_dim);
            }
            #endregion
            #region Get Attribute
            List<ISTAT.ENTITY.Attribute> atts = new List<ISTAT.ENTITY.Attribute>();
            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IAttributeObject att in dsd.Attributes)
            {
                ISTAT.ENTITY.Attribute _att = new ISTAT.ENTITY.Attribute(att);
                atts.Add(_att);
            }
            #endregion

            _ds.Dimensions = dims;
            _ds.Attributes = atts;
            _ds.DSDIdentifier = sdmxIdentity;
            _ds.IDDsd = ISTAT.DBDAL.DataSDMX.Get_IDDsd(sdmxIdentity);
            _ds.IsFinal = dsd.IsFinal.IsTrue;

            this._ds = _ds;

            return _ds;
        }
        public DataStructure Get_DSD(ISTAT.ENTITY.SDMXIdentifier sdmxIdentity)
        {
            DataStructure _ds = new ISTAT.ENTITY.DataStructure();
            Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IDataStructureObject dsd = ISTAT.DBDAL.DataSDMX.GetDSD(sdmxIdentity, false);

            #region Get Dimension
            List<Dimension> dims = new List<Dimension>();
            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IDimension dim in dsd.DimensionList.Dimensions)
            {
                Dimension _dim = new Dimension(dim);
                dims.Add(_dim);
            }
            #endregion
            #region Get Attribute
            List<ISTAT.ENTITY.Attribute> atts = new List<ISTAT.ENTITY.Attribute>();
            foreach (Org.Sdmxsource.Sdmx.Api.Model.Objects.DataStructure.IAttributeObject att in dsd.Attributes)
            {
                ISTAT.ENTITY.Attribute _att = new ISTAT.ENTITY.Attribute(att);
                if (att.AttachmentGroup != null)
                {
                    var group = dsd.Groups.FirstOrDefault(e => e.Id == att.AttachmentGroup);
                    if (group != null)
                        _att.DimensionReferences = new List<string>(group.DimensionRefs);
                }
                atts.Add(_att);
            }
            #endregion

            _ds.Dimensions = dims;
            _ds.Attributes = atts;
            _ds.DSDIdentifier = sdmxIdentity;
            _ds.IDDsd = ISTAT.DBDAL.DataSDMX.Get_IDDsd(sdmxIdentity);
            _ds.IsFinal = dsd.IsFinal.IsTrue;

            this._ds = _ds;

            return _ds;
        }