Skip to content

Instantly share code, notes, and snippets.

View jvanhoesen's full-sized avatar

Joshua Van Hoesen jvanhoesen

View GitHub Profile
@jvanhoesen
jvanhoesen / ZipArchiveRetrieve.cs
Created March 28, 2022 18:49
Retrieving a file from ZipArchive
//Creates a stream from the specified file within the .ZIP file
using (Stream fileStream = zip.OpenRead(info.Name))
{
using(MemoryStream innerStream = new MemoryStream())
{
fileStream.CopyTo(innerStream);
//Create Acumatica file from .Zip file content
fileInfo = new PX.SM.FileInfo(info.Name, null, innerStream.ToArray());
@jvanhoesen
jvanhoesen / ZipArchiveOpenBtn.cs
Created March 28, 2022 19:49
Opens a zip file attached to an Acumatica document
public PXAction<ARInvoice> OpenZip;
[PXButton(CommitChanges = false)]
[PXUIField(DisplayName = "Open .Zip", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update, Enabled = true)]
protected virtual IEnumerable openZip(PXAdapter pxAdapter)
{
if(Base.Document.Current != null)
{
//Retrieves the sample .Zip file from the invoice
Guid zipFile = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current).First();
@jvanhoesen
jvanhoesen / ZipArchiveCreateBtn.cs
Created March 28, 2022 20:22
Button to create .Zip file from files attached to Acumatica document
public PXAction<ARInvoice> CreateZip;
[PXButton(CommitChanges = false)]
[PXUIField(DisplayName = "Create .Zip", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update, Enabled = true)]
protected virtual IEnumerable createZip(PXAdapter pxAdapter)
{
if (Base.Document.Current != null)
{
UploadFileMaintenance uploadFileMaint = PXGraph.CreateInstance<UploadFileMaintenance>();