private static async Task <IEnumerable <PageStatus> > HitPages() { var listPageStatus = new List <PageStatus>(); try { using (var repoPages = new PagesRepository()) { using (var repoPageStatus = new PageStatusRepository()) { //Get page with Monitor bit on. var pages = repoPages.GetAllMonitor(); //var pages = repoPages.GetAllProdMonitor(); //var pages = repoPages.GetAllStgMonitor(); var pageGetter = new PageGetter(); foreach (var page in pages) { var pageStats = new PageStats { Url = page.Url }; var stats = await pageGetter.HTTP_GET(pageStats); var pageStatus = new PageStatus { Url = stats.Url, ResponseTime = stats.ResponseTime, ContentLength = stats.ContentLength, ExceptionMessage = stats.ExceptionMessage, Status = stats.Status.ToString(), Created = DateTime.Now }; repoPageStatus.Add(pageStatus); repoPageStatus.SaveChanges(); listPageStatus.Add(pageStatus); } } } } catch (Exception ex) { // ReSharper disable once UnusedVariable var msg = ex.Message; } return(listPageStatus); }
private static void DirectAccess() { var repoPages = new PagesRepository(); //var pages = repoPages.GetAllProdMonitor(); var pages = repoPages.GetAllStgMonitor(); var repoPageStatus = new PageStatusRepository(); var pageGetter = new PageGetter(); var counter = 1000; while (counter > 0) { foreach (var page in pages) { Console.WriteLine($"Page: {page.Url}"); var pageStats = new PageStats { Url = page.Url }; var result = pageGetter.HTTP_GET(pageStats); var stats = result.Result; var pageStatus = new PageStatus { Url = stats.Url, ResponseTime = stats.ResponseTime, ContentLength = stats.ContentLength, ExceptionMessage = stats.ExceptionMessage, Status = stats.Status.ToString(), Created = DateTime.Now }; repoPageStatus.Add(pageStatus); repoPageStatus.SaveChanges(); Console.WriteLine($"seconds: {stats.ResponseTime} length: {stats.ContentLength} time: {DateTime.Now}"); Console.WriteLine(); } Thread.Sleep(10000); counter--; } }
private static async Task <IEnumerable <AdHocPageStatu> > HitPage(string pageUrl, string user) { var listPageStatus = new List <AdHocPageStatu>(); try { using (var adHocPageStatusRepository = new AdHocPageStatusRepository()) { var pageGetter = new PageGetter(); var pageStats = new PageStats { Url = pageUrl }; var stats = await pageGetter.HTTP_GET(pageStats); var pageStatus = new AdHocPageStatu { Url = stats.Url, ResponseTime = stats.ResponseTime, ContentLength = stats.ContentLength, ExceptionMessage = stats.ExceptionMessage, Status = stats.Status.ToString(), Created = DateTime.Now, User = user }; adHocPageStatusRepository.Add(pageStatus); adHocPageStatusRepository.SaveChanges(); listPageStatus.Add(pageStatus); } } catch (Exception ex) { // ReSharper disable once UnusedVariable var msg = ex.Message; } return(listPageStatus); }