string GetFullBody() { if (TemplateType.Equals(TemplateTypes.SpecialMail)) { string body = ""; Assembly ass = Assembly.GetExecutingAssembly(); StreamReader sr = new StreamReader(ass.GetManifestResourceStream("Bobs.Emails.DsiEmailTemplateSpecial.htm")); string siteUserTemplate = sr.ReadToEnd(); string logInUrl = "http://" + Vars.DomainName + "/"; if (UsrRecipient != null) { logInUrl = UsrRecipient.LoginUrl; } if (RedirectUrl.Length > 0 && UsrRecipient != null) { logInUrl = UsrRecipient.LoginAndTransfer(RedirectUrl); } if (OverrideLoginLink.Length > 0) { logInUrl = OverrideLoginLink; } body = siteUserTemplate.Replace("[SUBJECT]", Subject); body = body.Replace("[BODY]", Body); body = body.Replace("[LOGIN]", logInUrl); body = AolCompliance(body); body = GenericReplacements(body); return body; } else if (TemplateType.Equals(TemplateTypes.AnotherSiteUser)) { string body = ""; Assembly ass = Assembly.GetExecutingAssembly(); StreamReader sr = new StreamReader(ass.GetManifestResourceStream("Bobs.Emails.DsiEmailTemplateSiteUser.htm")); string siteUserTemplate = sr.ReadToEnd(); RelevanceHolder rel = new RelevanceHolder(); UsrRecipient.AddRelevant(rel); BannerServer.Rules.RequestRules rules = new Bobs.BannerServer.Rules.RequestRules(); foreach (int musicTypeK in rel.RelevantMusic) { rules.MusicTypes.Add(musicTypeK); } foreach (int placeK in rel.RelevantPlaces) { rules.PlacesVisited.Add(placeK); } Bobs.BannerServer.Server server = new Bobs.BannerServer.Server(); BannerDataHolder bdh = server.GetBanner(Banner.Positions.EmailBanner, false, new UsrIdentity(UsrRecipient), rules); //Banner b = null; string bannerHtml = ""; if (bdh != null) { Banner b = new Banner(bdh.K); bannerHtml = @"<table cellpadding=""0"" cellspacing=""0"" border=""0""><tr><td rowspan=""3""><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""23"" height=""90""></td><td rowspan=""3""><a href=""[LOGIN]""><img src=""[WEB-ROOT]gfx/logo-200-90.jpg"" border=""0"" width=""200"" height=""90""></a></td><td rowspan=""3""><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""23"" height=""90""></td><td><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""331"" height=""20""></td><td rowspan=""3""><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""23"" height=""90""></td></tr><tr><td><a href=""[LOGIN(" + b.LinkUrlLive + @")]""><img src=""" + b.Misc.Url() + @""" border=""0"" width=""331"" height=""51""></a></td></tr><tr><td><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""331"" height=""19""></td></tr></table>"; b.RegisterHit(new UsrIdentity(UsrRecipient)); } else { bannerHtml = @"<table cellpadding=""0"" cellspacing=""0"" border=""0""><tr><td><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""23"" height=""90""></td><td><a href=""[LOGIN]""><img src=""[WEB-ROOT]gfx/logo-200-90.jpg"" border=""0"" width=""200"" height=""90""></a></td><td><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""377"" height=""90""></td></tr></table>"; } siteUserTemplate = siteUserTemplate.Replace("[BANNER]", bannerHtml); #region AnotherSiteUser string salutation = "Hi, "; string logInUrl = "http://" + Vars.DomainName + "/"; if (UsrRecipient != null) { if (UsrRecipient.NickName.Length > 0) salutation = "Dear " + HttpUtility.HtmlEncode(UsrRecipient.NickName) + ", "; logInUrl = UsrRecipient.LoginUrl; } if (RedirectUrl.Length > 0 && UsrRecipient != null) { logInUrl = UsrRecipient.LoginAndTransfer(RedirectUrl); } if (OverrideLoginLink.Length > 0) { logInUrl = OverrideLoginLink; } body = siteUserTemplate.Replace("[SUBJECT]", Subject); #region [QUICKLINK] if (ShowQuickLink) { body = body.Replace("[QUICKLINK]", @"[h1] Quick link [/h1] [div] <p align=""center"" style=""margin:8px 0px 4px 0px;""><a href=""[LOGIN]"" style=""font-size:18px;font-weight:bold;"">Click here for DontStayIn</a></p> [/div]"); } else body = body.Replace("[QUICKLINK]", ""); #endregion body = body.Replace("[BODY]", Body); body = body.Replace("[SALUTATION]", salutation); #endregion body = AolCompliance(body); body = body.Replace("[LOGIN]", logInUrl); body = GenericReplacements(body); return body; } else if (TemplateType.Equals(TemplateTypes.AdminNote)) { Assembly ass = Assembly.GetExecutingAssembly(); StreamReader sr = new StreamReader(ass.GetManifestResourceStream("Bobs.Emails.DsiEmailTemplateAdminNote.htm")); string adminNoteTemplate = sr.ReadToEnd(); #region AdminNote string logInUrl = "http://" + Vars.DomainName + "/"; if (Usr.Current != null) { logInUrl = Usr.Current.LoginAndTransfer(RedirectUrl); } if (OverrideLoginLink.Length > 0) logInUrl = OverrideLoginLink; Usr usrDave = new Usr(4); Usr usrJohn = new Usr(1); Usr usrTim = new Usr(2); string body = adminNoteTemplate.Replace("[SUBJECT]", Subject); body = body.Replace("[BODY]", Body); body = body.Replace("[LOGIN-URL-CURRENT]", logInUrl); body = body.Replace("[LOGIN-URL-DAVE]", usrDave.LoginAndTransfer(RedirectUrl)); body = body.Replace("[LOGIN-URL-JOHN]", usrJohn.LoginAndTransfer(RedirectUrl)); body = body.Replace("[LOGIN-URL-TIM]", usrTim.LoginAndTransfer(RedirectUrl)); body = GenericReplacements(body); return body; #endregion } else return "error"; }
public void AddBuddy(Usr buddyUsr, bool canBuddyInvite, bool sendNotificationEmailIfNewBuddyRequest, AddBuddySource source, Buddy.BuddyFindingMethod foundByMethod, string skeletonName) { ValidateBuddyUsr(buddyUsr, true); Buddy b; try { b = new Buddy(this.K, buddyUsr.K); } catch (BobNotFound) { b = new Buddy(); b.UsrK = this.K; b.BuddyUsrK = buddyUsr.K; b.CanBuddyInvite = canBuddyInvite; b.BuddyFoundByMethod = foundByMethod; b.SkeletonName = skeletonName; try { Buddy reverseBuddy = new Buddy(buddyUsr.K, this.K); reverseBuddy.FullBuddy = true; reverseBuddy.Denied = false; reverseBuddy.CanInvite = canBuddyInvite; b.CanInvite = reverseBuddy.CanBuddyInvite; b.FullBuddy = true; b.Denied = false; reverseBuddy.Update(); if (this.FacebookConnected && this.FacebookStoryNewBuddy) { try { FacebookPost.CreateNewBuddy(this, buddyUsr, true); } catch { } } if (buddyUsr.FacebookConnected && buddyUsr.FacebookStoryNewBuddy) { try { FacebookPost.CreateNewBuddy(buddyUsr, this, false); } catch { } } } catch (BobNotFound) { if (source == AddBuddySource.BuddyButtonClick || source == AddBuddySource.UsrPageSendPrivateMessage) { Usr.IncrementSpamBotDefeaterCounter(SpamBotDefeaterCounter.BuddyRequests, this.K); } b.CanInvite = false; b.FullBuddy = false; if (sendNotificationEmailIfNewBuddyRequest) { Mailer m = new Mailer(); m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; m.Subject = this.NickName + " has invited you to " + this.HisString(false) + " buddy list"; if (this.HasPic) { m.Body += "<a href=\"[LOGIN(" + this.Url() + ")]\"><img src=\"" + this.PicPath + "\" style=\"margin-left:5px;\" class=\"BorderBlack All\" width=\"100\" height=\"100\" align=\"right\" vspace=\"6\" border=\"0\"></a>"; } m.Body += "<h1>" + HttpUtility.HtmlEncode(this.NickName) + " has invited you to " + this.HisString(false) + " buddy list</h1>"; m.Body += "<p>Name: <a href=\"[LOGIN(" + this.Url() + ")]\">" + HttpUtility.HtmlEncode(this.FirstName) + " " + HttpUtility.HtmlEncode(this.LastName) + "</a>.</p>"; m.Body += "<p>To add " + HttpUtility.HtmlEncode(this.NickName) + " to your buddy list, view " + this.HisString(false) + " <a href=\"[LOGIN(" + this.Url() + ")]\">profile</a> and click the \"Add " + HttpUtility.HtmlEncode(this.NickName) + " to my buddy list\" button.</p>"; m.OverrideLoginLink = buddyUsr.LoginAndTransfer(this.Url()); m.UsrRecipient = buddyUsr; m.To = buddyUsr.Email; m.Send(); } } b.Update(); b.Usr.UpdateBuddyCount(null); b.BuddyUsr.UpdateBuddyCount(null); } }