コード例 #1
0
ファイル: Principal.cs プロジェクト: urumak/ProjektIO
        private string ScanUrl()
        {
            UrlLibrary library = new UrlLibrary();
            string     url     = HttpContext.Current.Request.Url.AbsolutePath;

            urlSegments = url.Split('/').ToList();
            urlSegments.RemoveAt(0);
            if (library.GroupFirst.Contains(urlSegments[0]))
            {
                if (library.GroupSecond.Find(p => p == urlSegments[1]) != null)
                {
                    return(urlSegments[2]);
                }
            }
            if (library.PostFirst.Contains(urlSegments[0]))
            {
                if (library.PostSecond.Find(p => p == urlSegments[1]) != null)
                {
                    return(urlSegments[2]);
                }
            }
            if (library.LeaderFirst.Contains(urlSegments[0]))
            {
                if (library.LeaderSecond.Find(p => p == urlSegments[1]) != null)
                {
                    return(urlSegments[2]);
                }
            }
            return(null);
        }
コード例 #2
0
        public void AddUrlToLibrary(UrlLibraryDTO newElement)
        {
            var dbElement = new UrlLibrary()
            {
                Url = newElement.Url
            };
            var dbElementConfiguration = new ScrappingConfiguration()
            {
                Interval = newElement.ScrappingInterval, UrlLibrary = dbElement, ScrappingResult = new ScrappingResult()
            };

            _context.Add(dbElementConfiguration);
            _context.SaveChanges();

            //start the new url scrapping
            _scrapperFactory.AddAndStartOperation(dbElementConfiguration.ScrappingConfigurationId);
        }