Skip to content

Instantly share code, notes, and snippets.

@smarenich
Last active March 29, 2016 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarenich/ebfb5399b31b4b694fe8 to your computer and use it in GitHub Desktop.
Save smarenich/ebfb5399b31b4b694fe8 to your computer and use it in GitHub Desktop.
public const string SessionKey = "MyFileImportSessionKey";
public PXAction<GLTran> UploadFileBatch;
[PXUIField(DisplayName = "Upload File as Batches", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = true)]
[PXButton()]
public virtual IEnumerable uploadFileBatch(PXAdapter adapter)
{
//Ask user to upload file, continue if it is OK
if (this.NewFilePanel.AskExt() == WebDialogResult.OK)
{
//Retreaving file from session by key
PX.SM.FileInfo info = PXContext.SessionTyped<PXSessionStatePXData>().FileInfo[SessionKey] as PX.SM.FileInfo;
//Binary data will be inside FileInfo
Byte[] bytes = info.BinData;
//Removing file from session to save memory
System.Web.HttpContext.Current.Session.Remove(SessionKey);
}
return adapter.Get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment