/// <summary>
        /// retrieves the codelist constrained
        /// </summary>
        /// <param name="_dataFlowCode">Dataflow Code</param>
        /// <param name="specialConcept">the <see cref="ISpecialConcept"/></param>
        /// <returns>list of Mutable Code Object</returns>
        public List <ICodeMutableObject> GetSpecialCodelist(string _dataFlowCode, ISpecialConcept specialConcept)
        {
            List <ICodeMutableObject> codes = new List <ICodeMutableObject>();

            switch (specialConcept.SpecialType)
            {
            case SpecialTypeEnum.CL_TIME_PERIOD:
                codes = SpecialCodelist_CL_TIME_PERIOD(_dataFlowCode);
                break;

            case SpecialTypeEnum.CL_COUNT:
                codes = SpecialCodelist_CL_COUNT(_dataFlowCode);
                break;

            case SpecialTypeEnum.CL_CONTRAINED:
                codes = SpecialCodelist_CL_CONTRAINED(_dataFlowCode, specialConcept);
                break;
            }
            return(codes);
        }
        /// <summary>
        /// retrieves the codelist constrained
        /// </summary>
        /// <param name="_dataFlowCode">Dataflow Code</param>
        /// <param name="specialConcept">the <see cref="ISpecialConcept"/></param>
        /// <returns>list of Mutable Code Object</returns>
        public List <ICodeMutableObject> GetSpecialCodelist(string _dataFlowCode, ISpecialConcept specialConcept)
        {
            List <IParameterValue> parametri = new List <IParameterValue>()
            {
                new ParameterValue()
                {
                    Item = "DataSetCode", Value = _dataFlowCode
                },
                new ParameterValue()
                {
                    Item = "WhereStatement", Value = "1=1"
                },
                new ParameterValue()
                {
                    Item = "UserName", Value = FlyConfiguration.UserName
                },
                new ParameterValue()
                {
                    Item = "Domain", Value = FlyConfiguration.Domain
                },
            };
            List <ICodeMutableObject> codes = new List <ICodeMutableObject>();

            switch (specialConcept.SpecialType)
            {
            case SpecialTypeEnum.CL_TIME_PERIOD:
                codes = SpecialCodelist_CL_TIME_PERIOD(_dataFlowCode);
                break;

            case SpecialTypeEnum.CL_COUNT:
                codes = SpecialCodelist_CL_COUNT(_dataFlowCode);
                break;

            case SpecialTypeEnum.CL_CONTRAINED:
                codes = SpecialCodelist_CL_CONTRAINED(_dataFlowCode, specialConcept);
                break;
            }
            return(codes);
        }
        private List <ICodeMutableObject> SpecialCodelist_CL_CONTRAINED(string _dataFlowCode, ISpecialConcept specialConcept)
        {
            string        WhereStatement = "1=1";
            string        Time           = "1=1";
            List <string> _ConceptWhere  = new List <string>();

            if (specialConcept.ContrainConceptREF != null && specialConcept.ContrainConceptREF.Keys.Count > 0)
            {
                foreach (string otherconept in specialConcept.ContrainConceptREF.Keys.ToList())
                {
                    if (specialConcept.ContrainConceptREF[otherconept] == null)
                    {
                        continue;
                    }
                    if (new List <string>()
                    {
                        "TIME", "TIME_PERIOD"
                    }.Contains(otherconept.Trim().ToUpper()))
                    {
                        if (specialConcept.ContrainConceptREF[otherconept].Count > 0 && specialConcept.TimeDimensionRef != null)
                        {
                            string    timedim   = string.Format(DataMessageManager.FormatWhereValue, ((IDimensionConcept)specialConcept.TimeDimensionRef).GetColumTimeName());
                            ISdmxDate StartDate = new SdmxDateCore(specialConcept.ContrainConceptREF[otherconept][0].Value);
                            string    STime     = TimePeriodDBFormat.GetTimeWhereStatment(timedim, TimePeriodDBFormat.TypeDateOperation.Major, StartDate.TimeFormatOfDate.EnumType, StartDate);
                            Time = String.Format("({0})", STime);
                            if (specialConcept.ContrainConceptREF[otherconept].Count == 2)
                            {
                                ISdmxDate EndDate = new SdmxDateCore(specialConcept.ContrainConceptREF[otherconept][1].Value);
                                string    ETime   = TimePeriodDBFormat.GetTimeWhereStatment(timedim, TimePeriodDBFormat.TypeDateOperation.Minor, EndDate.TimeFormatOfDate.EnumType, EndDate);
                                Time = String.Format("({0} AND {1})", STime, ETime);
                            }
                        }
                        continue;
                    }
                    if (otherconept.Trim().ToUpper() == "FREQ")
                    {
                        //Devo controllare se stò in modalità FakeFrequency se cosi
                        continue;
                    }
                    List <string> ConceptInternalWhere = new List <string>();
                    foreach (var item in specialConcept.ContrainConceptREF[otherconept])
                    {
                        ConceptInternalWhere.Add(string.Format("{0}='{1}'", string.Format(DataMessageManager.FormatWhereValue, otherconept), item.Value));
                    }
                    _ConceptWhere.Add(string.Format("({0})", string.Join(" OR ", ConceptInternalWhere)));
                }
            }
            WhereStatement = string.Format("{0}", string.Join(" AND ", _ConceptWhere));
            if (string.IsNullOrEmpty(WhereStatement))
            {
                WhereStatement = "1=1";
            }

            List <IParameterValue> parametri = new List <IParameterValue>()
            {
                new ParameterValue()
                {
                    Item = "DataSetCode", Value = _dataFlowCode
                },
                new ParameterValue()
                {
                    Item = "WhereStatement", Value = WhereStatement
                },
                new ParameterValue()
                {
                    Item = "Time", Value = Time
                },
                new ParameterValue()
                {
                    Item = "UserName", Value = FlyConfiguration.UserName
                },
                new ParameterValue()
                {
                    Item = "Domain", Value = FlyConfiguration.Domain
                },
            };

            List <ICodeMutableObject> codes = null;

            if (specialConcept.Id.Trim().ToUpper() == "FREQ")
            {
                codes = GetFrequencyCodelist();
            }
            else
            {
                DimensionCodelistsManager dimcm = new DimensionCodelistsManager(this.parsingObject, this.versionTypeResp);

                codes = dimcm.InternalGetDimensionCodelistConstrain(_dataFlowCode, specialConcept.Id);
            }

            List <string> existCode = ((DWHAccess)DbAccess).GetCL_CONTRAINED(parametri, specialConcept.Id);

            List <ICodeMutableObject> Contrainedcodes = new List <ICodeMutableObject>();

            for (int i = codes.Count - 1; i >= 0; i--)
            {
                if (existCode.Contains(codes[i].Id))
                {
                    Contrainedcodes.Add(codes[i]);
                }
            }
            for (int i = 0; i < Contrainedcodes.Count; i++)
            {
                ICodeMutableObject observeCode = Contrainedcodes[i];

                while (true)
                {
                    if (!string.IsNullOrEmpty(observeCode.ParentCode) && !Contrainedcodes.Exists(c => c.Id == observeCode.ParentCode))
                    {
                        ICodeMutableObject ParentCode = codes.Find(c => c.Id == observeCode.ParentCode);
                        if (ParentCode != null)
                        {
                            Contrainedcodes.Add(ParentCode);
                            observeCode = ParentCode;
                            continue;
                        }
                    }
                    break;
                }
            }

            return(Contrainedcodes);
        }