/// <summary>
        /// Parse a time where condition
        /// </summary>
        /// <param name="DateFrom">Date From in Sdmx Format</param>
        /// <param name="DateTo">Date To in Sdmx Format</param>
        /// <returns>string representing the date where formatted</returns>
        private string ParseTimeValueWhereStatment(ISdmxDate DateFrom, ISdmxDate DateTo)
        {
            try
            {
                IConceptObjectImpl realConceptTime = Concepts.Find(c => c.ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)c).DimensionType == DimensionTypeEnum.Time);
                string             timedim         = string.Format(FormatWhereValue, ((IDimensionConcept)realConceptTime).GetColumTimeName());
                List <string>      SingleValues    = new List <string>();

                //dò per scontato che i timeFormat delle 2 date siano Uguali
                TimeFormatEnumType tf = TimeFormatEnumType.Null;
                if (DateFrom != null && DateFrom.Date.HasValue)
                {
                    tf = DateFrom.TimeFormatOfDate.EnumType;
                    string wherestr = TimePeriodDBFormat.GetTimeWhereStatment(timedim, TimePeriodDBFormat.TypeDateOperation.Major, tf, DateFrom);
                    if (!string.IsNullOrEmpty(wherestr))
                    {
                        SingleValues.Add(wherestr);
                    }
                }

                if (DateTo != null && DateTo.Date.HasValue)
                {
                    if (tf == TimeFormatEnumType.Null)
                    {
                        tf = DateTo.TimeFormatOfDate.EnumType;
                    }
                    string wherestr = TimePeriodDBFormat.GetTimeWhereStatment(timedim, FlyController.Model.TimePeriodDBFormat.TypeDateOperation.Minor, tf, DateTo);
                    if (!string.IsNullOrEmpty(wherestr))
                    {
                        SingleValues.Add(wherestr);
                    }
                }

                if (SingleValues.Count > 0)
                {
                    return(string.Format("({0})", string.Join(") AND (", SingleValues)));
                }

                return(null);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, ex);
            }
        }
        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);
        }