Esempio n. 1
0
        public MapSite TestSites(IEnumerable <string> siteUrl, MapSite mapSite)
        {
            ICollection <SiteMapUrl> mapSiteUrlList = new List <SiteMapUrl>();
            SiteMapUrl siteMap = new SiteMapUrl();
            int        i       = 0;

            foreach (var item in siteUrl)
            {
                if (i < 20) //количество ссылок = 20
                {
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    HttpWebRequest  HttpWReq  = (HttpWebRequest)WebRequest.Create(item);
                    HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
                    HttpWResp.Close();
                    stopwatch.Stop();
                    TimeSpan ts = stopwatch.Elapsed;
                    mapSiteUrlList.Add(new SiteMapUrl {
                        UrlSite = item, TimeOut = ts.Milliseconds
                    });
                    i++;
                }
                else
                {
                    break;
                }
            }
            mapSite.SiteMapUrls = mapSiteUrlList;
            return(mapSite);
        }
Esempio n. 2
0
        protected override void Seed(SiteMapContext db)
        {
            MapSite mapSite = new MapSite()
            {
                NameSite = "http://podrobnosti.ua"
            };

            db.MapSites.Add(mapSite);
            db.SaveChanges();


            SiteMapUrl siteMaps1 = new SiteMapUrl()
            {
                MapSite = mapSite, TimeOut = 1, UrlSite = "http://podrobnosti.ua/2223807-v-ankare-progremel-vzryv-pervye-foto-i-video.html"
            };
            SiteMapUrl siteMaps2 = new SiteMapUrl()
            {
                MapSite = mapSite, TimeOut = 1, UrlSite = "http://podrobnosti.ua/2223806-pod-zhitomirom-zastrelilsja-ukrainskij-voennyj.html"
            };
            SiteMapUrl siteMaps3 = new SiteMapUrl()
            {
                MapSite = mapSite, TimeOut = 1, UrlSite = "http://podrobnosti.ua/2223767-pogoda-na-2-fevralja-ukrainu-nakrojut-dozhdi.html"
            };

            db.SiteMapsUrls.AddRange(new List <SiteMapUrl> {
                siteMaps1, siteMaps2, siteMaps3
            });
            db.SaveChanges();
        }