Exemplo n.º 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        ReqUtils  gn      = new ReqUtils();
        ArrayList NewList = gn.ExtractNewsLinks(txtString.Text, txtRegEx.Text, "");

        Response.Write(NewList.Count);
    }
Exemplo n.º 2
0
        private void SaveTabir(string WordName, string TabirUrl)
        {
            ReqUtils Reqs = new ReqUtils();

            TabirUrl = TabirUrl.Replace("\" target=\"_blank", "");
            string Result   = Reqs.GetHTML(TabirUrl, System.Text.Encoding.UTF8);
            string _pattern = @" class=""contentpaneopen_text"">\s*(.*?)</div>";
            Regex  r        = new Regex(_pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
            Match  m        = r.Match(Result);

            if (m.Success)
            {
                string Meaning = m.Groups[1].Captures[0].ToString();
                Meaning = Reqs.RemoveTags(Meaning);

                TabirDataContext            dc        = new TabirDataContext();
                Parsetv91._1.Code.DAL.Tabir NewRecord = new Code.DAL.Tabir();
                dc.Tabirs.InsertOnSubmit(NewRecord);
                NewRecord.WordName = WordName;
                NewRecord.Meaning  = Meaning;
                NewRecord.ID       = MainCounter.ToString();
                MainCounter++;
                dc.SubmitChanges();
            }
        }
Exemplo n.º 3
0
        public string FormatText2(Object obj, int CharCount)
        {
            if (obj == null)
            {
                return("");
            }
            ReqUtils rUtil = new ReqUtils();

            return(Tools.ShowBriefText(rUtil.RemoveTags(obj.ToString()), CharCount));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 将数据转化为模型
        /// 2016-04-18 基础数据类型:Int32,decimal
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        public static void ConvertToModel <T>(ref T t)
        {
            System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
            Type[] tempArr    = new Type[] { typeof(Int32), typeof(decimal) };
            object tempObject = null;

            for (Int32 i = 0; i < properties.Length; i++)
            {
                if (ReqUtils.FormString(properties[i].Name) != null || properties[i].PropertyType.Name.ToLower() == "httpfilecollection")
                {
                    switch (properties[i].PropertyType.Name.ToLower())
                    {
                    case "int32": tempObject = ConvertHelper.ToInt32(string.Format("{0}", ReqUtils.FormString(properties[i].Name))); break;

                    case "decimal": tempObject = ConvertHelper.ToDecimal(string.Format("{0}", ReqUtils.FormString(properties[i].Name))); break;

                    case "httpfilecollection": tempObject = System.Web.HttpContext.Current.Request.Files; break;

                    case "nullable`1":
                        if (properties[i].PropertyType.FullName.ToLower().Contains("int32"))
                        {
                            tempObject = ConvertHelper.ToInt32(string.Format("{0}", ReqUtils.FormString(properties[i].Name)));
                        }
                        else if (properties[i].PropertyType.FullName.ToLower().Contains("datetime"))
                        {
                            tempObject = ConvertHelper.ToDateTime(string.Format("{0}", ReqUtils.FormString(properties[i].Name)));
                        }
                        else
                        {
                            tempObject = null;
                        }
                        break;

                    case "boolean": tempObject = ConvertHelper.ToType <bool>(string.Format("{0}", ReqUtils.FormString(properties[i].Name))); break;   //2016-08-19zc

                    default:
                        tempObject = string.Format("{0}", ReqUtils.FormString(properties[i].Name));
                        break;
                    }
                    properties[i].SetValue(t, tempObject, null);
                }
            }
        }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            int    Code;
            string strCode = Request["Code"];
            Int32.TryParse(strCode, out Code);
            if (Code != 0)
            {
                BOLNews NewsBOL = new BOLNews();
                News    CurNews = ((IBaseBOL <News>)NewsBOL).GetDetails(Code);
                if (CurNews != null)
                {
                    Page.Title    = CurNews.Title;
                    hplTitle.Text = CurNews.Title;
                    //hplTitle.NavigateUrl = "~/News/" + Code + ".htm";
                    lblDate.Text = Tools.GetPrettyDate((DateTime)CurNews.NewsDate);
                    string   FullStory = CurNews.Contents;
                    ReqUtils Utils     = new ReqUtils();
                    FullStory = Utils.RemoveTags(FullStory);

                    lblContents.Text = Tools.ShowBriefText(FullStory, 300);
                    if (CurNews.PicName != null && CurNews.PicName != "")
                    {
                        imgPic.ImageUrl = CurNews.ImgUrl;
                        imgPic.CssClass = "img-fluid";
                    }
                    else
                    {
                        imgPic.Visible = false;
                    }
                    NewsList1.ShowRelatedNews(Code);
                }
            }
        }
        catch (Exception err)
        {
            BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs();
            ErrorLogsBOL.Insert(err.Message, DateTime.Now, Request.Url.AbsolutePath, "RelatedNews::Load");
        }
    }
Exemplo n.º 6
0
        protected void btnakairan_Click(object sender, EventArgs e)
        {
            int      Counter = 0;
            ReqUtils Reqs    = new ReqUtils();


            string Params = "-a.html,-b.html,-p.html,-t.html,-se.html,-j.html,-ch.html,-h.html,-kh.html,-d.html-zal.html,-r.html,-z.html,24263.html,-sin.html,-shin.html,-sad.html,-zad.html,-ta.html,-za.html,-eyn.html,-ghein.html,-f.html-gh.html,-k.html,-g.html,-l.html,-m.html,-n.html,-v.html,-he.html,-ye.html";

            string[] ParamsArray = Params.Split(',');
            for (int i = 0; i < ParamsArray.Length; i++)
            {
                string CurUrl = "";
                if (ParamsArray[i] == "")
                {
                    CurUrl = "http://tabirkhab.akairan.com/sleep/sleep/";
                }
                else
                {
                    CurUrl = "http://tabirkhab.akairan.com/sleep/sleep/jadval" + ParamsArray[i];
                }
                string Result   = Reqs.GetHTML(CurUrl, System.Text.Encoding.UTF8);
                string _pattern = @"<td class=""buttmtbl""><a href=""(.*?)"">(.*?)</a></td>";
                Regex  r        = new Regex(_pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                Match  m        = r.Match(Result);
                while (m.Success)
                {
                    Title = m.Groups[2].Captures[0].ToString();
                    Title = Tools.PersianTextCorrection(Title);
                    if (GetTabirCount(Title) == 0)
                    {
                        string TabirUrl = m.Groups[1].Captures[0].ToString();
                        SaveTabir(Title, TabirUrl);
                        Counter++;
                    }
                    m = m.NextMatch();
                }
                lblMessage.Text = Counter + " Tabirs added";
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //TextNewsList2.ShowLatestTextNews(100);

                int    Code;
                string strCode = Request["Code"];
                Int32.TryParse(strCode, out Code);
                if (Code != 0)
                {
                    BOLNews NewsBOL = new BOLNews();
                    //PageTools1.ItemCode = Code;
                    //PageTools1.HCEntityCode = 1;
                    vNewsDetail CurNews = NewsBOL.GetNewsByCode(Code);
                    if (CurNews == null)
                    {
                        msgText.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error;
                        msgText.Text            = "No news found";
                        //pnlShowNews.Visible = false;
                        return;
                    }

                    NewsUrl = CurNews.Url;
                    if (!NewsUrl.StartsWith("http://"))
                    {
                        NewsUrl = "http://" + NewsUrl;
                    }



                    NewsUrl = NewsUrl.Replace("http://https://", "https://");

                    Response.Redirect(NewsUrl);
                    Response.End();
                    return;

                    //NewsBOL.UpdateViewCount(Code);
                    Page.Title = CurNews.Title;
                    string FullStory = Tools.FormatString(CurNews.Contents);

                    HtmlMeta metaTitle = (HtmlMeta)Page.Master.FindControl("title");
                    metaTitle.Attributes["content"] = CurNews.Title.Trim();
                    HtmlMeta metaURL = (HtmlMeta)Page.Master.FindControl("url");
                    metaURL.Attributes["content"] = "https://www.khabardaan.ir/N" + CurNews.Code + "_" + Tools.ReplaceSpaceWithUnderline(CurNews.Title) + ".html";
                    HtmlMeta metaKeywords = (HtmlMeta)Page.Master.FindControl("keywords");
                    metaKeywords.Attributes["content"] = "";
                    HtmlMeta metaDescription = (HtmlMeta)Page.Master.FindControl("description");
                    string   BriefStory      = Tools.ShowBriefText(FullStory, 1100);
                    ReqUtils Utils           = new ReqUtils();
                    BriefStory = Utils.RemoveTags(BriefStory);
                    metaDescription.Attributes["content"] = BriefStory;

                    if (!string.IsNullOrEmpty(CurNews.PicName))
                    {
                        HtmlMeta metaImage = (HtmlMeta)Page.Master.FindControl("image");
                        metaImage.Attributes["content"] = "https://www.khabardaan.ir/Files/News/" + CurNews.PicName;
                    }


                    DateTimeMethods dtm = new DateTimeMethods();



                    if (Request.UserAgent == "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" ||
                        Request.UserAgent == "msnbot/2.0b (+http://search.msn.com/msnbot.htm)._" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" ||
                        Request.UserAgent == "Mozilla/5.0 (en-us) AppleWebKit/525.13 (KHTML, like Gecko; Google Web Preview) Version/3.1 Safari/525.13" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.3.3; http://www.majestic12.co.uk/bot.php?+)" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)" ||
                        Request.UserAgent == "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)"
                        )
                    {
                    }
                    else
                    {
                        NewsBOL.IncrementVisitCount(Code);
                    }
                    //if (FullStory.Length < 100)
                    //{
                    //    Response.Redirect(CurNews.Url);
                    //    return;
                    //}
                }
            }
            catch (Exception err)
            {
                //Response.Write(err.Message);
            }
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //TextNewsList2.ShowLatestTextNews(100);

                int    Code;
                string strCode = Request["Code"];
                Int32.TryParse(strCode, out Code);
                if (Code != 0)
                {
                    BOLNews NewsBOL = new BOLNews();
                    //PageTools1.ItemCode = Code;
                    //PageTools1.HCEntityCode = 1;
                    vNewsDetail CurNews = NewsBOL.GetNewsByCode(Code);
                    if (CurNews == null)
                    {
                        msgText.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error;
                        msgText.Text            = "خبری با این کد یافت نشد.";
                        //pnlShowNews.Visible = false;
                        return;
                    }
                    Response.Redirect("~/N" + CurNews.Code + "_" + Tools.ReplaceSpaceWithUnderline(CurNews.Title) + ".html", false);
                    return;

                    NewsUrl = CurNews.Url;
                    //NewsBOL.UpdateViewCount(Code);
                    Page.Title = CurNews.Title;
                    string FullStory = Tools.FormatString(CurNews.Contents);

                    HtmlMeta metaTitle = (HtmlMeta)Page.Master.FindControl("title");
                    metaTitle.Attributes["content"] = CurNews.Title;
                    HtmlMeta metaURL = (HtmlMeta)Page.Master.FindControl("url");
                    metaURL.Attributes["content"] = "https://www.khabardaan.ir/news/" + CurNews.Code + ".htm";
                    HtmlMeta metaKeywords = (HtmlMeta)Page.Master.FindControl("keywords");
                    metaKeywords.Attributes["content"] = "";
                    HtmlMeta metaDescription = (HtmlMeta)Page.Master.FindControl("description");
                    string   BriefStory      = Tools.ShowBriefText(FullStory, 400);
                    ReqUtils Utils           = new ReqUtils();
                    BriefStory = Utils.RemoveTags(BriefStory);
                    metaDescription.Attributes["content"] = BriefStory;

                    if (!string.IsNullOrEmpty(CurNews.PicName))
                    {
                        HtmlMeta metaImage = (HtmlMeta)Page.Master.FindControl("image");
                        metaImage.Attributes["content"] = "https://www.khabardaan.ir/Files/News/" + CurNews.PicName;
                    }


                    DateTimeMethods dtm = new DateTimeMethods();
                    //lblViewTitle.Text = CurNews.Title;
                    //lblViewNewsDate.Text = Tools.ChangeEnc(dtm.GetPersianLongDate((DateTime)CurNews.NewsDate));

                    //RelatedNews1.NewsCode = Code.ToString();
                    //KeywordList1.NewsCode = Code.ToString();

                    //lblViewCount.Text = NewsBOL.GetVisitCount(CurNews.Code);// Tools.ChangeEnc(CurNews.ViewCount.ToString());
                    //hplResourceName.Text = "جدید ترین خبرهای " + CurNews.Name;
                    //hplResourceName.NavigateUrl = "~/News/Resources/" + CurNews.ResouseSiteCode + ".htm";

                    //hplCatName.Text = "جدید ترین خبرهای " + CurNews.CatName;
                    //hplCatName.NavigateUrl = "~/News/NewsByCatCode.aspx?Code=" + CurNews.CatCode;
                    //hplRelatedNews.NavigateUrl = "~/News/RelatedNews.aspx?Code=" + CurNews.Code;


                    //hplViewResourceName.NavigateUrl = CurNews.Url;
                    //lblViewCode.Text = CurNews.Code.ToString();
                    //lblViewNewsTime.Text = Tools.ChangeEnc(CurNews.NewsDate.Value.Hour + ":" + CurNews.NewsDate.Value.Minute);

                    //ShareFaceBook.NavigateUrl = "~/ShareLink.aspx?Media=facebook&LinkUrl=" + Server.UrlEncode("https://www.khabardaan.ir/News/ShowNews.aspx?Code=" + CurNews.Code) + "&LinkTitle=" + Server.UrlEncode(CurNews.Title);
                    //ShareDigg.NavigateUrl = "~/ShareLink.aspx?Media=digg&LinkUrl=" + Server.UrlEncode("https://www.khabardaan.ir/News/ShowNews.aspx?Code=" + CurNews.Code) + "&LinkTitle=" + Server.UrlEncode(CurNews.Title);
                    //ShareTwitter.NavigateUrl = "~/ShareLink.aspx?Media=twitter&LinkUrl=" + Server.UrlEncode("https://www.khabardaan.ir/News/ShowNews.aspx?Code=" + CurNews.Code) + "&LinkTitle=" + Server.UrlEncode(CurNews.Title);



                    //rptResourceNewsList.DataSource = NewsBOL.GetLatestNewsByResourceCode((int)CurNews.ResouseSiteCode, 4, 1);
                    //rptResourceNewsList.DataBind();

                    //rptMostVisitedNews.DataSource = NewsBOL.GetMostVisitedTextNews(5, 1, 100);
                    //rptMostVisitedNews.DataBind();

                    //rptCatNews.DataSource = NewsBOL.GetNewsByCatCode((int)CurNews.CatCode, 4, 1);
                    //rptCatNews.DataBind();

                    //rptRelatedNews.DataSource = NewsBOL.GetRelatedNews((int)CurNews.Code, 4, 1);
                    //rptRelatedNews.DataBind();
                    //if (rptRelatedNews.Items.Count == 0)
                    //    pnlRelatedNews.Visible = false;

                    BOLNewsKeywords NewsKeywordsBOL = new BOLNewsKeywords(CurNews.Code);
                    //rptKeywords.DataSource = NewsKeywordsBOL.GetTopKeywords(CurNews.Code, 3);
                    //rptKeywords.DataBind();


                    if (Request.UserAgent == "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" ||
                        Request.UserAgent == "msnbot/2.0b (+http://search.msn.com/msnbot.htm)._" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" ||
                        Request.UserAgent == "Mozilla/5.0 (en-us) AppleWebKit/525.13 (KHTML, like Gecko; Google Web Preview) Version/3.1 Safari/525.13" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.3.3; http://www.majestic12.co.uk/bot.php?+)" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" ||
                        Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)" ||
                        Request.UserAgent == "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)"
                        )
                    {
                    }
                    else
                    {
                        NewsBOL.IncrementVisitCount(Code);
                    }
                    if (FullStory.Length < 100)
                    {
                        Response.Redirect(CurNews.Url);
                        return;
                    }
                }
            }

            catch (Exception err)
            {
                BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs();
                ErrorLogsBOL.Insert(err.Message, DateTime.Now, Request.Url.AbsolutePath, "ShowExternalNews::Load");
            }
        }
Exemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            int    Code;
            string strCode = Request["Code"];
            Int32.TryParse(strCode, out Code);
            if (Code != 0)
            {
                BOLNews NewsBOL = new BOLNews();
                //PageTools1.ItemCode = Code;
                //PageTools1.HCEntityCode = 1;
                vNewsDetail CurNews = NewsBOL.GetNewsByCode(Code);
                if (CurNews == null)
                {
                    msgText.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error;
                    msgText.Text            = "No news found.";
                    pnlShowNews.Visible     = false;
                    return;
                }

                strNewsCode = CurNews.Code.ToString();
                Tools.SetLink("lnkCanonical", "https://www.khabardaan.ir/" + "/News/" + CurNews.Code + ".html");

                Tools.SetMeta("keywords", CurNews.Title);
                Tools.SetMeta("description", CurNews.Title);
                Tools.SetMeta("twittercard", CurNews.Title);
                Tools.SetMeta("twittertitle", CurNews.Title);
                Tools.SetMeta("twitterdescription", CurNews.Title);
                Tools.SetMeta("ogtitle", CurNews.Title);
                Tools.SetMeta("ogurl", "https://www.khabardaan.ir/" + "/News/" + CurNews.Code + "_" + Tools.ReplaceSpaceWithUnderline(CurNews.Title) + ".html");
                Tools.SetMeta("twitterimagesrc", "");
                if (!string.IsNullOrEmpty(CurNews.PicName))
                {
                    Tools.SetMeta("ogimage", "https://static.parset.com/Files/News/" + CurNews.PicName);
                }
                Tools.SetMeta("ogdescription", CurNews.Title);


                //NewsBOL.UpdateViewCount(Code);
                lblViewTitle.Text = CurNews.Title;
                Page.Title        = CurNews.Title + " - خبردان";
                ReqUtils Utils     = new ReqUtils();
                string   FullStory = CurNews.Contents;
                FullStory = Utils.RemoveTags(FullStory);

                FullStory = Tools.FormatString(FullStory);
                FullStory = Tools.ShowBriefText(FullStory, 3000) + "...";

                FullStory = FullStory.Replace("<img ", "<img class=\"img-responsive\" ");

                //if (FullStory.IndexOf("<br />") == -1)
                //{
                //    if(FullStory.IndexOf("<img ") == -1)
                //        lblViewContents.Text = GenParagraph(FullStory);
                //    else
                //        lblViewContents.Text = CorrectEnters(FullStory);
                //}
                //else
                //    lblViewContents.Text = FullStory;


                DataTable dtNewsImages = new Converter <NewsImages>().ToDataTable(NewsBOL.GetNewsImages(CurNews.Code));

                lblViewContents.Text = GenParagraph(FullStory, dtNewsImages);

                DateTimeMethods dtm = new DateTimeMethods();
                lblViewNewsDate.Text = Tools.ChangeEnc(dtm.GetPersianDate((DateTime)CurNews.NewsDate));
                if (!string.IsNullOrEmpty(CurNews.PicName))
                {
                    imgPicName.ImageUrl = CurNews.ImgUrl;// "https://www.khabardaan.ir/Files/News/" + CurNews.PicName;
                    imgPicName.ToolTip  = CurNews.Title;
                }
                else
                {
                    pnlPic.Visible = false;
                }
                RelatedNews1.NewsCode = Code.ToString();
                KeywordList1.NewsCode = Code.ToString();

                lblViewCount.Text        = Tools.ChangeEnc(NewsBOL.GetVisitCount(CurNews.Code));
                hplViewResourceName.Text = CurNews.Name;
                hplMoreFull.NavigateUrl  = hplViewResourceName.NavigateUrl = CurNews.Url;
                //"https://www.khabardaan.ir/N" + CurNews.Code + "_" + Tools.ReplaceSpaceWithUnderline(CurNews.Title) + ".html";
                lblViewCode.Text = CurNews.Code.ToString();

                string strNewsHour = CurNews.NewsDate.Value.Hour.ToString();
                if (strNewsHour.Length == 1)
                {
                    strNewsHour = "0" + strNewsHour;
                }
                string strNewsMinute = CurNews.NewsDate.Value.Minute.ToString();
                if (strNewsMinute.Length == 1)
                {
                    strNewsMinute = "0" + strNewsMinute;
                }

                lblViewNewsTime.Text = Tools.ChangeEnc(strNewsHour + ":" + strNewsMinute);

                News3Col1.LoadPicNews();

                //rptNewsImages.DataSource = NewsBOL.GetNewsImages(CurNews.Code);
                //rptNewsImages.DataBind();

                //rptImages.DataSource = NewsBOL.GetSmallRelatedNews(CurNews.Code, 20, 1);
                //rptImages.DataBind();


                //int CatCode = (int)CurNews.CatCode;
                //switch (CatCode)
                //{
                //    case 1:
                //        {
                //            lblCatTitle.Text = "اجتماعي ";
                //            break;
                //        }
                //    case 2:
                //        {
                //            lblCatTitle.Text = "اقتصادي";
                //            break;
                //        }
                //    case 3:
                //        {
                //            lblCatTitle.Text = "سياسي";
                //            break;
                //        }
                //    case 4:
                //        {
                //            lblCatTitle.Text = "ورزشي";
                //            break;
                //        }
                //    case 5:
                //        {
                //            lblCatTitle.Text = "علمي";
                //            break;
                //        }
                //    case 6:
                //        {
                //            lblCatTitle.Text = "فرهنگي";
                //            break;
                //        }
                //    case 7:
                //        {
                //            lblCatTitle.Text = "ادب و هنر";
                //            break;
                //        }
                //    case 8:
                //        {
                //            lblCatTitle.Text = "بين‌الملل";
                //            break;
                //        }
                //    case 9:
                //        {
                //            lblCatTitle.Text = "حوادث";
                //            break;
                //        }
                //    default:
                //        break;
                //}
                //lblCatTitle.Text = "آخرین خبرهای  " + lblCatTitle.Text ;

                //NewsList1.ShowPager = false;
                //NewsList1.ShowNewsByCatCode((int)CurNews.CatCode, null);


                if (Request.UserAgent == "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" ||
                    Request.UserAgent == "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" ||
                    Request.UserAgent == "msnbot/2.0b (+http://search.msn.com/msnbot.htm)._" ||
                    Request.UserAgent == "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" ||
                    Request.UserAgent == "Mozilla/5.0 (en-us) AppleWebKit/525.13 (KHTML, like Gecko; Google Web Preview) Version/3.1 Safari/525.13" ||
                    Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.3.3; http://www.majestic12.co.uk/bot.php?+)" ||
                    Request.UserAgent == "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" ||
                    Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)" ||
                    Request.UserAgent == "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)"
                    )
                {
                }
                else
                {
                    NewsBOL.IncrementVisitCount(Code);
                }
                //if (FullStory.Length < 100)
                //{
                //    Response.Redirect(CurNews.Url);
                //    return;
                //}

                //SmallAdsList1.ShowAdsByNewsCode(Code);


                //dtlRelatedPicNews.DataSource = NewsBOL.GetRelatedPicNews(Code);
                //dtlRelatedPicNews.DataBind();

                //ProductsDataContext pdc = new ProductsDataContext();
                //vRandPayeganGood CurRandBanner = pdc.vRandPayeganGoods.SingleOrDefault();
                //if (CurRandBanner != null)
                //{
                //    hplPBanner.ImageUrl = CurRandBanner.strHBannerURL.Trim();
                //    hplPBanner.NavigateUrl = "http://forosh.biz/Detail.aspx?q=" + CurRandBanner.strGoodCode.Trim() + "&s=9144";
                //}
                //CurRandBanner = pdc.vRandPayeganGoods.SingleOrDefault();
                //if (CurRandBanner != null)
                //{
                //    hplPBanner2.ImageUrl = CurRandBanner.strHBannerURL.Trim();
                //    hplPBanner2.NavigateUrl = "http://forosh.biz/Detail.aspx?q=" + CurRandBanner.strGoodCode.Trim() + "&s=9144";
                //}
            }
        }
        catch (Exception err)
        {
            BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs();
            ErrorLogsBOL.Insert(err.Message, DateTime.Now, Request.Url.AbsolutePath, "ShowNews::Load");
        }
    }
Exemplo n.º 10
0
    void ListNews(int privateSiteCode, string privateNewsUrl, string privateNewsTitle, string privateREDetail, string privateREImage, string privateREVideo, int Count, string LinkDomainName, int EncodingTypeCode)
    {
        ReqUtils gn = new ReqUtils();
        string   NewsContentHtml = "";
        string   FullStory       = "";
        string   ImageSource     = "";
        string   VideoSource     = "";
        string   TextTitle       = "";
        string   NewsCode        = "";

        System.Text.Encoding enc = System.Text.Encoding.UTF8;
        if (EncodingTypeCode != 1)
        {
            IBaseBOL <DataTable> BolHardCode = new BOLHardCode();
            BolHardCode.QueryObjName = "HCEncodingTypes";
            DataTable dt = BolHardCode.GetDetails(EncodingTypeCode);
            enc = System.Text.Encoding.GetEncoding(dt.Rows[0]["Description"].ToString());
        }
        privateNewsUrl = privateNewsUrl.Replace("//", "/");
        privateNewsUrl = privateNewsUrl.Replace("http:/", "http://");
        privateNewsUrl = privateNewsUrl.Replace("https:/", "https://");
        if (privateREDetail.Length > 0)
        {
            NewsContentHtml = gn.GetHTML(privateNewsUrl, enc);

            if (privateREDetail != null && privateREDetail != "")
            {
                FullStory = gn.GetREGroup(NewsContentHtml, privateREDetail, "CONTENT");
            }
            if (privateREImage != null && privateREImage != "")
            {
                ImageSource = gn.GetREGroup(NewsContentHtml, privateREImage, "IMAGE");
            }
            if (privateREVideo != null && privateREVideo != "")
            {
                VideoSource = gn.GetREGroup(NewsContentHtml, privateREVideo, "VIDEO");
            }

            if (!ImageSource.StartsWith("http://") && !ImageSource.StartsWith("https://") && ImageSource != "")
            {
                ImageSource = LinkDomainName + ImageSource;
            }


            if (!VideoSource.StartsWith("http://") && VideoSource != "")
            {
                VideoSource = LinkDomainName + VideoSource;
            }


            FullStory = gn.RemoveTags(FullStory, "br");
            FullStory = FullStory.Replace("'", "");
            FullStory = FullStory.Replace("\"", "");
            FullStory = FullStory.Replace("\r", "");
            FullStory = FullStory.Replace("\t", "");
            FullStory = FullStory.Replace("&nbsp;", "");

            ImageSource = ImageSource.Replace("[", "%5B");
            ImageSource = ImageSource.Replace("]", "%5D");

            VideoSource = VideoSource.Replace("[", "%5B");
            VideoSource = VideoSource.Replace("]", "%5D");


            if (ImageSource != "") //Save News File
            {
                try
                {
                    int       SlashPos = ImageSource.LastIndexOf("/");
                    string    FileName = ImageSource.Substring(SlashPos + 1, ImageSource.Length - SlashPos - 1);
                    WebClient WebCl    = new WebClient();
                    string    FName    = Server.MapPath("~/Files/News/" + Tools.GetRandomFileName(FileName));
                    //WebCl.DownloadFile(ImageSource, FName);
                }
                catch
                {
                }
            }
        }
        TextTitle = gn.RemoveTags(privateNewsTitle);

        string ImageTag = "";

        if (ImageSource != "")
        {
            ImageSource = "<img src=\"" + ImageSource + "\">";
        }
        string outStr = string.Format("<table border=\"1\" class=\"cNews\" dir=\"rtl\" width=\"100%\" ><tr><td>{0}</td><td >{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr></table>", Count, TextTitle, FullStory.Length, ImageSource, VideoSource, privateNewsUrl);

        Response.Write(outStr);
        Response.Flush();


        gn.Dispose();
    }
Exemplo n.º 11
0
    public void GetSingleSite(int privateSiteCode, int privateLimitCount)
    {
        int    Count           = 1;
        string NewsTitle       = "";
        string HtmlContent     = "";
        string EditedNewsTitle = "";
        string NewsTextTitle   = "";

        ReqUtils gn;

        string SelectStatement = "";

        BOLResourseSiteCats ResourceSiteCatsBOL = new BOLResourseSiteCats(1);
        vResourseSiteCats   SingleSite          = ResourceSiteCatsBOL.GetSingleSite(privateSiteCode);

        int    SiteCode         = SingleSite.Code;
        string SiteName         = SingleSite.Name;
        string SiteUrl          = SingleSite.Url;
        int?   EncodingTypeCode = SingleSite.HCEncodingTypeCode;
        string BaseURL          = SingleSite.BaseURL;

        string RELink   = SingleSite.RELink;
        string REDetail = SingleSite.REDetail;
        string REImage  = SingleSite.REImage;
        string REVideo  = SingleSite.REVideo;

        ArrayList NewList = new ArrayList();

        gn = new ReqUtils();
        System.Text.Encoding enc = System.Text.Encoding.UTF8;
        if (EncodingTypeCode != 1)
        {
            IBaseBOL <DataTable> BolHardCode = new BOLHardCode();
            BolHardCode.QueryObjName = "HCEncodingTypes";
            DataTable dt = BolHardCode.GetDetails((int)EncodingTypeCode);
            enc = System.Text.Encoding.GetEncoding(dt.Rows[0]["Description"].ToString());
        }

        int    LastSlash = SiteUrl.LastIndexOf("/");
        string LinkDomainName;

        if (BaseURL != null && BaseURL != "")
        {
            LinkDomainName = BaseURL;
        }
        else
        {
            LinkDomainName = SiteUrl.Substring(0, LastSlash + 1);
        }
        if (!(bool)SingleSite.RssIsActive)
        {
            HtmlContent = gn.GetHTML(SiteUrl, enc);
            NewList     = gn.ExtractNewsLinks(HtmlContent, RELink, LinkDomainName);
        }
        else
        {
            NewList = GetNewsList(SingleSite.RssUrl);
        }

        IEnumerator NewENum = NewList.GetEnumerator();

        gn = new ReqUtils();
        while (NewENum.MoveNext())
        {
            NewsTitle     = NewENum.Current.ToString();
            NewsTextTitle = gn.RemoveTags(NewsTitle);
            BOLNews NewsBOl = new BOLNews();

            if (!NewsBOl.CheckNewsExists(NewsTextTitle, SiteCode))
            {
                string RealLink = gn.ExtractLink(NewsTitle);
                string outStr   = "";
                //outStr = string.Format("<table width=100% ><tr><td class=\"cNews\">{1}</td><td>{0}</td></tr></table>", Count, NewsTitle);
                //Response.Write(outStr);
                //Response.Flush();
                ListNews(SiteCode, RealLink, NewsTitle, REDetail, REImage, REVideo, Count, LinkDomainName, (int)EncodingTypeCode);
            }

            Count++;
            if (privateLimitCount != 0)
            {
                if (privateLimitCount == Count)
                {
                    break;
                }
            }
        }
    }
Exemplo n.º 12
0
        public string ShowText(Object obj)
        {
            int SelectLen = 180;

            try
            {
                if (obj != null)
                {
                    string str = obj.ToString();
                    try
                    {
                        ReqUtils Utils = new ReqUtils();
                        str = Utils.RemoveTags(str);
                        if (!string.IsNullOrEmpty(_keyword))
                        {
                            string FirstKeyword = _keyword;
                            if (_keyword.IndexOf(" ") != -1)
                            {
                                string[] KeywordArray = _keyword.Split(' ');
                                FirstKeyword = KeywordArray[0];
                            }
                            int FirstKeywordIndex = str.IndexOf(FirstKeyword);
                            if (FirstKeywordIndex > SelectLen)
                            {
                                int StartIndex = FirstKeywordIndex - 150;
                                int StopIndex  = FirstKeywordIndex + 150;
                                if (StopIndex > str.Length)
                                {
                                    StopIndex = str.Length;
                                }
                                int CutLen = StopIndex - StartIndex;
                                str = "..." + str.Substring(StartIndex, CutLen) + "...";
                            }
                        }
                    }
                    catch
                    {
                    }

                    if (str.Length > SelectLen)
                    {
                        str = str.Substring(0, SelectLen) + "...";
                    }

                    if (!string.IsNullOrEmpty(_keyword))
                    {
                        _keyword = _keyword.Trim();
                        string[] KeywordArray = _keyword.Split(' ');
                        for (int i = 0; i < KeywordArray.Length; i++)
                        {
                            if (KeywordArray[i].Length > 1)
                            {
                                str = str.Replace(KeywordArray[i], "<span class=keyworditem>" + KeywordArray[i] + "</span>");
                            }
                        }
                        return(str);
                    }
                    else
                    {
                        return(str);
                    }
                }
                else
                {
                    return("");
                }
            }
            catch
            {
                return(obj.ToString());
            }
        }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserCode"] == null)
            {
            }
            else
            {
            }

            if (!Page.IsPostBack)
            {
                if (Request["RefUserCode"] != null)
                {
                    Session["RefUserCode"] = Request["RefUserCode"];
                }

                strCode = Request["Code"];
                int Code;
                Int32.TryParse(strCode, out Code);
                if (Code != 0)
                {
                    BOLProducts ProductsBOL = new BOLProducts();
                    Products    CurProduct  = ((IBaseBOL <Products>)ProductsBOL).GetDetails(Code);
                    if (CurProduct != null)
                    {
                        ViewState["Code"] = Code.ToString();
                        if (Request.UserAgent == "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" ||
                            Request.UserAgent == "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" ||
                            Request.UserAgent == "msnbot/2.0b (+http://search.msn.com/msnbot.htm)._" ||
                            Request.UserAgent == "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" ||
                            Request.UserAgent == "Mozilla/5.0 (en-us) AppleWebKit/525.13 (KHTML, like Gecko; Google Web Preview) Version/3.1 Safari/525.13" ||
                            Request.UserAgent == "Mozilla/5.0 (compatible; MJ12bot/v1.3.3; http://www.majestic12.co.uk/bot.php?+)"
                            )
                        {
                            int ff = 1;
                        }
                        else
                        {
                            ProductsBOL.IncrementView(CurProduct.Code);
                            ProductsBOL.IncProVisits(CurProduct.Code);
                        }


                        hplBuy.NavigateUrl = "~/Cart.aspx?ProductCode=" + Code;
                        lblEnTitle.Text    = CurProduct.EnTitle;
                        lblFaTitle.Text    = CurProduct.FaTitle;

                        strEnTitle          = CurProduct.EnTitle;
                        lblDescription.Text = Tools.FormatString(CurProduct.Description);
                        lblPrice.Text       = Tools.ChangeEnc(Tools.FormatCurrency((Convert.ToInt32(CurProduct.Price) / 10).ToString())) + " تومان";

                        int?MarketPrice = CurProduct.MarketPrice;
                        if (MarketPrice != null)
                        {
                            if (MarketPrice > CurProduct.Price)
                            {
                                lblMarketPrice.Text    = Tools.ChangeEnc(Tools.FormatCurrency((Convert.ToInt32(CurProduct.MarketPrice) / 10).ToString())) + " تومان";
                                pnlMarketPrice.Visible = true;
                            }
                        }

                        ProTitle = CurProduct.FaTitle;
                        if (string.IsNullOrEmpty(CurProduct.FaTitle))
                        {
                            ProTitle = CurProduct.EnTitle;
                        }

                        ReqUtils Utils     = new ReqUtils();
                        string   FullDesc  = CurProduct.Description;
                        string   BriefDesc = Tools.ShowBriefText(Utils.RemoveTags(FullDesc), 300);



                        Page.Title = ProTitle;


                        //if (CurProduct.ProductCatCode != null)
                        //{
                        //    SelectedProducts1.CatCode = (int)CurProduct.ProductCatCode;
                        //    RelatedProducts1.ProductCode = CurProduct.Code;
                        //    RelatedProducts1.ShowSelectedProducts();

                        //}
                        //else
                        //    SelectedProducts1.Visible = false;



                        BOLHardCode HardCodeBOL = new BOLHardCode();

                        ltrHirarchy.Text = strHirarchy;

                        #region Fill Fields
                        #endregion


                        #region Visibility

                        #endregion


                        #region Box Visibility



                        #endregion



                        //string[] ProTitleArray = ProTitle.Split(' ');
                    }
                }
            }
        }
Exemplo n.º 14
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //BOLEntityKeywords EntityKeywordsBOL = new BOLEntityKeywords();

            //ReqUtils Utils = new ReqUtils();
            //ContentsDataContext dc = new ContentsDataContext();
            //var ContentList = dc.Contents;
            //foreach (var item in ContentList)
            //{
            //    try
            //    {
            //        string CurDesc = item.ContentText;
            //        CurDesc = Utils.RemoveTags(CurDesc);
            //        CurDesc = Tools.PersianTextCorrection(CurDesc);
            //        ExtractKeywords(CurDesc);
            //        string KeywordCodeList = Tools.GetkeywordCodes2(AdvertiseKeyword);
            //        EntityKeywordsBOL.SaveKeywordList(item.Code, KeywordCodeList, 4);
            //    }
            //    catch
            //    {
            //    }

            //}

            //BOLEntityKeywords EntityKeywordsBOL = new BOLEntityKeywords();
            //TabirDataContext dc = new TabirDataContext();

            //ReqUtils Utils = new ReqUtils();
            //var TabirList = dc.Tabirs;
            //foreach (var item in TabirList)
            //{
            //    try
            //    {
            //        string CurDesc = item.Meaning;
            //        CurDesc = Utils.RemoveTags(CurDesc);
            //        CurDesc = Tools.PersianTextCorrection(CurDesc);
            //        ExtractKeywords(CurDesc);
            //        string KeywordCodeList = Tools.GetkeywordCodes2(AdvertiseKeyword);
            //        EntityKeywordsBOL.SaveKeywordList(item.Code, KeywordCodeList, 5);
            //    }
            //    catch
            //    {
            //    }

            //}

            BOLEntityKeywords   EntityKeywordsBOL = new BOLEntityKeywords();
            ProductsDataContext dc = new ProductsDataContext();

            ReqUtils Utils       = new ReqUtils();
            var      ProductList = dc.Products;

            foreach (var item in ProductList)
            {
                try
                {
                    string CurDesc = item.Description;
                    CurDesc = Utils.RemoveTags(CurDesc);
                    CurDesc = Tools.PersianTextCorrection(CurDesc);
                    ExtractKeywords(CurDesc);
                    string KeywordCodeList = Tools.GetkeywordCodes2(AdvertiseKeyword);
                    EntityKeywordsBOL.SaveKeywordList(item.Code, KeywordCodeList, 6);
                }
                catch
                {
                }
            }
        }