/// <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); } }
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> /// Builds the specified writer engine. /// </summary> /// <param name="writer">The writer.</param> /// <param name="actions">The actions.</param> /// <returns> /// The <see cref="IStructureWriterManager" />. /// </returns> /// <exception cref="Org.Sdmxsource.Sdmx.Api.Exception.SdmxSemmanticException">Unsupported format.</exception> public IStructureWriterManager Build(XmlWriter writer, Queue <Action> actions) { actions.RunAll(); IStructureWriterManager structureWritingManager; switch (this._schema.EnumType) { case SdmxSchemaEnumType.VersionTwo: structureWritingManager = this._endpoint == WebServiceEndpoint.EstatEndpoint ? new StructureWriterManager(new SdmxStructureWriterV2Factory(writer)) : new StructureWriterManager(new SdmxStructureWriterFactory(writer)); break; case SdmxSchemaEnumType.VersionTwoPointOne: structureWritingManager = new StructureWriterManager(new SdmxStructureWriterFactory(writer)); break; default: throw new SdmxSemmanticException(string.Format("Unsupported format {0}", this._schema)); } return(structureWritingManager); }