AX2012 is a class that comes with QR code generation, which can be conveniently used in SSRS reports, which shows how to use a QR code in an RDP report, starting with the definition of a temporary table:
The field URL is the string to be used for the QR code, and QRCode is the container type that holds the resulting binary data of the two-dimensional code graphic.
DP class:
classTESTQRCODEDP extends srsreportdataproviderbase{testqrcodetmp qrcodetmp;} [Srsreportdatasetattribute (Tablestr (testqrcodetmp))] Publictestqrcodetmp getqrcodetmp () {Selectqrcodetmp; returnqrcodetmp;} Public voidProcessreport () {container imagecontainer; str URL='http://www.cnblogs.com/duanshuiliu/'; EFDOCQRCODE_BR QRCode=NewEfdocqrcode_br (); Imagecontainer=qrcode.generateqrcode (URL); Qrcodetmp.clear (); Qrcodetmp.url=URL; Qrcodetmp.qrcode=Imagecontainer; Qrcodetmp.insert ();}
This uses the class EFDOCQRCODE_BR to generate two-dimensional code images and saved in the container, from the suffix name should be the Brazilian region feature, the image default to BMP format. This class is a wrapper for the Microsoft.Dynamics.QRCode.Encoder class of. NET, and the AOT's C # Engineering QRCode contains the complete code.
EFDOCQRCODE_BR internally calls the Microsoft.Dynamics.QRCode.Encoder.GetTempFile (), which saves the QR code image after the temporary file, Using Bindata to read temporary file contents to container in Microsoft Dynamics AX, if you do not want to use this temporary file method, you want to implement directly in memory, you can use. NET encoder as follows:
Public voidProcessreport () {Microsoft.Dynamics.QRCode.Encoder QRCode=NewMicrosoft.Dynamics.QRCode.Encoder (); System.Drawing.Bitmap Bitmap; Container Imagecontainer; str URL='http://www.cnblogs.com/duanshuiliu/'; System.IO.MemoryStream MemoryStream=NewSystem.IO.MemoryStream ();Bitmap=qrcode.encode (URL); Bitmap. Save (MemoryStream, System.drawing.imaging.imageformat::get_png ()); Imagecontainer=Binary::constructfrommemorystream (MemoryStream). GetContainer (); Qrcodetmp.clear (); Qrcodetmp.url=URL; Qrcodetmp.qrcode=Imagecontainer; Qrcodetmp.insert ();}
The generated QR code image is encoded in PNG format saved in container, and finally inserted into the temporary table.
Create an SSRS report that uses this RDP as a dataset, which can be used on precision design or auto desgin, such as the following auto design:
The source of the set image is database, and the corresponding MIME type,expression is the data field of the dataset's QR code.
The final preview effect:
Take out your phone and sweep it.
[AX2012 R3] using QR codes in SSRS reports