Ejemplo n.º 1
0
        /// <summary>
        /// 生成红包码
        /// </summary>
        /// <param name="hbUrl0">红包码</param>
        /// <param name="HbDir">收款码保存路径</param>
        /// <returns></returns>
        public static string genHbPic(string hbUrl0, string HbDir)
        {
            string hbUrl   = hbUrl0.Trim();
            string picName = "";

            if (hbUrl.ToLower().StartsWith("https://qr.alipay.com/"))
            {
                picName = hbUrl.Substring("https://qr.alipay.com/".Length) + ".png";
            }
            else
            {
                picName = MD5.Encrypt(hbUrl) + ".png";
            }

            string picPath = AppDomain.CurrentDomain.BaseDirectory + HbDir + picName;

            if (!File.Exists(picPath))
            {
                Bitmap pic = QrTool_HB.ToHbPic(hbUrl);   // 生成红包码
                picName = QrTool_HB.Save(pic, HbDir, picName);
            }

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + HbDir + picName))
            {
                return(picName);
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String hbUrl = Request["p"];

            if (hbUrl == null)
            {
                MainPannel.Style.Add("display", "none");   // 隐藏控件
                return;
            }

            String showPic     = "";
            String downloadPic = "";

            // 制作红包收款码
            string picName = QrTool_HB.genHbPic(hbUrl, "tools\\QRTool\\QR_HB0\\");

            if (!picName.Equals(""))
            {
                String fullPath = "http://" + Request.Params.Get("HTTP_HOST") + "/tools/QRTool/QR_HB0/" + picName;
                showPic = fullPath;           // 显示生成的二维码

                downloadPic  = "http://" + Request.Params.Get("HTTP_HOST") + "/Pages/pic.aspx";
                downloadPic += "?path=" + fullPath + "&reName=000.jpg&download=true";
            }

            //String picHbUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/PageHB/PicHB.aspx";
            //showPic = picHbUrl + "?" + "path=" + HttpUtility.UrlEncode(hbUrl);
            //downloadPic = picHbUrl + "?" + "path=" + HttpUtility.UrlEncode(hbUrl) + "&download=true";

            String scanUrl = "alipayqr://platformapi/startapp?saId=10000007";

            DivPic.InnerHtml      = "<img src=\"" + showPic + "\" width=\"493\" height=\"742\"/>";
            DivDownload.InnerHtml = "<a id=\"HelpLinkHB\" target=\"_blank\" href=\"" + downloadPic + "\"> 或 用浏览器下载</a>";
            DivScan.InnerHtml     = "<a href=\"" + scanUrl + "\"><img src=\"../tools/HB_pic/scan_album.png\" Height=\"84px\" Width=\"538px\"/></a> ";
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String dirPath    = Request["path"];
            String reName     = Request["reName"];
            bool   isDownload = (Request["download"] != null && Request["download"].Equals("true"));

            if (dirPath == null)
            {
                Response.Write(Request.Url + "?" + "path=" + "http://t2.hddhhn.com/uploads/tu/201707/115/56.jpg" + "&" + "reName=" + "0.png" + "&" + "download=" + "false");
            }
            else
            {
                Bitmap img = QrTool_HB.ToHbPic(dirPath);
                if (reName == null)
                {
                    reName = "0.png";
                }

                // 输出图像
                try
                {
                    MemoryStream ms = new MemoryStream();
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                    Response.ClearContent();
                    Response.ContentType = "Image/png";
                    Response.AddHeader("Content-Disposition", (isDownload ? "attachment; " : "") + "filename=" + HttpUtility.UrlEncode(reName, System.Text.Encoding.UTF8));
                    Response.BinaryWrite(ms.ToArray());
                }
                catch (Exception ex) { }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 上传图像,解析二维码信息
        /// </summary>
        /// <param name="uploader">通过FileUpload上传二维码图像</param>
        /// <param name="textQr">解析二维码图像上传至此处</param>
        /// <param name="subDir">Uploads子目录</param>
        /// <returns>返回二维码图像名称,用于显示</returns>
        protected string Upload_Pic(FileUpload uploader, TextBox textQr, string subDir)
        {
            // 设置文件保存目录
            string appPath = Request.PhysicalApplicationPath + @"Uploads\" + subDir + "\\";

            if (!System.IO.Directory.Exists(appPath))
            {
                System.IO.Directory.CreateDirectory(appPath);
            }

            if (uploader.HasFile)
            {
                String fileName = uploader.FileName;
                string savePath = appPath + Server.HtmlEncode(uploader.FileName);    // 生成保存路径

                uploader.SaveAs(savePath);                                           // 保存文件

                Bitmap pic = null;
                // 解析二维码信息
                try
                {
                    pic = (Bitmap)Bitmap.FromFile(savePath);

                    textQr.Text = QrTool_HB.ToCode(pic);     // 解析二维码信息
                    if (textQr.Text.Equals(""))
                    {
                        textQr.Text = "Error:请重新上传有效的二维码图像";
                    }
                    else if (!textQr.Text.ToLower().StartsWith("http://") && !textQr.Text.ToLower().StartsWith("https://"))
                    {
                        textQr.Text = "Error:" + textQr.Text;
                        ScTool.Alert("您上传的二维码未能识别,可能是图像不够清晰,请重新上传!");
                    }
                    else
                    {
                        textQr.Enabled = false;              // 获取到二维码,则不允许修改
                    }
                    pic.Dispose();
                    pic = null;
                }
                catch (Exception ex)
                {
                    textQr.Text = "";
                    pic.Dispose();
                    pic = null;
                }

                //UploadStatusLabel.Text = "Your file was saved as ->" + savePath;
                return(fileName);
            }
            else
            {
                //UploadStatusLabel.Text = "You did not specify a file to upload.";
                return("");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 生成红包收款码
        /// </summary>
        /// <param name="HB_QR">收款码</param>
        /// <param name="Tittle">商家名称</param>
        /// <param name="Id">收款Id</param>
        /// <param name="HbSkDir">收款码保存路径</param>
        /// <returns></returns>
        public static string genHbSkPic(string HB_QR, string Tittle, string Id, string HbSkDir)
        {
            string picName = Id + ".png";
            string picPath = AppDomain.CurrentDomain.BaseDirectory + HbSkDir + picName;

            if (!File.Exists(picPath))
            {
                Bitmap pic = QrTool_HB.ToHbQr(HB_QR, Tittle);   // 生成红包收款码
                picName = QrTool_HB.Save(pic, HbSkDir, Id + ".png");
            }

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + HbSkDir + picName))
            {
                return(picName);
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 记录红包码、二维码、商家名称,返回记录id,生成新的红包收款码供商家收款
        /// </summary>
        /// <param name="e"></param>
        protected void ImageButton_Create_Click(object sender, ImageClickEventArgs e)
        {
            string QrUrl  = TextBox_SK.Text.Trim();     // 收款码
            string HbUrl  = TextBox_HB.Text.Trim();     // 红包码
            string Tittle = TextBox_Tittle.Text.Trim(); // 商家名称

            if (HbUrl.Equals("") || HbUrl.Contains("红包码") || HbUrl.StartsWith("Error:"))
            {
                Label_tip.Text = "请先点击,添加您的红包码!";
                return;
            }
            if (QrUrl.Equals("") || QrUrl.Contains("收款码") || QrUrl.StartsWith("Error:"))
            {
                Label_tip.Text = "请先点击,添加您的收款码!";
                return;
            }
            if (Tittle.Equals("") || Tittle.Contains("第8号当铺"))
            {
                Label_tip.Text = "请添加您的商家名称!";
                return;
            }

            // 红包码,收款码 数据校验
            if (!ChekQrTrue(ref QrUrl, ref HbUrl))
            {
                //Label_tip.Text = "红包码或收款码上传错误,请重新上传!";
                return;
            }

            // 记录红包码、收款码信息,返回记录id
            string commond = "TYPE=Add&QrUrl=" + QrUrl + "&HbUrl=" + HbUrl + "&Tittle=" + Tittle + "&ext=";

            string url = InfoUrl + "?" + commond;
            string Id  = ScTool.getWebData(url);

            if (Id.Equals(""))
            {
                Label_tip.Text = "红包收款码制作失败! -> Id为空";
                return;
            }
            //string Id = "100";



            // 生成红包收款码
            string PageUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/" + this.GetType().Name.Replace("_", "/").Replace("/aspx", ".aspx");
            string HB_QR   = PageUrl + "?" + "p=" + Id;

            // 制作红包收款码
            string picName = QrTool_HB.genHbSkPic(HB_QR, Tittle, Id, "tools\\QRTool\\QR_HB\\");

            if (!picName.Equals(""))
            {
                img_Example.Src = "~/tools/QRTool/QR_HB/" + picName;           // 显示生成的二维码
                Label_tip.Text  = "您的红包收款码已生成!";
            }
            else
            {
                Label_tip.Text = "红包收款码制作失败!";
            }

            //img_Example.Src = "~/tools/QRTool/QR/" + NAME;            // 现实二维码图像

            //Bitmap = QrTool_HB.ToQr()
            //showQR(HB_QR);

            // 制作红包收款码
            //...
            //HyperLink1.Text = "红包收款码:" + HyperLink1.NavigateUrl;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 记录红包码、二维码、商家名称,返回记录id,生成新的红包收款码供商家收款
        /// </summary>
        /// <param name="e"></param>
        protected void ImageButton_Create_Click(object sender, ImageClickEventArgs e)
        {
            // 检测红包码、收款码变动
            TextBox_HB_TextChanged(null, null);
            TextBox_SK_TextChanged(null, null);

            string QrUrl  = TextBox_SK.Text.Trim();     // 收款码
            string HbUrl  = TextBox_HB.Text.Trim();     // 红包码
            string Tittle = TextBox_Tittle.Text.Trim(); // 商家名称

            if (HbUrl.Equals("") || HbUrl.Contains("红包码") || HbUrl.StartsWith("Error:") || HbUrl.Contains("undefined"))
            {
                Label_tip.Text = "请先点击,添加您的红包码!";
                return;
            }
            if (QrUrl.Equals("") || QrUrl.Contains("收款码") || QrUrl.StartsWith("Error:") || QrUrl.Contains("undefined"))
            {
                Label_tip.Text = "请先点击,添加您的收款码!";
                return;
            }
            if (Tittle.Equals("") || Tittle.Contains("第8号当铺"))
            {
                Label_tip.Text = "请添加您的商家名称!";
                return;
            }

            // 红包码,收款码 数据校验
            if (!ChekQrTrue(ref QrUrl, ref HbUrl))
            {
                //Label_tip.Text = "红包码或收款码上传错误,请重新上传!";
                return;
            }

            String ext = "";

            if (/*img_HB.Src.Contains("success_hb.png") &&*/ img_SK.Src.Contains("success_sk.png"))
            {
                ext = "mode(3)";                            // 若收款码是通过扫码方式添加的,则使用模式3
            }
            if (!QrUrl.ToLower().Trim().StartsWith("http")) // 若非以http开头,则认为是文本信息,添加showinfo前缀在网页中展示
            {
                QrUrl = "ShowInfo_" + QrUrl;
                ext   = "mode(2)";
            }

            // 记录红包码、收款码信息,返回记录id
            string commond = "TYPE=Add&QrUrl=" + QrUrl + "&HbUrl=" + HbUrl + "&Tittle=" + Tittle + "&ext=" + ext;

            string url = InfoUrl + "?" + commond;
            string Id  = ScTool.getWebData(url);

            if (Id.Equals(""))
            {
                Label_tip.Text = "红包收款码制作失败! -> Id为空";
                return;
            }
            //string Id = "100";

            // 生成红包收款码
            //string PageUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/" + this.GetType().Name.Replace("_", "/").Replace("/aspx", ".aspx");
            string PageUrl = "http://scimence.gitee.io/url/HB.html";

            if (Product.UseStaticIpMode)
            {
                PageUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/" + this.GetType().Name.Replace("_", "/").Replace("/aspx", ".aspx");
            }

            string HB_QR = PageUrl + "?" + "p=" + Id;

            // 制作红包收款码
            string picName = QrTool_HB.genHbSkPic(HB_QR, Tittle, Id, "tools\\QRTool\\QR_HB\\");

            if (!picName.Equals(""))
            {
                img_Example.Src = "~/tools/QRTool/QR_HB/" + picName;           // 显示生成的二维码
                Label_tip.Text  = "您的红包收款码已生成!";
            }
            else
            {
                Label_tip.Text = "红包收款码制作失败!";
            }

            //img_Example.Src = "~/tools/QRTool/QR/" + NAME;            // 现实二维码图像

            //Bitmap = QrTool_HB.ToQr()
            //showQR(HB_QR);

            // 制作红包收款码
            //...
            //HyperLink1.Text = "红包收款码:" + HyperLink1.NavigateUrl;
        }