private ArtefactInfo Prepare_ArtefactInfo_From_ConceptScheme(ConceptSchemeType ConceptScheme, string FileName)
        {
            ArtefactInfo RetVal;
            SDMXObjectModel.Message.StructureType Structure;
            XmlDocument XmlContent;

            RetVal = null;
            XmlContent = null;

            try
            {
                Structure = this.Get_Structure_Object(ConceptScheme);
                XmlContent = Serializer.SerializeToXmlDocument(typeof(SDMXObjectModel.Message.StructureType), Structure);
                RetVal = new ArtefactInfo(ConceptScheme.id, ConceptScheme.agencyID, ConceptScheme.version, string.Empty, ArtefactTypes.ConceptS, FileName, XmlContent);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }

            return RetVal;
        }
        private SDMXObjectModel.Message.StructureType Get_Structure_Object(ConceptSchemeType ConceptScheme)
        {
            SDMXObjectModel.Message.StructureType RetVal;

            RetVal = new SDMXObjectModel.Message.StructureType();
            RetVal.Header = this.Get_Appropriate_Header();
            RetVal.Structures = new StructuresType(null, null, null, null, null, null, null, ConceptScheme, null, null, null, null, null, null, null);
            RetVal.Footer = null;

            return RetVal;
        }
        private ArtefactInfo Generate_MSD_Source_ConceptScheme()
        {
            ArtefactInfo RetVal;
            ConceptSchemeType ConceptScheme;
            string Query;
            DataTable DtMetadataCategory;

            RetVal = null;
            ConceptScheme = null;
            Query = string.Empty;
            DtMetadataCategory = null;

            try
            {
                ConceptScheme = new ConceptSchemeType(Constants.ConceptScheme.MSD_Source.Id, this.AgencyId, Constants.ConceptScheme.MSD_Source.Version, Constants.ConceptScheme.MSD_Source.Name, Constants.ConceptScheme.MSD_Source.Description, Constants.DefaultLanguage,null);

                Query = "SELECT * FROM UT_Metadata_Category_" + this.Language + " WHERE CategoryType = 'S'";
                DtMetadataCategory = this._diConnection.ExecuteDataTable(Regex.Replace(Query, "UT_", this._diConnection.DIDataSetDefault(), RegexOptions.IgnoreCase));
                this.Fill_ConceptScheme(ConceptScheme, DtMetadataCategory);

                RetVal = this.Prepare_ArtefactInfo_From_ConceptScheme(ConceptScheme, Constants.ConceptScheme.MSD_Source.FileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }

            return RetVal;
        }
        private ArtefactInfo Generate_DSD_ConceptScheme()
        {
            ArtefactInfo RetVal;
            ConceptSchemeType ConceptScheme;
            ConceptType Concept;
            string ConceptId, ConceptName, ConceptDescription;
            DataTable DtSubgroupType;
            DIQueries DIQueriesLanguage;

            RetVal = null;

            try
            {
                ConceptScheme = new ConceptSchemeType(Constants.ConceptScheme.DSD.Id, this.AgencyId, Constants.ConceptScheme.DSD.Version, Constants.ConceptScheme.DSD.Name, Constants.ConceptScheme.DSD.Description, Constants.DefaultLanguage, null);

                Concept = new ConceptType(Constants.Concept.TIME_PERIOD.Id, Constants.Concept.TIME_PERIOD.Name, Constants.Concept.TIME_PERIOD.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.OBS_VALUE.Id, Constants.Concept.OBS_VALUE.Name, Constants.Concept.OBS_VALUE.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.AREA.Id, Constants.Concept.AREA.Name, Constants.Concept.AREA.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.INDICATOR.Id, Constants.Concept.INDICATOR.Name, Constants.Concept.INDICATOR.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.UNIT.Id, Constants.Concept.UNIT.Name, Constants.Concept.UNIT.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.PERIODICITY.Id, Constants.Concept.PERIODICITY.Name, Constants.Concept.PERIODICITY.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.SOURCE.Id, Constants.Concept.SOURCE.Name, Constants.Concept.SOURCE.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.NATURE.Id, Constants.Concept.NATURE.Name, Constants.Concept.NATURE.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.DENOMINATOR.Id, Constants.Concept.DENOMINATOR.Name, Constants.Concept.DENOMINATOR.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.FOOTNOTES.Id, Constants.Concept.FOOTNOTES.Name, Constants.Concept.FOOTNOTES.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.CONFIDENCE_INTERVAL_UPPER.Id, Constants.Concept.CONFIDENCE_INTERVAL_UPPER.Name, Constants.Concept.CONFIDENCE_INTERVAL_UPPER.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                Concept = new ConceptType(Constants.Concept.CONFIDENCE_INTERVAL_LOWER.Id, Constants.Concept.CONFIDENCE_INTERVAL_LOWER.Name, Constants.Concept.CONFIDENCE_INTERVAL_LOWER.Description, Constants.DefaultLanguage, string.Empty, null);
                ConceptScheme.Items.Add(Concept);

                DIQueriesLanguage = new DIQueries(this.DIQueries.DataPrefix, this.Language);
                DtSubgroupType = this.DIConnection.ExecuteDataTable(DIQueriesLanguage.SubgroupTypes.GetSubgroupTypes(FilterFieldType.None, string.Empty));
                foreach (DataRow DrSubgroupType in DtSubgroupType.Rows)
                {
                    ConceptId = DrSubgroupType[SubgroupTypes.SubgroupTypeGID].ToString();
                    ConceptName = DrSubgroupType[SubgroupTypes.SubgroupTypeName].ToString();

                    switch (ConceptId)
                    {
                        case Constants.Concept.SUBGROUP.AGE.Id:
                            ConceptDescription = Constants.Concept.SUBGROUP.AGE.Description;
                            break;
                        case Constants.Concept.SUBGROUP.SEX.Id:
                            ConceptDescription = Constants.Concept.SUBGROUP.SEX.Description;
                            break;
                        case Constants.Concept.SUBGROUP.LOCATION.Id:
                            ConceptDescription = Constants.Concept.SUBGROUP.LOCATION.Description;
                            break;
                        default:
                            ConceptDescription = Constants.Concept.SUBGROUP.Description;
                            break;
                    }

                    Concept = new ConceptType(ConceptId, ConceptName, ConceptDescription, this.Language, string.Empty, null);
                    ConceptScheme.Items.Add(Concept);
                }

                RetVal = this.Prepare_ArtefactInfo_From_ConceptScheme(ConceptScheme, Constants.ConceptScheme.DSD.FileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }

            return RetVal;
        }
        private void Fill_ConceptScheme(ConceptSchemeType ConceptScheme, DataTable DtMetadataCategory)
        {
            ConceptType Concept;
            string CategoryGId, CategoryName, CategoryDescription, ParentCategoryNId, ParentCategoryGId;

            Concept = null;
            CategoryGId = string.Empty;
            CategoryName = string.Empty;
            CategoryDescription = string.Empty;
            ParentCategoryNId = string.Empty;
            ParentCategoryGId = string.Empty;

            foreach (DataRow DrMetadataCategory in DtMetadataCategory.Rows)
            {
                CategoryGId = DrMetadataCategory["CategoryGId"].ToString();
                CategoryName = DrMetadataCategory["CategoryName"].ToString();
                CategoryDescription = DrMetadataCategory["CategoryDescription"].ToString();
                ParentCategoryNId = DrMetadataCategory["ParentCategoryNId"].ToString();
                ParentCategoryGId = this.Get_ParentCategoryGId(ParentCategoryNId, DtMetadataCategory);

                Concept = new ConceptType(CategoryGId, CategoryName, CategoryDescription, this.Language, ParentCategoryGId, null);
                this.Handle_All_Languages(Concept, CategoryGId);
                ConceptScheme.Items.Add(Concept);
            }
        }
        public StructuresType(ProvisionAgreementType provisionAgreement, ConstraintType constraint, ProcessType process, 
                              ReportingTaxonomyType reportingTaxonomoy, StructureSetType structureSet, DataStructureType dataStructure, 
                              MetadataStructureType metadataStructure, ConceptSchemeType conceptScheme, 
                              HierarchicalCodelistType hierarchicalCodelist, CodelistType codelist, CategorisationType categorisation, 
                              CategorySchemeType categoryScheme, MetadataflowType metadataFlow, DataflowType dataFlow, 
                              OrganisationSchemeType organisationScheme)
        {
            if (provisionAgreement != null)
            {
                this.provisionAgreementsField = new List<ProvisionAgreementType>();
                this.provisionAgreementsField.Add(provisionAgreement);
            }

            if (constraint != null)
            {
                this.constraintsField = new List<ConstraintType>();
                this.constraintsField.Add(constraint);
            }

            if (process != null)
            {
                this.processesField = new List<ProcessType>();
                this.processesField.Add(process);
            }

            if (reportingTaxonomoy != null)
            {
                this.reportingTaxonomiesField = new List<ReportingTaxonomyType>();
                this.reportingTaxonomiesField.Add(reportingTaxonomoy);
            }

            if (structureSet != null)
            {
                this.structureSetsField = new List<StructureSetType>();
                this.structureSetsField.Add(structureSet);
            }

            if (dataStructure != null)
            {
                this.dataStructuresField = new List<DataStructureType>();
                this.dataStructuresField.Add(dataStructure);
            }

            if (metadataStructure != null)
            {
                this.metadataStructuresField = new List<MetadataStructureType>();
                this.metadataStructuresField.Add(metadataStructure);
            }

            if (conceptScheme != null)
            {
                this.conceptsField = new List<ConceptSchemeType>();
                this.conceptsField.Add(conceptScheme);
            }

            if (hierarchicalCodelist != null)
            {
                this.hierarchicalCodelistsField = new List<HierarchicalCodelistType>();
                this.hierarchicalCodelistsField.Add(hierarchicalCodelist);
            }

            if (codelist != null)
            {
                this.codelistsField = new List<CodelistType>();
                this.codelistsField.Add(codelist);
            }

            if (categorisation != null)
            {
                this.categorisationsField = new List<CategorisationType>();
                this.categorisationsField.Add(categorisation);
            }

            if (categoryScheme != null)
            {
                this.categorySchemesField = new List<CategorySchemeType>();
                this.categorySchemesField.Add(categoryScheme);
            }

            if (metadataFlow != null)
            {
                this.metadataflowsField = new List<MetadataflowType>();
                this.metadataflowsField.Add(metadataFlow);
            }

            if (dataFlow != null)
            {
                this.dataflowsField = new List<DataflowType>();
                this.dataflowsField.Add(dataFlow);
            }

            if (organisationScheme != null)
            {
                this.organisationSchemesField = new List<OrganisationSchemeType>();
                this.organisationSchemesField.Add(organisationScheme);
            }
        }