private void FillPageStats(PageStats ps, MNPage p) { ps.checkboxes = 0; ps.selections = 0; ps.texts = 0; ps.pictures = 0; ps.textview = 0; foreach (SMControl c in p.Objects) { if (c is SMImage) { ps.pictures++; } else if (c is SMLabel) { ps.texts++; } else if (c is SMCheckBox) { ps.checkboxes++; } else if (c is SMSelection) { ps.selections++; } else if (c is SMTextView) { ps.textview++; } } }
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); }
public void Import_PageViews() { var pageViews = "~/../../page-views.txt".MapAbsolutePath().ReadAllText(); var map = pageViews.ParseKeyValueText(); "{0} page view entries".Print(map.Count); CheckUniqueStats(pageViews); using (var db = Factory.OpenDbConnection()) { db.DropAndCreateTable <PageStats>(); var now = DateTime.UtcNow; foreach (var entry in map) { var parts = entry.Key.Substring(1).SplitOnFirst('/'); if (parts.Length != 2) { continue; } var type = parts[0]; var slug = parts[1]; var pageStats = new PageStats { Id = entry.Key, RefType = type, RefSlug = slug, RefId = 0, ViewCount = long.Parse(entry.Value), LastModified = now, }; db.Insert(pageStats); } } }
public bool Contains(PageStats ps) { if (texts >= 0 && ps.texts != texts) { return(false); } if (pictures >= 0 && ps.pictures != pictures) { return(false); } if (selections >= 0 && ps.selections != selections) { return(false); } if (checkboxes >= 0 && ps.checkboxes != checkboxes) { return(false); } if (textview >= 0 && ps.textview != textview) { return(false); } return(true); }
private void textBox1_TextChanged(object sender, EventArgs e) { string[] tags = textBox1.Text.Split(spaceCharacterSet, StringSplitOptions.RemoveEmptyEntries); PageStats ps = new PageStats(); PageStats pageFindStats = new PageStats(); string text = ""; foreach (string sto in tags) { if (Char.IsLetter(sto[0])) { text = sto; } else if (sto.EndsWith("t")) { int.TryParse(sto.Substring(0, sto.Length - 1), out ps.texts); } else if (sto.EndsWith("c")) { int.TryParse(sto.Substring(0, sto.Length - 1), out ps.checkboxes); } else if (sto.EndsWith("p")) { int.TryParse(sto.Substring(0, sto.Length - 1), out ps.pictures); } else if (sto.EndsWith("s")) { int.TryParse(sto.Substring(0, sto.Length - 1), out ps.selections); } else if (sto.EndsWith("tv")) { int.TryParse(sto.Substring(0, sto.Length - 2), out ps.textview); } } listBox1.BeginUpdate(); listBox1.Items.Clear(); foreach (MNPage page in MNSharedObjects.internalDocument.Data.Templates) { if (text.Length > 0) { if (page.Title.IndexOf(text, 0, StringComparison.CurrentCultureIgnoreCase) >= 0) { listBox1.Items.Add(page); } } else { FillPageStats(pageFindStats, page); //Debugger.Log(0, "", "Page " + page.Title + " = " + pageFindStats.ToString() + "\n"); if (ps.Contains(pageFindStats)) { listBox1.Items.Add(page); } } } listBox1.EndUpdate(); if (listBox1.Items.Count > 0) { listBox1.SelectedIndex = 0; } }