コード例 #1
0
        private static void AnalyzeMetas(ref PageFragment pf, ref HtmlDocument htmlDocument)
        {
            List <HtmlNode> metas = htmlDocument.DocumentNode.Descendants("meta").ToList();

            foreach (HtmlNode meta in metas)
            {
                if (meta.GetAttributeValue("name", "null") == "robots")
                {
                    if (meta.GetAttributeValue("content", "null") == "noindex")
                    {
                        pf.Indexability       = "Non-Indexable";
                        pf.IndexabilityStatus = "Noindex";
                    }
                }
                else if (meta.GetAttributeValue("name", "null") == "description")
                {
                    if (pf.MetaDescriptions.Count == Utils.MaxDescs)
                    {
                        continue;
                    }

                    MetaDescription metaDesc = new MetaDescription();
                    metaDesc.MetaDescriptionText   = meta.GetAttributeValue("content", "");
                    metaDesc.MetaDescriptionLength = metaDesc.MetaDescriptionText.Length;

                    Font arialBold = new Font("Arial", 13.0F);
                    metaDesc.MetaDescriptionPixelWidth = System.Windows.Forms.TextRenderer
                                                         .MeasureText(metaDesc.MetaDescriptionText, arialBold).Width;

                    pf.MetaDescriptions.Add(metaDesc);
                }
                else if (meta.GetAttributeValue("name", "null") == "keywords")
                {
                    if (pf.MetaKeywords.Count == Utils.MaxKeywords)
                    {
                        continue;
                    }

                    MetaKeywords metaKey = new MetaKeywords();
                    metaKey.MetaKeywordsText   = meta.GetAttributeValue("content", "");
                    metaKey.MetaKeywordsLength = metaKey.MetaKeywordsText.Length;

                    pf.MetaKeywords.Add(metaKey);
                }
            }
        }
コード例 #2
0
ファイル: MediaDetail.cs プロジェクト: kikkoi/FlexDotnetCMS
        public string GetMetaKeywords()
        {
            if (!string.IsNullOrEmpty(contextMetaKeywords))
            {
                return(contextMetaKeywords);
            }

            var metaKeywords = MetaKeywords.Trim();

            if (string.IsNullOrEmpty(metaKeywords) || metaKeywords.Length < 30)
            {
                metaKeywords = GetPageTitle();
            }

            contextMetaKeywords = metaKeywords;

            return(contextMetaKeywords);
        }
コード例 #3
0
        private void showContent()
        {
            MAHAITDBAccess = new BL.BL(System.Configuration.ConfigurationManager.AppSettings["APPID"].ToString());

            LangID = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();

            if (Request.QueryString["Keyword"] != null)
            {
                hdn_keyword.Value = Request.QueryString["Keyword"];
            }

            if (hdn_keyword.Value != string.Empty)
            {
                KeywordChange = Convert.ToString(hdn_keyword.Value);
                SearchString  = "<span style='background:yellow;'>" + KeywordChange + "</span>";
            }

            string siteUrl = string.Empty;

            siteUrl = Request.Url.OriginalString.Replace(HttpUtility.UrlDecode(Request.Url.PathAndQuery), string.Empty);
            int tempMenuID = 0;

            if (Int32.TryParse(this.Page.RouteData.Values["MenuID"].ToString(), out tempMenuID))
            {
                MenuID = Convert.ToInt32(this.Page.RouteData.Values["MenuID"].ToString());
            }
            else if (this.Request.QueryString["MenuID"] != null)
            {
                if (Int32.TryParse(this.Request.QueryString["MenuID"].ToString(), out tempMenuID))
                {
                    MenuID = Convert.ToInt32(this.Request.QueryString["MenuID"].ToString());
                }
            }

            //if (this.Page.RouteData.Values["MenuID"] != null)
            //{
            //    MenuID = Convert.ToInt32(this.Page.RouteData.Values["MenuID"].ToString());
            //}
            //else
            //{
            //    MenuID = Convert.ToInt32(this.Request.QueryString["MenuID"].ToString());
            //}

            if (MenuID != 0)
            {
                objCMSSchema.MenuID = MenuID;

                //To Bind Menu
                BindLeftMenu(objCMSSchema.MenuID);



                objCMSSchema.LangType    = Convert.ToString(LangID).ToLower();
                objCMSSchema.IsQuickMenu = false;
                ds = objCMSBL.GetCMSDetails(objCMSSchema);
                if (ds != null)
                {
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        if (objCMSSchema.MenuID != 1030)
                        {
                            lblHeading.Text    = Convert.ToString(ds.Tables[0].Rows[0]["PageHeading"]);
                            lblHeading.Visible = true;
                        }
                        PageTile        = Convert.ToString(ds.Tables[0].Rows[0]["PageTitle"]);
                        MetaDescription = Convert.ToString(ds.Tables[0].Rows[0]["MetaDescription"]);

                        MetaKeywords = Convert.ToString(ds.Tables[0].Rows[0]["MetaKeywords"]);
                        string DepartmentName = string.Empty;
                        if (Convert.ToString(LangID).ToLower() == Convert.ToString("mr-IN").ToLower())
                        {
                            DepartmentName = System.Configuration.ConfigurationManager.AppSettings["DepartmentNameMarathi"].ToString();
                        }
                        else if (Convert.ToString(LangID).ToLower() == Convert.ToString("en-IN").ToLower())
                        {
                            DepartmentName = System.Configuration.ConfigurationManager.AppSettings["DepartmentNameEnglish"].ToString();
                        }
                        else
                        {
                            DepartmentName = System.Configuration.ConfigurationManager.AppSettings["DepartmentNameUrdu"].ToString();
                        }
                        this.Page.Title           = PageTile + "-" + DepartmentName;
                        this.Page.MetaDescription = MetaDescription;
                        this.Page.MetaKeywords    = MetaKeywords;

                        StringBuilder contentHtml = new StringBuilder();

                        if (rowscount != 0)
                        {
                            foreach (DataRow dr in ds.Tables[1].Rows)
                            {
                                contentHtml.Append("<div class='col-xs-12 col-sm-9 col-md-9 col-lg-9 border-l'> ");
                                contentHtml.Append("<div class='archive'>");
                                if (Convert.ToString(dr["PageTitle"]) != string.Empty)
                                {
                                    contentHtml.Append("<h2>");
                                    contentHtml.Append(Convert.ToString(dr["PageTitle"]));
                                    contentHtml.Append("</h2>");
                                }


                                contentHtml.Append("<div>");

                                if (Convert.ToString(dr["ShortDescription"]) != "")
                                {
                                    contentHtml.Append(Convert.ToString(dr["ShortDescription"]));
                                }
                                else
                                {
                                    if (Convert.ToString(dr["LongDescription"]) != "")
                                    {
                                        contentHtml.Append(Convert.ToString(dr["LongDescription"]).Replace("~", Request.Url.OriginalString.Replace(HttpUtility.UrlDecode(Request.Url.PathAndQuery), string.Empty)));
                                    }
                                    else
                                    {
                                        contentHtml.Append("Information not Available !!!");
                                    }
                                }
                                contentHtml.Append("</div>");

                                if (Convert.ToString(dr["ShortDescription"]) != "")
                                {
                                    if (LangID == "en-IN")
                                    {
                                        contentHtml.Append("<a class='read_more' href='" + siteUrl + "/" + dr["MenuID"] + "/" + Convert.ToString(dr["MenuContentID"]) + "/" + Convert.ToString(dr["Title"]).Replace(" ", "-") + "'> More " + Convert.ToString(dr["PageTitle"]) + " </a>");
                                    }
                                    else
                                    {
                                        contentHtml.Append("<a class='read_more' href='" + siteUrl + "/" + dr["MenuID"] + "/" + Convert.ToString(dr["MenuContentID"]) + "/" + Convert.ToString(dr["Title"]).Replace(" ", "-") + "'> अधिक " + Convert.ToString(dr["PageTitle"]) + "</a>");
                                    }
                                }

                                contentHtml.Append("</div>");
                                contentHtml.Append("</div>");
                            }
                        }
                        else
                        {
                            foreach (DataRow dr in ds.Tables[1].Rows)
                            {
                                contentHtml.Append("<div class='col-xs-12 col-sm-12 col-md-12 col-lg-12'> ");
                                contentHtml.Append("<div class='archive'>");
                                if (Convert.ToString(dr["PageTitle"]) != string.Empty)
                                {
                                    contentHtml.Append("<h2>");
                                    contentHtml.Append(Convert.ToString(dr["PageTitle"]));
                                    contentHtml.Append("</h2>");
                                }


                                contentHtml.Append("<div>");

                                if (Convert.ToString(dr["ShortDescription"]) != "")
                                {
                                    contentHtml.Append(Convert.ToString(dr["ShortDescription"]));
                                }
                                else
                                {
                                    if (Convert.ToString(dr["LongDescription"]) != "")
                                    {
                                        contentHtml.Append(Convert.ToString(dr["LongDescription"]).Replace("~", Request.Url.OriginalString.Replace(HttpUtility.UrlDecode(Request.Url.PathAndQuery), string.Empty)));
                                    }
                                    else
                                    {
                                        contentHtml.Append("Information not Available !!!");
                                    }
                                }
                                contentHtml.Append("</div>");

                                if (Convert.ToString(dr["ShortDescription"]) != "")
                                {
                                    if (LangID == "en-IN")
                                    {
                                        contentHtml.Append("<a class='read_more' href='" + siteUrl + "/" + dr["MenuID"] + "/" + Convert.ToString(dr["MenuContentID"]) + "/" + Convert.ToString(dr["Title"]).Replace(" ", "-") + "'> More " + Convert.ToString(dr["PageTitle"]) + " </a>");
                                    }
                                    else
                                    {
                                        contentHtml.Append("<a class='read_more' href='" + siteUrl + "/" + dr["MenuID"] + "/" + Convert.ToString(dr["MenuContentID"]) + "/" + Convert.ToString(dr["Title"]).Replace(" ", "-") + "'> अधिक " + Convert.ToString(dr["PageTitle"]) + "</a>");
                                    }
                                }

                                contentHtml.Append("</div>");
                                contentHtml.Append("</div>");
                            }
                        }



                        if (KeywordChange != "")
                        {
                            CMSContent.InnerHtml = HttpUtility.HtmlDecode(Convert.ToString(Regex.Replace(contentHtml.ToString(), KeywordChange, SearchString, RegexOptions.IgnoreCase)));
                        }
                        else
                        {
                            CMSContent.InnerHtml = HttpUtility.HtmlDecode(Convert.ToString(contentHtml));
                        }

                        if (KeywordChange != "")
                        {
                            lblHeading.Text.Replace(KeywordChange, SearchString);
                            PageTile.Replace(KeywordChange, SearchString);
                            MetaDescription.Replace(KeywordChange, SearchString);
                            MetaKeywords.Replace(KeywordChange, SearchString);
                        }
                    }
                }
            }
            else
            {
                CMSContent.InnerHtml = "Error !!!";
            }
        }
コード例 #4
0
        private void showContent()
        {
            LangID = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();

            MAHAITDBAccess = new BL.BL(System.Configuration.ConfigurationManager.AppSettings["APPID"].ToString());

            if (Request.QueryString["Keyword"] != null)
            {
                hdn_keyword.Value = Request.QueryString["Keyword"];
            }

            if (hdn_keyword.Value != string.Empty)
            {
                KeywordChange = Convert.ToString(hdn_keyword.Value);
                SearchString  = "<span style='background:yellow;'>" + KeywordChange + "</span>";
            }

            //TODO Check Why "MenuID" contain "Images", should contain int only

            if (this.Page.RouteData.Values["MenuID"] != null)
            {
                if (Int32.TryParse(this.Page.RouteData.Values["MenuID"].ToString(), out MenuID) == false)
                {
                    MenuID = 0;
                }
            }
            else if (this.Request.QueryString["MenuID"] != null)
            {
                if (Int32.TryParse(this.Request.QueryString["MenuID"].ToString(), out MenuID) == false)
                {
                    MenuID = 0;
                }
            }

            if (this.Page.RouteData.Values["ContentID"] != null)
            {
                if (Int32.TryParse(this.Page.RouteData.Values["ContentID"].ToString(), out ContentID) == false)
                {
                    ContentID = 0;
                }
            }
            else if (this.Request.QueryString["ContentID"] != null)
            {
                if (Int32.TryParse(this.Request.QueryString["ContentID"].ToString(), out ContentID) == false)
                {
                    ContentID = 0;
                }
            }

            //------------

            t_SQLCmd = new SqlCommand();
            if (ContentID != 0)
            {
                objCMSSchema.MenucontentID = ContentID;
                objCMSSchema.MenuID        = MenuID;
                objCMSSchema.IsQuickMenu   = false;
                objCMSSchema.LangType      = Convert.ToString(LangID).ToLower();
                ds = objCMSBL.GetCMSMoreDetails(objCMSSchema);
                if (ds != null)
                {
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        lblHeading.Text = Convert.ToString(ds.Tables[0].Rows[0]["PageTitle"]);
                        PageTile        = Convert.ToString(ds.Tables[0].Rows[0]["PageTitle"]);

                        if (ds.Tables[1].Rows.Count > 0)
                        {
                            MetaDescription = Convert.ToString(ds.Tables[1].Rows[0]["MetaDescription"]) != "" ? Convert.ToString(ds.Tables[1].Rows[0]["MetaDescription"]) : "";
                            MetaKeywords    = Convert.ToString(ds.Tables[1].Rows[0]["MetaKeywords"]) != "" ? Convert.ToString(ds.Tables[1].Rows[0]["MetaKeywords"]) : "";
                        }

                        this.Page.Title           = PageTile;
                        this.Page.MetaDescription = MetaDescription;
                        this.Page.MetaKeywords    = MetaKeywords;

                        StringBuilder contentHtml = new StringBuilder();
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            contentHtml.Append("<div class='archive-more'>");
                            if (Convert.ToString(dr["ShortDescription"]) != "" || Convert.ToString(dr["LongDescription"]) != "")
                            {
                                contentHtml.Append("<p> ");
                                contentHtml.Append(Convert.ToString(dr["ShortDescription"]).Replace("~", Request.Url.OriginalString.Replace(HttpUtility.UrlDecode(Request.Url.PathAndQuery), string.Empty)));
                                contentHtml.Append("</p> ");
                                contentHtml.Append(Convert.ToString(dr["LongDescription"]).Replace("~", Request.Url.OriginalString.Replace(HttpUtility.UrlDecode(Request.Url.PathAndQuery), string.Empty)));
                            }
                            else
                            {
                                contentHtml.Append("Information not Available !!!");
                            }
                            contentHtml.Append("</div>");
                        }

                        if (KeywordChange != "")
                        {
                            CMSContent.InnerHtml = HttpUtility.HtmlDecode(Convert.ToString(Regex.Replace(contentHtml.ToString(), KeywordChange, SearchString, RegexOptions.IgnoreCase)));
                        }
                        else
                        {
                            CMSContent.InnerHtml = HttpUtility.HtmlDecode(Convert.ToString(contentHtml));
                        }
                        if (KeywordChange != "")
                        {
                            lblHeading.Text.Replace(KeywordChange, SearchString);
                            PageTile.Replace(KeywordChange, SearchString);
                            MetaDescription.Replace(KeywordChange, SearchString);
                            MetaKeywords.Replace(KeywordChange, SearchString);
                        }
                    }
                }
                else
                {
                    CMSContent.InnerHtml = "Web site Content Under Departmental Aproval !!!";
                }
            }
        }