Пример #1
0
        //public Serializer(IList<Invoice> invoices)
        //{
        //    Invoices = invoices;
        //}



        public void Serialize(IList <Invoice> invoices)
        {
            Invoices = invoices;
            var wrapper = new OdsWrapper();

            wrapper.ExctractXmlFromODS(Paths.InputFolderPath + Path.DirectorySeparatorChar + "template.ods", Paths.InputFolderPath + Path.DirectorySeparatorChar);
            XDocument doc  = XDocument.Load(Paths.InputFolderPath + Path.DirectorySeparatorChar + "content.xml");
            var       root = doc.Root;

            var spreadsheet = root.Descendants()
                              .Where(element => element.Name.LocalName == "spreadsheet")
                              .First();

            AddNewTables(spreadsheet);

            var tables = root.Descendants()
                         .Where(element => element.Name.LocalName == "table")
                         .ToList();


            for (int i = 0; i < Invoices.Count; i++)
            {
                SerializeInvoice(Invoices.ElementAt(i), tables.ElementAt(i));
            }
            doc.Save(Paths.InputFolderPath + "content.xml");
            wrapper.InsertXmlToODS(Paths.InputFolderPath, System.IO.Path.Combine(Paths.OutputFolderPath, "result.ods"));
            TableCount = 3;
        }
Пример #2
0
    public MainWindow() : base(WindowType.Toplevel)
    {
        Build();

        if (System.IO.File.Exists(System.IO.Path.Combine(Paths.OutputFolderPath, "result.ods")))
        {
            var wrapper = new OdsWrapper();
            wrapper.ExctractXmlFromODS(System.IO.Path.Combine(Paths.OutputFolderPath, "result.ods"), System.IO.Path.Combine(Paths.InputFolderPath));
            creditInvoices = serializer.DeSerialize(Paths.InputFolderPath + "content.xml").Where(c => c.Type == InvoiceType.CREDIT).ToList();
            debtInvoices   = serializer.DeSerialize(Paths.InputFolderPath + "content.xml").Where(c => c.Type == InvoiceType.DEBT).ToList();
        }

        populateNodeview(nodeviewCredit, creditInvoices);
        populateNodeview(nodeviewDebt, debtInvoices);

        foreach (var value in Enum.GetValues(typeof(InvoiceType)))
        {
            comboboxType.AppendText(value.ToString());
        }
        comboboxType.Active = 0;
    }