public ReportList GetReports(string tag, OReportSortOrder sortOrder) { List <Report> reports = new List <Report>(); IComparer <Report> comparer = null; switch (sortOrder) { case OReportSortOrder.Alphabet: comparer = new ReportAbcComparer(); break; case OReportSortOrder.Popularity: comparer = new ReportPopularityComparer(); break; } foreach (Report report in Reports) { if ((report.Flag & Flag.Internal) != 0) { continue; } string[] reportTags = report.Tags; if (!reportTags.Contains(tag, StringComparer.CurrentCultureIgnoreCase)) { continue; } reports.Add(report); } reports.Sort(comparer); return(reports); }
private void LoadDocument(string tag, OReportSortOrder sortOrder) { if (tag.Equals(_tag) && _sortOrder == sortOrder) { return; } _tag = tag; _sortOrder = sortOrder; try { // Load page template string dir = GetAppDir(); dir = Path.Combine(dir, "Template"); dir = Path.Combine(dir, "Reports"); string languageCode = CultureInfo.CreateSpecificCulture(UserSettings.Language).TwoLetterISOLanguageName; string file = string.Format("page.{0}.tpl.html", languageCode); file = Path.Combine(dir, file); file = File.Exists(file) ? file : Path.Combine(dir, "page.tpl.html"); string tpl = File.ReadAllText(file, Encoding.UTF8); // Load report div template file = Path.Combine(dir, "report.tpl.html"); string tplReport = File.ReadAllText(file, Encoding.UTF8); // Construct an html page from parts StringBuilder sb = new StringBuilder(20 * 1024); foreach (Report report in Service.GetReports(_tag, _sortOrder)) { string[] parts = new[] { report.Guid.ToString(), report.Title, report.Description, report.Starred ? "star on" : "star off", 0 == report.OpenCount ? "" : report.OpenCount.ToString() }; sb.Append(string.Format(tplReport, parts)); } file = Path.Combine(dir, "tag.tpl.html"); string tplTag = File.ReadAllText(file, Encoding.UTF8); string[] tagsFormated = _tags .Select(t => string.Format(tplTag, t)) .ToArray(); string tagsElement = string.Join(string.Empty, tagsFormated); string fileCss = Path.Combine(dir, "style.css"); string bodyId = _tag; string bodyClass = "sort-by-" + _sortOrder.ToString().ToLower(); string[] partsPage = new[] { fileCss, bodyId, bodyClass, sb.ToString(), wbReports.Version.ToString(), tagsElement }; string html = string.Format(tpl, partsPage); file = Path.Combine(dir, "reports.html"); File.WriteAllText(file, html); // Now load the page into the web browser // Once it's loaded DocumentCompleted is invoked wbReports.Url = new Uri(file, UriKind.Absolute); } finally { _lastSelected = null; } }
public static void SetReportSortOrder(OReportSortOrder sortOrder) { OctopusKey.SetValue("ReportSortOrder", sortOrder.ToString()); }
private void LoadDocument(string tag, OReportSortOrder sortOrder) { if(tag.Equals(_tag) && _sortOrder == sortOrder) return; _tag = tag; _sortOrder = sortOrder; try { // Load page template string dir = GetAppDir(); dir = Path.Combine(dir, "Template"); dir = Path.Combine(dir, "Reports"); string languageCode = CultureInfo.CreateSpecificCulture(UserSettings.Language).TwoLetterISOLanguageName; string file = string.Format("page.{0}.tpl.html", languageCode); file = Path.Combine(dir, file); file = File.Exists(file) ? file : Path.Combine(dir, "page.tpl.html"); string tpl = File.ReadAllText(file, Encoding.UTF8); // Load report div template file = Path.Combine(dir, "report.tpl.html"); string tplReport = File.ReadAllText(file, Encoding.UTF8); // Construct an html page from parts StringBuilder sb = new StringBuilder(20*1024); foreach (Report report in Service.GetReports(_tag, _sortOrder)) { string[] parts = new[] { report.Guid.ToString(), report.Title, report.Description, report.Starred ? "star on" : "star off", 0 == report.OpenCount ? "" : report.OpenCount.ToString() }; sb.Append(string.Format(tplReport, parts)); } file = Path.Combine(dir, "tag.tpl.html"); string tplTag = File.ReadAllText(file, Encoding.UTF8); string[] tagsFormated = _tags .Select(t => string.Format(tplTag, t)) .ToArray(); string tagsElement = string.Join(string.Empty, tagsFormated); string fileCss = Path.Combine(dir, "style.css"); string bodyId = _tag; string bodyClass = "sort-by-" + _sortOrder.ToString().ToLower(); string[] partsPage = new[] { fileCss, bodyId, bodyClass, sb.ToString(), wbReports.Version.ToString(), tagsElement }; string html = string.Format(tpl, partsPage); file = Path.Combine(dir, "reports.html"); File.WriteAllText(file, html); // Now load the page into the web browser // Once it's loaded DocumentCompleted is invoked wbReports.Url = new Uri(file, UriKind.Absolute); } finally { _lastSelected = null; } }
public ReportList GetReports(string tag, OReportSortOrder sortOrder) { List<Report> reports = new List<Report>(); IComparer<Report> comparer = null; switch (sortOrder) { case OReportSortOrder.Alphabet: comparer = new ReportAbcComparer(); break; case OReportSortOrder.Popularity: comparer = new ReportPopularityComparer(); break; } foreach (Report report in Reports) { if((report.Flag & Flag.Internal) != 0) continue; string[] reportTags = report.Tags; if (!reportTags.Contains(tag, StringComparer.CurrentCultureIgnoreCase)) continue; reports.Add(report); } reports.Sort(comparer); return reports; }