public void Update(DataCollectionContext context) { var application = context.Application; var activity = context.Activity; var behavior = context.Behavior; var request = application.Request; activity.HostName = request.Url.Host; activity.Url = request.Url.PathAndQuery; activity.UserHostAddress = request.UserHostAddress; activity.UserHostName = request.UserHostName; activity.Machine = application.Server.MachineName; activity.MachineFqn = GetMachineFullyQualifiedName(); activity.StartedAt = new DenormalizedDateTime(DateTime.UtcNow); var ignore = behavior.IgnoreRequestBody || request.ContentLength > 1048576; activity.Request = new Request { Body = ignore ? null : request.InputStream.ReadToEnd(), BodyIgnored = ignore, Headers = GetHeaders(request), HttpMethod = request.HttpMethod, RawUrl = request.Url.OriginalString, Protocol = request.ServerVariables["SERVER_PROTOCOL"], ContentType = request.ContentType, ContentEncoding = request.ContentEncoding.WebName, ContentLength = request.ContentLength }; }
public void Update(DataCollectionContext context) { var requestRouteData = context.Application.Context.Request.RequestContext.RouteData; if (requestRouteData == null || requestRouteData.Route == null) { return; } if (context.Behavior.IgnoreRouteData) { context.Activity.RouteDataIgnored = true; return; } var routeData = new DomainModel.Entities.RouteData(); var route = requestRouteData.Route as Route; if (route == null) { return; } routeData.Name = Name(route); routeData.Template = route.Url; routeData.Constraints = ToList(route.Constraints); routeData.DataTokens = ToList(route.DataTokens); routeData.Defaults = ToList(route.Defaults); routeData.Values = ToList(requestRouteData.Values); context.Activity.RouteData = routeData; }
public void Update(DataCollectionContext context) { if (context.Behavior.IgnoreServerVariables) { context.Activity.VariablesIgnored = true; return; } var request = context.Application.Request; context.Activity.Variables = request.ServerVariables.AllKeys .Select(x => new NameValue(x, request.ServerVariables[x])) .ToList(); }
/// <inheritdoc/> public override void LogError(DataCollectionContext context, string text) { ValidateArg.NotNull(context, "context"); ValidateArg.NotNull(text, "text"); if (EqtTrace.IsErrorEnabled) { EqtTrace.Error( "Data collector '{0}' logged the following error: {1}", this.dataCollectorConfig.TypeUri, text); } this.SendTextMessage(context, text, TestMessageLevel.Error); }
/// <summary> /// Stop vanguard /// </summary> /// <param name="context">Context</param> protected void StopVanguard(DataCollectionContext context) { EqtTrace.Info("DynamicCoverageDataCollectorImpl.StopVanguard: Calling Stop Vanguard. datacollection context sessionID: {0}", context.SessionId); if (this.Vanguard != null) { this.Vanguard.Stop(); if (this.fileHelper.Exists(this.coverageFilePath)) { this.dataSink.SendFileAsync(context, this.coverageFilePath, false); } this.Vanguard = null; } }
public void RaiseEventsShouldNotRaiseEventsIfEventIsUnRegisterd() { this.isEventRaised = false; var testCase = new TestCase(); this.context = new DataCollectionContext(testCase); this.events.SessionStart += this.SessionStartMessageHandler; this.events.SessionStart -= this.SessionStartMessageHandler; var eventArgs = new SessionStartEventArgs(this.context); this.events.RaiseEvent(eventArgs); Assert.IsFalse(this.isEventRaised); }
public CoverletCoverageDataCollectorTests() { _mockDataColectionEvents = new Mock <DataCollectionEvents>(); _mockDataCollectionSink = new Mock <DataCollectionSink>(); _mockLogger = new Mock <DataCollectionLogger>(); _configurationElement = null; TestCase testcase = new TestCase { Id = Guid.NewGuid() }; _dataCollectionContext = new DataCollectionContext(testcase); _context = new DataCollectionEnvironmentContext(_dataCollectionContext); _mockCoverageWrapper = new Mock <ICoverageWrapper>(); }
private void CreateDirectory(DataCollectionContext context, string path) { try { this.directoryHelper.CreateDirectory(path); } catch (Exception ex) { EqtTrace.Error("DynamicCoverageDataCollectorImpl.CreateDirectory:Failed to create directory: {0}, with exception: {1}", path, ex); this.logger.LogError( context, string.Format(CultureInfo.CurrentUICulture, Resources.FailedToCreateDirectory, path, ex)); throw; } }
private void WriteCollectedEventLogEntries( DataCollectionContext dataCollectionContext, bool isSessionEnd, TimeSpan requestedDuration, DateTime timeRequestReceived) { var context = this.GetEventLogSessionContext(dataCollectionContext); context.CreateEventLogContainerEndIndexMap(); List <EventLogEntry> eventLogEntries = new List <EventLogEntry>(); foreach (KeyValuePair <string, IEventLogContainer> kvp in this.eventLogContainerMap) { try { if (isSessionEnd) { kvp.Value.EventLog.EnableRaisingEvents = false; } for (int i = context.EventLogContainerStartIndexMap[kvp.Key]; i <= context.EventLogContainerEndIndexMap[kvp.Key]; i++) { eventLogEntries.Add(kvp.Value.EventLogEntries[i]); } } catch (Exception e) { this.logger.LogWarning( dataCollectionContext, string.Format( CultureInfo.InvariantCulture, Resource.CleanupException, kvp.Value.EventLog, e.ToString())); } } var fileName = this.WriteEventLogs(eventLogEntries, isSessionEnd ? int.MaxValue : this.maxEntries, dataCollectionContext, requestedDuration, timeRequestReceived); // Add the directory to the list this.eventLogDirectories.Add(Path.GetDirectoryName(fileName)); lock (this.ContextMap) { this.ContextMap.Remove(dataCollectionContext); } }
public void SendFileAsyncShouldInvokeAttachmentManagerWithValidFileTransferInfo() { var filename = Path.Combine(AppContext.BaseDirectory, "filename.txt"); File.WriteAllText(filename, string.Empty); var guid = Guid.NewGuid(); var sessionId = new SessionId(guid); var context = new DataCollectionContext(sessionId); var fileTransferInfo = new FileTransferInformation(context, filename, false); this.dataCollectionSink.SendFileAsync(fileTransferInfo); this.attachmentManager.Verify(x => x.AddAttachment(It.IsAny <FileTransferInformation>(), It.IsAny <AsyncCompletedEventHandler>(), It.IsAny <Uri>(), It.IsAny <string>()), Times.Once()); }
public void AddAttachmentShouldNotAddNewFileTransferIfSessionIsNotConfigured() { var filename = "filename.txt"; File.WriteAllText(Path.Combine(TempDirectoryPath, filename), string.Empty); var datacollectioncontext = new DataCollectionContext(this.sessionId); var friendlyName = "TestDataCollector"; var uri = new Uri("datacollector://Company/Product/Version"); var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(TempDirectoryPath, filename), false); this.attachmentManager.AddAttachment(dataCollectorDataMessage, null, uri, friendlyName); Assert.AreEqual(this.attachmentManager.AttachmentSets.Count, 0); }
/// <inheritdoc /> public virtual void Start(string outputName, DataCollectionContext context) { EqtTrace.Info("Vanguard.Start: Starting CodeCoverage.exe for output file: {0} datacollection session id: {1}", outputName, context.SessionId); this.vanguardProcessExitEvent = new ManualResetEvent(false); this.outputName = outputName; this.context = context; var collectCommand = this.vanguardCommandBuilder.GenerateCommandLine( VanguardCommand.Collect, this.sessionName, this.outputName, this.configurationFileName); this.vanguardProcess = this.StartVanguardProcess(collectCommand, false, true); this.WaitForRunningEvent(); }
public AttachmentManager(DataCollectionSink dataSink, DataCollectionContext dataCollectionContext, TestPlatformLogger logger, TestPlatformEqtTrace eqtTrace, string reportFileName, string reportDirectoryName, FileHelper fileHelper, DirectoryHelper directoryHelper) { // Store input vars this.dataSink = dataSink; this.dataCollectionContext = dataCollectionContext; this.logger = logger; this.eqtTrace = eqtTrace; this.reportFileName = reportFileName; this.fileHelper = fileHelper; this.directoryHelper = directoryHelper; // Report directory to store the coverage reports. this.reportDirectory = Path.Combine(Path.GetTempPath(), reportDirectoryName); // Register events this.dataSink.SendFileCompleted += this.OnSendFileCompleted; }
public AttachmentManagerTests() { _mockDataCollectionSink = new Mock <DataCollectionSink>(); _mockDataCollectionLogger = new Mock <DataCollectionLogger>(); var testcase = new TestCase { Id = Guid.NewGuid() }; _dataCollectionContext = new DataCollectionContext(testcase); _testPlatformLogger = new TestPlatformLogger(_mockDataCollectionLogger.Object, _dataCollectionContext); _eqtTrace = new TestPlatformEqtTrace(); _mockFileHelper = new Mock <IFileHelper>(); _mockDirectoryHelper = new Mock <IDirectoryHelper>(); _attachmentManager = new AttachmentManager(_mockDataCollectionSink.Object, _dataCollectionContext, _testPlatformLogger, _eqtTrace, "report.cobertura.xml", @"E:\temp", _mockFileHelper.Object, _mockDirectoryHelper.Object); }
public AttachmentManager(DataCollectionSink dataSink, DataCollectionContext dataCollectionContext, TestPlatformLogger logger, TestPlatformEqtTrace eqtTrace, string reportDirectoryName, IFileHelper fileHelper, IDirectoryHelper directoryHelper, ICountDownEvent countDownEvent) { // Store input variabless _dataSink = dataSink; _dataCollectionContext = dataCollectionContext; _logger = logger; _eqtTrace = eqtTrace; _fileHelper = fileHelper; _directoryHelper = directoryHelper; _countDownEvent = countDownEvent; // Report directory to store the coverage reports. _reportDirectory = Path.Combine(Path.GetTempPath(), reportDirectoryName); // Register events _dataSink.SendFileCompleted += OnSendFileCompleted; }
public AttachmentManagerTests() { this.mockDataCollectionSink = new Mock <DataCollectionSink>(); this.mockDataCollectionLogger = new Mock <DataCollectionLogger>(); TestCase testcase = new TestCase { Id = Guid.NewGuid() }; this.dataCollectionContext = new DataCollectionContext(testcase); this.testPlatformLogger = new TestPlatformLogger(this.mockDataCollectionLogger.Object, this.dataCollectionContext); this.eqtTrace = new TestPlatformEqtTrace(); this.mockFileHelper = new Mock <IFileHelper>(); this.mockDirectoryHelper = new Mock <IDirectoryHelper>(); this.attachmentManager = new AttachmentManager(this.mockDataCollectionSink.Object, this.dataCollectionContext, this.testPlatformLogger, this.eqtTrace, "report.cobertura.xml", @"E:\temp", this.mockFileHelper.Object, this.mockDirectoryHelper.Object); }
public CoverletCoverageDataCollectorTests() { _mockDataColectionEvents = new Mock <DataCollectionEvents>(); _mockDataCollectionSink = new Mock <DataCollectionSink>(); _mockLogger = new Mock <DataCollectionLogger>(); _configurationElement = null; TestCase testcase = new TestCase { Id = Guid.NewGuid() }; _dataCollectionContext = new DataCollectionContext(testcase); _context = new DataCollectionEnvironmentContext(_dataCollectionContext); _mockCoverageWrapper = new Mock <ICoverageWrapper>(); _mockCountDownEventFactory = new Mock <ICountDownEventFactory>(); _mockCountDownEventFactory.Setup(def => def.Create(It.IsAny <int>(), It.IsAny <TimeSpan>())).Returns(new Mock <ICountDownEvent>().Object); }
private EventLogSessionContext GetEventLogSessionContext(DataCollectionContext dataCollectionContext) { EventLogSessionContext eventLogSessionContext; bool eventLogContainerFound; lock (this.ContextMap) { eventLogContainerFound = this.ContextMap.TryGetValue(dataCollectionContext, out eventLogSessionContext); } if (!eventLogContainerFound) { string msg = string.Format( CultureInfo.InvariantCulture, Resource.ContextNotFoundException, dataCollectionContext.ToString()); throw new EventLogCollectorException(msg, null); } return(eventLogSessionContext); }
public EventLogContainerTests() { this.eventSources = new HashSet <string>(); this.eventSources.Add("Application"); this.entryTypes = new HashSet <EventLogEntryType>(); this.entryTypes.Add(EventLogEntryType.Error); this.logger = new Mock <DataCollectionLogger>(); this.eventLog = new EventLog("Application"); this.entryWrittenEventArgs = new EntryWrittenEventArgs(this.eventLog.Entries[this.eventLog.Entries.Count - 1]); this.dataCollectionContext = new DataCollectionContext(new SessionId(Guid.NewGuid())); this.eventLogContainer = new EventLogContainer( this.eventLogName, this.eventSources, this.entryTypes, int.MaxValue, this.logger.Object, this.dataCollectionContext); }
public void GetAttachmentsShouldNotReturnAttachmentsAfterCancelled() { var filename = "filename1.txt"; File.WriteAllText(Path.Combine(AppContext.BaseDirectory, filename), string.Empty); this.attachmentManager.Initialize(this.sessionId, AppContext.BaseDirectory, this.messageSink.Object); var datacollectioncontext = new DataCollectionContext(this.sessionId); var friendlyName = "TestDataCollector"; var uri = new Uri("datacollector://Company/Product/Version"); var dataCollectorDataMessage = new FileTransferInformation(datacollectioncontext, Path.Combine(AppContext.BaseDirectory, filename), true); this.attachmentManager.AddAttachment(dataCollectorDataMessage, null, uri, friendlyName); this.attachmentManager.Cancel(); var result = this.attachmentManager.GetAttachments(datacollectioncontext); Assert.AreEqual(0, result[0].Attachments.Count); }
/// <inheritdoc/> public override void LogError(DataCollectionContext context, string text, Exception exception) { ValidateArg.NotNull(context, "context"); ValidateArg.NotNull(text, "text"); ValidateArg.NotNull(exception, "exception"); // Make sure the data collection context is not a derived data collection context. This // is done to safeguard from 3rd parties creating their own data collection contexts. if (context.GetType() != typeof(DataCollectionContext)) { throw new InvalidOperationException(Resources.Resources.WrongDataCollectionContextType); } if (EqtTrace.IsErrorEnabled) { EqtTrace.Error( "Data collector '{0}' logged the following error:" + Environment.NewLine + "Description: {1}" + Environment.NewLine + "Exception type: {2}" + Environment.NewLine + "Exception message: {3}" + Environment.NewLine + "Exception stack trace: {4}", this.dataCollectorConfig.TypeUri, text, exception.GetType(), exception.Message, exception.StackTrace); } // Currently there is one type of DataCollectionMessage sent accross client for all message kind. // If required new type can be created for different message type. var message = string.Format( CultureInfo.CurrentCulture, Resources.Resources.ReportDataCollectorException, exception.GetType(), exception.Message, text); this.SendTextMessage(context, message, TestMessageLevel.Error); }
/// <summary> /// The trigger test case end. /// </summary> public virtual void TriggerTestCaseEnd(TestCase testCase, TestOutcome outcome) { bool isTestCaseEndAlreadySent = false; lock (testCaseEndStatusSyncObject) { isTestCaseEndAlreadySent = this.testCaseEndStatusMap.Contains(testCase.Id); if (!isTestCaseEndAlreadySent) { this.testCaseEndStatusMap.Add(testCase.Id); } // Do not support multiple - testcasends for a single test case start // TestCaseEnd must always be preceded by testcasestart for a given test case id if (!isTestCaseEndAlreadySent) { var dataCollectionContext = new DataCollectionContext(testCase); var testCaseEndArgs = new TestCaseEndArgs(dataCollectionContext, outcome); // Call all in-proc datacollectors - TestCaseEnd event this.TriggerInProcDataCollectionMethods(Constants.TestCaseEndMethodName, testCaseEndArgs); // If dictionary contains results for this test case, update them with in-proc data and flush them if (testResultDictionary.ContainsKey(testCase.Id)) { foreach (var testResult in testResultDictionary[testCase.Id]) { this.SetInProcDataCollectionDataInTestResult(testResult); // TestResult updated with in-proc data, just flush this.testRunCache.OnNewTestResult(testResult); } this.testResultDictionary.Remove(testCase.Id); } } } }
/// <summary> /// Initializes data collector /// </summary> /// <param name="configurationElement">Configuration element</param> /// <param name="events">Events to register on</param> /// <param name="dataSink">Data sink to send attachments to test platform</param> /// <param name="logger">Test platform logger</param> /// <param name="environmentContext">Environment context</param> public override void Initialize( XmlElement configurationElement, DataCollectionEvents events, DataCollectionSink dataSink, DataCollectionLogger logger, DataCollectionEnvironmentContext environmentContext) { if (_eqtTrace.IsInfoEnabled) { _eqtTrace.Info("Initializing {0} with configuration: '{1}'", CoverletConstants.DataCollectorName, configurationElement?.OuterXml); } // Store input variables _events = events; _configurationElement = configurationElement; _dataSink = dataSink; _dataCollectionContext = environmentContext.SessionDataCollectionContext; _logger = new TestPlatformLogger(logger, _dataCollectionContext); // Register events _events.SessionStart += OnSessionStart; _events.SessionEnd += OnSessionEnd; }
/// <summary> /// Initializes a new instance of the <see cref="BlameCollectorTests"/> class. /// </summary> public BlameCollectorTests() { // Initializing mocks this.mockLogger = new Mock <DataCollectionLogger>(); this.mockDataColectionEvents = new Mock <DataCollectionEvents>(); this.mockDataCollectionSink = new Mock <DataCollectionSink>(); this.mockBlameReaderWriter = new Mock <IBlameReaderWriter>(); this.blameDataCollector = new TestableBlameCollector(this.mockBlameReaderWriter.Object); // Initializing members TestCase testcase = new TestCase { Id = Guid.NewGuid() }; this.dataCollectionContext = new DataCollectionContext(testcase); this.configurationElement = null; this.context = new DataCollectionEnvironmentContext(this.dataCollectionContext); this.filepath = Path.Combine(Path.GetTempPath(), "Test"); FileStream stream = File.Create(this.filepath); stream.Dispose(); }
/// <summary> /// Start vanguard /// </summary> /// <param name="context">Context</param> protected void StartVanguard(DataCollectionContext context) { if (this.Vanguard != null) { string outputCoverageFolder = Path.Combine(this.sessionDirectory, Guid.NewGuid().ToString()); this.CreateDirectory(context, outputCoverageFolder); this.coverageFilePath = Path.Combine(outputCoverageFolder, this.coverageFileName); try { this.Vanguard.Start(this.coverageFilePath, context); } catch (Exception ex) { EqtTrace.Error( "DynamicCoverageDataCollectorImpl.StartVanguard: Failed to start Vanguard for datacollection context sessionID: {0}, with exception: {1}", context.SessionId, ex); this.logger.LogError(context, ex); throw; } } }
public void Update(DataCollectionContext context) { var application = context.Application; var activity = context.Activity; var behavior = context.Behavior; var response = application.Response; activity.EndedAt = new DenormalizedDateTime(DateTime.UtcNow); activity.StatusCode = response.StatusCode; var ignore = behavior.IgnoreResponseBody || response.Filter.Length > 1048576; activity.Response = new Response { Body = ignore ? null : response.Filter.ToString(), BodyIgnored = ignore, Headers = GetHeaders(response), StatusCode = response.StatusCode, StatusDescription = response.StatusDescription, SubStatusCode = GetSubStatusCode(response), ContentType = response.ContentType, ContentEncoding = response.ContentEncoding.WebName, ContentLength = response.Filter.Length }; if (activity.Status == ActivityStatus.Failure) { return; } if (application.Response.StatusCode < 400) { activity.SetStatusToSuccess(); return; } activity.SetStatusToFailure(FailureDeterminedBy.HttpCode); }
/// <inheritdoc/> public Collection <AttachmentSet> TestCaseEnded(TestCaseEndEventArgs testCaseEndEventArgs) { if (!this.isDataCollectionEnabled) { return(new Collection <AttachmentSet>()); } var context = new DataCollectionContext(this.dataCollectionEnvironmentContext.SessionDataCollectionContext.SessionId, testCaseEndEventArgs.TestElement); testCaseEndEventArgs.Context = context; this.SendEvent(testCaseEndEventArgs); List <AttachmentSet> result = null; try { result = this.attachmentManager.GetAttachments(testCaseEndEventArgs.Context); } catch (Exception ex) { if (EqtTrace.IsErrorEnabled) { EqtTrace.Error("DataCollectionManager.TestCaseEnded: Failed to get attachments : {0}", ex); } return(new Collection <AttachmentSet>(result)); } if (EqtTrace.IsVerboseEnabled) { this.LogAttachments(result); } return(new Collection <AttachmentSet>(result)); }
/// <inheritdoc/> public List <AttachmentSet> GetAttachments(DataCollectionContext dataCollectionContext) { try { Task.WhenAll(this.attachmentTasks[dataCollectionContext].ToArray()).Wait(); } catch (Exception ex) { EqtTrace.Error(ex.Message); } List <AttachmentSet> attachments = new List <AttachmentSet>(); Dictionary <Uri, AttachmentSet> uriAttachmentSetMap; if (this.AttachmentSets.TryGetValue(dataCollectionContext, out uriAttachmentSetMap)) { attachments = uriAttachmentSetMap.Values.ToList(); this.attachmentTasks.Remove(dataCollectionContext); this.AttachmentSets.Remove(dataCollectionContext); } return(attachments); }
/// <summary> /// Initializes a new instance of the <see cref="BasicTransferInformation"/> class. /// </summary> /// <param name="context"> /// The data collection context for the transfer. /// </param> protected BasicTransferInformation(DataCollectionContext context) { //EqtAssert.ParameterNotNull(context, "context"); this.Context = context; this.Description = string.Empty; }
/// <summary> /// Initializes a new instance of the <see cref="EventLogContainer"/> class. /// </summary> /// <param name="eventLogName"> /// Event Log Name for which logs has to be collected. /// </param> /// <param name="eventSources"> /// The event Sources. /// </param> /// <param name="entryTypes"> /// The entry Types. /// </param> /// <param name="maxLogEntries"> /// Max entries to store /// </param> /// <param name="dataCollectionLogger"> /// Data Collection Logger /// </param> /// <param name="dataCollectionContext"> /// Data Collection Context /// </param> public EventLogContainer(string eventLogName, ISet <string> eventSources, ISet <EventLogEntryType> entryTypes, int maxLogEntries, DataCollectionLogger dataCollectionLogger, DataCollectionContext dataCollectionContext) { this.CreateEventLog(eventLogName); this.eventSources = eventSources; this.entryTypes = entryTypes; this.maxLogEntries = maxLogEntries; this.dataCollectionLogger = dataCollectionLogger; this.dataCollectionContext = dataCollectionContext; this.eventLogEntries = new List <EventLogEntry>(); }
public void InitializeTest() { this.dataCollectionSink = new InProcDataCollectionSink(); this.testCase = new TestCase("DummyNS.DummyC.DummyM", new Uri("executor://mstest/v1"), "Dummy.dll"); this.dataCollectionContext = new DataCollectionContext(this.testCase); }
public PopulationRegistrationRepository() { collectionContext = new DataCollectionContext(); }
/// <summary> /// The write event logs. /// </summary> /// <param name="eventLogEntries"> /// The event log entries. /// </param> /// <param name="maxLogEntries"> /// Max Log Entries. /// </param> /// <param name="dataCollectionContext"> /// The data collection context. /// </param> /// <param name="requestedDuration"> /// The requested duration. /// </param> /// <param name="timeRequestReceived"> /// The time request received. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> internal string WriteEventLogs(List <EventLogEntry> eventLogEntries, int maxLogEntries, DataCollectionContext dataCollectionContext, TimeSpan requestedDuration, DateTime timeRequestReceived) { // Generate a unique but friendly Directory name in the temp directory string eventLogDirName = string.Format( CultureInfo.InvariantCulture, "{0}-{1}-{2:yyyy}{2:MM}{2:dd}-{2:HH}{2:mm}{2:ss}.{2:fff}", "Event Log", Environment.MachineName, DateTime.Now); string eventLogDirPath = Path.Combine(Path.GetTempPath(), eventLogDirName); // Create the directory this.fileHelper.CreateDirectory(eventLogDirPath); string eventLogBasePath = Path.Combine(eventLogDirPath, EventLogFileName); bool unusedFilenameFound = false; string eventLogPath = eventLogBasePath + ".xml"; if (this.fileHelper.Exists(eventLogPath)) { for (int i = 1; !unusedFilenameFound; i++) { eventLogPath = eventLogBasePath + "-" + i.ToString(CultureInfo.InvariantCulture) + ".xml"; if (!this.fileHelper.Exists(eventLogPath)) { unusedFilenameFound = true; } } } DateTime minDate = DateTime.MinValue; // Limit entries to a certain time range if requested if (requestedDuration < TimeSpan.MaxValue) { try { minDate = timeRequestReceived - requestedDuration; } catch (ArgumentOutOfRangeException) { minDate = DateTime.MinValue; } } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); EventLogXmlWriter.WriteEventLogEntriesToXmlFile( eventLogPath, eventLogEntries.Where( entry => entry.TimeGenerated > minDate && entry.TimeGenerated < DateTime.MaxValue).OrderBy(x => x.TimeGenerated).ToList().Take(maxLogEntries).ToList(), this.fileHelper); stopwatch.Stop(); if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose( string.Format( CultureInfo.InvariantCulture, "EventLogDataContainer: Wrote {0} event log entries to file '{1}' in {2} seconds", eventLogEntries.Count, eventLogPath, stopwatch.Elapsed.TotalSeconds.ToString(CultureInfo.InvariantCulture))); } // Write the event log file FileTransferInformation fileTransferInformation = new FileTransferInformation(dataCollectionContext, eventLogPath, true, this.fileHelper); this.dataSink.SendFileAsync(fileTransferInformation); if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose( "EventLogDataContainer: Event log successfully sent for data collection context '{0}'.", dataCollectionContext.ToString()); } return(eventLogPath); }
public TestPlatformLogger(DataCollectionLogger logger, DataCollectionContext dataCollectionContext) { _logger = logger; _dataCollectionContext = dataCollectionContext; }