public ActionResult EnrollQRCode(int userId, int eventId, int ticketAmount)
        {
            QRCodeMaker qrcm = new QRCodeMaker(userId, eventId, ticketAmount);

            byte[] bytes = qrcm.GenerateQRCode();
            ViewBag.QRCodeImage = "data:image/png;base64," + Convert.ToBase64String(bytes);

            return(View("PDF"));
        }
Beispiel #2
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    QRCodeMaker gen_ret = new QRCodeMaker();
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to QRCodeMaker constructor!"));
        }
Beispiel #3
0
        static int _m_createQRCode_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    string _encoding_text = LuaAPI.lua_tostring(L, 1);
                    int    _width         = LuaAPI.xlua_tointeger(L, 2);
                    int    _height        = LuaAPI.xlua_tointeger(L, 3);

                    UnityEngine.Color32[] gen_ret = QRCodeMaker.createQRCode(_encoding_text, _width, _height);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
        public MemoryStream CreateDocument(int eventId)
        {
            string CurrentUser = HttpContext.User.Identity.Name;

            MyDatabaseEntities db = new MyDatabaseEntities();

            var user  = db.Users.Where(a => a.EmailID == CurrentUser).FirstOrDefault();
            var Event = db.Events.Where(a => a.EventId == eventId).FirstOrDefault();

            MemoryStream output = new MemoryStream();

            #region Creating PDF
            Chunk chunk; Paragraph line; PdfPTable table; PdfPCell cell; Image image;

            Document  pdf           = new Document(PageSize.A4, 25, 25, 25, 15);
            PdfWriter pdfWriterMail = PdfWriter.GetInstance(pdf, output);
            PdfWriter pdfWriter     = PdfWriter.GetInstance(pdf, Response.OutputStream);
            pdf.Open();

            table = new PdfPTable(2);
            table.WidthPercentage     = 100;
            table.HorizontalAlignment = 0;
            table.SpacingBefore       = 20f;
            table.SpacingAfter        = 30f;

            cell        = new PdfPCell();
            cell.Border = 0;
            image       = Image.GetInstance(Server.MapPath("~\\ticket_example.jpg"));
            image.ScaleAbsolute(200, 150);
            cell.AddElement(image);
            table.AddCell(cell);

            chunk       = new Chunk($"{Event.Name}", FontFactory.GetFont("Arial", 30, Font.NORMAL, BaseColor.RED));
            cell        = new PdfPCell();
            cell.Border = 0;
            cell.AddElement(chunk);
            table.AddCell(cell);

            pdf.Add(table);

            chunk = new Chunk("Event's Informations", FontFactory.GetFont("Arial", 15, Font.BOLDITALIC, BaseColor.GREEN));
            pdf.Add(chunk);

            line = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_RIGHT, 1)));
            pdf.Add(line);

            table = new PdfPTable(2);
            table.WidthPercentage     = 100;
            table.HorizontalAlignment = 0;
            table.SpacingBefore       = 20f;
            table.SpacingAfter        = 30f;

            chunk       = new Chunk($"EventId :{Event.EventId} \nType: {Event.Type}", FontFactory.GetFont("Arial", 15, Font.NORMAL, BaseColor.BLACK));
            cell        = new PdfPCell();
            cell.Border = 0;
            cell.AddElement(chunk);
            table.AddCell(cell);

            TimeSpan time = (TimeSpan)Event.Time;

            chunk       = new Chunk($"Date: {Event.Date.ToString("dd.MM.yyyy")}\nTime: {time.Hours}:{time.Minutes} \nLocalization: {Event.Localization}", FontFactory.GetFont("Arial", 15, Font.NORMAL, BaseColor.BLACK));
            cell        = new PdfPCell();
            cell.Border = 0;
            cell.AddElement(chunk);
            table.AddCell(cell);

            pdf.Add(table);

            chunk = new Chunk("Participant's Personal Informations", FontFactory.GetFont("Arial", 15, Font.BOLDITALIC, BaseColor.GREEN));
            pdf.Add(chunk);

            line = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1)));
            pdf.Add(line);

            table = new PdfPTable(1);
            table.WidthPercentage     = 50;
            table.HorizontalAlignment = 0;
            table.SpacingBefore       = 20f;
            table.SpacingAfter        = 30f;

            chunk       = new Chunk($"UserId :{user.UserId} \nName: {user.FirstName} \nLast Name: {user.LastName}", FontFactory.GetFont("Arial", 15, Font.NORMAL, BaseColor.BLACK));
            cell        = new PdfPCell();
            cell.Border = 0;
            cell.AddElement(chunk);
            table.AddCell(cell);

            pdf.Add(table);

            line = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1)));
            pdf.Add(line);

            QRCodeMaker qrcm      = new QRCodeMaker(Convert.ToInt32(Event.EventId), Event.Type, Event.Name, Event.Localization, Event.Date, time);
            byte[]      byteImage = qrcm.GenerateQRCode();
            image = Image.GetInstance(byteImage);
            image.ScaleAbsolute(100, 100);
            image.Alignment = 2;
            pdf.Add(image);

            pdfWriter.CloseStream     = false;
            pdfWriterMail.CloseStream = false;
            pdf.Close();
            TempData["PDF"] = pdf;
            #endregion

            output.Position = 0;

            return(output);
        }