Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

            qrCodeEncoder.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeScale        = 4;
            qrCodeEncoder.QRCodeVersion      = 0;
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            String code = context.Request["code"];

            if (string.IsNullOrEmpty(code))
            {
                apiResp.msg = "code 参数必传";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                return;
            }
            System.Drawing.Bitmap image = qrCodeEncoder.Encode(code);
            string fileName             = string.Format("{0}.jpg", Guid.NewGuid().ToString());
            string relatePath           = string.Format("/FileUpload/QCode/{0}", fileName);

            image.Save(context.Server.MapPath(relatePath));

            if (bll.WebsiteOwner != "songhe")
            {
                relatePath = bll.CompoundImageLogoToOss(relatePath, bll.WebsiteOwner);
            }
            apiResp.status = true;
            apiResp.msg    = "ok";
            apiResp.result = new
            {
                qrcode_url = relatePath
            };
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

            qrCodeEncoder.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeScale        = 4;
            qrCodeEncoder.QRCodeVersion      = 0;
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            String data = context.Request["code"];

            System.Drawing.Bitmap image = qrCodeEncoder.Encode(data);

            string filename   = string.Format("{0}.jpg", Guid.NewGuid().ToString());
            string relatePath = string.Format("/FileUpload/QCode/{0}", filename);

            image.Save(context.Server.MapPath(relatePath));

            relatePath = bll.CompoundImageLogoToOss(relatePath, bll.WebsiteOwner);

            context.Response.Write(relatePath);
        }