예제 #1
0
        protected override bool Process(Player player, RealmTime time, string[] args)
        {
            var giftCode = player.Client.Account.NextGiftCode();

            if (giftCode == null)
            {
                player.SendError("No new giftcode found.");
                return(false);
            }

            var data        = AccountDataHelper.GenerateAccountGiftCodeData(player.AccountId, giftCode).Write();
            var qrGenerator = new QrCodeGenerator();
            var qrCode      = qrGenerator.CreateQrCode($"{Program.Settings.GetValue<string>("serverDomain")}/account/redeemGiftCode?data={data}", QrCodeGenerator.EccLevel.H);
            var bmp         = qrCode.GetGraphic(5);
            var rgbValues   = bmp.GetPixels();

            player.Client.SendPacket(new PicPacket
            {
                BitmapData = new BitmapData
                {
                    Bytes  = rgbValues,
                    Height = bmp.Height,
                    Width  = bmp.Width
                }
            });
            return(true);
        }
        public IActionResult OnGet([FromQuery] string url)
        {
            //Gera a imagem do QRCode com array de bytes
            var image = QrCodeGenerator.GenerateByteArray(url);

            return(File(image, "image/jpeg"));
        }
예제 #3
0
 public QrCodeHelper(string documentCode, IExecutor executor)
 {
     _qrCodeGenerator  = new QrCodeGenerator();
     _docxInsertHelper = new DocxInsertHelper();
     _documentCode     = documentCode;
     _executor         = executor;
 }
예제 #4
0
 public void UploadQrImages(List <MatchSeatTicketInfo> matchSeatTicketInfos, ImageType imageType)
 {
     try
     {
         var clientId     = _settings.GetConfigSetting <string>(SettingKeys.Messaging.Aws.S3.AccessKey);
         var clientSecret = _settings.GetConfigSetting <string>(SettingKeys.Messaging.Aws.S3.SecretKey);
         var bucketName   = _settings.GetConfigSetting <string>(SettingKeys.Messaging.Aws.S3.BucketName);
         foreach (var item in matchSeatTicketInfos)
         {
             using (var stream = QrCodeGenerator.GetQrcodeStream(item.BarcodeNumber))
             {
                 using (IAmazonS3 s3Client = new AmazonS3Client(clientId, clientSecret, RegionEndpoint.GetBySystemName("us-west-2")))
                 {
                     var transferUtility = new TransferUtility(s3Client);
                     {
                         transferUtility.Upload(stream, bucketName, ImageFilePathProvider.GetImageFilePath(item.BarcodeNumber, imageType));
                     };
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _logger.Log(LogCategory.Error, ex);
     }
 }
예제 #5
0
        private async Task InitQRCode()
        {
            // this is vaild for 10 minutes
            _uuid      = Guid.NewGuid().ToString();
            _gotQRCode = await QrCodeGenerator.RequestNew_QR_Code(_uuid, ApplicationStateManager.RigID());

            if (_gotQRCode)
            {
                // create qr code
                var(image, ok) = QrCodeImageGenerator.GetQRCodeImage(_uuid);
                if (ok)
                {
                    rect_qrCode.Fill          = image;
                    ScanLabel.Content         = "Scan with official NiceHash mobile application";
                    ScanConfirmButton.Content = "Confirm scan";
                }
                else
                {
                    ScanLabel.Content            = "QR Code image generation failed";
                    ScanConfirmButton.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                ScanConfirmButton.Visibility = Visibility.Collapsed;
                ScanLabel.Content            = "Unable to retreive QR Code";
                //ScanConfirmButton.Content = "Retry QR code";
            }
        }
예제 #6
0
        public IActionResult GetQrCode(string text)
        {
            if (text is not null)
            {
                var imageT = QrCodeGenerator.GenerateByteArray(text);
                return(File(imageT, "image/jpeg"));;
            }

            return(RedirectToAction(actionName: "Index", controllerName: "Home"));
        }
예제 #7
0
        public IActionResult GetByUrl([FromQuery] string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                url = "https://medium.com/@marcosvinicios_net";
            }
            var image = QrCodeGenerator.GenerateByteArray(url);

            return(File(image, "image/jpeg"));
        }
예제 #8
0
 /// <summary>
 /// 生成为SVG字符串
 /// </summary>
 /// <param name="content">二维码内容</param>
 /// <param name="pixelsPerModule">单元像素</param>
 /// <returns></returns>
 public string GeneratorToSvg(string content, int pixelsPerModule = 20)
 {
     using (var qrGenerator = new QrCodeGenerator())
     {
         using (var qrCodeData = qrGenerator.CreateQrCode(content, QrCodeGenerator.EccLevel.Q))
         {
             using (var qrCode = new SvgQrCode(qrCodeData))
             {
                 return(qrCode.GetGraphic(pixelsPerModule));
             }
         }
     }
 }
예제 #9
0
 /// <summary>
 /// 生成为ascii字符串数组
 /// </summary>
 /// <param name="content">二维码内容</param>
 /// <param name="pixelsPerModule">单元像素</param>
 /// <returns></returns>
 public string[] GeneratorToAsciiArr(string content, int pixelsPerModule = 20)
 {
     using (var qrGenerator = new QrCodeGenerator())
     {
         using (var qrCodeData = qrGenerator.CreateQrCode(content, QrCodeGenerator.EccLevel.Q))
         {
             using (var qrCode = new AsciiQrCode(qrCodeData))
             {
                 return(qrCode.GetLineByLineGraphic(pixelsPerModule));
             }
         }
     }
 }
예제 #10
0
        public void DownloadImage(string altId, ImageType imageType)
        {
            try
            {
                var clientId     = _settings.GetConfigSetting <string>(SettingKeys.Messaging.Aws.S3.AccessKey);
                var clientSecret = _settings.GetConfigSetting <string>(SettingKeys.Messaging.Aws.S3.SecretKey);
                var bucketName   = _settings.GetConfigSetting <string>(SettingKeys.Messaging.Aws.S3.BucketName);

                QrCodeGenerator.GenerateQrCode(altId);
                var s3Client        = new AmazonS3Client(clientId, clientSecret, RegionEndpoint.GetBySystemName("us-west-2"));
                var transferUtility = new TransferUtility(s3Client);
                transferUtility.Download(Path.Combine(QrCodeGenerator.ApplicationPath(), ImageFilePathProvider.GetImageFilePath(altId, imageType)), bucketName, ImageFilePathProvider.GetImageFilePath(altId, imageType));
            }
            catch (Exception ex)
            {
                _logger.Log(LogCategory.Error, ex);
            }
        }
        public async Task <IActionResult> Get2FaInfo()
        {
            var user = await _userService.FindAsync(int.Parse(User.Identity.Name));

            if (!_twoFactorAuthenticatorManager.GenerateResult(user.Email.Value, "localhost", out var result))
            {
                throw new Exception("Can't generate valid 2FA data");
            }

            var token = _jsonWebTokenService.CreateTwoFactorToken(user, result.Secret);

            return(Ok(new SuccessResult <CreateTwoFactorResponseModel>
            {
                Data = new CreateTwoFactorResponseModel
                {
                    Base64QrCode = QrCodeGenerator.StringAsBase64ImageData(result.ToString()),
                    Secret = result.Secret,
                    SecurityToken = token.TokenString
                }
            }));
        }
예제 #12
0
        static void Main(string[] args)
        {
            var normalData = new QrData
            {
                Header  = new QrHeader(),
                CdtrInf = new QrCdtrInf
                {
                    IBAN = "CH8300700114000048160",
                    Cdtr = new QrCdtr
                    {
                        Name   = "Pascal Lüscher",
                        StrtNm = "Bernstrasse",
                        BldgNb = "159",
                        PstCd  = "4852",
                        TwnNm  = "Rothrist",
                        City   = "CH"
                    }
                },
                CcyAmtDate = new QrCcyAmtDate
                {
                    Amt         = 123456789.12654655m,
                    Ccy         = QrCcyAmtDate.CurrencySelection.CHF,
                    ReqdExctnDt = DateTime.Today.AddDays(30)
                },
                RmtInf = new QrRmtInf
                {
                    Tp    = QrRmtInf.TpSelection.NON,
                    Ref   = "",
                    Ustrd = ""
                }
            };



            QrCodeGenerator.Generate(normalData, "E:\\temp\\outputNormal.png");
            normalData.RmtInf.Tp    = QrRmtInf.TpSelection.QRR;
            normalData.RmtInf.Ref   = "210000000003139471430009017";
            normalData.RmtInf.Ustrd = "uftrag vom15.09.2019##S5.09.2019##S1/01/20170309/11/10201409/20/14000000/22/36958/30/CH106017086/40/1020/41/3010";
            QrCodeGenerator.Generate(normalData, "E:\\temp\\outputRef.png");
        }
예제 #13
0
        private async Task ProcessQRCode()
        {
            stopWatch = new Stopwatch();
            stopWatch.Start();

            var rigID = ApplicationStateManager.RigID();
            var res   = await QrCodeGenerator.RequestNew_QR_Code(_uuid, rigID);

            if (!res)
            {
                lbl_qr_status.Visibility = Visibility.Visible;
                lbl_qr_status.Content    = "Unable to retreive QR Code";
                return;
            }

            var(image, ok) = QrCodeImageGenerator.GetQRCodeImage(_uuid, GUISettings.Instance.DisplayTheme == "Light");

            if (!ok)
            {
                lbl_qr_status.Visibility = Visibility.Visible;
                lbl_qr_status.Content    = "QR Code image generation failed";
                return;
            }

            rect_qrCode.Fill = image;
            while (true)
            {
                await Task.Delay(5000);

                if (stopWatch.ElapsedMilliseconds >= (1000 * 60 * 10))
                {
                    lbl_qr_status.Visibility = Visibility.Visible;
                    btn_gen_qr.Visibility    = Visibility.Visible;
                    lbl_qr_status.Content    = Translations.Tr("QR Code timeout. Please generate new one.");
                    return;
                }
            }
        }
예제 #14
0
파일: QrCode.cs 프로젝트: Hugoberry/WEB
 public QrCode(IExecutor executor) : base(executor)
 {
     _qrCodeGenerator = new QrCodeGenerator();
 }
예제 #15
0
        public IActionResult OnGet([FromQuery] string url)
        {
            var image = QrCodeGenerator.GenerateByteArray(url);

            return(File(image, "image/jpeg"));
        }
예제 #16
0
        public IActionResult GetQrCode()
        {
            var imageQr = QrCodeGenerator.GenerateByteArray("https://docs.microsoft.com/pt-br/dotnet/");

            return(File(imageQr, "image/jpeg"));
        }
예제 #17
0
 public void OnGet()
 {
     Image = QrCodeGenerator.GenerateByteArray("https://balta.io");
 }
예제 #18
0
        public byte[] Encode(string sysPrimaryKey, string qrInfo)
        {
            List <string> encodes        = new List <string>();
            var           reportResponse = reportRep.Get(new Nest.DocumentPath <es_t_bp_item>(sysPrimaryKey));
            string        result         = string.Empty;
            string        reportNum      = string.Empty;

            if (reportResponse.IsValid && reportResponse.Source != null)
            {
                var reportItem = reportResponse.Source;

                reportNum = reportItem.REPORTNUM;

                encodes.Add(GetEncodeString(reportItem.REPORTNUM));   //报告编号
                encodes.Add(GetEncodeString(reportItem.PROJECTNAME)); //工程名称
                encodes.Add(GetEncodeString(reportItem.STRUCTPART));  //工程部位
                string itemName = reportItem.ITEMCHNAME;
                string parmName = string.Empty;
                //var subItem = itemNameService.GetItemByItemCode(reportItem.SUBITEMCODE);
                //if (subItem != null)
                //{
                //    itemName = subItem.itemname;
                //}
                //if (itemName.IsNullOrEmpty())
                //{
                //    itemName = reportItem.SUBITEMCODE;
                //}

                //var parmItem = itemNameService.GetItemByParamCode(reportItem.PARMCODE);
                //if (parmItem != null)
                //{
                //    parmName = parmItem.parmname;
                //}
                //if (parmName.IsNullOrEmpty())
                //{
                //    parmName = reportItem.PARMCODE;
                //}

                encodes.Add(GetEncodeString(itemName));                //CheckItem
                encodes.Add(GetEncodeString(parmName));                //CheckParam
                encodes.Add(GetConclusion(reportItem.CONCLUSIONCODE)); //检测结论
                //报告日期
                if (reportItem.PRINTDATE.HasValue)
                {
                    encodes.Add(reportItem.PRINTDATE.Value.ToString("yyyy年MM月dd日"));
                }
                else
                {
                    encodes.Add(defalutStr);
                }
                //encodes.Add(GetEncodeString(reportItem.QRCODEBAR)); //见证取样二维码
                //sencodes.Add(GetEncodeString(reportItem.ITEMNAME));  //检测项目代号
                if (reportItem.CODEBAR.IsNullOrEmpty())
                {
                    encodes.Add(GetEncodeString("委托送检")); //防伪标记
                }
                else
                {
                    encodes.Add(GetEncodeString("见证取样")); //防伪标记
                }
            }

            string encodeStr = string.Join("|", encodes) + "|";

            result = ConvertToUnicode(encodeStr);
            string content = Of_stringToHex(result, ToInt(reportNum)) + (ToInt(reportNum) + 256).ToString();

            return(QrCodeGenerator.Generate(3, content));
        }