void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { Clipboard.SetText(e.Exception.Message); DebugOutput.WriteLine(string.Empty); DebugOutput.WriteLine("Unhandled exception occured, please, restart the application. Exception message has been copied to the clipboard."); DebugOutput.WriteLine(e.Exception.Message); e.Handled = true; }
public void SetUpTracing() { if (!TraceSources.Common.Listeners.Contains(listener)) { TraceSources.Common.Listeners.Add(listener); TraceSources.Common.Switch.Level = SourceLevels.Verbose; } listener.WriteLine("Start " + TestContext.CurrentContext.Test.FullName); }
public void SetUpTracing() { foreach (var trace in Traces) { if (!trace.Listeners.Contains(listener)) { listener.TraceOutputOptions = TraceOptions.DateTime; trace.Listeners.Add(listener); trace.Switch.Level = System.Diagnostics.SourceLevels.Verbose; } } listener.WriteLine("Start " + TestContext.CurrentContext.Test.FullName); }
public static void WriteLineExpectedOutput(bool value) { RemoteExecutor.Invoke((_value) => { string message = "A new message to the listener"; bool setErrorStream = bool.Parse(_value); using (var stringWriter = new StringWriter()) { if (setErrorStream) { Console.SetError(stringWriter); } else { Console.SetOut(stringWriter); } using (var listener = new ConsoleTraceListener(useErrorStream: setErrorStream)) { listener.WriteLine(message); Assert.Contains(message, stringWriter.ToString() + Environment.NewLine); } } }, value.ToString()).Dispose(); }
/// <summary> /// Ecrit dans la console le message /// </summary> /// <param name="message">message</param> public static void WriteInConsole(string message) { ConsoleTraceListener consoleTracer; consoleTracer = new ConsoleTraceListener(true); consoleTracer.WriteLine(message); consoleTracer.Close(); }
static void Main(string[] args) { TraceListener trace = new ConsoleTraceListener(); var rentalConnector = new TrademeRentalConnector("v1/Search/Property/Rental.json?", trace); TrademeStatsRepository respository = new TrademeStatsRepository(new TrademeStatsContext()); while (true) { IEnumerable <RentalListing> rentalListings = rentalConnector.GetListings(); Stopwatch sw = Stopwatch.StartNew(); sw.Start(); foreach (var rentalListing in rentalListings) { trace.WriteLine($"Adding listing ID: {rentalListing.ListingId}"); respository.AddRentalListing(rentalListing); } respository.SaveChanges(); sw.Stop(); trace.WriteLine($"Finished fetching listings, took {sw.Elapsed.TotalSeconds} seconds. Press enter to exit."); Thread.Sleep(600000); } }
public void ConsoleTraceListener_BasicVerification() { var expectedText = Guid.NewGuid().ToString(); using (var memoryStream = new MemoryStream()) using (var textWriter = new StreamWriter(memoryStream)) using (var listener = new ConsoleTraceListener(textWriter)) { listener.WriteLine(expectedText); listener.Flush(); textWriter.Flush(); var buf = memoryStream.ToArray(); var actualText = Encoding.UTF8.GetString(buf, 0, buf.Length); Assert.IsTrue(actualText.Contains(expectedText)); } }
internal static void Main() { using (var server = Server.Create("Default")) { // If you want to publish this server, or connect to an already existing server, // please see the product documentation "Publishing and Connecting to a StreamInsight Server" // to find out how to replace, or add to the above server creation code. You must publish // the server for the Event Flow debugger to be able to connect to the server. var application = server.CreateApplication("TutorialApp"); // Define device configuration var inputConfig = new CsvInputConfig { InputFileName = @"..\..\..\TollInput.txt", Delimiter = new char[] { ',' }, BufferSize = 4096, CtiFrequency = 1, CultureName = "en-US", Fields = new List <string>() { "TollId", "LicensePlate", "State", "Make", "Model", "VehicleType", "VehicleWeight", "Toll", "Tag" }, NonPayloadFieldCount = 2, StartTimePos = 1, EndTimePos = 2 }; var outputConfigForPassThroughQuery = new CsvOutputConfig { // The adapter recognizes empty filename as a write to console OutputFileName = string.Empty, Delimiter = new string[] { "\t" }, CultureName = "en-US", Fields = new List <string>() { "TollId", "LicensePlate", "State", "Make", "Model", "VehicleType", "VehicleWeight", "Toll", "Tag" } }; var outputConfigForCountQuery = new CsvOutputConfig { OutputFileName = string.Empty, Delimiter = new string[] { "\t" }, CultureName = "en-US", Fields = new List <string>() { "Count" } }; // Define console trace listener TraceListener tracer = new ConsoleTraceListener(); // set up advance time settings to enqueue CTIs - to deliver output in a timely fashion var advanceTimeGenerationSettings = new AdvanceTimeGenerationSettings(inputConfig.CtiFrequency, TimeSpan.Zero, true); var advanceTimeSettings = new AdvanceTimeSettings(advanceTimeGenerationSettings, null, AdvanceTimePolicy.Adjust); // Define input stream object, mapped to stream names // Instantiate an adapter from the input factory class var inputStream = CepStream <TollReading> .Create( "TollStream", typeof(CsvInputFactory), inputConfig, EventShape.Interval, advanceTimeSettings); var passthroughQuery = from e in inputStream select e; var countQuery = from w in inputStream.TumblingWindow(TimeSpan.FromMinutes(3), HoppingWindowOutputPolicy.ClipToWindowEnd) select new TollCount { Count = w.Count() }; // Create a runnable query by binding the query template to the // input stream of interval events, and to an output stream of // fully ordered point events (through an output adapter instantiated // from the output factory class) Query query = countQuery.ToQuery( application, "HelloTollTutorial", "Hello Toll Query", typeof(CsvOutputFactory), outputConfigForCountQuery, EventShape.Interval, StreamEventOrder.FullyOrdered); query.Start(); Console.WriteLine("*** Hit Return to see Query Diagnostics after this run ***"); Console.WriteLine(); Console.ReadLine(); // Retrieve diagnostic information from the CEP server about the query. // See the section "Connecting to and Publishing a Server" in the StreamInsight MSDN documentation on // how to make the debugger client connect to the server and retrieve these diagnostics Console.WriteLine(string.Empty); RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/EventManager")), tracer); RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/PlanManager")), tracer); RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/TutorialApp/Query/HelloTollTutorial")), tracer); DiagnosticSettings settings = new DiagnosticSettings(DiagnosticAspect.GenerateErrorReports, DiagnosticLevel.Always); server.SetDiagnosticSettings(new Uri("cep:/Server"), settings); tracer.WriteLine("Global Server Diagnostics"); RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/EventManager")), tracer); RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/PlanManager")), tracer); RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Query")), tracer); tracer.WriteLine(string.Empty); tracer.WriteLine("Summary Query Diagnostics for"); RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/TutorialApp/Query/HelloTollTutorial")), tracer); tracer.WriteLine(string.Empty); query.Stop(); Console.WriteLine("*** Query Completed *** Hit Return to Exit"); Console.WriteLine(); Console.ReadLine(); } return; }