Beispiel #1
0
        private void bWorker_DoWork_1(object sender, DoWorkEventArgs e)
        {
            String website = "www.smokeball.com.au";
            String keyword = "Conveyancing Software";
            int    _Count  = 0;

            keyword results = GetPosition(website, keyword);

            if (results.Link != null)
            {
                string link       = results.Link;
                var    linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b?&sa", RegexOptions.Compiled | RegexOptions.IgnoreCase);

                foreach (Match m in linkParser.Matches(link))
                {
                    link = m.Value;
                }
                string pattern     = "&sa";
                string replacement = "";
                Regex  rgx         = new Regex(pattern);
                string new_link    = rgx.Replace(link, replacement);
                if (results.Postion > 0)
                {
                    SEO_DataTable.Rows.Add(website, keyword, results.Postion.ToString(), link);
                    if (SEOData.InvokeRequired)
                    {
                        SEOData.Invoke(new MethodInvoker(delegate { SEOData.DataSource = SEO_DataTable; }));
                    }
                    _Count++;
                }
            }
        }
Beispiel #2
0
        public void GetDeatilsFromUrl(bool isExternalLinks, bool isMetaTags, bool isWordCount, bool isStopWord,
                                      string searchText, string spotWordsPath, int linkcount, int metaTagsCount, int wordsCount)
        {
            var @params = new SEOParams()
            {
                IsExternalLinks = isExternalLinks,
                IsMetaTags      = isMetaTags,
                IsWordCount     = isWordCount,
                IsStopWord      = isStopWord,
                SearchText      = searchText,
                SpotWordsPath   = spotWordsPath
            };
            var data = new SEOData();
            var mockwebParserProvider = Substitute.For <IWebParserProvider>();
            var SEOAnalyserProvider   = Substitute.For <ISEOAnalyserProvider>();
            var mockSEOBuilderFactory = Substitute.For <ISEOBuilderFactory>();

            IDictionary <string, int> linksCount = new Dictionary <string, int>();

            linksCount.Add("hello", 1);
            linksCount.Add("batman", 10);

            IDictionary <string, int> metaTags = new Dictionary <string, int>();

            metaTags.Add("animal", 1);
            metaTags.Add("design", 1);

            SEOAnalyserProvider.GetExternalLinks(@params.SearchText).Returns(linksCount);
            SEOAnalyserProvider.GetMetaTasDetails(@params).Returns(metaTags);
            SEOAnalyserProvider.GetWordsDetails(@params).Returns(new Dictionary <string, int>());
            mockSEOBuilderFactory.Build(@params.SearchText).Returns(SEOAnalyserProvider);
            var AnalyserManager = new AnalyserManager(mockSEOBuilderFactory, data);


            var result = AnalyserManager.GetDetails(@params);

            Assert.AreEqual(result.LinksCount.Count, linksCount.Count);
            Assert.AreEqual(result.MetatagsCount.Count, metaTags.Count);
        }
Beispiel #3
0
 protected override void DeleteSEO()
 {
     SEOData.DeleteSEOData("~/", "news-press-details.aspx", "Id", NewsPressID);
 }
 //for Unit test only
 public AnalyserManager(ISEOBuilderFactory builder, SEOData data)
 {
     _builder = builder;
     _data    = data;
 }
 public AnalyserManager(ISEOBuilderFactory builder)
 {
     _builder = builder;
     _data    = new SEOData();
 }
Beispiel #6
0
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            string micrositeName = requestContext.RouteData.Values.ContainsKey("Microsite") ? requestContext.RouteData.Values["Microsite"].ToString() : string.Empty;
            string pageName      = requestContext.RouteData.Values.ContainsKey("CMPage") ? requestContext.RouteData.Values["CMPage"].ToString() : requestContext.RouteData.Values["MicrositeOrCMPage"].ToString();
            string virtualPath   = string.Empty;
            string templateName  = string.Empty;

            if (File.Exists(requestContext.HttpContext.Server.MapPath("~/") + pageName + (pageName.EndsWith(".aspx") ? "" : ".aspx")))
            {
                virtualPath = "~/" + pageName + (pageName.EndsWith(".aspx") ? "" : ".aspx");
                if (!String.IsNullOrEmpty(micrositeName))
                {
                    CMSHelpers.SetCurrentRequestCMSMicrosite(CMMicrosite.CMMicrositeGetByName(micrositeName.Replace("-", " ")).FirstOrDefault(), requestContext.HttpContext.ApplicationInstance.Context);
                }
            }
            else
            {
                SEOData seo = SEOData.SEODataGetByFriendlyFilename(pageName).Find(s => s.Approved && (!s.LanguageID.HasValue || s.LanguageID == Helpers.GetCurrentLanguage().LanguageID));
                if (!String.IsNullOrEmpty(micrositeName) && seo == null)
                {
                    seo = SEOData.SEODataGetByFriendlyFilename(micrositeName + "/" + pageName).Find(s => s.Approved && (!s.LanguageID.HasValue || s.LanguageID == Helpers.GetCurrentLanguage().LanguageID));
                }
                if (seo != null)
                {
                    virtualPath = seo.PageURL;
                    if (!String.IsNullOrEmpty(micrositeName))
                    {
                        CMSHelpers.SetCurrentRequestCMSMicrosite(CMMicrosite.CMMicrositeGetByName(micrositeName.Replace("-", " ")).FirstOrDefault(), requestContext.HttpContext.ApplicationInstance.Context);
                    }
                }
                else
                {
                    CMPage      cmsPage         = null;
                    CMMicrosite micrositeEntity = null;
                    if (Classes.ContentManager.Settings.EnableMicrosites)
                    {
                        micrositeEntity = CMMicrosite.CMMicrositeGetByName((!String.IsNullOrEmpty(micrositeName) ? micrositeName : pageName).Replace("-", " ")).FirstOrDefault();
                        if (micrositeEntity != null && String.IsNullOrEmpty(micrositeName))
                        {
                            cmsPage = CMPage.CMPagePage(0, 0, "", "", true, new CMPage.Filters {
                                FilterCMPageFileName = "Home" + (Globals.Settings.RequireASPXExtensions ? ".aspx" : string.Empty), FilterCMPageDeleted = false.ToString(), FilterCMPageCMMicrositeID = micrositeEntity.CMMicroSiteID.ToString()
                            }).FirstOrDefault(c => !c.OriginalCMPageID.HasValue);
                        }
                    }
                    if (cmsPage == null)
                    {
                        cmsPage = CMPage.CMPagePage(0, 0, "", "", true, new CMPage.Filters {
                            FilterCMPageDeleted = false.ToString(), FilterCMPageFileName = pageName, FilterCMPageCMMicrositeID = (micrositeEntity != null ? micrositeEntity.CMMicroSiteID.ToString() : null)
                        }).FirstOrDefault(c => !c.OriginalCMPageID.HasValue);
                    }

                    if (cmsPage == null || !cmsPage.CMTemplateID.HasValue)                     //No templateID means its a global region since programmed pages wouldn't be hitting this
                    {
                        requestContext.HttpContext.Response.Redirect("~/" + (!String.IsNullOrEmpty(micrositeName) ? micrositeName + "/" : string.Empty) + "404.aspx?page=" + pageName);
                    }
                    else
                    {
                        CMTemplate cmTemplate = CMTemplate.GetByID(cmsPage.CMTemplateID.Value);
                        CMSHelpers.SetCurrentRequestCMSPage(cmsPage, requestContext.HttpContext.ApplicationInstance.Context);
                        if (micrositeEntity != null)
                        {
                            CMSHelpers.SetCurrentRequestCMSMicrosite(micrositeEntity, requestContext.HttpContext.ApplicationInstance.Context);
                        }
                        templateName = cmTemplate.FileName;
                        virtualPath  = "~/" + templateName + "?filename=" + pageName;
                    }
                }
            }
            //Showcase hardcoding fix
            virtualPath = virtualPath.Replace("~/home-details", "~/showcase-item.aspx");
            string queryString = ((virtualPath.Contains("?") ? "&" : "?") + requestContext.HttpContext.Request.QueryString).TrimEnd('?').TrimEnd('&');

            HttpContext.Current.RewritePath(virtualPath + queryString, false);
            try
            {
                return((Page)BuildManager.CreateInstanceFromVirtualPath(virtualPath.Split('?')[0], typeof(Page)));
            }
            catch (Exception ex)
            {
                if (!String.IsNullOrEmpty(templateName) && ex.Message.Contains(templateName))
                {
                    throw new Exception("Could not load the page.  Does the CMS Template file '" + virtualPath.Split('?')[0] + "' exist?");
                }
                else
                {
                    throw ex;
                }
            }
        }
Beispiel #7
0
 protected override void DeleteSEO()
 {
     SEOData.DeleteSEOData("~/", "newsletter-details.aspx", "Id", NewsletterID);
 }
Beispiel #8
0
 protected override void DeleteSEO()
 {
     SEOData.DeleteSEOData("~/", "home-details", "id", ShowcaseItemID);
 }
Beispiel #9
0
 protected override void DeleteSEO()
 {
     SEOData.DeleteSEOData("~/" + Name, "", "", null);
 }
Beispiel #10
0
        public static void LoadSEOData(string pageURL, string queryString)
        {
            Page          page         = HttpContext.Current.CurrentHandler as Page;
            StringBuilder titleBuilder = new StringBuilder();
            string        oldPageTitle = string.Empty;

            if (page != null && page.Header != null)
            {
                oldPageTitle = page.Title;
                titleBuilder.Append(Globals.Settings.SiteTitle);
                if (!String.IsNullOrEmpty(page.Title))
                {
                    page.Title = page.Title + " - " + titleBuilder;
                }
                else
                {
                    page.Title = titleBuilder.ToString();
                }

                if (HttpContext.Current != null)
                {
                    page.Title = HttpContext.Current.Server.HtmlEncode(page.Title);
                }
                else
                {
                    page.Title = page.Title.Replace("& ", "&amp; ");
                }
            }
            //Check if SEO output is desired
            //Don't hit database for Admin pages
            if (!Config.Settings.DisableDynamicSEOOutput && !pageURL.ToLower().Contains("admin/") && !pageURL.ToLower().Contains("blog/") && !pageURL.ToLower().Contains("forum/") && !pageURL.ToLower().Contains("tft-js/core/") && page != null && !pageURL.ToLower().Contains("session-keep-alive.aspx"))
            {
                if (!String.IsNullOrEmpty(page.Request.QueryString["filename"]))
                {
                    pageURL     = "~/" + Classes.ContentManager.CMSHelpers.GetCurrentRequestCMSPagePathWithMicrosite();
                    queryString = queryString.Replace("filename=" + page.Request.QueryString["filename"], string.Empty);
                }

                //Get the data from the database for the possible page - URL
                SEOData currentSEO = SEOData.GetSEOForSpecificPath(pageURL, queryString);
                if (currentSEO != null)
                {
                    //Using this in case it is decided to setup somethig for the title besides what is typed in
                    if (!string.IsNullOrEmpty(currentSEO.Title) && !currentSEO.Title.Equals("Default Title"))
                    {
                        titleBuilder.Insert(0, currentSEO.Title + " - ");
                    }
                    else
                    {
                        titleBuilder.Insert(0, String.IsNullOrEmpty(oldPageTitle) ? "" : oldPageTitle + " - ");
                    }

                    if (page.Header != null)
                    {
                        if (HttpContext.Current != null)
                        {
                            page.Title = HttpContext.Current.Server.HtmlEncode(titleBuilder.ToString());
                        }
                        else
                        {
                            page.Title = titleBuilder.ToString().Replace("& ", "&amp; ");
                        }

                        page.MetaDescription = currentSEO.Description + (!String.IsNullOrEmpty(page.MetaDescription) ? ", " + page.MetaDescription : "");
                        page.MetaKeywords    = currentSEO.Keywords + (!String.IsNullOrEmpty(page.MetaKeywords) ? ", " + page.MetaKeywords : "");
                    }
                }
            }
        }