private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) { ProcessOutputData?.Invoke(this, new ProcessOutputEventArgs() { Message = e.Data }); }
public HttpResponseMessage GetResourceFile(string type) { if (String.IsNullOrEmpty(type)) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } type = type.ToUpper(); string destFilePath = String.Empty; switch (type) { case "SOURCE": destFilePath = GlobalValues.PATH_SOURCE_FILE; break; case "VOTING_STATUS": destFilePath = ProcessOutputData.ExportVotingStatus(); break; case "FINAL_RESULTS": destFilePath = ProcessOutputData.ExportFinalResults(); break; default: return(Request.CreateResponse(HttpStatusCode.BadRequest)); } if (!File.Exists(destFilePath)) { return(Request.CreateResponse(HttpStatusCode.NoContent)); } byte[] dataBytes = File.ReadAllBytes(destFilePath); //adding bytes to memory stream MemoryStream dataStream = new MemoryStream(dataBytes); HttpResponseMessage httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK); httpResponseMessage.Content = new StreamContent(dataStream); httpResponseMessage.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); httpResponseMessage.Content.Headers.ContentDisposition.FileName = Path.GetFileName(destFilePath); httpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); return(httpResponseMessage); }