protected void exportAttachmnts()
    {
        var order = Base.Document.Current;

        PXLongOperation.StartOperation(Base, () =>
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (PX.Common.ZipArchive archive = PX.Common.ZipArchive.CreateFrom(stream, false))
                {
                    UploadFileMaintenance upload = PXGraph.CreateInstance <UploadFileMaintenance>();
                    Guid[] uids = PXNoteAttribute.GetFileNotes(Base.Document.Cache, order);
                    foreach (Guid uid in uids)
                    {
                        PX.SM.FileInfo fileInfo = upload.GetFile(uid);
                        archive.AddFile(fileInfo.Name, fileInfo.BinData);
                    }
                }
                PX.SM.FileInfo info = new PX.SM.FileInfo(
                    string.Format("{0}-{1}-Attachmets.zip", order.OrderType, order.OrderNbr),
                    null, stream.ToArray());
                throw new PXRedirectToFileException(info, true);
            }
        });
    }
        public static void TransferDocProcessingCenter(PXGraph graph, CABatch doc, CABatchExt docExt)
        {
            var pcGraph = PXGraph.CreateInstance <CCProcessingCenterMaint>();

            pcGraph.ProcessingCenter.Current = pcGraph.
                                               ProcessingCenter.
                                               Search <CCProcessingCenter.processingCenterID>
                                                   (docExt.ProcessingCenterID);

            var processingCenter = pcGraph.ProcessingCenter.Current;

            if (processingCenter != null)
            {
                var providerIsDirectDeposit = PXMultipleProviderTypeSelectorAttribute.IsProvider <CCProcessingCenter.processingTypeName, IDDPaymentProcessing>(pcGraph.ProcessingCenter.Cache, processingCenter);
                if (providerIsDirectDeposit)
                {
                    IDDPaymentProcessing provider = null;
                    try
                    {
                        Type providerType = PXBuildManager.GetType(processingCenter.ProcessingTypeName, true);
                        provider = (IDDPaymentProcessing)Activator.CreateInstance(providerType);
                        provider.Initialize(pcGraph);
                    }
                    catch (Exception ex)
                    {
                        throw new PXException(Messages.FailedToCreateDirectDepositProvider, ex.Message);
                    }
                    var fileNotes = PXNoteAttribute.GetFileNotes(graph.Views[graph.PrimaryView].Cache, doc);
                    if (fileNotes.Length == 1)
                    {
                        var fileNote = fileNotes[0];
                        UploadFileMaintenance upload = PXGraph.CreateInstance <UploadFileMaintenance>();
                        var    file = upload.GetFile(fileNote);
                        string message;
                        if (!provider.DoTransaction(file.FullName, file.BinData, out message))
                        {
                            throw new PXException(message);
                        }
                        else
                        {
                            docExt.FileTransferTime = DateTime.Now;
                            graph.Views[graph.PrimaryView].Cache.Update(doc);
                            graph.Actions.PressSave();
                        }
                    }
                    else
                    {
                        if (fileNotes.Length > 1)
                        {
                            throw new Exception(Messages.ACHTransferFailMoreThanOneAttachment);
                        }
                        else
                        {
                            throw new PXException(Messages.ACHTransferFailNoAttachment);
                        }
                    }
                }
                else
                {
                    throw new PXException(Messages.ACHTransferFailProviderIsNotForDirectDeposit);
                }
            }
            else
            {
                throw new PXException(Messages.ACHTransferFailNoProcessingCenterSelected);
            }
        }