コード例 #1
0
        //0.8-1.0: Homepage, subdomains, product info, major features
        //0.4-0.7: Articles and blog entries, category pages, FAQs
        protected virtual Task <IList <SitemapNode> > GetSitemapNodes(CancellationToken cancellationToken)
        {
            var siteUrl = AppSettings.SiteUrl;

            List <SitemapNode> nodes = new List <SitemapNode>();

            nodes.Add(
                new SitemapNode()
            {
                Url      = siteUrl,
                Priority = 1
            });

            foreach (var menuItem in _navigationService.GetNavigation("navigation.json"))
            {
                nodes.Add(
                    new SitemapNode()
                {
                    Url      = Url.AbsoluteUrl((string)menuItem.Action, (string)menuItem.Controller, AppSettings, null),
                    Priority = 0.9
                });
            }

            IList <SitemapNode> result = nodes;

            return(Task.FromResult(result));
        }
コード例 #2
0
        //0.8-1.0: Homepage, subdomains, product info, major features
        //0.4-0.7: Articles and blog entries, category pages, FAQs
        protected async virtual Task <IList <SitemapNode> > GetSitemapNodes(CancellationToken cancellationToken)
        {
            var siteUrl = AppSettings.SiteUrl;

            List <SitemapNode> nodes = new List <SitemapNode>();

            nodes.Add(
                new SitemapNode()
            {
                Url      = siteUrl,
                Priority = 1
            });

            foreach (dynamic menuItem in Url.NavigationMenu().Menu)
            {
                nodes.Add(
                    new SitemapNode()
                {
                    Url      = Url.AbsoluteUrl((string)menuItem.Action, (string)menuItem.Controller, null),
                    Priority = 0.9
                });
            }

            return(nodes);
        }
コード例 #3
0
        public virtual IActionResult Embed(string formUrlSlug)
        {
            string absoluteFormUrl   = Url.AbsoluteUrl <DynamicFormsController>(c => c.Edit(formUrlSlug, ""), true);
            string iFrameEmbedPath   = Path.Combine(_hostingEnvironment.ContentRootPath, @"Mvc\DynamicForms\Scripts\IFrameEmbed.js");
            var    iFrameEmbedScript = System.IO.File.ReadAllText(iFrameEmbedPath);

            iFrameEmbedScript = iFrameEmbedScript.Replace("{absoluteFormUrl}", absoluteFormUrl);
            return(new JavaScriptResult(iFrameEmbedScript));
        }
コード例 #4
0
        public async Task <ActionResult> AuthPocket()
        {
            var pocket = new PocketAccount();

            pocket.CallbackUri = Url.AbsoluteUrl("~/List/AuthPocket");
            var reqCode = await pocket.GetRequestCode();

            var callbackUri = Url.AbsoluteUrl("~/List/AuthPocketResult?reqCode=") + reqCode;
            var uri         = pocket.Auth(callbackUri);

            return(Redirect(uri.ToString()));
        }
コード例 #5
0
        protected async override Task <IEnumerable <System.ServiceModel.Syndication.SyndicationItem> > RSSItems(CancellationToken cancellationToken)
        {
            var posts = (await _blogService.BlogPostApplicationService.GetPostsAsync(0, 200, cancellationToken)).Select
                        (
                p => new SyndicationItem
                (
                    p.Title,
                    HtmlOutputHelper.RelativeToAbsoluteUrls(p.Description, AppSettings.SiteUrl),
                    new Uri(Url.AbsoluteUrl <BlogController>(c => c.Post(p.DateCreated.Year, p.DateCreated.Month, p.UrlSlug)))
                )

                        ).ToList();

            return(posts);
        }
コード例 #6
0
        public async Task <ActionResult> Feed()
        {
            var cts = TaskHelper.CreateChildCancellationTokenSource(ClientDisconnectedToken());

            // Create a collection of SyndicationItemobjects from the latest posts
            var rssItems = await RSSItems(cts.Token);

            foreach (var item in rssItems)
            {
                if (item.Id == null)
                {
                    item.Id = item.Links[0].Uri.ToString();
                }
            }

            // Create an instance of SyndicationFeed class passing the SyndicationItem collection
            var feed = new SyndicationFeed(SiteTitle, SiteDescription, new Uri(SiteUrl), rssItems)
            {
                Copyright = new TextSyndicationContent(String.Format("Copyright © {0}", SiteTitle)),
                Language  = Thread.CurrentThread.CurrentUICulture.Name
            };

            // self link (Required) - The URL for the syndication feed.
            string feedLink = Url.AbsoluteUrl("Feed", "Home", new { });

            // Format feed in RSS format through Rss20FeedFormatter formatter
            var feedFormatter = new Rss20FeedFormatter(feed);

            feedFormatter.SerializeExtensionsAsAtom = false;

            XNamespace atom = "http://www.w3.org/2005/Atom";

            feed.AttributeExtensions.Add(new XmlQualifiedName("atom", XNamespace.Xmlns.NamespaceName), atom.NamespaceName);

            feed.ElementExtensions.Add(new XElement(atom + "link", new XAttribute("href", feedLink), new XAttribute("rel", "self"), new XAttribute("type", "application/rss+xml")));
            feed.ElementExtensions.Add(new XElement(atom + "link", new XAttribute("href", SiteUrl), new XAttribute("rel", "alternate"), new XAttribute("type", "text/html")));

            // Call the custom action that write the feed to the response
            return(new RSSActionResult(feedFormatter));
        }
コード例 #7
0
        public async Task Validate([FromForm] string payload)
        {
            try
            {
                var data = JsonConvert.DeserializeObject <PayloadResponseDto>(payload);

                if (data == null)
                {
                    throw new Exception($"Payload is null, Body: {payload}");
                }

                int jobOpportunityId = Convert.ToInt32(data.callback_id);
                var jobOpportunity   = _jobsService.GetById(jobOpportunityId);
                var isJobApproved    = data.actions.FirstOrDefault()?.value == "approve";
                var isJobRejected    = data.actions.FirstOrDefault()?.value == "reject";
                var isTokenValid     = data.token == _configuration["Slack:VerificationToken"];

                if (isTokenValid && isJobApproved)
                {
                    jobOpportunity.IsApproved    = true;
                    jobOpportunity.PublishedDate = DateTime.UtcNow;
                    _jobsService.Update(jobOpportunity);
                    await _slackService.PostJobResponse(jobOpportunity, Url, data.response_url, data?.user?.id, true);

                    try
                    {
                        var tweetText = jobOpportunity.Title + " " + Url.AbsoluteUrl("Details", "Jobs", new { Id = jobOpportunityId });
                        await _twitterService.Tweet(tweetText);
                    }
                    catch (Exception tweetException)
                    {
                        HttpContext.RiseError(tweetException);
                        if (tweetException.InnerException != null)
                        {
                            HttpContext.RiseError(tweetException.InnerException);
                        }
                    }
                }
                else if (isTokenValid && isJobRejected)
                {
                    // Jobs are rejected by default, so there's no need to update the DB
                    if (jobOpportunity == null)
                    {
                        await _slackService.PostJobErrorResponse(jobOpportunity, Url, data.response_url);
                    }
                    else
                    {
                        await _slackService.PostJobResponse(jobOpportunity, Url, data.response_url, data?.user?.id, false);
                    }
                }
                else
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                }
            }
            catch (Exception ex)
            {
                HttpContext.RiseError(ex);
                if (ex.InnerException != null)
                {
                    HttpContext.RiseError(ex.InnerException);
                }
            }
        }
コード例 #8
0
        // GET: Consulta/Dashboard
        public ActionResult Index()
        {
            string token = Rp3.Web.Http.AutoLogin.GenerateToken(this.ApplicationId, Url.AbsoluteUrl(), "smartview", "smartview-app-marketforce", "rp3-smartview");

            return(Redirect(String.Format("{0}/Security/Account/AutoLogin?token={1}", ConfigurationManager.AppSettings["SmartViewUrl"], Url.Encode(token))));
        }
コード例 #9
0
        protected async override Task <IList <SitemapNode> > GetSitemapNodes(CancellationToken cancellationToken)
        {
            IList <SitemapNode> nodes = await base.GetSitemapNodes(cancellationToken);

            //Locations
            nodes.Add(
                new SitemapNode()
            {
                Url      = Url.AbsoluteUrl <LocationsController>(c => c.Index(1, 20, nameof(LocationDto.Name) + " asc", ""), AppSettings, false),
                Priority = 0.9
            });

            //countries
            nodes.Add(
                new SitemapNode()
            {
                Url      = Url.AbsoluteUrl <CountriesController>(c => c.Index(1, 20, nameof(LocationDto.Name) + " asc", ""), AppSettings, false),
                Priority = 0.9
            });

            foreach (TagDto t in (await _blogService.TagApplicationService.GetAllAsync(cancellationToken, null, null, null)))
            {
                nodes.Add(
                    new SitemapNode()
                {
                    Url       = Url.AbsoluteUrl(nameof(BlogController.Tag), "Blog", AppSettings, new { tagSlug = t.UrlSlug }),
                    Frequency = SitemapFrequency.Weekly,
                    Priority  = 0.8
                });
            }

            foreach (CategoryDto c in (await _blogService.CategoryApplicationService.GetAsync(cancellationToken, c => c.Published, null, null)))
            {
                nodes.Add(
                    new SitemapNode()
                {
                    Url       = Url.AbsoluteUrl(nameof(BlogController.Category), "Blog", AppSettings, new { categorySlug = c.UrlSlug }),
                    Frequency = SitemapFrequency.Weekly,
                    Priority  = 0.8
                });
            }

            foreach (BlogPostDto p in (await _blogService.BlogPostApplicationService.GetPostsAsync(0, 200, cancellationToken)))
            {
                nodes.Add(
                    new SitemapNode()
                {
                    Url       = Url.AbsoluteUrl <BlogController>(c => c.Post(p.CreatedOn.Year, p.CreatedOn.Month, p.UrlSlug), AppSettings),
                    Frequency = SitemapFrequency.Weekly,
                    Priority  = 0.7
                });
            }

            var repository = _fileSystemGenericRepositoryFactory.CreateFolderRepository(cancellationToken, _hostingEnvironment.MapWwwPath(AppSettings.Folders[Folders.Gallery]));

            foreach (DirectoryInfo f in (await repository.GetAllAsync(UIHelper.GetOrderByIQueryableDelegate <DirectoryInfo>(nameof(DirectoryInfo.LastWriteTime) + " desc"), null, null)))
            {
                nodes.Add(
                    new SitemapNode()
                {
                    Url       = Url.AbsoluteUrl("Gallery", "Gallery", AppSettings, new { name = f.Name.ToSlug() }),
                    Frequency = SitemapFrequency.Weekly,
                    Priority  = 0.7
                });
            }

            foreach (LocationDto l in (await _locationService.GetAllAsync(cancellationToken, null, null, null)))
            {
                if (!string.IsNullOrEmpty(l.UrlSlug))
                {
                    nodes.Add(
                        new SitemapNode()
                    {
                        Url       = Url.AbsoluteUrl <LocationsController>(lc => lc.Location(l.UrlSlug), AppSettings),
                        Frequency = SitemapFrequency.Weekly,
                        Priority  = 0.6
                    });
                }
            }

            return(nodes);
        }