public static EQRInfo UpdateMasterUrlById(EQRInfo qr) { string fp = HttpContext.Current.Server.MapPath(qr.OrigFilePath); System.Drawing.Image qrImg = new Bitmap(HttpContext.Current.Server.MapPath(fp)); Bitmap bkImg = ImgHelper.CreateBlankImg(qrImg.Width, qrImg.Height + 80, Brushes.White); using (Graphics g = Graphics.FromImage(bkImg)) { string s = "此邀请码不收费!"; Font font = new Font("黑体", 12, FontStyle.Bold); SolidBrush b = new SolidBrush(Color.FromArgb(50, 159, 250)); g.DrawString(s, font, b, new PointF(20, qrImg.Height + 10)); s = "平台入驻不收费,请谨防骗子!"; g.DrawString(s, font, b, new PointF(20, qrImg.Height + 200)); } Bitmap finImg = ImgHelper.CombineImage(bkImg, qrImg, 80); string filePath = "/Content/QR/Invite/QRInvite_" + qr.ID + ".jpg"; qr.FilePath = filePath; string fullPath = HttpContext.Current.Server.MapPath(filePath); finImg.Save(fullPath); finImg.Dispose(); bkImg.Dispose(); return(qr); }
public static EQRInfo Create_PP_AR(EQRInfo qr) {/* * string site = ConfigurationManager.AppSettings["Main_SiteUrl"]; * string url = site + "Wap/Auth_AR?qrId="+qr.ID; * * string filePath = QRManager.CreateQR(url); * qr.Url = url; * qr.FilePath = filePath; */ return(qr); }
/// <summary> /// 邀请码 /// </summary> /// <param name="qr"></param> /// <param name="context"></param> /// <returns></returns> public static EQRInfo CreateMasterUrlById(EQRInfo qr, HttpContext context) { try { if (qr.ID == 0) { throw new Exception("创建QR错误,QR ID 不存在"); } string url = "http://wx.iqianba.cn/api/wx/CreateInviteQR"; string data = string.Format("QRId={0}&QRType={1}", qr.ID, qr.Type); string res = HttpHelper.RequestUrlSendMsg(url, HttpHelper.HttpMethod.Post, data, "application/x-www-form-urlencoded"); SSOQR obj = JsonConvert.DeserializeObject <SSOQR>(res); qr.TargetUrl = obj.TargetUrl; System.Drawing.Image bkImg = ImgHelper.GetImgFromUrl(qr.TargetUrl); string filePath = "/Content/QR/Invite/Orig_QRInvite_" + qr.ID + ".jpg"; qr.OrigFilePath = filePath; string fullPath = context.Server.MapPath(filePath); bkImg.Save(fullPath); Bitmap logo = new Bitmap(context.Server.MapPath(@"/Content/QR/Logo_AR.png")); Bitmap finImg = ImgHelper.ImageWatermark(new Bitmap(bkImg), logo); filePath = "/Content/QR/Invite/QRInvite_" + qr.ID + ".jpg"; qr.FilePath = filePath; fullPath = context.Server.MapPath(filePath); finImg.Save(fullPath); finImg.Dispose(); bkImg.Dispose(); return(qr); } catch (Exception ex) { IQBLog log = new IQBLog(); log.log("CreateMasterUrlById Error:" + ex.Message); throw ex; } }