public void ExportStart() { Logger.WriteSeparatorLine('*'); Logger.WriteLine("Starting Export"); MAStatistics.StartOperation(MAOperationType.Export); this.ProcessOperationEvents(AcmaEventOperationType.Export); }
protected override void BeginProcessing() { try { if (this.ExportObjects == null || this.ExportObjects.Length == 0) { ThrowTerminatingError(new ErrorRecord(new ArgumentNullException("ExportObjects"), "NoObjects", ErrorCategory.InvalidArgument, null)); } this.totalObjectCount = this.ExportObjects.Length; Global.ThrowIfNotConnected(this); this.writer = null; MAStatistics.StartOperation(MAOperationType.Import); Console.WriteLine("Writing export file... "); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewLineChars = Environment.NewLine; writer = XmlWriter.Create(this.FileName, settings); writer.WriteStartDocument(); writer.WriteStartElement("acma-export"); progress = new ProgressRecord(0, "Export", "Starting export"); 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); } catch (Exception ex) { if (this.timer != null) { this.timer.Stop(); this.timer.Elapsed -= this.timer_Elapsed; this.timer = null; } if (writer != null) { writer.Close(); } ThrowTerminatingError(new ErrorRecord(ex, "UnknownError", ErrorCategory.InvalidOperation, null)); } }
public ImportResponse ImportStart(ImportStartRequest request) { Logger.WriteLine("Import request received"); MAStatistics.StartOperation(MAOperationType.Import); ImportResponse response = new ImportResponse(); CachedImportRequest cachedRequest = new CachedImportRequest(); cachedRequest.Request = request; if (cachedRequest.Request.ImportType == OperationType.Delta) { this.ProcessOperationEvents(AcmaEventOperationType.DeltaImport); } else { this.ProcessOperationEvents(AcmaEventOperationType.FullImport); } byte[] watermark = ActiveConfig.DB.GetHighWatermarkMAObjectsDelta(); response.Watermark = watermark == null ? null : Convert.ToBase64String(watermark); cachedRequest.HighWatermark = watermark; Logger.WriteLine("Got delta watermark: {0}", response.Watermark); ResultEnumerator enumerator; if (cachedRequest.Request.ImportType == OperationType.Delta) { enumerator = ActiveConfig.DB.EnumerateMAObjectsDelta(watermark); } else { enumerator = ActiveConfig.DB.EnumerateMAObjects(cachedRequest.Request.Schema.Types.Select(t => t.Name).ToList(), null, null); } cachedRequest.Queue = new ConcurrentQueue <CSEntryChange>(); cachedRequest.Count = enumerator.TotalCount; this.StartProducerThread(enumerator, request.Schema, cachedRequest); response.Context = Guid.NewGuid().ToString(); this.AddToCache(response.Context, cachedRequest); this.GetResultPage(response, request.PageSize); return(response); }
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; } } }