Beispiel #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);
        }
Beispiel #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();
        }
Beispiel #3
0
 public void Update(MapSite item)
 {
     siteMapContext.Entry(item).State = EntityState.Modified;
     siteMapContext.SaveChanges();
 }
Beispiel #4
0
 public void Remove(MapSite item)
 {
     siteMapContext.MapSites.Remove(item);
     siteMapContext.SaveChanges();
 }
Beispiel #5
0
 public void Create(MapSite item)
 {
     siteMapContext.MapSites.Add(item);
     siteMapContext.SaveChanges();
 }