public static FileInfo GetHtmlFormattedReport(string sessionId, bool condensed) { IDiskCacheGroup group = GetReportCacheGroup(sessionId); string directory = condensed ? "Condensed" : "Full"; FileInfo htmlReportFile = group.GetFileInfo(Path.Combine(directory, HtmlReportFileName)); if (!htmlReportFile.Exists) { Report report = LoadSerializedReport(sessionId); if (report == null) { return(null); } group.CreateSubdirectory(directory); IReportManager reportManager = RuntimeAccessor.ServiceLocator.Resolve <IReportManager>(); FileSystemReportContainer reportContainer = new FileSystemReportContainer(htmlReportFile.DirectoryName, ReportBaseName); IReportWriter reportWriter = reportManager.CreateReportWriter(report, reportContainer); var reportFormatterOptions = new ReportFormatterOptions(); reportManager.Format(reportWriter, condensed ? "Html-Condensed" : "Html", reportFormatterOptions, NullProgressMonitor.CreateInstance()); } return(htmlReportFile); }
public ReportFilePool(IDiskCacheGroup cacheGroup, int numberOfFiles) { for (var i = 0; i < numberOfFiles; i++) { var uniqueFilename = string.Format("{0}.{1}.html", ReportName, Hash64.CreateUniqueHash()); files.Add(cacheGroup.GetFileInfo(uniqueFilename)); } }
public static void SaveSerializedReport(string sessionId, Report report) { IDiskCacheGroup group = GetReportCacheGroup(sessionId); group.Delete(); BinaryFormatter formatter = CreateBinaryFormatter(); using (Stream stream = group.OpenFile(SerializedReportFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Delete)) formatter.Serialize(stream, report); }
public HtmlTestStepRunFormatter() { var runtime = RuntimeAccessor.Instance; var resourcesPath = runtime.ResourceLocator.ResolveResourcePath(new Uri("plugin://Gallio.Reports/Resources/")); resourcesUrl = new Uri(resourcesPath); cssUrl = new Uri(resourcesUrl, "css"); imgUrl = new Uri(resourcesUrl, "img"); jsDir = Path.Combine(resourcesPath, "js"); cache = new TemporaryDiskCache("Gallio.UI"); cacheGroup = cache.Groups[Guid.NewGuid().ToString()]; reportFilePool = new ReportFilePool(cacheGroup, 5); attachmentPaths = new HashSet<string>(); }
public HtmlTestStepRunFormatter() { var runtime = RuntimeAccessor.Instance; var resourcesPath = runtime.ResourceLocator.ResolveResourcePath(new Uri("plugin://Gallio.Reports/Resources/")); resourcesUrl = new Uri(resourcesPath); cssUrl = new Uri(resourcesUrl, "css"); imgUrl = new Uri(resourcesUrl, "img"); jsDir = Path.Combine(resourcesPath, "js"); cache = new TemporaryDiskCache("Gallio.UI"); cacheGroup = cache.Groups[Guid.NewGuid().ToString()]; reportFilePool = new ReportFilePool(cacheGroup, 5); attachmentPaths = new HashSet <string>(); }
public static Report LoadSerializedReport(string sessionId) { try { if (HasSerializedReport(sessionId)) { IDiskCacheGroup group = GetReportCacheGroup(sessionId); BinaryFormatter formatter = CreateBinaryFormatter(); using (Stream stream = group.OpenFile(SerializedReportFileName, FileMode.Open, FileAccess.Read, FileShare.Delete)) return((Report)formatter.Deserialize(stream)); } } catch (DiskCacheException) { } return(null); }
public static bool HasSerializedReport(string sessionId) { IDiskCacheGroup group = GetReportCacheGroup(sessionId); return(group.Exists && group.GetFileInfo(SerializedReportFileName).Exists); }
public static void ClearSerializedReport(string sessionId) { IDiskCacheGroup group = GetReportCacheGroup(sessionId); group.Delete(); }
public ReportFilePool(IDiskCacheGroup cacheGroup, int numberOfFiles) { for (var i = 0; i < numberOfFiles; i++) { var uniqueFilename = string.Format("{0}.{1}.html", ReportName, Hash64.CreateUniqueHash()); files.Add(cacheGroup.GetFileInfo(uniqueFilename)); } }