Esempio n. 1
0
        /// <summary>
        /// Sends the specified <paramref name="request"/> to the Web Service defined by <see cref="_config"/>
        /// </summary>
        /// <param name="request">
        /// The <see cref="IComplexStructureQuery"/>
        /// </param>
        /// <returns>
        /// The ISdmxObjects returned by the Web Service
        /// </returns>
        private ISdmxObjects SendQueryStructureRequest(string request)
        {
            string tempFileName = Path.GetTempFileName();

            try
            {
                this.SendRequest(request, tempFileName, RequestType.Structure);

                ISdmxObjects             structureObjects = new SdmxObjectsImpl();
                IStructureParsingManager parsingManager   = new StructureParsingManager(SdmxSchemaEnumType.Null);
                using (var dataLocation = new FileReadableDataLocation(tempFileName))
                {
                    IStructureWorkspace structureWorkspace = parsingManager.ParseStructures(dataLocation);
                    structureObjects = structureWorkspace.GetStructureObjects(false);
                }

                NsiClientValidation.CheckResponse(structureObjects);
                return(structureObjects);
            }
            finally
            {
                // Delete the temporary file
                File.Delete(tempFileName);
            }
        }
        /// <summary>
        /// Sends the specified <paramref name="complexStructureQuery"/> to the Web Service defined by <see cref="_config"/>
        /// </summary>
        /// <param name="complexStructureQuery">The <see cref="IComplexStructureQuery"/></param>
        /// <returns>The ISdmxObjects returned by the Web Service</returns>
        private ISdmxObjects SendQueryStructureRequest(IComplexStructureQuery complexStructureQuery, SDMXWSFunctionV21 sdmxwsFunctionV21)
        {
            IStructureQueryFormat <XDocument> queryFormat = new ComplexQueryFormatV21();

            IComplexStructureQueryFactory <XDocument>        factory = new ComplexStructureQueryFactoryV21 <XDocument>();
            IComplexStructureQueryBuilderManager <XDocument> complexStructureQueryBuilderManager = new ComplexStructureQueryBuilderManager <XDocument>(factory);
            var wdoc = complexStructureQueryBuilderManager.BuildComplexStructureQuery(complexStructureQuery, queryFormat);
            var doc  = new XmlDocument();

            doc.LoadXml(wdoc.ToString());

            string tempFileName = Path.GetTempFileName();

            try
            {
                this.SendRequest(doc, sdmxwsFunctionV21, tempFileName);

                ISdmxObjects             structureObjects = new SdmxObjectsImpl();
                IStructureParsingManager parsingManager   = new StructureParsingManager(SdmxSchemaEnumType.Null);
                using (var dataLocation = new FileReadableDataLocation(tempFileName))
                {
                    IStructureWorkspace structureWorkspace = parsingManager.ParseStructures(dataLocation);

                    structureObjects = structureWorkspace.GetStructureObjects(false);
                }

                NsiClientValidation.CheckResponse(structureObjects);
                return(structureObjects);
            }
            finally
            {
                //Delete the temporary file
                File.Delete(tempFileName);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sends the specified <paramref name="references"/> to the Web Service defined by <see cref="_config"/>
        /// </summary>
        /// <param name="references">The <see cref="IStructureReference"/></param>
        /// <param name="resolveReferences">
        /// The resolve references
        /// </param>
        /// <returns>The QueryStructureResponse returned by the Web Service</returns>
        public ISdmxObjects SendQueryStructureRequest(
            IEnumerable <IStructureReference> references,
            bool resolveReferences)
        {
            var queryStructureRequestBuilderManager = new QueryStructureRequestBuilderManager();

            IStructureQueryFormat <XDocument> queryFormat = new QueryStructureRequestFormat();
            var wdoc = queryStructureRequestBuilderManager.BuildStructureQuery(references, queryFormat, resolveReferences);

            var doc = new XmlDocument();

            doc.LoadXml(wdoc.ToString());

            string tempFileName = Path.GetTempFileName();

            try
            {
                this.SendRequest(doc, SDMXWSFunction.QueryStructure, tempFileName);

                ISdmxObjects             structureObjects = new SdmxObjectsImpl();
                IStructureParsingManager parsingManager   = new StructureParsingManager(SdmxSchemaEnumType.Null);
                using (var dataLocation = new FileReadableDataLocation(tempFileName))
                {
                    IStructureWorkspace structureWorkspace = parsingManager.ParseStructures(dataLocation);
                    structureObjects = structureWorkspace.GetStructureObjects(false);
                }

                NsiClientValidation.CheckResponse(structureObjects);
                return(structureObjects);
            }
            finally
            {
                //delete the temporary file
                File.Delete(tempFileName);
            }
        }
Esempio n. 4
0
        public ISdmxObjects GetDsd(string DsdId, string DsdAgency, string DsdVersion, bool resolseRef = false)
        {
            Logger.InfoFormat(
                CultureInfo.InvariantCulture,
                Resources.InfoGettingStructureFormat3,
                DsdAgency,
                DsdId,
                DsdVersion);



            System.Reflection.Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();
            string path         = System.IO.Path.GetDirectoryName(ass.CodeBase);
            string templateFile = Path.Combine(path, "Model\\XMLQueryTemplate\\DOTSTAT_GetDataStructureDefinition.xml");
            var    doc          = new XmlDocument();

            doc.Load(templateFile);

            var nodesId = doc.GetElementsByTagName("KeyFamily");

            if (nodesId == null || nodesId.Count < 1)
            {
                return(null);
            }
            nodesId[0].InnerText = DsdId;

            var nodeAgency = doc.GetElementsByTagName("Receiver");

            if (nodeAgency == null || nodeAgency.Count < 1)
            {
                return(null);
            }
            nodeAgency[0].Attributes.GetNamedItem("id").Value = DsdAgency;

            string tempFileName = Path.GetTempFileName();

            try
            {
                this.SendRequest(doc, SDMXWSFunction.GetDataStructureDefinition, tempFileName);


                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(tempFileName);


                var codes = xmlDoc.GetElementsByTagName("Code");
                for (int i = 0; i < codes.Count; i++)
                {
                    var val = codes.Item(i).Attributes.GetNamedItem("value");
                    var par = codes.Item(i).Attributes.GetNamedItem("parentCode");
                    if (val != null && par != null && val.Value == par.Value)
                    {
                        codes.Item(i).Attributes.GetNamedItem("parentCode").Value = null;
                    }
                }

                var time_dimensions = xmlDoc.GetElementsByTagName("TimeDimension");
                time_dimensions.Item(0).Attributes.RemoveNamedItem("codelist");

                xmlDoc.Save(tempFileName);

                ISdmxObjects             structureObjects = new SdmxObjectsImpl();
                IStructureParsingManager parsingManager   = new StructureParsingManager(SdmxSchemaEnumType.VersionTwo);

                using (var dataLocation = new FileReadableDataLocation(tempFileName))
                {
                    IStructureWorkspace structureWorkspace = parsingManager.ParseStructures(dataLocation);
                    structureObjects = structureWorkspace.GetStructureObjects(false);
                }

                NsiClientValidation.CheckResponse(structureObjects);
                return(structureObjects);
            }
            finally
            {
                //delete the temporary file
                File.Delete(tempFileName);
            }
        }