Esempio n. 1
0
        public void AddLinks()
        {
            ClassLibrary.BLL.InternalLink   linksBLL   = new ClassLibrary.BLL.InternalLink();
            ClassLibrary.Model.InternalLink linksModel = new ClassLibrary.Model.InternalLink();

            if (string.IsNullOrEmpty(Request.Form["Title"]))
            {
                Response.Write("<script>alert('请输入标题!');history.back(-1);</script>");
                return;
            }
            else
            {
                linksModel.Title = Request.Form["Title"];
            }
            linksModel.LinkURL = Request.Form["LinkURL"];

            if (linksBLL.Add(linksModel) > 0)
            {
                Function.goMessagePage("添加友情链接", "操作成功", "Links/InternalLinkList.aspx");
            }
            else
            {
                Function.goMessagePage("添加友情链接", "操作失败,请稍后再试", "Links/InternalLinkList.aspx");
            }
        }
Esempio n. 2
0
        private void InternalLinkDelete(HttpContext context)
        {
            string id = context.Request.QueryString["id"];

            ClassLibrary.BLL.InternalLink linksBLL = new ClassLibrary.BLL.InternalLink();

            if (linksBLL.Delete(int.Parse(id)) > 0)
            {
                Print(context, "success");
            }
            else
            {
                Print(context, "errors");
            }
        }
Esempio n. 3
0
        private void RefreshLinks(HttpContext context)
        {
            ClassLibrary.BLL.News                  newsBll  = new ClassLibrary.BLL.News();
            ClassLibrary.BLL.Routes                routeBll = new ClassLibrary.BLL.Routes();
            ClassLibrary.BLL.RouteDetails          rdBll    = new ClassLibrary.BLL.RouteDetails();
            ClassLibrary.BLL.InternalLink          linkBll  = new ClassLibrary.BLL.InternalLink();
            List <ClassLibrary.Model.InternalLink> linkList = linkBll.GetModelList(string.Empty);

            List <ClassLibrary.Model.News> newsList = newsBll.GetModelList("");

            foreach (ClassLibrary.Model.News model in newsList)
            {
                string tmpContent = ClassLibrary.BLL.WebClass.addInternelLink(model.Content, ClassLibrary.Common.SysConfig.linkCount, linkList);
                if (model.Content != tmpContent)
                {
                    model.Content = tmpContent;
                    newsBll.Update(model);
                }
            }

            List <ClassLibrary.Model.Routes> routeList = routeBll.GetModelList("");

            foreach (ClassLibrary.Model.Routes model in routeList)
            {
                model.RouteFeature     = ClassLibrary.BLL.WebClass.addInternelLink(model.RouteFeature, 1, linkList);
                model.DescriptionRoute = ClassLibrary.BLL.WebClass.addInternelLink(model.DescriptionRoute, 3, linkList);
                model.DescriptionPrice = ClassLibrary.BLL.WebClass.addInternelLink(model.DescriptionPrice, 1, linkList);
                model.RouteNotice      = ClassLibrary.BLL.WebClass.addInternelLink(model.RouteNotice, 1, linkList);
                routeBll.Update(model);
                if (model.DetailType)
                {
                    List <ClassLibrary.Model.RouteDetails> rdList = rdBll.GetModelList("routeid=" + model.ID);
                    foreach (ClassLibrary.Model.RouteDetails model2 in rdList)
                    {
                        string tmpDetail = ClassLibrary.BLL.WebClass.addInternelLink(model2.DayDetail, 1, linkList);
                        if (model2.DayDetail != tmpDetail)
                        {
                            model2.DayDetail = tmpDetail;
                            rdBll.Update(model2);
                        }
                    }
                }
            }

            Print(context, "success");
        }
Esempio n. 4
0
        public static string addInternelLink(string content, int linkCount, List <ClassLibrary.Model.InternalLink> list)
        {
            if (content == null)
            {
                return("");
            }

            int len = content.Length;

            if (len > 200)
            {
                int acount = Function.getTagACount(content);
                if (acount < 3)
                {
                    int count = (linkCount + acount) > 3 ? (3 - acount) : linkCount;
                    List <ClassLibrary.Model.InternalLink> linkList = new List <ClassLibrary.Model.InternalLink>();
                    if (list != null && list.Count > 0)
                    {
                        foreach (ClassLibrary.Model.InternalLink model in list)
                        {
                            linkList.Add(model);
                        }
                    }
                    else
                    {
                        ClassLibrary.BLL.InternalLink linkBll = new ClassLibrary.BLL.InternalLink();
                        linkList = linkBll.GetModelList(string.Empty);
                    }

                    linkList = setListSortNone(linkList);
                    foreach (ClassLibrary.Model.InternalLink model in linkList)
                    {
                        if (content.Contains(model.Title) && !Function.IsInTagA(content.ToLower(), model.Title))
                        {
                            if (model.LinkURL.IndexOf("http://") == -1)
                            {
                                model.LinkURL = "http://" + model.LinkURL;
                            }
                            if (Function.IsInTagImg(content, model.Title))
                            {
                                if (!Function.ClearImg(content).Contains(model.Title))
                                {
                                    continue;
                                }
                                string rule       = "<img[^>]+?" + model.Title + "+[^>]+?>";
                                Match  match      = Regex.Match(content, rule);
                                int    index      = 0;
                                int    length     = 0;
                                string temcontent = "";
                                while (true)
                                {
                                    if (match.ToString() == "")
                                    {
                                        string str1 = content.Substring(0, content.IndexOf(model.Title));
                                        string str2 = content.Substring(content.IndexOf(model.Title) + model.Title.Length);
                                        string str3 = string.Format("<a href=\"{0}\" title=\"{1}\" target=\"_blank\">{1}</a>", model.LinkURL, model.Title);
                                        content = str1 + str3 + str2;
                                        break;
                                    }
                                    else
                                    {
                                        index  = match.Index;
                                        length = match.Length;
                                        if (content.Substring(0, index).Contains(model.Title))
                                        {
                                            string str1 = content.Substring(0, content.IndexOf(model.Title));
                                            string str2 = content.Substring(content.IndexOf(model.Title) + model.Title.Length);
                                            string str3 = string.Format("<a href=\"{0}\" title=\"{1}\" target=\"_blank\">{1}</a>", model.LinkURL, model.Title);
                                            content = str1 + str3 + str2;
                                            break;
                                        }
                                        temcontent += content.Substring(0, index + length);
                                        content     = content.Substring(index + length);
                                        match       = Regex.Match(content, rule);
                                    }
                                }
                                content = temcontent + content;
                                count--;
                            }
                            else
                            {
                                count--;
                                string str1 = content.Substring(0, content.IndexOf(model.Title));
                                string str2 = content.Substring(content.IndexOf(model.Title) + model.Title.Length);
                                string str3 = string.Format("<a href=\"{0}\" title=\"{1}\" target=\"_blank\">{1}</a>", model.LinkURL, model.Title);
                                content = str1 + str3 + str2;
                                if (count <= 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            return(content);
        }