protected override void EndProcessing() { writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); progress.RecordType = ProgressRecordType.Completed; WriteProgress(progress); Console.WriteLine("Done"); MAStatistics.StopOperation(); Console.WriteLine(MAStatistics.ToString()); if (this.timer != null) { this.timer.Stop(); this.timer.Elapsed -= this.timer_Elapsed; } if (writer != null) { writer.Close(); } }
public void ImportEnd(ImportReleaseRequest request) { try { CachedImportRequest originalRequest; try { originalRequest = GetFromCache(request.Context); } catch (InvalidOperationException) { Logger.WriteLine("Could not release the request as it was not found in the cache"); return; } if (originalRequest.HighWatermark != null) { if (request.NormalTermination) { ActiveConfig.DB.ClearDeltas(originalRequest.HighWatermark); } } RemoveFromCache(request.Context); MAStatistics.StopOperation(); Logger.WriteLine(MAStatistics.ToString()); } catch (Exception ex) { Logger.WriteLine("Could not release the request"); Logger.WriteException(ex); } }
public void ExportEnd() { Logger.WriteLine("Export Complete"); Logger.WriteSeparatorLine('*'); MAStatistics.StopOperation(); Logger.WriteLine(MAStatistics.ToString()); }
protected override void ProcessRecord() { Global.ThrowIfNotConnected(this); try { UnitTestFile file = this.LoadUnitTestFile(); UnitTestFile.BreakOnTestFailure = this.BreakOnTestFailure; MAStatistics.StartOperation(MAOperationType.Export); Console.WriteLine(string.Empty.PadRight(79, '-')); Console.WriteLine("Executing unit tests from: {0}", Path.GetFileName(ActiveConfig.XmlConfig.FileName)); Console.WriteLine(); UnitTest.UnitTestStartingEvent += UnitTest_UnitTestStartingEvent; UnitTest.UnitTestCompletedEvent += UnitTest_UnitTestCompletedEvent; UnitTestGroup.UnitTestGroupStartingEvent += UnitTestGroup_UnitTestGroupStartingEvent; UnitTestGroup.UnitTestGroupCompletedEvent += UnitTestGroup_UnitTestGroupCompletedEvent; UnitTestOutcomes report = file.Execute(); MAStatistics.StopOperation(); Console.WriteLine(); Console.WriteLine(string.Empty.PadRight(79, '-')); if (report.TestCount > 0) { Console.WriteLine("Executed {0} tests", report.TestCount); if (report.TestCount == report.TestSuccessfulCount) { Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine("{0} ({1}%) successful", report.TestSuccessfulCount, report.TestSuccessfulPercent.ToString("D")); Console.ForegroundColor = ConsoleColor.Gray; if (report.TestFailedCount > 0) { Console.ForegroundColor = ConsoleColor.Yellow; } Console.WriteLine("{0} ({1}%) failed", report.TestFailedCount, report.TestFailedPercent.ToString("D")); Console.ForegroundColor = ConsoleColor.Gray; if (report.TestInconclusiveCount > 0) { Console.ForegroundColor = ConsoleColor.Yellow; } Console.WriteLine("{0} ({1}%) inconclusive", report.TestInconclusiveCount, report.TestInconclusivePercent.ToString("D")); Console.ForegroundColor = ConsoleColor.Gray; if (report.TestErrorCount > 0) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine("{0} ({1}%) error{2}", report.TestErrorCount, report.TestErrorPercent.ToString("D"), report.TestErrorCount == 1 ? string.Empty : "s"); Console.ForegroundColor = ConsoleColor.Gray; } else { Console.WriteLine("No tests were executed"); } Console.WriteLine(string.Empty.PadRight(79, '-')); Console.WriteLine(MAStatistics.ToString()); Console.WriteLine(string.Empty.PadRight(79, '-')); if (!string.IsNullOrWhiteSpace(this.HtmlReportFileName)) { Console.Write("Writing test results to: {0}... ", this.HtmlReportFileName); report.ToHtml(this.HtmlReportFileName); Console.WriteLine("Done"); } } catch (Exception ex) { ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null); ThrowTerminatingError(error); } finally { UnitTest.UnitTestStartingEvent -= UnitTest_UnitTestStartingEvent; UnitTest.UnitTestCompletedEvent -= UnitTest_UnitTestCompletedEvent; UnitTestGroup.UnitTestGroupStartingEvent -= UnitTestGroup_UnitTestGroupStartingEvent; UnitTestGroup.UnitTestGroupCompletedEvent -= UnitTestGroup_UnitTestGroupCompletedEvent; } }
protected override void ProcessRecord() { Global.ThrowIfNotConnected(this); try { MAStatistics.StartOperation(MAOperationType.Export); ActiveConfig.DB.CanCache = true; Console.WriteLine("Reading import file... "); StreamReader r = new StreamReader(this.FileName); XmlReader reader = XmlReader.Create(r); var doc = XDocument.Load(reader); Console.WriteLine("Importing objects... "); this.totalObjectCount = doc.Root.Elements().Count(); ProgressRecord progress = new ProgressRecord(0, "Import", "Starting import"); this.operationStartTime = DateTime.Now; this.sampleIntervalStartTime = DateTime.Now; this.timer = new Timer(1000); this.timer.Elapsed += this.timer_Elapsed; this.timer.Start(); progress.RecordType = ProgressRecordType.Processing; progress.PercentComplete = 0; this.WriteProgress(progress); foreach (var node in doc.Root.Elements("object-change")) { bool refretry; //XElement element = node; AcmaCSEntryChange csentry = CSEntryChangeXmlImport.ImportFromXml(node, !this.IgnoreMissingAttributes.IsPresent); progress.PercentComplete = Convert.ToInt32(((decimal)this.currentObjectCount / this.totalObjectCount) * 100); progress.StatusDescription = string.Format("Importing {0}/{1}... {2} ({3} objects/sec)", this.currentObjectCount, this.totalObjectCount, csentry.DN, this.sampleOpsSec); progress.CurrentOperation = string.Format("Average rate: {0} objects/sec", this.averageOpsSec); progress.SecondsRemaining = this.secondsRemaining; this.WriteProgress(progress); try { CSEntryExport.PutExportEntry(csentry, out refretry); } catch (Exception ex) { Console.WriteLine("Error importing object {0}: {1}: {2}", this.currentObjectCount, csentry.DN, ex.Message); } this.currentObjectCount++; } progress.RecordType = ProgressRecordType.Completed; WriteProgress(progress); Console.WriteLine("Done"); MAStatistics.StopOperation(); Console.WriteLine(MAStatistics.ToString()); } catch (Exception ex) { Logger.WriteException(ex); ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, this.FileName); ThrowTerminatingError(error); } finally { if (this.timer != null) { this.timer.Stop(); this.timer.Elapsed -= this.timer_Elapsed; } } }