modern day pattern isn't a sample but a "cookbook" that shows a way to use the FileManagement library to down load diverse data as a .zip file via Microsoft Dynamics NAV in a way that works on all types of customers.
abstractThe aim of this pattern is to allow the clients to down load assorted files as a zip file in its place of downloading separately. On the Microsoft Dynamics NAV web customer, here is the favourite approach of delivering diverse data when you consider that it is likely one of the internet patterns and we can't use the File administration codeunit to location files silently on the desktop.
DescriptionWhen generating studies that incorporates distinctive, and constantly an unknown variety of data, the developer will must tackle the down load which also depends on the customer the consumer is on. The issue is that the Microsoft Dynamics NAV windows client has entry to the user's file gadget, whereas the web customer does not. Following web instructions, and the proven fact that client-facet .net is not attainable in net customer, that you would be able to't initiate multiple downloads which requires the developer respond to the category of client. In some browsers it is feasible to download information one-through-one in the net client by using a ascertain dialog, however here's a hack and may not be used.
To clear up this issue, a ordinary down load mechanism is used that is client based adventure when diverse info should be downloaded. For the internet customer, the files are compressed the usage of ZIP, and for the home windows client the info are downloaded without delay to the file gadget.
The pattern is usable for all objects that output dissimilar data and is attainable in each home windows client and net client.
usageThe sample includes two steps: 1) Gathering the information and a couple of) downloading the file(s)
For first step contains a loop that goes during the info that must be downloaded. whether it is on the web client, the information are delivered to a zip archive server-side the use of a naming conference described with the aid of the combination characteristic GetSeriesFileName. This feature takes a filename and number, and transforms it to interesting names following a significant deterministic sample e.g. prepend an integer before the file extension. The same feature is used when the temporary info are created server facet, so the information can be found deterministically later. This eliminates the want for storing filenames and subsequently permits an arbitrary variety of info. The 2d integration function: GetTotalNumberOfFiles, returns the overall variety of data generated all over the records processing and makes the pattern in a position to handle an arbitrary variety of info.
The 2d step is the in reality download of file(s). For the net customer this incorporates closing the ZIP obtain and downloading via the standard download handler that works within the internet customer. For the Win client, the information are saved without delay to the client right through step one.
Code 1: File loop shows an example implementation of this pattern. ServerFileName is generated initially of the record/codeunit, and is the bottom for GetSeriesFilename. The file that is in reality written to all the way through records processing is stored in a different variable which holds the output from GetSeriesFilename on the present file number. notice; the illustration code will best create a zip file if there definitely are distinct files to be downloaded.
read more on the NAV Design Patterns Wiki....
most fulfilling regards,
Martin Dam at Microsoft construction core Copenhagen
No comments:
Post a Comment