Exemple #1
0
        protected bool CreateQRCodeForSubject(out string qr_code_url)
        {
            qr_code_url = null;

            /* obtain the URL which should be encoded in the QR code (being
             * the back-reference to the object which this report is about,
             * for example a safety incident report */
            var url_of_subject = URLOfSubject;

            if (String.IsNullOrWhiteSpace(url_of_subject))
            {
                Tracing.WarningBkg("Unable to ");
            }
            else
            {
                /* create the qr code */
                var c = new QRCode();
                using (var qr_pic = c.Generate(url_of_subject, Html.cstQRCode_EdgePx, Html.cstQRCode_EdgePx, 20, HRefIdentifierOfSubject))
                {
                    if (qr_pic == null)
                    {
                        Tracing.WarningBkg("Failed to create QR code image");
                    }
                    else
                    {
                        int qr_binid;
                        using (var image = new MemoryStream())
                        {
                            qr_pic.Save(image, ImageFormat.Png);
                            var obj = new WebFileDescriptor()
                            {
                                Contenttype = mime.cstMIMEPNG,
                                EOK         = null,
                                Label       = url_of_subject,
                                LCID        = LCID,
                                URI         = String.Empty,
                                Chunk       = image
                            };
                            /* store the picture */
                            qr_binid = OnBuiltinReportStoreobject(obj);
                        }
                        /* return the reference to the picture */
                        if (qr_binid <= 0)
                        {
                            Tracing.WarningBkg("Could not store QR code image");
                        }
                        else
                        {
                            qr_code_url = MediaURL(qr_binid, null, null, null);
                        }
                    }
                }
            }
            /* if we managed to obtain an url, we deem suceeded */
            return(!String.IsNullOrWhiteSpace(qr_code_url));
        }
Exemple #2
0
 protected int OnBuiltinReportStoreobject(WebFileDescriptor obj)
 {
     if (BuiltinReportStoreobject == null)
     {
         return(-1);
     }
     else
     {
         var payl = new ReportStoreobjectEvent()
         {
             object_to_store = obj,
             BinID           = -1
         };
         BuiltinReportStoreobject(this, payl);
         if (payl != null)
         {
             return(payl.BinID);
         }
         else
         {
             return(-1);
         }
     }
 }