Esempio n. 1
0
        public IActionResult Sample()
        {
            // create object
            var bySquareXmlDocuments = this.CreateSampleBySquareXmlDocument(this.AppSettings.ExternalGenerator);

            // serialize object
            ViewData["XML"] = new BySquareXmlSerializer().SerializeAsXml(bySquareXmlDocuments);

            // generate QR code
            var qrstring = this.Encoder.Encode(bySquareXmlDocuments.Documents[0]);

            // create final image
            var image = new ImageManipulator(this.Environment).CreateQrCodeWithLogo(qrstring);

            ViewData["IMAGE"] = new ImageManipulator(this.Environment).EncodeImageAsBase64String(image);

            // render object
            return(View());
        }
Esempio n. 2
0
        public IActionResult SampleFile()
        {
            var serializer       = new BySquareXmlSerializer();
            var encoder          = new BySquareInternalEncoder();
            var imageManipulator = new ImageManipulator(this.Environment);
            var excelManipulator = new ExcelManipulator(encoder, imageManipulator, null);

            var filePath = Path.Combine(this.Environment.ContentRootPath, "Samples", "platobny_harok.xlsx");

            (_, var bySquareDocuments) = excelManipulator.ReadPaymentList(filePath);

            // alter date to current date
            bySquareDocuments[0].Payments[0].PaymentDueDate = DateTime.Today.AddDays(1);

            ViewData["XML"] = serializer.SerializeAsXml(bySquareDocuments[0]);

            // generate QR code
            var qrstring = this.Encoder.Encode(bySquareDocuments[0]);
            var image    = imageManipulator.CreateQrCodeWithLogo(qrstring);

            ViewData["IMAGE"] = imageManipulator.EncodeImageAsBase64String(image);

            return(View("Sample"));
        }