Esempio n. 1
0
        public static BitmapSource GetQRCode(string content, int size, string paytype)
        {
            Bitmap bitmap  = QRCodeHelper.Create(content, size);
            IntPtr hbitmap = bitmap.GetHbitmap();
            bool   flag    = paytype == "weixin";
            Bitmap bitmap2;

            if (flag)
            {
                bitmap2 = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "pic\\qrcode1.png");
            }
            else
            {
                bitmap2 = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "pic\\qrcode2.png");
            }
            IntPtr       hbitmap2 = bitmap2.GetHbitmap();
            Bitmap       bitmap3  = QRCodeHelper.MergeQrImg(bitmap, bitmap2, 0.23);
            IntPtr       hbitmap3 = bitmap3.GetHbitmap();
            BitmapSource result   = Imaging.CreateBitmapSourceFromHBitmap(hbitmap3, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            PayHelper.DeleteObject(hbitmap3);
            PayHelper.DeleteObject(hbitmap2);
            PayHelper.DeleteObject(hbitmap);
            bitmap3.Dispose();
            bitmap2.Dispose();
            bitmap.Dispose();
            return(result);
        }
Esempio n. 2
0
        // GET api/common/5
        public string GetQRCode(string url, string logoUrl)
        {
            string result = @"{""returnCode"":""9999"",""returnMsg"":""请输入内容""}";

            if (string.IsNullOrEmpty(url))
            {
                return(result);
            }
            string timeStr = DateTime.Now.ToFileTime().ToString();
            Bitmap bitmap;

            if (string.IsNullOrEmpty(logoUrl))
            {
                bitmap = QRCodeHelper.Create(url);
            }
            else
            {
                bitmap = QRCodeHelper.CreateQRCodeWithLogo(url, logoUrl);
            }
            string fileName = System.Web.HttpContext.Current.Server.MapPath("~") + "\\Images\\" + timeStr + ".jpg";

            bitmap.Save(fileName);                                //保存位图
            string imageUrl = "../../Images/" + timeStr + ".jpg"; //显示图片

            return(@"{""returnCode"":""0000"",""returnMsg"":""" + imageUrl + @"""}");
        }
Esempio n. 3
0
        public virtual int DistanceOf(Point other)
        {
            int x = other.X;
            int y = other.Y;

            return(QRCodeHelper.Sqrt((this.x - x) * (this.x - x) + (this.y - y) * (this.y - y)));
        }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        switch (mode)
        {
        case Mode.QR:
            if (webcamTexture[currentNum] != null)
            {
                _result = QRCodeHelper.Read(webcamTexture[currentNum]);
                Debug.LogFormat("result : " + _result);

                if (_result != "error")
                {
                    id = _result;
                    canvas[0].SetActive(false);
                    canvas[1].SetActive(true);
                    canvas[2].SetActive(false);
                    mode = Mode.Brrow;
                }
            }
            break;

        case Mode.Brrow:
            break;
        }
    }
Esempio n. 5
0
        //生成二维码
        private void BtnCreateQr_BtnClick(object sender, EventArgs e)
        {
            var rows = DataGrid.SelectRows;

            if (rows != null)
            {
                var ids = string.Empty;
                rows.ForEach(p => ids += $"{((AssetsInformation)((UCDataGridViewRow)p).DataSource).id},");
                ids = ids.TrimEnd(',');
                using (var db = new AssetsInformationDB(dbPath))
                {
                    var list = db.Query <AssetsInformation>($"select * from assetsinformation where id in ({ids})");
                    if (list != null && list.Any())
                    {
                        foreach (var item in list)
                        {
                            item.QdPath = QRCodeHelper.CreateQRCodeImage(new QRCodeMsg()
                            {
                                Content   = $"资产编码:{item.AssetCode}\r\n资产名称:{item.AssetName}\r\n资产类型:{item.AssetModel}\r\n管理部门:{item.ManagementDepartment}\r\n使用部门:{item.UseDepartment}\r\n使用状态:{item.UseState}\r\n使用年限:{item.UseDate}\r\n使用地点:{item.UsePlace}\r\n安装日期:{item.InstallationDate}",
                                ImageName = $"{item.AssetCode}{DateTime.Now.ToLongDateString()}{DateTime.Now.Hour}{DateTime.Now.Minute}{DateTime.Now.Second}",
                                FilePath  = $"{Environment.CurrentDirectory}"
                            });
                        }
                        db.UpdateAll(list);
                    }
                }
                FrmTips.ShowTips(this, $"二维码生成成功!", 3000, true, ContentAlignment.MiddleCenter, null,
                                 TipsSizeMode.Large, new Size(200, 80), TipsState.Success);
                GetList();
            }
        }
Esempio n. 6
0
        public IActionResult Post([FromBody] CreateDeviceViewModel deviceViewModel)
        {
            try
            {
                deviceViewModel.Name = deviceViewModel.Name.Trim();

                if (_deviceRepository.List(d => d.Name.Equals(deviceViewModel.Name, StringComparison.OrdinalIgnoreCase)).Any())
                {
                    return(BadRequest("Duplicate device name!"));
                }

                var device = _mapper.Map <Device>(deviceViewModel);

                device.IsDeleted  = false;
                device.IsBorrowed = false;
                device.CreatedOn  = DateTime.Now;
                device.CreatedBy  = User.Identity.Name;

                _deviceRepository.Add(device);

                string qrCodeFileName = $"P{device.Id}_{Guid.NewGuid().ToString().Replace("-", "")}.png";
                string qrCodeContent  = "{\"objectType\":\"" + AssetClassifications.DEVICE + "\",\"objectId\":" + device.Id + "}";

                device.QrCodeImageUrl = QRCodeHelper.GenerateQrCodeImage(qrCodeFileName, qrCodeContent);
                device.QrCodeContent  = qrCodeContent;

                _deviceRepository.Update(device);
                return(Ok());
            }
            catch (Exception EX)
            {
                return(StatusCode(500, EX.Message));
            }
        }
Esempio n. 7
0
        public BitSquare Merge(BitSquare qrCode, int typeNumber, BitMatrix backgroundMatrix)
        {
            if (qrCode == null)
            {
                throw new ArgumentNullException(nameof(qrCode));
            }
            if (backgroundMatrix == null)
            {
                throw new ArgumentNullException(nameof(backgroundMatrix));
            }

            int moduleCount = qrCode.Size;
            var result      = new BitSquare(moduleCount * 3);

            backgroundMatrix.CopyTo(result);

            for (var r = 0; r < moduleCount; r += 1)
            {
                for (var c = 0; c < moduleCount; c += 1)
                {
                    if (QRCodeHelper.IsPositionProbePattern(typeNumber, r, c) ||
                        QRCodeHelper.IsPositionAdjustPattern(typeNumber, r, c))
                    {
                        result.Fill(r * 3, c * 3, 3, 3, qrCode[r, c]);
                    }
                    else
                    {
                        result[r * 3 + 1, c * 3 + 1] = qrCode[r, c];
                    }
                }
            }
            return(result);
        }
        public void CreateQrCode()
        {
            string        host = Request.Url.Host;
            var           port = Request.Url.Port;
            string        str  = "http://" + host + ":" + port + "/Chemical/ShowChemicalDevice?id=" + Request.Form["qrcode"];
            SqlConnection con  = new SqlConnection(ConfigurationManager.ConnectionStrings["SewagePlantIMS"].ConnectionString);

            con.Open();
            string     sqlStr  = "select cd_name from dm_chemical_device where id = " + Request.Form["qrcode"] + ";";
            SqlCommand cmd     = new SqlCommand(sqlStr, con);
            string     cd_name = cmd.ExecuteScalar().ToString();

            con.Close();
            using (var memoryStream = QRCodeHelper.GetQRCode(str, 10))
            {
                System.Drawing.Image img = Image.FromStream(memoryStream);
                img = QRCodeHelper.AddTextToImg(img, cd_name, cd_name);

                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                Response.ContentType = "application/octet-stream";
                //文件名+文件格式 (这里编码采用的是utf-8)
                Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(cd_name + ".png", System.Text.Encoding.UTF8));
                Response.BinaryWrite(ms.ToArray());
                ms.Dispose();
                img.Dispose();
            }
        }
Esempio n. 9
0
        public IActionResult Post([FromBody] CreateProductViewModel productViewModel)
        {
            try
            {
                productViewModel.Name = productViewModel.Name.Trim();

                if (_productRepository.List(p => p.Name.Equals(productViewModel.Name, StringComparison.OrdinalIgnoreCase)).Any())
                {
                    return(BadRequest("Duplicate product name!"));
                }

                var product = _mapper.Map <Product>(productViewModel);
                product.MaxOrderQuantity = 10;
                product.CreatedOn        = DateTime.Now;
                product.CreatedBy        = User.Identity.Name;

                _productRepository.Add(product);

                string qrCodeFileName = $"P{product.Id}_{Guid.NewGuid().ToString().Replace("-", "")}.png";
                string qrCodeContent  = "{\"objectType\":\"" + AssetClassifications.PRODUCT + "\",\"objectId\":" + product.Id + "}";

                product.QrCodeContent  = qrCodeContent;
                product.QrCodeImageUrl = QRCodeHelper.GenerateQrCodeImage(qrCodeFileName, qrCodeContent);

                _productRepository.Update(product);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 10
0
        public ActionResult GetReportQRCode(Guid?ReportId, string ControllerName)
        {
            ReportId = ReportId ?? Guid.Empty;
            var url = Request.Url.ToString().Replace(Request.Url.PathAndQuery, "") + "/" + ControllerName + "/ReportMobileDetail?reportId=" + ReportId.Value;

            return(File(QRCodeHelper.GetQRCodeByteArray(url), "image/Jpeg"));
        }
Esempio n. 11
0
        public ActionResult CreateQrCode()

        {
            string host = Request.Url.Host;
            var    port = Request.Url.Port;

            string str = "http://" + host + ":" + port + "/Home/Detail?id=100";

            using (var memoryStream = QRCodeHelper.GetQRCode(str, 10))
            {
                /*Response.ContentType = "image/jpeg";
                 * Response.OutputStream.Write(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
                 * Response.End();*/
                Image img = Image.FromStream(memoryStream);
                //Graphics graphics = Graphics.FromImage(img);
                string savePath = "C:/Users/11619/Desktop/dsds/123.png";
                img.Save(savePath, ImageFormat.Png);

                AddTextToImg("C:/Users/11619/Desktop/dsds/123.png", "鼓风机房配电柜", "yehongjiang");
                img.Dispose();
                img = Image.FromFile("C:/Users/11619/Desktop/dsds/567.png");
                //下面这段是将image转换为流从而输出到页面的img标签上去
                MemoryStream ms        = new MemoryStream();
                byte[]       imagedata = null;
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                imagedata            = ms.GetBuffer();
                Response.ContentType = "image/jpeg";
                Response.OutputStream.Write(ms.GetBuffer(), 0, (int)ms.Length);
                Response.End();
            }
            return(null);
        }
Esempio n. 12
0
        /// <summary>
        /// 发送支付请求
        /// </summary>
        public void Send()
        {
            WxPayImpl        wxPayImpl = new WxPayImpl();
            HttpResponseBase Response  = null;

            QRCodeHelper.OutPutQRCodeImage(wxPayImpl.RechargeTo("order001", 500, 1, "product"), Response);
        }
Esempio n. 13
0
        public ActionResult Index()
        {
            string          str;
            long            id = base.CurrentUser.Id;
            UserInviteModel memberInviteInfo = ServiceHelper.Create <IMemberInviteService>().GetMemberInviteInfo(id);
            InviteRuleInfo  inviteRule       = ServiceHelper.Create <IMemberInviteService>().GetInviteRule();
            string          host             = base.Request.Url.Host;

            if (base.Request.Url.Port != 80)
            {
                int port = base.Request.Url.Port;
                str = string.Concat(":", port.ToString());
            }
            else
            {
                str = "";
            }
            string str1 = string.Concat(host, str);

            memberInviteInfo.InviteLink = string.Format("http://{0}/Register/index/{1}", str1, id);
            Bitmap       bitmap       = QRCodeHelper.Create(memberInviteInfo.InviteLink);
            MemoryStream memoryStream = new MemoryStream();

            bitmap.Save(memoryStream, ImageFormat.Gif);
            string str2 = string.Concat("data:image/gif;base64,", Convert.ToBase64String(memoryStream.ToArray()));

            memoryStream.Dispose();
            memberInviteInfo.QR = str2;
            Tuple <UserInviteModel, InviteRuleInfo, UserMemberInfo> tuple = new Tuple <UserInviteModel, InviteRuleInfo, UserMemberInfo>(memberInviteInfo, inviteRule, base.CurrentUser);

            return(View(tuple));
        }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="url">存储内容</param>
        /// <param name="pixel">像素大小</param>
        /// <returns></returns>
        public Bitmap GetQRCodeB(string url, int pixel, bool hasLogo = false)
        {
            QRCodeGenerator generator = new QRCodeGenerator();
            QRCodeData      codeData  = generator.CreateQrCode(url, QRCodeGenerator.ECCLevel.M, true);
            QRCode          qrcode    = new QRCode(codeData);
            Bitmap          qrImage   = qrcode.GetGraphic(pixel);

            if (hasLogo)
            {
                System.IO.MemoryStream MStream = new System.IO.MemoryStream();
                qrImage.Save(MStream, ImageFormat.Png);

                System.IO.MemoryStream MStream1 = new System.IO.MemoryStream();
                var logoPath = _host.WebRootPath + "/images/yh_logo_36.png"; // Path.Combine(AppContext.BaseDirectory, "images/yh_logo.png");

                var    resultImg = QRCodeHelper.CombinImage(qrImage, logoPath);
                Bitmap codeImg   = new Bitmap(resultImg);

                return(codeImg);
            }
            else
            {
                return(qrImage);
            }
        }
Esempio n. 15
0
        private string GetQRCode(string verificationCode)
        {
            //string qrCodeImagePath = string.Empty;
            //Image qrcode = Core.Helper.QRCodeHelper.Create(verificationCode);
            //string fileName = DateTime.Now.ToString("yyMMddHHmmssffffff") + ".jpg";
            //qrCodeImagePath = CurrentUrlHelper.CurrentUrl() + "/temp/" + fileName;
            //qrcode.Save(Current.Server.MapPath("~/temp/") + fileName);
            //return qrCodeImagePath;

            string result = "";

            if (!string.IsNullOrWhiteSpace(verificationCode))
            {
                var qrcode = QRCodeHelper.Create(verificationCode);

                Bitmap       bmp = new Bitmap(qrcode);
                MemoryStream ms  = new MemoryStream();
                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] arr = new byte[ms.Length];
                ms.Position = 0;
                ms.Read(arr, 0, (int)ms.Length);
                ms.Close();
                qrcode.Dispose();
                result = Convert.ToBase64String(arr);
                result = "data:image/png;base64," + result;
            }
            return(result);
        }
        public ActionResult CodeGenerate(string code)
        {
            string         accessToken = Common.WeChatPush.WeChatTools.GetAccessoken();
            U_WeChatUserID userInfo    = new U_WeChatUserID();
            string         userInfoStr = Common.WeChatPush.WeChatTools.GetUserInfoByCode(accessToken, code);

            userInfo = Common.JsonHelper.JsonToModel <U_WeChatUserID>(userInfoStr); //用户ID
            //userInfo.UserId = "WangCunBiao";
            var    personInfoModel = _wl.GetUserInfo(userInfo.UserId);              //获取人员表信息
            string file            = personInfoModel.Vguid + ".jpg";
            string forder          = "UploadFile/WeChatQRCode";
            string filePath        = Path.Combine(forder, file);

            string fileName = Server.MapPath(filePath);

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }
            var configStr = _codeGenerateLogic.GetPersonConfiguration(personInfoModel);

            QRCodeHelper.GenerateQRCode(configStr, "/Areas/WeChatPush/Views/_img/logo1.png", forder, file);
            ViewData["Vguid"] = personInfoModel.Vguid;
            ViewData["url"]   = ConfigSugar.GetAppString("OpenHttpAddress") + forder + "/" + file;
            return(View());
        }
Esempio n. 17
0
 private void Update()
 {
     if (_webCam != null)
     {
         Result = QRCodeHelper.Read(_webCam);
     }
 }
Esempio n. 18
0
        public ActionResult Detail(int id = 0)
        {
            ViewBag.Title = "课程详情";

            var vip = GetVipInfo();

            if (vip.FeeStatus != 1)
            {
                return(Content($"<script>alert('没有支付无法观看课程');window.location.href='{Url.Action("Categories")}'</script>"));
            }

            var video = dal.Get <Video>(id);

            if (video == null)
            {
                return(RedirectToAction("Categories"));
            }

            var vipId     = 1;
            var qrImg     = $"~/upload/qrcode/qr{vipId.ToString()}.png";
            var qrImgPath = Server.MapPath(qrImg);

            if (!System.IO.File.Exists(qrImgPath))
            {
                QRCodeHelper.GenerateQRCode($"userid={vipId.ToString()}", qrImgPath);
            }
            ViewBag.QrCodePath = qrImg;

            ViewBag.VideoComments = dal.GetAll <VideoComment>().Where(p => p.VideoId == id).OrderByDescending(p => p.CreatedTime).ToList();

            return(View(video));
        }
Esempio n. 19
0
        static Stream?GetQrCodeStream(IEnumerable <IGAPAuthenticatorDTO> datas)
        {
            var dtos  = datas.Select(x => x.ToLightweightExportDTO()).ToArray();
            var bytes = Serializable.SMP(dtos);

#if DEBUG
            var bytes_compress_gzip = bytes.CompressByteArray();
#endif
            var bytes_compress_br = bytes.CompressByteArrayByBrotli();
#if DEBUG
            Toast.Show($"bytesLength, source: {bytes.Length}, gzip: {bytes_compress_gzip.Length}, br: {bytes_compress_br.Length}");
#endif
            (var result, var stream, var e) = QRCodeHelper.Create(bytes_compress_br);
            switch (result)
            {
            case QRCodeHelper.QRCodeCreateResult.DataTooLong:
                Toast.Show(AppResources.AuthLocal_ExportToQRCodeTooLongErrorTip);
                break;

            case QRCodeHelper.QRCodeCreateResult.Exception:
                e?.LogAndShowT(TAG);
                break;
            }
            return(stream);
        }
Esempio n. 20
0
        public IActionResult Index(string path)
        {
            var qrcode = QRCodeHelper.Generate(path);
            var base64 = QRCodeHelper.BitMapToBase64(qrcode);

            return(Content(base64));
        }
Esempio n. 21
0
        public ActionResult Mesas(int id)
        {
            var QRHelper  = new QRCodeHelper();
            var codeImage = QRHelper.GenerateQRCode(id.ToString(), 120);

            codeImage.Save(Server.MapPath("~/Uploads/mesa" + id + ".png"), ImageFormat.Png);
            return(RedirectToAction("Mesas"));
        }
        //[HttpPost]
        public ActionResult GetORImageContent(string imageName)
        {
            string fileUrl = Server.MapPath("~") + "Img\\QRImage\\" + imageName;
            Bitmap bitMap  = new Bitmap(fileUrl);
            string content = QRCodeHelper.QRCodeDecoderUtil(bitMap);

            return(Content(content));
        }
        public ActionResult QRCode(string url)
        {
            var bit    = QRCodeHelper.GetFile(url);
            var stream = new MemoryStream();

            bit.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
            return(File(stream.ToArray(), "image/bmp"));
        }
        public GeneratePromoCodeResponse GeneratePromoCode(GeneratePromoCodeRequest _request)
        {
            GeneratePromoCodeResponse response = new GeneratePromoCodeResponse();
            var order = (from o in db_Evoucher.TblPurchaseOrders
                         where o.PurchaseOrderNo == _request.PurchaseOrder_No &&
                         o.VoucherGenerated == false
                         select o
                         ).FirstOrDefault();

            if (order != null)
            {
                for (int i = 0; i < order.Quantity; i++)
                {
                    bool   isUnique  = false;
                    string promoCode = StringHelper.GeneatePromo();
                    string qrCodePath;
                    do
                    {
                        isUnique = !(from gp in db_Evoucher.TblGeneratedEvouchers
                                     where gp.PromoCode == promoCode
                                     select true
                                     ).FirstOrDefault();
                    } while (!isUnique);

                    qrCodePath = QRCodeHelper.GenerateQRCode(promoCode);

                    if (qrCodePath != "")
                    {
                        TblGeneratedEvoucher generatedEvoucher = new TblGeneratedEvoucher
                        {
                            ExpiryDate       = order.ExpiryDate,
                            OwnerName        = order.BuyerName,
                            OwnerPhone       = order.BuyerPhone,
                            PromoCode        = promoCode,
                            PurchaseOrderNo  = order.PurchaseOrderNo,
                            QrImagePath      = qrCodePath,
                            Status           = (int)RecordStatus.Active,
                            VoncherAmount    = order.VoncherAmount,
                            VoucherImagePath = order.ImagePath,
                            VoucherNo        = order.VoucherNo
                        };

                        db_Evoucher.TblGeneratedEvouchers.Add(generatedEvoucher);
                    }
                }
                order.VoucherGenerated = true;
            }
            else
            {
                response.StatusCode   = 404;
                response.ErrorType    = "Not-Found";
                response.ErrorMessage = "Record Not Found";
            }
            db_Evoucher.SaveChanges();
            response.PromoCodeGenerated = true;

            return(response);
        }
Esempio n. 25
0
        public ActionResult Index()
        {
            string str;

            ViewBag.WeiXin = false;
            if (!string.IsNullOrWhiteSpace(_siteSetting.WeixinAppId) && !string.IsNullOrWhiteSpace(_siteSetting.WeixinAppSecret) && base.PlatformType == ChemCloud.Core.PlatformType.WeiXin)
            {
                ViewBag.WeiXin = true;
                string        empty        = string.Empty;
                IWXApiService wXApiService = ServiceHelper.Create <IWXApiService>();
                empty = wXApiService.GetTicket(_siteSetting.WeixinAppId, _siteSetting.WeixinAppSecret);
                JSSDKHelper jSSDKHelper = new JSSDKHelper();
                string      timestamp   = JSSDKHelper.GetTimestamp();
                string      noncestr    = JSSDKHelper.GetNoncestr();
                string      signature   = jSSDKHelper.GetSignature(empty, noncestr, timestamp, base.Request.Url.AbsoluteUri);
                ViewBag.Timestamp = timestamp;
                ViewBag.NonceStr  = noncestr;
                ViewBag.Signature = signature;
                ViewBag.AppId     = _siteSetting.WeixinAppId;
            }
            long                        id = base.CurrentUser.Id;
            UserInviteModel             memberInviteInfo   = ServiceHelper.Create <IMemberInviteService>().GetMemberInviteInfo(id);
            InviteRuleInfo              inviteRule         = ServiceHelper.Create <IMemberInviteService>().GetInviteRule();
            MemberIntegralExchangeRules integralChangeRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralChangeRule();

            if (integralChangeRule != null)
            {
                dynamic viewBag = base.ViewBag;
                int     value   = inviteRule.InviteIntegral.Value / integralChangeRule.IntegralPerMoney;
                viewBag.IntergralMoney = value.ToString("f2");
            }
            string host = base.Request.Url.Host;
            string str1 = host;

            if (base.Request.Url.Port != 80)
            {
                int port = base.Request.Url.Port;
                str = string.Concat(":", port.ToString());
            }
            else
            {
                str = "";
            }
            host = string.Concat(str1, str);
            memberInviteInfo.InviteLink = string.Format("http://{0}/Register/index/{1}", host, id);
            inviteRule.ShareIcon        = string.Format("http://{0}{1}", host, inviteRule.ShareIcon);
            Bitmap       bitmap       = QRCodeHelper.Create(memberInviteInfo.InviteLink);
            MemoryStream memoryStream = new MemoryStream();

            bitmap.Save(memoryStream, ImageFormat.Gif);
            string str2 = string.Concat("data:image/gif;base64,", Convert.ToBase64String(memoryStream.ToArray()));

            memoryStream.Dispose();
            memberInviteInfo.QR = str2;
            Tuple <UserInviteModel, InviteRuleInfo, UserMemberInfo> tuple = new Tuple <UserInviteModel, InviteRuleInfo, UserMemberInfo>(memberInviteInfo, inviteRule, base.CurrentUser);

            return(View(tuple));
        }
Esempio n. 26
0
        public void can_render_qrcode_from_helper()
        {
            //Create QR code
            var bmp = QRCodeHelper.GetQRCode("This is a quick test! 123#?", 10, Color.Black, Color.White, QRCodeGenerator.ECCLevel.H);

            var result = HelperFunctions.BitmapToHash(bmp);

            result.ShouldBe("e8c61b8f0455924fe08ba68686d0d296");
        }
Esempio n. 27
0
        public ActionResult QRCodeGenera(string data)
        {
            var          image = QRCodeHelper.QRCode(data);
            MemoryStream ms    = new MemoryStream();

            image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            ms.Position = 0;
            return(File(ms, "image/jpeg"));
        }
Esempio n. 28
0
 void Update()
 {
     if (_webCam != null)
     {
         _result = QRCodeHelper.Read(_webCam);
         Debug.LogFormat("result : " + _result);
     }
     CheckDebugMode();
 }
        public List <string> GetShareImage(int user_id, string appid)
        {
            try
            {
                dm_userEntity dm_UserEntity = GetEntityByCache(user_id);
                if (dm_UserEntity.IsEmpty())
                {
                    throw new Exception("用户信息异常!");
                }
                if (dm_UserEntity.headpic.IsEmpty())
                {
                    throw new Exception("您先上传个人头像!");
                }

                List <string> shareList = new List <string>();

                string basePath = System.AppDomain.CurrentDomain.BaseDirectory.TrimEnd("\\".ToCharArray());

                string newPath1 = "/Resource/ShareImage/Share" + user_id + "1.jpg";
                string newPath2 = "/Resource/ShareImage/Share" + user_id + "2.jpg";
                string newPath3 = "/Resource/ShareImage/Share" + user_id + "3.jpg";

                dm_basesettingEntity dm_BasesettingEntity = dm_BaseSettingService.GetEntityByCache(appid);

                if (File.Exists(basePath + newPath1) && File.Exists(basePath + newPath2) && File.Exists(basePath + newPath3))
                {
                    shareList.Add(dm_BasesettingEntity.qianzhui_image + newPath1);
                    shareList.Add(dm_BasesettingEntity.qianzhui_image + newPath2);
                    shareList.Add(dm_BasesettingEntity.qianzhui_image + newPath3);
                }
                else
                {
                    Bitmap qrCode = QRCodeHelper.Generate3(dm_UserEntity.invitecode, 200, 200, basePath + dm_UserEntity.headpic);

                    //背景图片,海报背景
                    string path1 = basePath + @"/Resource/ShareImage/1.jpg";
                    string path2 = basePath + @"/Resource/ShareImage/2.jpg";
                    string path3 = basePath + @"/Resource/ShareImage/3.jpg";
                    GeneralShareImage(basePath + newPath1, path1, qrCode);
                    shareList.Add(dm_BasesettingEntity.qianzhui_image + newPath1);
                    GeneralShareImage(basePath + newPath2, path2, qrCode);
                    shareList.Add(dm_BasesettingEntity.qianzhui_image + newPath2);
                    GeneralShareImage(basePath + newPath3, path3, qrCode);
                    shareList.Add(dm_BasesettingEntity.qianzhui_image + newPath3);
                }

                return(shareList);
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                throw ExceptionEx.ThrowServiceException(ex);
            }
        }
Esempio n. 30
0
        public async void Test4()
        {
            var i = QRCodeHelper.EncodeQrCode("1234");

            ImageHelper.Save((Bitmap)i, "D:\\1.jpg");



            Assert.True(true);
        }