|
18.07.2024, 21:16 | #1 |
Участник
|
dynamicsaxinsight: D365: Download multiple files in X++
Источник: https://dynamicsaxinsight.com/2024/0...-files-in-xpp/
============== Purpose: Demonstrate how can download multiple files in X++. Application: Dynamics 365 for Finance and Operations Business requirement: Business requirement is to let users download multiple files using a single browser session. Solution: We can use the code below to download multiple files using a single browser session. Code class ATLAS_Vend_File_Export{ private void exportFile(TextStreamIo _file, Filename _fileName) { System.IO.StreamReader reader; System.IO.Stream stream; str fileContent; stream = _file.getStream(); stream.Position = 0; reader = new System.IO.StreamReader(stream); fileContent = reader.ReadToEnd(); File::SendStringAsFileToUserNewTab(fileContent, _fileName); }} [ExtensionOf(classStr(File))]final class ATLAS_File_Extension{ public static void SendStringAsFileToUserNewTab(str content, str fileName, System.Text.Encoding encoding = System.Text.Encoding::get_UTF8(), ClassName fileUploadStrategyClassName = classstr(FileUploadTemporaryStorageStrategy)) { System.Byte[] byteArray = encoding.GetBytes(content); System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray); File::SendFileToUserNewTab(stream, fileName, fileUploadStrategyClassName); } public static void SendFileToUserNewTab(System.IO.Stream stream, str fileName, ClassName fileUploadStrategyClassName = classstr(FileUploadTemporaryStorageStrategy)) { Browser br = new Browser(); str downloadUrl; downloadUrl = File::SendFileToTempStore(stream, fileName, fileUploadStrategyClassName, true); if (downloadUrl != "") { br.navigate(downloadUrl, true, false); } else { warning("@ApplicationPlatform:DownloadFailed"); } }} Источник: https://dynamicsaxinsight.com/2024/0...-files-in-xpp/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|