public virtual Task Send(object value) { JsonSerializer.Stringify(value, OutputWriter); OutputWriter.Flush(); return(Context.Response.FlushAsync()); }
/// <summary> /// Reads from the stream until the external program is ended. /// </summary> private void StreamReaderThread_Output() { StreamReader reader = _stdOut; bool doAppend = OutputAppend; while (true) { string logContents = reader.ReadLine(); if (logContents == null) { break; } // ensure only one thread writes to the log at any time lock (_lockObject) { if (Output != null) { StreamWriter writer = new StreamWriter(Output.FullName, doAppend); writer.WriteLine(logContents); doAppend = true; writer.Close(); } else { OutputWriter.WriteLine(logContents); } } } lock (_lockObject) { OutputWriter.Flush(); } }
public void Dispose() { if (OutputWriter != null) { OutputWriter.Flush(); OutputWriter.Close(); } }
/// <summary> /// Signals that the last target has finished. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A <see cref="BuildEventArgs" /> object that contains the event data.</param> /// <remarks> /// This event will still be fired if an error occurred during the build. /// </remarks> public void BuildLoggingFinished(object sender, BuildEventArgs e) { lock (_xmlWriter) { if (e.Exception != null) { _xmlWriter.WriteStartElement("failure"); WriteErrorNode(e.Exception); _xmlWriter.WriteEndElement(); } WriteDuration(e.Stopwatch); // close buildresults node _xmlWriter.WriteEndElement(); _xmlWriter.Flush(); } // remove an item from the project stack _projectStack.Pop(); // check if there are still nested projects executing if (_projectStack.Count != 0) { // do not yet persist build results, as the main project is // not finished yet return; } try { // write results to file if (OutputWriter != null) { OutputWriter.Write(_buffer.ToString()); OutputWriter.Flush(); } else { // Xmlogger is used as BuildListener string outFileName = e.Project.GetGlobalProperty("XmlLogger.file"); if (outFileName == null) { outFileName = "log.xml"; } // convert to full path relative to project base directory outFileName = e.Project.GetFullPath(outFileName); // write build log to file using (StreamWriter writer = new StreamWriter(new FileStream(outFileName, FileMode.Create, FileAccess.Write, FileShare.Read), Encoding.UTF8)) { writer.Write(_buffer.ToString()); } } } catch (Exception ex) { throw new BuildException("Unable to write to log file.", ex); } }
public override Task KeepAlive() { OutputWriter.Write("data: {}"); OutputWriter.WriteLine(); OutputWriter.WriteLine(); OutputWriter.Flush(); return(Context.Response.FlushAsync()); }
public override Task KeepAlive() { OutputWriter.Write("<script>r(c, {});</script>"); OutputWriter.WriteLine(); OutputWriter.WriteLine(); OutputWriter.Flush(); return(Context.Response.FlushAsync()); }
public virtual Task Send(object value) { Context.Response.ContentType = Json.MimeType; JsonSerializer.Stringify(value, OutputWriter); OutputWriter.Flush(); return(Context.Response.EndAsync()); }
public void Play(int i) { var outputWriter = new OutputWriter(i, _output); foreach (var analyzer in _analyzers) { analyzer.Process(outputWriter, i); } outputWriter.Flush(); }
public override Task Send(PersistentResponse response) { OnSendingResponse(response); OutputWriter.Write("<script>r(c, "); JsonSerializer.Serialize(response, OutputWriter); OutputWriter.Write(");</script>\r\n"); OutputWriter.Flush(); return(Context.Response.FlushAsync().Catch(IncrementErrorCounters)); }
public override Task Send(PersistentResponse response) { OnSendingResponse(response); OutputWriter.Write("<script>r(c, "); JsonSerializer.Stringify(response, OutputWriter); OutputWriter.Write(");</script>\r\n"); OutputWriter.Flush(); return(Context.Response.FlushAsync()); }
public virtual Task Send(object value) { Context.Response.ContentType = Json.MimeType; return(EnqueueOperation(() => { JsonSerializer.Serialize(value, OutputWriter); OutputWriter.Flush(); return Context.Response.EndAsync().Catch(IncrementErrorCounters); })); }
public override Task KeepAlive() { return(EnqueueOperation(() => { OutputWriter.Write("data: {}"); OutputWriter.WriteLine(); OutputWriter.WriteLine(); OutputWriter.Flush(); return Context.Response.FlushAsync(); })); }
public override Task KeepAlive() { return(EnqueueOperation(() => { OutputWriter.Write("<script>r(c, {});</script>"); OutputWriter.WriteLine(); OutputWriter.WriteLine(); OutputWriter.Flush(); return Context.Response.FlushAsync(); })); }
protected override Task InitializeResponse(ITransportConnection connection) { return(base.InitializeResponse(connection) .Then(initScript => { Context.Response.ContentType = "text/html"; OutputWriter.Write(initScript); OutputWriter.Flush(); return Context.Response.FlushAsync(); }, _initPrefix + Context.Request.QueryString["frameId"] + _initSuffix)); }
public override Task Send(PersistentResponse response) { OnSendingResponse(response); OutputWriter.Write("id: "); OutputWriter.Write(response.MessageId); OutputWriter.WriteLine(); OutputWriter.Write("data: "); JsonSerializer.Serialize(response, OutputWriter); OutputWriter.WriteLine(); OutputWriter.WriteLine(); OutputWriter.Flush(); return(Context.Response.FlushAsync().Catch(IncrementErrorCounters)); }
public override Task Send(PersistentResponse response) { OnSendingResponse(response); return(EnqueueOperation(() => { OutputWriter.Write("data: "); JsonSerializer.Serialize(response, OutputWriter); OutputWriter.WriteLine(); OutputWriter.WriteLine(); OutputWriter.Flush(); return Context.Response.FlushAsync().Catch(IncrementErrorCounters); })); }
bool Processing(HttpListenerContext context) { var finished = false; var request = context.Request; var response = "OK"; var stream = request.InputStream; var data = string.Empty; using (var reader = new StreamReader(stream)) data = reader.ReadToEnd(); stream.Close(); switch (request.RawUrl) { case "/Start": if (!connected_once) { connected_once = true; Connected(request.RemoteEndPoint.ToString()); } break; case "/Finish": if (!finished) { OutputWriter.Write(data); OutputWriter.Flush(); finished = true; } break; default: Log.WriteLine("Unknown upload url: {0}", request.RawUrl); response = $"Unknown upload url: {request.RawUrl}"; break; } var buf = System.Text.Encoding.UTF8.GetBytes(response); context.Response.ContentLength64 = buf.Length; context.Response.OutputStream.Write(buf, 0, buf.Length); context.Response.OutputStream.Close(); context.Response.Close(); return(finished); }
protected override Task InitializeResponse(ITransportConnection connection) { return(base.InitializeResponse(connection) .Then(() => { Context.Response.ContentType = "text/event-stream"; // "data: initialized\n\n" OutputWriter.Write("data: initialized"); OutputWriter.WriteLine(); OutputWriter.WriteLine(); OutputWriter.Flush(); return Context.Response.FlushAsync(); })); }
/// <summary> /// Reads from the stream until the external program is ended. /// </summary> protected virtual void StreamReaderThread_Output() { StreamReader reader = _stdOut; bool doAppend = OutputAppend; StringBuilder Capture = new StringBuilder(); while (true) { string logContents = reader.ReadLine(); if (logContents == null) { break; } // ensure only one thread writes to the log at any time lock (_lockObject) { OutputWriter.WriteLine(logContents); if (!String.IsNullOrEmpty(this.OutputProperty)) { Capture.AppendLine(logContents); } if (Output != null) { StreamWriter writer = new StreamWriter(Output.FullName, doAppend); writer.WriteLine(logContents); doAppend = true; writer.Close(); } } } if (!String.IsNullOrEmpty(this.OutputProperty)) { if (!this.Properties.Contains(this.OutputProperty)) { this.Properties.Add(this.OutputProperty, string.Empty); } this.Properties[this.OutputProperty] = Capture.ToString(); } OutputWriter.Flush(); }
public virtual Task Send(object value) { Context.Response.ContentType = IsJsonp ? Json.JsonpMimeType : Json.MimeType; if (IsJsonp) { OutputWriter.Write(JsonpCallback); OutputWriter.Write("("); } _jsonSerializer.Stringify(value, OutputWriter); if (IsJsonp) { OutputWriter.Write(");"); } OutputWriter.Flush(); return(Context.Response.EndAsync()); }
protected void Finished(bool early_termination = false) { if (stopped.TrySetResult(early_termination)) { if (early_termination) { Log.WriteLine("Tests were terminated before completion"); } else { Log.WriteLine("Tests have finished executing"); } if (xml_data != null) { OutputWriter.WriteLine($"<!-- \n{xml_data}\n -->"); OutputWriter.Flush(); xml_data = null; } } }
public virtual Task Send(object value) { Context.Response.ContentType = IsJsonp ? Json.JsonpMimeType : Json.MimeType; return(EnqueueOperation(() => { if (IsJsonp) { OutputWriter.Write(JsonpCallback); OutputWriter.Write("("); } _jsonSerializer.Serialize(value, OutputWriter); if (IsJsonp) { OutputWriter.Write(");"); } OutputWriter.Flush(); return Context.Response.EndAsync(); })); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Reads from the stream until the external program is ended. /// </summary> /// ------------------------------------------------------------------------------------ private void StreamReaderThread_Output() { try { var reader = m_StdOut; while (true) { var logContents = reader.ReadLine(); if (logContents == null) { break; } // ensure only one thread writes to the log at any time lock (LockObject) { if (Verbose) { OutputWriter.WriteLine(logContents); } MemoryWriter.WriteLine(logContents); } } lock (LockObject) { OutputWriter.Flush(); MemoryWriter.Flush(); } } catch (Exception) { // just ignore any errors } }