View ZipArchiveCreateBtn.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); |
View ZipArchiveOpenBtn.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
View ZipArchiveRetrieve.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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()); |
View ZipArchiveIterate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Iterate through all files and retrieve each files ItemInfo containing it's name | |
foreach (ZipArchive.ItemInfo info in zip.GetFiles()) | |
{ | |
//Use file name to retrieve file from .Zip Archive | |
} |
View ZipArchiveOpen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Retrieving .ZIP file attached to Acumatica document | |
PX.SM.FileInfo fileInfo = uploadFileMaint.GetFile(zipFile); | |
if(fileInfo != null) | |
{ | |
//Create a new memory stream from .ZIP file data | |
using (MemoryStream stream = new MemoryStream(fileInfo.BinData)) | |
{ | |
//Create new instance of ZipArchive to interact with .ZIP file | |
using (ZipArchive zip = ZipArchive.CreateFrom(stream, true)) | |
{ |
View FileAddition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (ZipArchive zip = ZipArchive.CreateFrom(zipStream, false)) | |
{ | |
using (MemoryStream fileStream = new MemoryStream()) | |
{ | |
fileStream.Seek(0, SeekOrigin.Begin); | |
file.Write(fileStream); | |
fileStream.Seek(0, SeekOrigin.Begin); |
View ZipArchiveCreate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (MemoryStream zipStream = new MemoryStream()) | |
{ | |
zipStream.Seek(0, SeekOrigin.Begin); | |
//2nd Parameter determines if .Zip is read only | |
using (ZipArchive zip = ZipArchive.CreateFrom(zipStream, false)) | |
{ | |
//Read or write data | |
} | |
} |
View Prefetch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Default implementation | |
public void Prefetch() | |
{ | |
_InventoryItems.Clear(); | |
foreach (InventoryItem item in PXDatabase.SelectRecords<InventoryItem>()) | |
{ | |
_InventoryItems[item.InventoryID.Value] = item; | |
} | |
} |
View Properties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static CacheStaticInfo _staticInfo; | |
private static Type _pXCacheExtensionCollectionType; | |
protected static CacheStaticInfo StaticInfo | |
{ | |
get | |
{ | |
if (_staticInfo == null) | |
{ |
View AAInventoryItemCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal sealed class AAInventoryItemCache : IPrefetchable | |
{ | |
private Dictionary<int, InventoryItem> _InventoryItems = new Dictionary<int, InventoryItem>(); | |
public void Prefetch() | |
{ | |
_InventoryItems.Clear(); | |
foreach (InventoryItem item in AACache<InventoryItem>.SelectRecords()) | |
{ |
NewerOlder