Exemple #1
0
        public IActionResult ShortenUrl(string url)
        {
            var     authDb = new UserRepository(_connectionString);
            var     repo   = new UrlRepository(_connectionString);
            UrlLink ul     = new UrlLink();

            if (User.Identity.IsAuthenticated)
            {
                ul.HashedUrl = repo.GetHashedUrlForUser(url, authDb.GetIdForEmail(User.Identity.Name));
            }
            else
            {
                ul.HashedUrl = repo.GetHashedUrl(url);
            }

            if (ul.HashedUrl == null)
            {
                if (User.Identity.IsAuthenticated)
                {
                    repo.AddUrl(url, authDb.GetIdForEmail(User.Identity.Name));
                }
                else
                {
                    repo.AddUrl(url, null);
                }
                ul.HashedUrl = repo.GetHashedUrl(url);
            }
            return(Json(new HashedObj {
                HashedUrl = GetFullUrl(ul.HashedUrl)
            }));
        }
        private string StripUrlObject(UrlLink urlObject)
        {
            if (String.IsNullOrEmpty(urlObject?.Href))
            {
                throw new ArgumentException($"Url object is null or href is empty: {urlObject}");
            }

            return(urlObject.Href.Replace(ApiEndPoint, String.Empty));
        }
Exemple #3
0
        private void ValidateUrlLink(UrlLink urlObject)
        {
            // Make sure the URL is not empty
            if (String.IsNullOrEmpty(urlObject?.Href))
            {
                throw new ArgumentException($"Url object is null or href is empty: {urlObject}");
            }

            // Don't execute any requests that don't point to the Mollie API URL for security reasons
            if (!urlObject.Href.Contains(ApiEndPoint))
            {
                throw new ArgumentException($"Url does not point to the Mollie API: {urlObject.Href}");
            }
        }
Exemple #4
0
        /// <summary>
        /// Validates the URL link.
        /// </summary>
        /// <param name="urlObject">The URL object.</param>
        /// <exception cref="ArgumentException">Url object is null or href is empty: {urlObject}</exception>
        /// <exception cref="ArgumentException">Url does not point to the ISynergy.Framework.Payment.Mollie API: {urlObject.Href}</exception>
        /// <exception cref="ArgumentException">Url object is null or href is empty: {urlObject}</exception>
        public void ValidateUrlLink(UrlLink urlObject)
        {
            // Make sure the URL is not empty
            if (string.IsNullOrEmpty(urlObject?.Href))
            {
                throw new ArgumentException($"Url object is null or href is empty: {urlObject}");
            }

            // Don't execute any requests that don't point to the ISynergy.Framework.Payment.Mollie API URL for security reasons
            if (!urlObject.Href.Contains(Constants.ApiEndpoint))
            {
                throw new ArgumentException($"Url does not point to the ISynergy.Framework.Payment.Mollie API: {urlObject.Href}");
            }
        }
Exemple #5
0
        public Token ProcessSymbolUsage(SyntaxToken token, ISymbol symbol, bool isDeclaration)
        {
            string fullName     = GetSymbolName(symbol);
            string value        = token.ToString();
            string type         = String.Empty;
            int    lineNumber   = token.GetLocation().GetLineSpan().StartLinePosition.Line + 1;
            bool   isSearchable = isDeclaration;

            if (symbol is INamedTypeSymbol)
            {
                type = _walkerUtils.TypeTokenTypeName;
            }
            else
            {
                type = _walkerUtils.IdentifierTokenTypeName;
            }

            //Do not allow us to search locals
            if (symbol.Kind == SymbolKind.Local || symbol.Kind == SymbolKind.Parameter)
            {
                isSearchable = false;
            }

            var tokenModel = new Token(this.DocumentModel, fullName, value, type, lineNumber, isDeclaration, isSearchable);

            //If we can find the declaration, we'll link it ourselves
            if (symbol.DeclaringSyntaxReferences.Any() &&
                !(symbol is INamespaceSymbol))
            {
                var link = new SymbolLink(referencedSymbolName: fullName);
                tokenModel = tokenModel.WithLink(link);
            }
            //Otherwise, we try to link to the .Net Reference source
            else if (_refsourceLinkProvider.Assemblies.Contains(symbol.ContainingAssembly?.Identity?.Name) &&
                     !(symbol is INamespaceSymbol))
            {
                var link = new UrlLink(url: _refsourceLinkProvider.GetLink(symbol));
                tokenModel = tokenModel.WithLink(link);
            }

            return(tokenModel);
        }
Exemple #6
0
        public Site PopulateSite(ObservableCollection <Site> sites, Account account)
        {
            Site site = sites.FirstOrDefault(s => s.SiteCode == account.SiteCode);

            if (site == null)
            {
                site = new Site()
                {
                    SiteCode = account.SiteCode
                };
                sites.Add(site);
            }

            EbayContext    context = new EbayContext(account.EbayToken);
            GetEbayDetails command = new GetEbayDetails(context);

            command.SiteCode = account.SiteCode;
            command.Execute();

            foreach (URLDetailsType urlDetails in command.UrlDetails)
            {
                UrlLink link = site.UrlLinks.FirstOrDefault(u => u.UrlType == urlDetails.URLType);
                if (link == null)
                {
                    link = new UrlLink()
                    {
                        UrlType = urlDetails.URLType
                    };
                    site.UrlLinks.Add(link);
                }

                link.Url = urlDetails.URL;
            }

            SitesFactory factory = new SitesFactory();

            factory.Save(sites);

            return(site);
        }
Exemple #7
0
 string getToolTip(UrlLink link)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("Node ID: ");
     sb.Append(link.Content.NodeId);
     sb.Append("<br/>URL: ");
     sb.Append(HttpUtility.HtmlEncode(link.Url));
     sb.Append("<br/>STATUS: ");
     sb.Append(HttpUtility.HtmlEncode(link.Status.ToString()));
     if (link.StatusCode != 0) {
         sb.Append("<br/>HTTP CODE: ");
         sb.Append(link.StatusCode);
         sb.Append(" ");
         sb.Append(HttpUtility.HtmlEncode(link.StatusDescription));
     } else {
         if (link.StatusDescription != null && link.StatusDescription.Length > 0) {
             sb.Append("<br/>");
             sb.Append(HttpUtility.HtmlEncode(link.StatusDescription));
         }
     }
     return sb.ToString();
 }
Exemple #8
0
 public string GetUrl(UserControl parent, UrlLink urlLink)
 {
     return parent.ResolveUrl(urlLink.ToString() + ".aspx");
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OverviewNavigationLinksModel"/> class.
 /// </summary>
 /// <param name="previous">The previous.</param>
 /// <param name="next">The next.</param>
 /// <autogeneratedoc />
 public OverviewNavigationLinksModel(UrlLink previous, UrlLink next)
 {
     Previous = previous;
     Next     = next;
 }
Exemple #10
0
 public Task <Message> Say(UrlLink urlLink, params Contact[]?replyTo)
 {
     throw new NotImplementedException();
 }