Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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));
 }