public override void GlobalContext() { base.GlobalContext(); LoadProject(_projectName); _reportsDir = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Reports", _projectName)); if (!_reportsDir.Exists) { _reportsDir.Create(); } _reportingTask = IoC.Resolve <IReportingTask>(); _reportConfiguration = new ReportConfiguration { Title = "Testing Reports", Author = "Unit Tests Engine", Keywords = new[] { "Tests", "PKReporting", "SBSuite" }, Software = "SBSuite", SubTitle = "SubTitle", SoftwareVersion = "5.2", ContentFileName = "Content", DeleteWorkingDir = true, ColorStyle = ReportSettings.ReportColorStyles.Color }; _reportConfiguration.Template = new ReportTemplate { Path = DomainHelperForSpecs.TEXTemplateFolder() }; //Add all simulation to repository as they will be required when deserialzing the summary charts var repo = IoC.Resolve <IWithIdRepository>(); All <Simulation>().Each(repo.Register); }
public override void GlobalContext() { base.GlobalContext(); _reportingProject = LoadProject(_projectName); _reportingTask = IoC.Resolve <IReportingTask>(); _reportsDir = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Reports", _projectName)); if (!_reportsDir.Exists) { _reportsDir.Create(); } _reportConfiguration = new ReportConfiguration { Title = "Testing Reports", Author = "Unit Tests Engine", Keywords = new[] { "Tests", "PKReporting", "SBSuite" }, Software = "SBSuite", SubTitle = "SubTitle", SoftwareVersion = "5.2", ContentFileName = "Content", DeleteWorkingDir = true, ColorStyle = ReportSettings.ReportColorStyles.Color }; _reportConfiguration.Template = new ReportTemplate { Path = TEXTemplateFolder() }; }
protected AbstractReportingPresenter(IReportingView view, IReportTemplateRepository reportTemplateRepository, IDialogCreator dialogCreator, IReportingTask reportingTask, IStartOptions startOptions) : base(view) { _reportTemplateRepository = reportTemplateRepository; _dialogCreator = dialogCreator; _reportingTask = reportingTask; _startOptions = startOptions; }
public ProgressReporter(IReportingTask taskContext) { InitializeComponent(); TaskContext = taskContext; // Change the visual controls when the task's progress changes // This needs to be done in this form's thread, hence the BeginInvoke UpdateProgress = () => BeginInvoke((Action) delegate { var roundedValue = (int)Math.Round(TaskContext.Progress * 100); if (roundedValue == 0) { ProgressText.Text = "Preparing action..."; } else if (roundedValue == 100) { ProgressText.Text = "Finalizing action..."; } else { ProgressText.Text = roundedValue + "%"; } ProgressBar.Value = roundedValue; }); TaskContext.ProgressChanged += UpdateProgress; UpdateDescription = () => BeginInvoke((Action) delegate { if (TaskContext.Description != null) { DetailsLabel.Text = TaskContext.Description; } }); TaskContext.DescriptionChanged += UpdateDescription; }
/// <summary> /// Performs an asynchronous task in foreground (blocking the host form's user input) and reports its progress. /// </summary> /// <typeparam name="T">The task's result type</typeparam> /// <param name="host">The host form</param> /// <param name="taskContext">The task to perform</param> /// <param name="onSuccess">What to do if the operation succeceeds; the parameter is the task's result</param> /// <param name="onError">What to do if the operation fails; the parameter is the cause of the failure</param> public static void PerformForegroundTask <T>(Form host, IReportingTask <T> taskContext, Action <T> onSuccess, Action <Exception> onError) { // Disable the host form (like ShowDialog would do) host.Enabled = false; var reporter = new ProgressReporter(taskContext); reporter.Show(host); // When the task completes, taskContext.Task.ContinueWith(delegate { // Determine if there was an error bool success = false; bool canceled = taskContext.Task.IsCanceled; Exception error = null; if (!taskContext.Task.IsCanceled) { error = taskContext.Task.Exception; // It really sucks to have an aggregate exception with a single inner... while (error != null && error is AggregateException && (error as AggregateException).InnerExceptions.Count == 1) { error = error.InnerException; } // Target invocation exceptions are also meaningless wrappers while (error != null && error is TargetInvocationException) { error = error.InnerException; } success = error == null; } // Bring back the host context (in its own thread) bool enteredOnce = false; Action bringBackHostContext = () => { if (!enteredOnce) { enteredOnce = true; reporter.Close(); reporter = null; host.Enabled = true; host.Focus(); // Execute the provided actions if (success) { var result = taskContext.Task.Result; taskContext.Dispose(); onSuccess(result); } else if (!canceled) { taskContext.Dispose(); onError(error); } } }; // Try as many times as required, but only allow 1 execution of the action IAsyncResult ar = host.BeginInvoke(bringBackHostContext); while (!ar.AsyncWaitHandle.WaitOne(100, false) && !enteredOnce) { ar = host.BeginInvoke(bringBackHostContext); } }); }
public ReportingPresenter(IReportingView view, IReportTemplateRepository reportTemplateRepository, IDialogCreator dialogCreator, IReportingTask reportingTask, IObjectTypeResolver objectTypeResolver, IStartOptions startOptions) : base(view, reportTemplateRepository, dialogCreator, reportingTask, startOptions) { _objectTypeResolver = objectTypeResolver; }