예제 #1
0
 public SdmxStructureFormat(StructureOutputFormat structureFormat)
 {
     if (structureFormat == null)
     {
         throw new ArgumentException("STRUCTURE_OUTPUT_FORMAT can not be null");
     }
     this._structureFormat = structureFormat;
 }
예제 #2
0
        /// <summary>
        /// Call CreateDSD and Write SdmxObject in XElement Streaming to return with processed metadata result
        /// </summary>
        /// <returns>Object for Write response in streaming <see cref="IFlyWriterBody"/></returns>
        public virtual IFlyWriterBody WriteDSD()
        {
            try
            {
                ISdmxObjects sdmxObject = CreateDSD();
                sdmxObject.Action = DatasetAction.GetFromEnum(DatasetActionEnumType.Append);

                //Oggetto che crea l'output
                StructureWriterManager swm = new StructureWriterManager();

                StructureOutputFormat sofType = null;
                if (VersionTypeResp == SdmxSchemaEnumType.VersionTwo)
                {
                    sofType = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument);
                }
                else if (VersionTypeResp == SdmxSchemaEnumType.VersionTwoPointOne)
                {
                    sofType = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV21StructureDocument);
                }
                else
                {
                    throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.UnrecognizedVersion, new Exception("Version: " + VersionTypeResp.ToString()));
                }
                SdmxStructureFormat sof = new SdmxStructureFormat(sofType);

                //IStructureFormat

                //Dove metto il risultato Stream
                IFlyWriterBody WriterBody = new FlyMetadataWriterBody()
                {
                    StructureFormat = sof,
                    SdmxObject      = sdmxObject
                };
                FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Create Callback for Writing SDMXObject");
                return(WriterBody);
                //MemoryStream ms = new MemoryStream();
                //swm.WriteStructures(sdmxObject, sof, ms);
                //ms.Position = 0;
                //StreamReader rdr = new System.IO.StreamReader(ms);
                //ms.Position = 0;
                //string DSDris = rdr.ReadToEnd();
                //return XElement.Parse(DSDris);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateSdmxObjectError, ex);
            }
        }
        private void SaveSdmxOBJ(ISdmxObjects SdmxOBJ, string FileName)
        {
            if (SdmxOBJ == null)
            {
                return;
            }

            StructureWriterManager swm     = new StructureWriterManager();
            StructureOutputFormat  sofType = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument);
            SdmxStructureFormat    sof     = new SdmxStructureFormat(sofType);
            string FullNamePath            = Path.Combine(Utils.GetTreeCachePath(), FileName);

            using (Stream ms = File.Create(FullNamePath))
            {
                swm.WriteStructures(SdmxOBJ, sof, ms);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SdmxStructureXmlFormat" /> class.
        /// </summary>
        /// <param name="sdmxOutputFormat">The SDMX output format.</param>
        /// <param name="endpoint">The endpoint.</param>
        /// <param name="xmlWriter">The XML writer.</param>
        /// <param name="actions">The actions.</param>
        /// <exception cref="System.ArgumentNullException">
        /// sdmxOutputFormat
        /// or
        /// xmlWriter
        /// </exception>
        /// <exception cref="ArgumentNullException"><paramref name="sdmxOutputFormat" /> is <see langword="null" />.</exception>
        public SdmxStructureXmlFormat(StructureOutputFormat sdmxOutputFormat, WebServiceEndpoint endpoint, XmlWriter xmlWriter, Queue<Action> actions)
        {
            if (sdmxOutputFormat == null)
            {
                throw new ArgumentNullException("sdmxOutputFormat");
            }

            if (xmlWriter == null)
            {
                throw new ArgumentNullException("xmlWriter");
            }

            this._sdmxOutputFormat = sdmxOutputFormat;
            this._endpoint = endpoint;
            this._xmlWriter = xmlWriter;
            this._actions = actions;
        }
예제 #5
0
        private void SaveSDMXFile(ISdmxObjects sdmxObjects, StructureOutputFormatEnumType version, string outputFileName)
        {
            StructureWriterManager swm = new StructureWriterManager();

            StructureOutputFormat soFormat     = StructureOutputFormat.GetFromEnum(version);
            IStructureFormat      outputFormat = new SdmxStructureFormat(soFormat);

            MemoryStream memoryStream = new MemoryStream();

            swm.WriteStructures(sdmxObjects, outputFormat, memoryStream);


            byte[] bytesInStream = memoryStream.ToArray();
            memoryStream.Close();

            SendAttachment(bytesInStream, outputFileName);
        }
 /// <summary>
 /// Gets the stream controller.
 /// </summary>
 /// <param name="structureOutputFormat">The structure output format.</param>
 /// <param name="sdmxObjects">The SDMX objects.</param>
 /// <param name="encoding">The encoding.</param>
 /// <returns>The <see cref="IStreamController{XmlWriter}" />.</returns>
 private IStreamController<Stream> GetStreamController(StructureOutputFormat structureOutputFormat, ISdmxObjects sdmxObjects, Encoding encoding)
 {
     IStreamController<Stream> streamController =
         new StreamController<Stream>(
             (writer, queue) =>
                 {
                     using (var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings() { Encoding = encoding }))
                     {
                         IStructureFormat format = new SdmxStructureXmlFormat(structureOutputFormat, WebServiceEndpoint.StandardEndpoint, xmlWriter, queue);
                         this._writerManager.WriteStructures(sdmxObjects, format, null);
                     }
                 });
     return streamController;
 }
 /// <summary>
 ///     Gets the stream controller.
 /// </summary>
 /// <param name="endpoint">The endpoint.</param>
 /// <param name="structureOutputFormat">The structure output format.</param>
 /// <param name="sdmxObjects">The SDMX objects.</param>
 /// <returns>The <see cref="IStreamController{XmlWriter}" />.</returns>
 private IStreamController<XmlWriter> GetStreamController(WebServiceEndpoint endpoint, StructureOutputFormat structureOutputFormat, ISdmxObjects sdmxObjects)
 {
     IStreamController<XmlWriter> streamController =
         new StreamController<XmlWriter>(
             (writer, queue) =>
             {
                 IStructureFormat format = new SdmxStructureXmlFormat(structureOutputFormat, endpoint, writer, queue);
                 this._writerManager.WriteStructures(sdmxObjects, format, null);
             });
     return streamController;
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StructureResponseGenerator"/> class.
 /// </summary>
 /// <param name="structureManagerBuilder">
 /// The structure manager builder.
 /// </param>
 /// <param name="format">
 /// The format.
 /// </param>
 public StructureResponseGenerator(IWriterBuilder <IStructureWriterManager, XmlWriter> structureManagerBuilder, StructureOutputFormatEnumType format)
 {
     this._structureManagerBuilder = structureManagerBuilder;
     this._sdmxStructureFormat     = new SdmxStructureFormat(StructureOutputFormat.GetFromEnum(format));
 }