예제 #1
0
        /// <summary>
        /// Génération de la facture
        /// </summary>
        /// <param name="invoice"></param>
        public byte[] GenerateInvoice(Invoice invoice, bool Stockage = false)
        {
            try
            {
                DataInvoice.SOLUTIONS.GENERAL.GENERATOR.DocGeneratorPO docgeneratorpo = GeneratorProvide.GetDocGenerator(1);

                NGLib.COMPONENTS.DOCUMENT.DOCGENERATOR.IDocGeneratorItem result = GeneratorProvide.Generate(docgeneratorpo, invoice); //, new FileInfo(@"C:\TEST\res.pdf")
                if (result == null || result.ContentData == null)
                {
                    return(null);
                }



                if (Stockage)
                {
                    InvoiceProvide.AddFile(invoice, result.ContentData);
                }
                return(result.ContentData);
            }
            catch (Exception ex)
            {
                throw new Exception("GenerateInvoice " + ex.Message);
            }
        }
예제 #2
0
        private Invoice GetInvoice(int idInvoice, int?selectedIDCampaign = null)
        {
            SOLUTIONS.GENERAL.ACCOUNT.AccountProvider accountProvider = new SOLUTIONS.GENERAL.ACCOUNT.AccountProvider(this.Connector);
            SOLUTIONS.GENERAL.ACCOUNT.Account         MyAccount       = accountProvider.GetAccount(this.MyUser.IDAccount);

            SOLUTIONS.INVOICES.CAMPAIGN.Campaign selectedCampaign = null;
            if (selectedIDCampaign.HasValue)
            {
                selectedCampaign = campaignProvider.getCampagne(selectedIDCampaign.Value);                             //  camapgne par default si besoin de création
            }
            Invoice invoice = null;

            if (idInvoice == 0)
            {
                return(null);                // invalide
            }
            if (idInvoice == -2)
            {
                InvoiceCache = null;                  // Force la recréation
            }
            if (idInvoice < 0)
            { // mode création nouvelle facture
                if (InvoiceCache == null)
                {
                    InvoiceCache = this.invoiceProvider.PrepareInvoice(MyAccount, selectedCampaign);
                }
                invoice = this.InvoiceCache;
            }
            else
            {
                invoice = invoiceProvider.GetInvoice(idInvoice);  // en base
            }
            this.ViewBag.invoice = invoice;

            DataInvoice.SOLUTIONS.GENERAL.GENERATOR.DocGeneratorProvider generatorprovider = new SOLUTIONS.GENERAL.GENERATOR.DocGeneratorProvider(this.Connector);
            DataInvoice.SOLUTIONS.GENERAL.GENERATOR.DocGeneratorPO       docgenerator      = generatorprovider.GetDocGenerator(1);
            this.ViewBag.docgenerator = docgenerator;

            return(invoice);
        }
예제 #3
0
        public void GenerateInvoice()
        {
            DataInvoice.GLOBAL.DataInvoiceEnv env = new GLOBAL.DataInvoiceEnv();


            DataInvoice.SOLUTIONS.GENERAL.GENERATOR.DocGeneratorProvider generatorprovider = new DataInvoice.SOLUTIONS.GENERAL.GENERATOR.DocGeneratorProvider(env.Connector);
            DataInvoice.SOLUTIONS.INVOICES.INVOICE.InvoiceProvider       invoiceprovider   = new DataInvoice.SOLUTIONS.INVOICES.INVOICE.InvoiceProvider(env.Connector);

            DataInvoice.SOLUTIONS.GENERAL.GENERATOR.DocGeneratorPO po      = generatorprovider.GetDocGenerator(1);
            DataInvoice.SOLUTIONS.INVOICES.INVOICE.Invoice         invoice = invoiceprovider.GetInvoice(1);

            Console.WriteLine("MODEL GENERATOR " + po.UniqueLabel);
            Console.WriteLine("INVOICE " + invoice.InvoiceTitle);

            System.IO.FileInfo fileout = new System.IO.FileInfo(pathIDrtemp + "test2.pdf");

            System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew();
            generatorprovider.Generate(po, invoice, fileout);
            watch.Stop();


            Console.WriteLine("watch " + watch.ElapsedMilliseconds);
        }