static string _HeadLineTotal(CXDB xdb, int limit) { const string fmt = "<h2>{0}</h2>"; const string fmtOne = "<p>Top {0} Views as of: {1}</p>{2}"; return(string.Format(fmt, string.Format(fmtOne, limit, xdb.Date.Today, _PicturePhrase(xdb.Pictures.Total, xdb.Views.Total)))); }
private void btn_Click(object sender, EventArgs e) { btnClearBrowser.PerformClick(); CWorker.BasePath = _BasePath; txtbxStatus.Text = "Read Flickr Data"; txtbxStatus.Refresh(); CReadFlickr reader = new CReadFlickr(); CDB cDB = reader.Exec(); txtbxStatus.Text += System.Environment.NewLine + "Update DB Store"; txtbxStatus.Refresh(); reader.Commit(); txtbxStatus.Text += System.Environment.NewLine + "Calculate Statistics"; txtbxStatus.Refresh(); CStatistics xStatistics = new CStatistics(cDB); CXDB xDB = xStatistics.Exec(); txtbxStatus.Text += System.Environment.NewLine + "Max Statistics Collected per Photo: " + xDB.MaxCount; CHTML html = new CHTML(xDB, 25); txtbxStatus.Text += System.Environment.NewLine + "Create HTML"; txtbxStatus.Refresh(); html.Exec(); //MessageBox.Show("Ready.", "Read Flickr plus Statistics plus HTML", MessageBoxButtons.OK); btnDaily.PerformClick(); }
private void btnStatistics_Click(object sender, EventArgs e) { CStatistics xStatistics = new CStatistics(); CXDB xDB = xStatistics.Exec(); xStatistics.Commit(); MessageBox.Show("Statistic Generation Completed."); }
public CTotalViews FindTotalViews(string dateSTR, CXDB xDB) { DateTime dt = CWorker.Str2DT(dateSTR); foreach (CTotalViews record in xDB.Totals) { if (dt == CWorker.Str2DT(record.Date)) { return(record); } } return(null); }
static string _MakeDailyTotals(CXDB xDB) { StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine("<html>"); sb.AppendLine(_CSS2()); sb.AppendLine("<body>"); sb.AppendLine(string.Format("<p><h2>Total Views</h2></p>")); sb.AppendLine(_DailyTotalsTable(xDB)); sb.AppendLine("</body>"); sb.AppendLine("</html>"); return(sb.ToString()); }
private void btnCombo_Click(object sender, EventArgs e) { txtbxStatus.Text = "Calculate Statistics and Create HTML"; txtbxStatus.Refresh(); CStatistics xStatistics = new CStatistics(); CXDB xDB = xStatistics.Exec(); txtbxStatus.Text += System.Environment.NewLine + "Max Statistics Collected per Photo: " + xDB.MaxCount; //xStatistics.Commit(); CHTML html = new CHTML(xDB, 25); html.Exec(); //MessageBox.Show("Ready.","Statistics plus HTML",MessageBoxButtons.OK); btnDaily.PerformClick(); }
public void UpdateTotals(CXDB xDB, List <CStats> stats) { foreach (CStats stat in stats) { CTotalViews totalView = FindTotalViews(stat.Date, xDB); if (totalView != null) { totalView.Total += stat.Views; } else { CTotalViews tView = new CTotalViews(stat.Date); tView.Total = stat.Views; xDB.Totals.Add(tView); } } }
static string _DailyTotalsTable(CXDB xDB) { StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine(string.Format("<h3><p>Sample Days: {0}</p></h3>", xDB.Totals.Count - 1)); sb.AppendLine("<table class='dailyTotalsTable'>"); List <string> strings = new List <string>(); foreach (CTotalViews record in xDB.Totals) { strings.Add(_MakeRowViewTotals(record, null)); } for (int ndx = strings.Count - 1; ndx != -1; ndx--) { sb.AppendLine(strings[ndx]); } sb.AppendLine("</table>"); return(sb.ToString()); }
static string _Sample(CXDB xDB, CWorker.SampleTypeEnum sType, int limit) { StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine("<html>"); sb.AppendLine(_CSS2()); sb.AppendLine("<body>"); string viewsString = string.Empty; var sortedList = new List <CData>(); switch (sType) { case CWorker.SampleTypeEnum.Month: sb.Append(_HeadLine(xDB.Date.Month, xDB.Pictures.Month, xDB.Views.Month, limit)); sortedList = (from x in xDB.Data orderby x.Total descending orderby x.Month descending select x).ToList(); break; case CWorker.SampleTypeEnum.Week: sb.Append(_HeadLine(xDB.Date.Week, xDB.Pictures.Week, xDB.Views.Week, limit)); sortedList = (from x in xDB.Data orderby x.Total descending orderby x.Week descending select x).ToList(); break; case CWorker.SampleTypeEnum.Today: sb.Append(_HeadLine(xDB.Date.Today, xDB.Pictures.Today, xDB.Views.Today, limit)); sortedList = (from x in xDB.Data orderby x.Total descending orderby x.Today descending select x).ToList(); break; case CWorker.SampleTypeEnum.Total: sb.Append(_HeadLineTotal(xDB, limit)); sortedList = (from x in xDB.Data orderby x.Total descending select x).ToList(); break; default: throw new ApplicationException("Program Error"); } sb.AppendLine(_Table(sortedList, limit)); sb.AppendLine("</body>"); sb.AppendLine("</html>"); return(sb.ToString()); }
List <CTotalViews> TotalDelta(CXDB xDB) { List <CTotalViews> output = new List <CTotalViews>(); CTotalViews prior = null; foreach (CTotalViews record in xDB.Totals) { CTotalViews recordOut = new CTotalViews(record.Date); recordOut.Date = record.Date; if (prior != null) { recordOut.Views = record.Views; recordOut.Total = record.Views - prior.Views; } else { recordOut.Total = 0; } prior = record; output.Add(recordOut); } return(output); }
public void Commit(CXDB xdb) { CWorker.StoreXDB(xdb); }
public CHTML(int displayLimit) { _DisplayLimit = displayLimit; _XtractBaseName = "XTRACT"; _XDB = CWorker.ReadXDB(_XtractBaseName); }
public CHTML(CXDB xDB, int displayLimit) { _XDB = xDB; _DisplayLimit = displayLimit; }