Welcome!

This community is for professionals and enthusiasts of the Genio platform.
Share your questions and challenges, and help your partners!

1

1
Pedro Galhardo
On 1/31/22, 6:27 PM

Yes, but you should not do it.

 
Why it should not be done

A QR code is, basically, a way of displaying text that cameras can easily read. Assuming the database already contains the information behind the QR code, storing its image representation (in bytes) would be a duplication of the information. Since the cost of storing an image (in bytes) is much higher than storing a simple text, the size of each record could significantly increase. For this reason alone, the QR code should be generated on demand, rather than being stored in the database.

Additionally, note that the server-side manual code to support this behavior will not be taken into consideration by the reindex steps: reindexing the database will not automatically update the stored QR code image.


How to generate the QR code on demand

As you mentioned, Genio currently offers a way to generate the QR code on demand, based on a given text input. Additional information regarding this topic can be found in https://geniodoc.quidgest.net/patterns/field-types/text#qr-code.

To support more complex use cases, such as displaying QR codes in SSRS reports, additional steps might be required to take. For a more in-depth guide on how to use a QR code in a SSRS report, please visit https://geniodoc.quidgest.net/guides/how-to-use-a-qr-code-in-a-ssrs-report.

Despite this, if you still find necessary to store the QR code image representation in the database, here is how you can do it using C#.

Solution

  1. Create an image field that will be used to store the QR code.

  2. Use manual C# code to change the value of the field before the record is saved. Use: Platform: CS | Type: BEFOREUPDATE | Parameters: <Table Name>.

  3. Implement the body of the function. Example for a table called "Album":

    // We will need:
    // - a field with the source data (in this case, "LINKSRC")
    // - a blank field to fill with the result (in this case, "QRCODE")

    // Get the input text from the source field string inputText = (string)returnValueField("album.linksrc"); // Get the byte array that represents the image of the QR code byte[] bytes = GlobalFunctions.StringToQRcode(inputText);

    // Update the value of the field
    insertNameValueField("album.qrcode", bytes);
    return StatusMessage.OK();


Keep Informed

About the Community

This platform is for beginners and experts willing to share their Genio knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers. Read Guidelines

Question tools

43 follower(s)

Stats

Asked: 1/28/22, 7:43 AM
Seen: 1529 times
Last updated: 1/31/22, 6:41 PM