-2

How can I generate several text files at the same time locally?

I am using the method: throw new PXRedirectToFileException (file, true); ![enter image description here][1]

However, this method only generates 1 text file. I need more than 1 text file to be generated at a time.

                List<object> data1099Misc = new List<object> { };
                ARInvoice ari = Base.Document.Current;
                foreach (xvrFSCab diot in PXSelect<xvrFSCab,
                Where<xvrFSCab.invoiceNbr,
                In<Required<xvrFSCab.invoiceNbr>>>>.Select(Base, ari.InvoiceNbr))
                {
                    data1099Misc.Add(CreatePayerARecord(diot));
                }

                FixedLengthFile flatFile = new FixedLengthFile();

                flatFile.WriteToFile(data1099Misc, sw);
                sw.Flush();
                sw.FlushAsync();
                int cont = 0;
                while ( cont<3)
                {
                    cont = cont + 1;
                    string path = "DIOTJOSE" + ".txt";
                    PX.SM.FileInfo file = new PX.SM.FileInfo(path, null, stream.ToArray());
                    throw new PXRedirectToFileException(file, true);
                }

1 Answers1

0

Acumatica had the same issue when they had to open multiple reports at one click (with RedirectException).

For this reason Acumatica supports multiple RequiredException only for Reports. They have a method called "CombineReport" that works with multiple PXReportRequiredException (PXReportsRedirectList)

Sad part is that they did not make something for other RequiredException or RedirectException

I tried to make my own "Combine" method but I was not able to create it just because the RedirectHelper.TryRedirect method use hardcoded types of the RedirectException inside body instead to use an generic or base object :(