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"; }
//[Test] public void BannerQuerySetInfosInDescendingPriorityOrderWorksAsIEnumerable() { Common.Automation.Sql.Database db = new Common.Automation.Sql.Database(Common.Properties.ConnectionString); db.ExecuteScalar("DELETE FROM Banner"); 10.Times(i => AddValidBanner(1, i)); Rules.RequestRules rr = new Bobs.BannerServer.Rules.RequestRules(); int expectedPriority = 9; bool firstOfThisPriority = true; // due to Required then Desired Sets, we expect each banner to turn up twice foreach (BannerQuerySetInfo bqsi in rr.BannerQuerySetInfosInDescendingPriorityOrder(Timeslots.GetCurrentTimeslot())) { Assert.AreEqual(1, bqsi.Banners.Count); Assert.AreEqual(expectedPriority, bqsi.Banners[0].Priority); if (firstOfThisPriority) { firstOfThisPriority = false; } else { firstOfThisPriority = true; expectedPriority--; } } }