public static string writeDiscInvoiceConvertUblToXml(InvoiceType createdUBL, string invoiceType) { //olusturulan xmli diske kaydediyor string xmlPath = ""; if (invoiceType == nameof(EI.Invoice.Invoices)) { xmlPath = invoiceFolderDraftPath + createdUBL.ID.Value + "." + nameof(EI.DocumentType.XML); } else if (invoiceType == nameof(EI.Invoice.ArchiveInvoices)) { xmlPath = archiveFolderPath + createdUBL.ID.Value + "." + nameof(EI.DocumentType.XML); } createInboxIfDoesNotExist(Path.GetDirectoryName(xmlPath)); //dosya yolu yoksa olustur using (FileStream stream = new FileStream(xmlPath, FileMode.Create)) { XmlSerializer xmlSerializer = new XmlSerializer(createdUBL.GetType()); xmlSerializer.Serialize(stream, createdUBL, InvoiceSerializer.GetXmlSerializerNamespace()); } return(xmlPath); //// ////xmli strıng durunde return edıyoruz contentını dondurmek ıcın asagıdakı kodu acarız //using (StringWriter textWriter = new StringWriter()) //{ // XmlSerializer xmlSerializer = new XmlSerializer(createdUBL.GetType()); // xmlSerializer.Serialize(textWriter, createdUBL, InvoiceSerializer.GetXmlSerializerNamespace()); // return textWriter.ToString(); //} }
public static string writeDiscDespatchConvertUblToXml(DespatchAdviceType createdUBL) { //olusturulan xmli diske kaydediyor string xmlPath = FolderControl.createDespatchDocPath(createdUBL.ID.Value, nameof(EI.Direction.DRAFT), nameof(EI.DocumentType.XML)); createInboxIfDoesNotExist(Path.GetDirectoryName(xmlPath)); //dosya yolu yoksa olustur using (FileStream stream = new FileStream(xmlPath, FileMode.Create)) { XmlSerializer xmlSerializer = new XmlSerializer(createdUBL.GetType()); xmlSerializer.Serialize(stream, createdUBL, InvoiceSerializer.GetXmlSerializerNamespace()); } return(xmlPath); //// ////xmli strıng durunde return edıyoruz contentını dondurmek ıcın asagıdakı kodu acarız //using (StringWriter textWriter = new StringWriter()) //{ // XmlSerializer xmlSerializer = new XmlSerializer(createdUBL.GetType()); // xmlSerializer.Serialize(textWriter, createdUBL, InvoiceSerializer.GetXmlSerializerNamespace()); // return textWriter.ToString(); //} }