コード例 #1
0
        public void AddUrls(string[] urls, int depth, string baseUrl)
        {
            LinkDAL dalLink = new LinkDAL();

            foreach (string url in urls)
            {
                string cleanUrl = url.Trim();
                int    end      = cleanUrl.IndexOf(' ');
                if (end > 0)
                {
                    cleanUrl = cleanUrl.Substring(0, end);
                }

                //检测是否是当前网站的链接
                if (cleanUrl.Contains(baseUrl) && !SelectExistByUrl(cleanUrl))
                {
                    Link link = new Link();
                    link.Url        = cleanUrl;
                    link.Depth      = depth;
                    link.CreateTime = DateTime.Now;
                    link.UpdateTime = DateTime.Now;
                    link.Status     = Link.StatusAttribute.IsUse;

                    int insertId = dalLink.Insert(link);
                    link.Id = insertId;
                }
                else
                {
                    // 外链
                }
            }
        }
コード例 #2
0
        public void AddUrl(string url, int depth)
        {
            LinkDAL dalLink = new LinkDAL();

            if (!dalLink.SelectExistByUrl(url))
            {
                Link link = new Link();
                link.Url        = url;
                link.Depth      = depth;
                link.Status     = Link.StatusAttribute.IsUse;
                link.CreateTime = DateTime.Now;
                link.UpdateTime = DateTime.Now;
                link.IsDownload = false;
                int insertId = dalLink.Insert(link);
                link.Id = insertId;
            }
        }