/// <summary> /// Writes a coverage report in the configured format. /// </summary> /// <param name="models">The models to include in the coverage file.</param> /// <param name="configuration">The report configuration,</param> public void WriteReport(IEnumerable <CoverageNodeModel> models, ReportConfigurationModel configuration) { Contract.RequiresNotNull(models, nameof(models)); Contract.Requires(models.Any(), "No coverage data to create a report for.", nameof(models)); Contract.RequiresNotNull(configuration, nameof(configuration)); ReportWriter writer; switch (configuration.ReportFormat) { case ReportFormat.HtmlSingleFile: writer = new HtmlSingleFileReportWriter(); break; case ReportFormat.HtmlMultiFile: writer = new HtmlMultiFileReportWriter(); break; default: throw Utility.UnreachableCode("Unexpected report type."); } CoverageDSPriv merged = ConcatenateFiles(models.Select(CreateSerializable)); var reportModel = new CoverageExport(configuration.ProjectName, merged); writer.WriteReport(reportModel, configuration); }
/// <summary> /// Creates a report of the open coverage data. /// </summary> public void CreateCoverageReport() { var config = new ReportConfigurationModel(); // set some defaults. config.ProjectName = CoverageRows.FirstOrDefault()?.DisplayName; var configDlg = new ReportConfigurationDlg(config); configDlg.Owner = Owner; // note: nullable bools... if (configDlg.ShowDialog() == true) { var writer = new CoverageWriter(); writer.WriteReport(CoverageRows.Select(vm => vm.Model), config); if (config.OpenWhenDone) { Process.Start( new ProcessStartInfo { FileName = config.DestinationPath, UseShellExecute = true, } ); } } }
/// <summary> /// Initializes a new instance of <see cref="ReportConfigurationDlg"/>. /// </summary> /// <param name="configuration">The model to bind to.</param> internal ReportConfigurationDlg(ReportConfigurationModel configuration) { InitializeComponent(); SourceInitialized += HandleSourceInitialized; ViewModel.Owner = this; ViewModel.Model = configuration; }
public ReportModel2(IHub hub, ReportConfigurationModel config) : base(hub, config) { _activityModel = config.ActivityInstance; // Default each dispatchable type to the current thread's dispatcher. Any controls which register a dispatcher will change this. foreach (var eventType in config.SubscriptionList) { _dispatchingMap[eventType] = Dispatcher.CurrentDispatcher; } }
public SessionModel(HubConfigurationModel hubConfig, BrokerConfigurationModel brokerConfig, ResponseConfigurationModel responseConfig, ReportConfigurationModel reportConfig) { _hub = DarkLightFactory.GetHub(hubConfig); _broker = DarkLightFactory.GetBroker(_hub, brokerConfig); _responseList = DarkLightFactory.GetResponseList(_hub, responseConfig); _reporter = DarkLightFactory.GetReporter(_hub, reportConfig); //_riskMgr = DarkLightFactory.GetRiskManager(_hub, reportConfig); //_portfolioMgr = DarkLightFactory.GetPortfolioManager(_hub, reportConfig); //_hub.EventDict[EventType.ReportMessage] }
public static IReporter GetReporter(IHub hub, ReportConfigurationModel config) { switch (config.Type) { case ReportType.Batch: return(new BatchReportModel2(hub, config)); case ReportType.Streaming: return(new BatchReportModel2(hub, config)); //TODO: make streaming model with _isBatch = false default: return(new BatchReportModel2(hub, config)); } }
/// <inheritdoc /> public override void WriteReport(CoverageExport dataset, ReportConfigurationModel configuration) { using (var tempFile = WriteToTempFile(dataset)) { var transform = new XslCompiledTransform(); using (var xslReader = XmlReader.Create(new StringReader(Resources.HTMLTransform))) { transform.Load(xslReader); } var args = new XsltArgumentList(); args.AddParam(ReportConstants.HtmlGenDate, "", DateTime.Now.ToString("dd MMM yyyy HH:mm:ss")); args.AddParam(ReportConstants.HtmlTotalLines, "", dataset.LinesCovered + dataset.LinesPartiallyCovered + dataset.LinesNotCovered); args.AddParam(ReportConstants.HtmlTotalBlocks, "", dataset.BlocksCovered + dataset.BlocksNotCovered); args.AddParam(ReportConstants.HtmlExpansionDepth, "", (int)configuration.DefaultExpansion); args.AddParam("jQuerySource", "", ReportConstants.JQueryCDNLocation); using (var outputFile = new FileStream(configuration.DestinationPath, FileMode.Create, FileAccess.Write)) { using (var tempReader = XmlReader.Create(tempFile.Stream)) { transform.Transform(tempReader, args, outputFile); } } } }
//HistSim _histSim; #endregion #region Constructors public BatchReportModel2(IHub hub, ReportConfigurationModel config) : base(hub, config) { _isBatch = true; ReportName = config.ReportName; }
/// <summary> /// Writes a report containing the given coverage data. /// </summary> /// <param name="dataset">The coverage dataset to write to the report.</param> /// <param name="configuration">The report configuration.</param> public abstract void WriteReport(CoverageExport dataset, ReportConfigurationModel configuration);
/// <inheritdoc /> /// <devdoc> /// This will delete a pre-existing _files folder. Be sure the user has at least seen an /// overwrite prompt for the web page by now! /// </devdoc> public override void WriteReport(CoverageExport dataset, ReportConfigurationModel configuration) { EnsureJQueryIsCached(); // Note (Windows-specific): // when a web page ("Page.html") is accompanied by a folder named like "Page_files", // windows will try to keep the folder with the html page when moved, and warn if one of // these are renamed (since the other will not be, and any links in the page will not work). string filesDirName = Path.GetFileNameWithoutExtension(configuration.DestinationPath) + "_files"; string filesDirPath = Path.Combine(Path.GetDirectoryName(configuration.DestinationPath), filesDirName); // make sure we're working with a fresh files folder. var filesDir = new DirectoryInfo(filesDirPath); if (filesDir.Exists) { filesDir.Delete(recursive: true); } filesDir.Create(); string jQueryFullPath = Path.Combine(filesDirPath, ReportConstants.JQueryFileName); File.Copy(JQueryCachedPath, jQueryFullPath); using (var tempFile = WriteToTempFile(dataset)) { var transform = new XslCompiledTransform(); using (var xslReader = XmlReader.Create(new StringReader(Resources.HTMLTransform))) { transform.Load(xslReader); } var args = new XsltArgumentList(); args.AddParam(ReportConstants.HtmlGenDate, "", DateTime.Now.ToString("dd MMM yyyy HH:mm:ss")); args.AddParam(ReportConstants.HtmlTotalLines, "", dataset.LinesCovered + dataset.LinesPartiallyCovered + dataset.LinesNotCovered); args.AddParam(ReportConstants.HtmlTotalBlocks, "", dataset.BlocksCovered + dataset.BlocksNotCovered); args.AddParam(ReportConstants.HtmlExpansionDepth, "", (int)configuration.DefaultExpansion); args.AddParam("jQuerySource", "", Path.Combine(filesDirName, ReportConstants.JQueryFileName)); using (var outputFile = new FileStream(configuration.DestinationPath, FileMode.Create, FileAccess.Write)) { using (var tempReader = XmlReader.Create(tempFile.Stream)) { transform.Transform(tempReader, args, outputFile); } } } }
private void RunBacktestButton_Click2(object sender, System.Windows.RoutedEventArgs e) { UnbindInitializationModels(); UnbindReportModels(); _backtest2.Clear(); _activityModel.Status = "Backtest started."; var tickDataGroups = BacktestingTickFileControl.GetSelectedFilePaths(); _activityModel.NumberTestsToRun = tickDataGroups.Count; _activityModel.NumberTestsCompleted = 0; Task.Factory.StartNew(() => { _activityModel.AllRunsCompleted.WaitOne(); if (_backtest2.BacktestReports.Any()) { _backtest2.SelectedReport = _backtest2.BacktestReports.First(); BindStatisticsModels2("Results"); } }); foreach (var _tickDataGroup in tickDataGroups) { var hubConfig = new HubConfigurationModel(HubType.Local); var brokerConfig = new BrokerConfigurationModel(BrokerType.Sim); brokerConfig.PlayToValue = _backtestingConfigurationModel.SelectedPlayToValue; brokerConfig.SimUseBidAskFills = false; brokerConfig.TickFiles = _tickDataGroup; brokerConfig.SubscriptionList = new List <byte[]> { EventType.Basket, EventType.CancelOrder, EventType.Order }; var responseConfig = new ResponseConfigurationModel(); responseConfig.ResponseList.Add(_backtestingConfigurationModel.GetFreshResponseInstance()); responseConfig.SubscriptionList = new List <byte[]> { EventType.CancelOrderAck, EventType.Fill, EventType.Message, EventType.OrderAck, EventType.Tick }; var reportConfig = new ReportConfigurationModel(); reportConfig.Type = ReportType.Batch; reportConfig.ActivityInstance = _activityModel; var info = TickFileNameInfo.GetTickFileInfoFromLongName(_tickDataGroup.First()); reportConfig.ReportName = "Y:" + info.Year.ToString() + ",M:" + info.Month.ToString() + ",D:" + info.Day.ToString(); reportConfig.SubscriptionList = new List <byte[]> { EventType.ChartLabel, EventType.Fill, EventType.Indicator, EventType.Message, EventType.Order, EventType.ServiceTransition, EventType.Tick }; reportConfig.FilterMode = true; var sessionModel = new SessionModel(hubConfig, brokerConfig, responseConfig, reportConfig); _backtest2.AddRun(sessionModel); sessionModel.Reporter.RegisterDispatcher(EventType.Fill, FillsTab.Dispatcher); sessionModel.Reporter.RegisterDispatcher(EventType.Indicator, IndicatorTab.Dispatcher); sessionModel.Reporter.RegisterDispatcher(EventType.Message, MessagesTab.Dispatcher); sessionModel.Reporter.RegisterDispatcher(EventType.Order, OrdersTab.Dispatcher); sessionModel.Reporter.RegisterDispatcher(EventType.Plot, BacktestPlotter.Dispatcher); sessionModel.Reporter.RegisterDispatcher(EventType.Position, PositionTab.Dispatcher); } BindInitializationModels2(); _backtest2.Start(0); }