private StringWriter writeTicketToXml(ticket t, client c, administrator admin, L_IckEtS_EF.type tp, IEnumerable <action> actions) { XElement ticket_xml = XMLUtils.ticketToXml(t); ticket_xml.Add(XMLUtils.ownerToXml(c)); ticket_xml.Add(XMLUtils.supervisorToXml(admin)); ticket_xml.Add(new XElement("description", t.description)); ticket_xml.Add(XMLUtils.typeToXml(tp)); ticket_xml.Add(XMLUtils.actionsToXml(actions)); XDocument final = new XDocument(new XDeclaration("1.0", "utf-8", null), ticket_xml); //StringWriter returns encoding utf-16. No worries :) var wr = new StringWriter(); //TODO: Save into file final.Save(wr); return(wr); }
private void export_Click(object sender, EventArgs e) { client c = null; administrator admin = null; type tp = null; IEnumerable <action> actions = null; using (ticket_systemEntities db = new ticket_systemEntities()) { c = new TicketSystemDBQueryable().getClientById(db, t.client_id); admin = new TicketSystemDBQueryable().getAdminById(db, t.admin_id); if (t.id_type != null) { tp = new TicketSystemDBQueryable().getTypeById(db, t.id_type); } actions = new TicketSystemDBQueryable().getTicketActions(db, t.code); StringWriter wr = writeTicketToXml(t, c, admin, tp, actions); Console.Write(wr.GetStringBuilder().ToString()); } }