protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["ReferralId"], out this.userId)) { base.GotoResourceNotFound(""); } DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(this.userId); if (userIdDistributors == null) { base.GotoResourceNotFound(""); } this.imglogo = (HtmlImage)this.FindControl("QrcodeImg"); int currentMemberUserId = Globals.GetCurrentMemberUserId(); this.editPanel = (HtmlControl)this.FindControl("editPanel"); this.editPanel.Visible = false; if (currentMemberUserId == this.userId) { this.imglogo.Attributes.Add("Admin", "true"); MemberInfo currentMember = MemberProcessor.GetCurrentMember(); DateTime cardCreatTime = userIdDistributors.CardCreatTime; string str = File.ReadAllText(HttpRuntime.AppDomainAppPath.ToString() + "Storage/Utility/StoreCardSet.js"); JObject obj2 = JsonConvert.DeserializeObject(str) as JObject; DateTime time2 = new DateTime(); if ((obj2 != null) && (obj2["writeDate"] != null)) { time2 = DateTime.Parse(obj2["writeDate"].ToString()); } if (string.IsNullOrEmpty(userIdDistributors.StoreCard) || (cardCreatTime < time2)) { StoreCardCreater creater = new StoreCardCreater(str, currentMember.UserHead, userIdDistributors.Logo, Globals.HostPath(HttpContext.Current.Request.Url) + "/Follow.aspx?ReferralId=" + this.userId.ToString(), currentMember.UserName, userIdDistributors.StoreName, this.userId); string imgUrl = ""; if (creater.ReadJson() && creater.CreadCard(out imgUrl)) { DistributorsBrower.UpdateStoreCard(this.userId, imgUrl); } } } if (string.IsNullOrEmpty(userIdDistributors.StoreCard)) { userIdDistributors.StoreCard = "/Storage/master/DistributorCards/StoreCard" + this.userId.ToString() + ".jpg"; } this.ShareInfo = (HtmlInputHidden)this.FindControl("ShareInfo"); this.imglogo.Src = userIdDistributors.StoreCard; PageTitle.AddSiteNameTitle("掌柜名片"); }
protected override void OnInit(System.EventArgs e) { string a = System.Web.HttpContext.Current.Request["action"]; if (a == "ReCreadt") { System.Web.HttpContext.Current.Response.ContentType = "application/json"; string text = System.Web.HttpContext.Current.Request["imageUrl"]; string s = ""; if (string.IsNullOrEmpty(text)) { s = "{\"success\":\"false\",\"message\":\"图片地址为空\"}"; } try { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(currentMember.UserId); string setJson = System.IO.File.ReadAllText(System.Web.HttpRuntime.AppDomainAppPath.ToString() + "Storage/Utility/StoreCardSet.js"); StoreCardCreater storeCardCreater = new StoreCardCreater(setJson, text, text, Globals.HostPath(System.Web.HttpContext.Current.Request.Url) + "/Follow.aspx?ReferralId=" + this.userId.ToString(), currentMember.UserName, userIdDistributors.StoreName, currentMember.UserId); string text2 = ""; if (storeCardCreater.ReadJson() && storeCardCreater.CreadCard(out text2)) { s = "{\"success\":\"true\",\"message\":\"生成成功\"}"; DistributorsBrower.UpdateStoreCard(this.userId, text2); } else { s = "{\"success\":\"false\",\"message\":\"" + text2 + "\"}"; } } catch (System.Exception ex) { s = "{\"success\":\"false\",\"message\":\"" + ex.Message + "\"}"; } System.Web.HttpContext.Current.Response.Write(s); System.Web.HttpContext.Current.Response.End(); } if (this.SkinName == null) { this.SkinName = "skin-VStoreCard.html"; } base.OnInit(e); }
public bool CreadCard(out string imgUrl) { bool flag = false; bool result; if (this.resultObj == null || this.resultObj["BgImg"] == null) { imgUrl = "掌柜名片模板未设置,无法生成名片!"; result = flag; } else { imgUrl = "生成失败"; System.Drawing.Bitmap bitmap = null; if (this.CodeUrl.Contains("weixin.qq.com")) { bitmap = this.getNetImg(this.CodeUrl); } else { bitmap = new QRCodeEncoder { QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE, QRCodeScale = 8, QRCodeVersion = 8, QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M }.Encode(this.CodeUrl); } int num = int.Parse(this.resultObj["DefaultHead"].ToString()); if (string.IsNullOrEmpty(this.UserHead) || (!this.UserHead.ToLower().StartsWith("http") && !System.IO.File.Exists(Globals.MapPath(this.UserHead)))) { this.UserHead = "/Utility/pics/imgnopic.jpg"; } if (!this.StoreLogo.ToLower().StartsWith("http") && !System.IO.File.Exists(Globals.MapPath(this.StoreLogo))) { this.StoreLogo = "/Utility/pics/headLogo.jpg"; } if (num == 2) { this.UserHead = ""; } else if (num == 1) { this.UserHead = this.StoreLogo; } System.Drawing.Image image; if (this.UserHead.ToLower().StartsWith("http")) { image = this.getNetImg(this.UserHead); } else if (System.IO.File.Exists(Globals.MapPath(this.UserHead))) { image = System.Drawing.Image.FromFile(Globals.MapPath(this.UserHead)); } else { image = new System.Drawing.Bitmap(100, 100); } System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); graphicsPath.AddEllipse(new System.Drawing.Rectangle(0, 0, image.Width, image.Width)); System.Drawing.Bitmap bitmap2 = new System.Drawing.Bitmap(image.Width, image.Width); using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap2)) { graphics.SetClip(graphicsPath); graphics.DrawImage(image, 0, 0, image.Width, image.Width); } image.Dispose(); bitmap = StoreCardCreater.CombinImage(bitmap, bitmap2, 80); System.Drawing.Bitmap bitmap3 = new System.Drawing.Bitmap(480, 735); System.Drawing.Graphics graphics2 = System.Drawing.Graphics.FromImage(bitmap3); graphics2.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; graphics2.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; graphics2.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; graphics2.Clear(System.Drawing.Color.White); System.Drawing.Bitmap bitmap4 = new System.Drawing.Bitmap(100, 100); if (this.resultObj["BgImg"] != null && System.IO.File.Exists(Globals.MapPath(this.resultObj["BgImg"].ToString()))) { bitmap4 = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(Globals.MapPath(this.resultObj["BgImg"].ToString())); bitmap4 = StoreCardCreater.GetThumbnail(bitmap4, 735, 480); } graphics2.DrawImage(bitmap4, 0, 0, 480, 735); System.Drawing.Font font = new System.Drawing.Font("微软雅黑", (float)((int)this.resultObj["myusernameSize"] * 6 / 5)); System.Drawing.Font font2 = new System.Drawing.Font("微软雅黑", (float)((int)this.resultObj["shopnameSize"] * 6 / 5)); graphics2.DrawImage(bitmap2, (int)((decimal)this.resultObj["posList"][0]["left"] * 480m), (int)this.resultObj["posList"][0]["top"] * 735 / 490, (int)((decimal)this.resultObj["posList"][0]["width"] * 480m), (int)((decimal)this.resultObj["posList"][0]["width"] * 480m)); System.Drawing.StringFormat format = new System.Drawing.StringFormat(System.Drawing.StringFormatFlags.DisplayFormatControl); string text = this.resultObj["myusername"].ToString().Replace("{{昵称}}", "$"); string text2 = this.resultObj["shopname"].ToString().Replace("{{店铺名称}}", "$"); string[] array = text.Split(new char[] { '$' }); string[] array2 = text2.Split(new char[] { '$' }); graphics2.DrawString(array[0], font, new System.Drawing.SolidBrush(System.Drawing.ColorTranslator.FromHtml(this.resultObj["myusernameColor"].ToString())), (float)((int)((decimal)this.resultObj["posList"][1]["left"] * 480m)), (float)((int)this.resultObj["posList"][1]["top"] * 735 / 490), format); if (array.Length > 1) { System.Drawing.SizeF sizeF = graphics2.MeasureString(" ", font); System.Drawing.SizeF sizeF2 = graphics2.MeasureString(array[0], font); graphics2.DrawString(this.UserName, font, new System.Drawing.SolidBrush(System.Drawing.ColorTranslator.FromHtml(this.resultObj["nickNameColor"].ToString())), (float)((int)((decimal)this.resultObj["posList"][1]["left"] * 480m)) + sizeF2.Width - sizeF.Width, (float)((int)this.resultObj["posList"][1]["top"] * 735 / 490), format); System.Drawing.SizeF sizeF3 = graphics2.MeasureString(this.UserName, font); graphics2.DrawString(array[1], font, new System.Drawing.SolidBrush(System.Drawing.ColorTranslator.FromHtml(this.resultObj["myusernameColor"].ToString())), (float)((int)((decimal)this.resultObj["posList"][1]["left"] * 480m)) + sizeF2.Width - sizeF.Width * 2f + sizeF3.Width, (float)((int)this.resultObj["posList"][1]["top"] * 735 / 490), format); } graphics2.DrawString(array2[0], font2, new System.Drawing.SolidBrush(System.Drawing.ColorTranslator.FromHtml(this.resultObj["shopnameColor"].ToString())), (float)((int)((decimal)this.resultObj["posList"][2]["left"] * 480m)), (float)((int)this.resultObj["posList"][2]["top"] * 735 / 490)); if (array2.Length > 1) { System.Drawing.SizeF sizeF4 = graphics2.MeasureString(" ", font2); System.Drawing.SizeF sizeF5 = graphics2.MeasureString(array2[0], font2); graphics2.DrawString(this.StoreName, font2, new System.Drawing.SolidBrush(System.Drawing.ColorTranslator.FromHtml(this.resultObj["storeNameColor"].ToString())), (float)((int)((decimal)this.resultObj["posList"][2]["left"] * 480m)) + sizeF5.Width - sizeF4.Width, (float)((int)this.resultObj["posList"][2]["top"] * 735 / 490), format); System.Drawing.SizeF sizeF6 = graphics2.MeasureString(this.StoreName, font2); graphics2.DrawString(array2[1], font2, new System.Drawing.SolidBrush(System.Drawing.ColorTranslator.FromHtml(this.resultObj["shopnameColor"].ToString())), (float)((int)((decimal)this.resultObj["posList"][2]["left"] * 480m)) + sizeF5.Width - sizeF4.Width * 2f + sizeF6.Width, (float)((int)this.resultObj["posList"][2]["top"] * 735 / 490), format); } graphics2.DrawImage(bitmap, (int)((decimal)this.resultObj["posList"][3]["left"] * 480m), (int)this.resultObj["posList"][3]["top"] * 735 / 490, (int)((decimal)this.resultObj["posList"][3]["width"] * 480m), (int)((decimal)this.resultObj["posList"][3]["width"] * 480m)); bitmap.Dispose(); if (this.ReferralId == 0) { bitmap3.Save(Globals.MapPath(string.Concat(new object[] { Globals.GetStoragePath(), "/DistributorCards/MemberCard", this.userId, ".jpg" })), System.Drawing.Imaging.ImageFormat.Jpeg); imgUrl = string.Concat(new object[] { Globals.GetStoragePath(), "/DistributorCards/MemberCard", this.userId, ".jpg" }); } else { bitmap3.Save(Globals.MapPath(string.Concat(new object[] { Globals.GetStoragePath(), "/DistributorCards/StoreCard", this.ReferralId, ".jpg" })), System.Drawing.Imaging.ImageFormat.Jpeg); imgUrl = string.Concat(new object[] { Globals.GetStoragePath(), "/DistributorCards/StoreCard", this.ReferralId, ".jpg" }); } bitmap3.Dispose(); flag = true; result = flag; } return(result); }
protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["ReferralId"], out this.userId)) { this.Context.Response.Redirect("/"); } else { DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(this.userId); if (userIdDistributors == null) { this.Context.Response.Redirect("/"); } else { this.imglogo = (HtmlImage)this.FindControl("QrcodeImg"); int currentMemberUserId = Globals.GetCurrentMemberUserId(false); this.editPanel = (HtmlControl)this.FindControl("editPanel"); this.editPanel.Visible = false; if (currentMemberUserId == this.userId) { this.imglogo.Attributes.Add("Admin", "true"); MemberInfo currentMember = MemberProcessor.GetCurrentMember(); DateTime cardCreatTime = userIdDistributors.CardCreatTime; string str = File.ReadAllText(HttpRuntime.AppDomainAppPath.ToString() + "Storage/Utility/StoreCardSet.js"); JObject obj2 = JsonConvert.DeserializeObject(str) as JObject; DateTime time2 = new DateTime(); if ((obj2 != null) && (obj2["writeDate"] != null)) { time2 = DateTime.Parse(obj2["writeDate"].ToString()); } ScanInfos info = ScanHelp.GetScanInfosByUserId(currentMember.UserId, 0, "WX"); if (info == null) { ScanHelp.CreatNewScan(currentMember.UserId, "WX", 0); info = ScanHelp.GetScanInfosByUserId(currentMember.UserId, 0, "WX"); } string codeUrl = ""; if (info == null) { codeUrl = Globals.HostPath(HttpContext.Current.Request.Url) + "/Follow.aspx?ReferralId=" + currentMember.UserId.ToString(); } else { codeUrl = info.CodeUrl; if (string.IsNullOrEmpty(codeUrl)) { string token = TokenApi.GetToken_Message(this.siteSettings.WeixinAppId, this.siteSettings.WeixinAppSecret); if (TokenApi.CheckIsRightToken(token)) { string str4 = BarCodeApi.CreateTicket(token, info.Sceneid, "QR_LIMIT_SCENE", "2592000"); if (!string.IsNullOrEmpty(str4)) { codeUrl = str4; info.CodeUrl = str4; info.CreateTime = DateTime.Now; info.LastActiveTime = DateTime.Now; ScanHelp.updateScanInfosCodeUrl(info); } } } if (string.IsNullOrEmpty(codeUrl)) { codeUrl = Globals.HostPath(HttpContext.Current.Request.Url) + "/Follow.aspx?ReferralId=" + currentMember.UserId.ToString(); } else { codeUrl = BarCodeApi.GetQRImageUrlByTicket(codeUrl); } } if (string.IsNullOrEmpty(userIdDistributors.StoreCard) || (cardCreatTime < time2)) { string storeName = userIdDistributors.StoreName; if (!this.siteSettings.IsShowDistributorSelfStoreName) { storeName = this.siteSettings.SiteName; } StoreCardCreater creater = new StoreCardCreater(str, currentMember.UserHead, userIdDistributors.Logo, codeUrl, currentMember.UserName, storeName, this.userId, this.userId); string imgUrl = ""; if (creater.ReadJson() && creater.CreadCard(out imgUrl)) { DistributorsBrower.UpdateStoreCard(this.userId, imgUrl); } } } if (string.IsNullOrEmpty(userIdDistributors.StoreCard)) { userIdDistributors.StoreCard = "/Storage/master/DistributorCards/StoreCard" + this.userId.ToString() + ".jpg"; } this.ShareInfo = (HtmlInputHidden)this.FindControl("ShareInfo"); this.imglogo.Src = userIdDistributors.StoreCard; PageTitle.AddSiteNameTitle("掌柜名片"); } } }
protected override void OnInit(EventArgs e) { string str = HttpContext.Current.Request["action"]; if (str == "ReCreadt") { HttpContext.Current.Response.ContentType = "application/json"; string str2 = HttpContext.Current.Request["imageUrl"]; string s = ""; if (string.IsNullOrEmpty(str2)) { s = "{\"success\":\"false\",\"message\":\"图片地址为空\"}"; } try { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(currentMember.UserId); string str4 = str2; string str5 = str2; ScanInfos infos = ScanHelp.GetScanInfosByUserId(currentMember.UserId, 0, "WX"); if (infos == null) { ScanHelp.CreatNewScan(currentMember.UserId, "WX", 0); infos = ScanHelp.GetScanInfosByUserId(currentMember.UserId, 0, "WX"); } string qRImageUrlByTicket = ""; if (infos == null) { qRImageUrlByTicket = Globals.HostPath(HttpContext.Current.Request.Url) + "/Follow.aspx?ReferralId=" + currentMember.UserId.ToString(); } else { qRImageUrlByTicket = BarCodeApi.GetQRImageUrlByTicket(infos.CodeUrl); } string str7 = File.ReadAllText(HttpRuntime.AppDomainAppPath.ToString() + "Storage/Utility/StoreCardSet.js"); string storeName = userIdDistributors.StoreName; if (!this.siteSettings.IsShowDistributorSelfStoreName) { storeName = this.siteSettings.SiteName; } StoreCardCreater creater = new StoreCardCreater(str7, str4, str5, qRImageUrlByTicket, currentMember.UserName, storeName, currentMember.UserId, currentMember.UserId); string imgUrl = ""; if (creater.ReadJson() && creater.CreadCard(out imgUrl)) { s = "{\"success\":\"true\",\"message\":\"生成成功\"}"; DistributorsBrower.UpdateStoreCard(currentMember.UserId, imgUrl); } else { s = "{\"success\":\"false\",\"message\":\"" + imgUrl + "\"}"; } } catch (Exception exception) { s = "{\"success\":\"false\",\"message\":\"" + exception.Message + "\"}"; } HttpContext.Current.Response.Write(s); HttpContext.Current.Response.End(); } if (this.SkinName == null) { this.SkinName = "skin-VStoreCard.html"; } base.OnInit(e); }
protected override void OnInit(System.EventArgs e) { string a = System.Web.HttpContext.Current.Request["action"]; if (a == "ReCreadt") { System.Web.HttpContext.Current.Response.ContentType = "application/json"; string text = System.Web.HttpContext.Current.Request["imageUrl"]; string s = ""; if (string.IsNullOrEmpty(text)) { s = "{\"success\":\"false\",\"message\":\"图片地址为空\"}"; } try { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(currentMember.UserId); string userHeadPath = text; string storeLogoPath = text; ScanInfos scanInfosByUserId = ScanHelp.GetScanInfosByUserId(currentMember.UserId, 0, "WX"); if (scanInfosByUserId == null) { ScanHelp.CreatNewScan(currentMember.UserId, "WX", 0); scanInfosByUserId = ScanHelp.GetScanInfosByUserId(currentMember.UserId, 0, "WX"); } string codeUrl; if (scanInfosByUserId == null) { codeUrl = Globals.HostPath(System.Web.HttpContext.Current.Request.Url) + "/Follow.aspx?ReferralId=" + currentMember.UserId.ToString(); } else { codeUrl = BarCodeApi.GetQRImageUrlByTicket(scanInfosByUserId.CodeUrl); } string setJson = System.IO.File.ReadAllText(System.Web.HttpRuntime.AppDomainAppPath.ToString() + "Storage/Utility/StoreCardSet.js"); string storeName = userIdDistributors.StoreName; if (!this.siteSettings.IsShowDistributorSelfStoreName) { storeName = this.siteSettings.SiteName; } StoreCardCreater storeCardCreater = new StoreCardCreater(setJson, userHeadPath, storeLogoPath, codeUrl, currentMember.UserName, storeName, currentMember.UserId, currentMember.UserId); string text2 = ""; if (storeCardCreater.ReadJson() && storeCardCreater.CreadCard(out text2)) { s = "{\"success\":\"true\",\"message\":\"生成成功\"}"; DistributorsBrower.UpdateStoreCard(currentMember.UserId, text2); } else { s = "{\"success\":\"false\",\"message\":\"" + text2 + "\"}"; } } catch (System.Exception ex) { s = "{\"success\":\"false\",\"message\":\"" + ex.Message + "\"}"; } System.Web.HttpContext.Current.Response.Write(s); System.Web.HttpContext.Current.Response.End(); } if (this.SkinName == null) { this.SkinName = "skin-VStoreCard.html"; } base.OnInit(e); }