Ejemplo n.º 1
0
        private ReadOnlyUrl GetUrl(TemplateContext context, TemplateProperties properties)
        {
            // Get the user id.

            var user = properties["To"] as IUser;

            if (user == null)
            {
                throw new ApplicationException("No user has been supplied.");
            }

            // Get the application path.

            var applicationPath = "~/communications/definitions/" + context.Definition;
            var queryString     = new QueryString(
                "userId", user.Id.ToString(),
                "contextId", context.Id.ToString(),
                "definition", context.Definition,
                "category", context.Category);

            if (context.VerticalId != null)
            {
                queryString.Add("verticalId", context.VerticalId.Value.ToString());
            }

            return(_webSiteQuery.GetUrl(WebSite.Management, null, false, applicationPath, queryString));
        }
Ejemplo n.º 2
0
        public void EmailTestsInitialize()
        {
            Resolve <IDbConnectionFactory>().DeleteAllTestData();
            _emailServer = EmailHost.Start();
            _emailServer.ClearEmails();

            InsecureRootPath = _webSiteQuery.GetUrl(WebSite.LinkMe, null, false, "~/").AbsoluteUri.ToLower();
            SecureRootPath   = _webSiteQuery.GetUrl(WebSite.LinkMe, null, true, "~/").AbsoluteUri.ToLower();

            MockEmailTestExtensions.RootPath = InsecureRootPath;

            _australia    = _locationQuery.GetCountry("Australia");
            _notAustralia = _locationQuery.GetCountry("New Zealand");
        }
Ejemplo n.º 3
0
        public string Register(bool secure, string applicationPath, ReadOnlyQueryString queryString)
        {
            var longUrl = _webSiteQuery.GetUrl(_webSite, _verticalId, secure, applicationPath, queryString);

            // Create a tiny id and add the mapping.

            var tinyId = Guid.NewGuid();

            Add(tinyId, longUrl);

            // The url contains the id.

            return(_webSiteQuery.GetUrl(_webSite, _verticalId, false, "~/url/" + tinyId.ToString("n")).AbsoluteUri);
        }
Ejemplo n.º 4
0
        public Job Map(JobAd jobAd, IEnumerable <int> categoryIds)
        {
            var applyUrl = _webSiteQuery.GetUrl(WebSite.LinkMe, VerticalId, false,
                                                "/jobs/Job.aspx", new ReadOnlyQueryString("jobAdId", jobAd.Id.ToString("N")))
                           .ToString();

            var post = new Job
            {
                id          = jobAd.Id.ToString("N"),
                title       = jobAd.Title,
                description = GetDescription(jobAd.Description.BulletPoints, jobAd.Description.Content, applyUrl),
                reference   = jobAd.Integration.ExternalReferenceId,
                //startdate = jobAd.CreatedTime, startdateSpecified = true,
                categories = categoryIds.Select(id => new JobCategory {
                    id = id, name = CategoryNames[id]
                }).ToArray(),
                jobtype     = MapJobType(jobAd.Description.JobTypes),
                region      = _locationMapper.Map(jobAd.Description.Location),
                application = new JobApplication
                {
                    url     = applyUrl,
                    emailto = (jobAd.ContactDetails != null && jobAd.ContactDetails.EmailAddress != null) ? jobAd.ContactDetails.EmailAddress : string.Empty,
                }
            };

            return(post);
        }
Ejemplo n.º 5
0
        public static void TestInitialize()
        {
            _webSiteQuery = Container.Current.Resolve <IWebSiteQuery>();
            Container.Current.Resolve <ITinyUrlQuery>();

            _rootPath = _webSiteQuery.GetUrl((int)WebSite.LinkMe, null, false, "~/").AbsoluteUri.ToLower();
            MockEmailTestExtensions.RootPath = _rootPath;
        }
Ejemplo n.º 6
0
        private ActionResult RedirectToNonVerticalRoute(string verticalUrl, string verticalUrl2, RouteReference route)
        {
            try
            {
                // Set the current context based upon the URL parameter.

                var vertical = string.IsNullOrEmpty(verticalUrl2)
                    ? _verticalsCommand.GetVerticalByUrl(verticalUrl)
                    : _verticalsCommand.GetVerticalByUrl(verticalUrl + "/" + verticalUrl2);

                if (vertical != null)
                {
                    // If it is not deleted then set everything up for the vertical, else simply redirect to the non-vertical page.

                    if (!vertical.IsDeleted)
                    {
                        if (!string.IsNullOrEmpty(vertical.Host))
                        {
                            // Redirect to the vertical domain.

                            var redirectUrl            = route.GenerateUrl();
                            var redirectPermanentlyUrl = _webSiteQuery.GetUrl(WebSite.LinkMe, vertical.Id, redirectUrl.Scheme == "https", "~/".AddUrlSegments(redirectUrl.AppRelativePath));
                            return(RedirectToUrl(redirectPermanentlyUrl, true));
                        }

                        ActivityContext.Set(vertical);
                    }

                    // Redirect to the associated web site page.  For SEO purposes
                    // make this a permanent redirection.

                    return(RedirectToUrl(route.GenerateUrl(), true));
                }
            }
            catch (Exception)
            {
                // Ignore.
            }

            // Not found. Since this is somewhat of a catch all return a "not found" result.

            HandleNotFoundError();
            return(null);
        }
Ejemplo n.º 7
0
        public static TinyUrlMapping Map(this TinyUrlMappingEntity entity, IWebSiteQuery webSiteQuery)
        {
            var webSite    = (WebSite)entity.webSite;
            var verticalId = entity.verticalId == Guid.Empty ? (Guid?)null : entity.verticalId;

            return(new TinyUrlMapping
            {
                CreatedTime = entity.createdTime,
                TinyId = entity.tinyId,
                WebSite = webSite,
                UserId = entity.userId,
                VerticalId = verticalId,
                LongUrl = webSiteQuery.GetUrl(webSite, verticalId, entity.secure, entity.longUrl),
                ContextId = entity.contextId,
                Definition = entity.definition,
                MimeType = entity.mimeType,
                Instance = entity.instance
            });
        }
Ejemplo n.º 8
0
        private void GetLongUrlDetails(TinyUrlMapping mapping, out string longUrl, out bool secure)
        {
            secure = mapping.LongUrl.Scheme == Url.SecureScheme;

            // If the long url is not an application url then just return the absolute values.

            if (!(mapping.LongUrl is ApplicationUrl || mapping.LongUrl is ReadOnlyApplicationUrl))
            {
                longUrl = mapping.LongUrl.AbsoluteUri;
                return;
            }

            // Compare the url against the root url to determine whether the long url can be stored as am application relative value.

            var applicationRootUrl = _webSiteQuery.GetUrl(mapping.WebSite, mapping.VerticalId, secure, "~/");

            if (!mapping.LongUrl.AbsoluteUri.StartsWith(applicationRootUrl.AbsoluteUri, StringComparison.InvariantCultureIgnoreCase))
            {
                longUrl = mapping.LongUrl.AbsoluteUri;
            }
            else
            {
                // Use the application relative path.

                string appRelativePathAndQuery;
                if (mapping.LongUrl is ApplicationUrl)
                {
                    appRelativePathAndQuery = ((ApplicationUrl)mapping.LongUrl).AppRelativePathAndQuery;
                }
                else
                {
                    appRelativePathAndQuery = ((ReadOnlyApplicationUrl)mapping.LongUrl).AppRelativePathAndQuery;
                }

                longUrl = "~" + appRelativePathAndQuery;
            }
        }
Ejemplo n.º 9
0
        private static string GetTrackingPixelUrl(TemplateEmail email)
        {
            var applicationPath = "~/url/" + email.Id.ToString("n") + ".aspx";

            return(_webSiteQuery.GetUrl((int)WebSite.LinkMe, email.AffiliateId, false, applicationPath).AbsoluteUri);
        }
Ejemplo n.º 10
0
        private MergeSettings CreateSettings(Guid?verticalId)
        {
            var settings = new MergeSettings();

            // Add references to some needed assemblies, i.e. Core and Common.

            settings.References.Add(typeof(NamesExtensions).Assembly);
            settings.References.Add(typeof(EmailsExtensions).Assembly);
            settings.References.Add(typeof(TextUtil).Assembly);
            settings.References.Add(typeof(IUser).Assembly);
            settings.References.Add(typeof(Url).Assembly);
            settings.References.Add(typeof(WebSite).Assembly);
            settings.References.Add(typeof(IInstrumentable).Assembly);
            settings.References.Add(typeof(ICommunicationRecipient).Assembly);
            settings.References.Add(typeof(Definition).Assembly);
            settings.References.Add(typeof(OrderReport).Assembly);
            settings.References.Add(typeof(JobAd).Assembly);

            // Add a namespace for the EmailManager.

            settings.Usings.Add(typeof(NamesExtensions));
            settings.Usings.Add(typeof(EmailsExtensions));
            settings.Usings.Add(typeof(TextUtil));
            settings.Usings.Add(typeof(UrlExtensions));
            settings.Usings.Add(typeof(WebSite));
            settings.Usings.Add(typeof(IInstrumentable));
            settings.Usings.Add(typeof(ICommunicationRecipient));

            // Add some useful methods.

            settings.Fields.Add(new MergeField("RootPath", _webSiteQuery.GetUrl(WebSite.LinkMe, null, false, "~/").AbsoluteUri.ToLower()));
            settings.Fields.Add(new MergeField("SecureRootPath", _webSiteQuery.GetUrl(WebSite.LinkMe, null, true, "~/").AbsoluteUri.ToLower()));
            settings.Fields.Add(new MergeField("VerticalRootPath", _webSiteQuery.GetUrl(WebSite.LinkMe, verticalId, false, "~/").AbsoluteUri.ToLower()));

            settings.Methods.Add(
                @"        private static string MakeNamePossessive(string name)
        {
            return NamesExtensions.MakeNamePossessive(name);
        }");

            settings.Methods.Add(
                @"        private static string GetPrice(decimal price, LinkMe.Domain.Currency currency)
        {
            return price.ToString(" + "\"C\"" + @", currency.CultureInfo);
        }");

            settings.Methods.Add(@"        private static string GetUrl(bool secure, string applicationPath)
        {
            if (applicationPath.Length > 0 && applicationPath[0] == '~')
                applicationPath = applicationPath.Substring(1);
            if (secure)
                return UrlExtensions.AddUrlSegments(SecureRootPath, applicationPath).ToLower();
            else
                return UrlExtensions.AddUrlSegments(RootPath, applicationPath).ToLower();
        }");

            settings.Methods.Add(@"        private static string GetTrackingPixelUrl(Guid id)
        {
            string applicationPath = ""/url/"" + id.ToString(""n"") + "".aspx"";
            return UrlExtensions.AddUrlSegments(VerticalRootPath, applicationPath).ToLower();
        }");

            settings.Methods.Add(@"        private static string DoNotEncode(string text)
        {
            return text;
        }");

            settings.Methods.Add(@"        private static string ConvertHtmlToPlainText(string text)
        {
            return EmailsExtensions.ConvertHtmlToPlainText(text);
        }");

            return(settings);
        }
Ejemplo n.º 11
0
 public static string ImageUrl(this HtmlHelper htmlHelper, string fileName)
 {
     return(_webSiteQuery.GetUrl(WebSite.LinkMe, null, false, "~/email/images/" + fileName).AbsoluteUri);
 }