public ActionResult Index() { var startTime = DateTime.Now; var portNumber = ConfigurationManager.AppSettings["LogViewerPort"]; var duration = ConfigurationManager.AppSettings["LogViewerDuration"]; #region Get parameters if (string.IsNullOrEmpty(portNumber)) { portNumber = "878"; } if (!int.TryParse(portNumber, out var port)) { port = 878; } if (string.IsNullOrEmpty(duration)) { duration = "120"; } if (!int.TryParse(duration, out var durationValue)) { durationValue = 120; } var durationTimeSpan = TimeSpan.FromSeconds(durationValue); #endregion var processor = new Html5WebConsole(Response) { Title = $"Live Log Viewer (Port {port}) during " + ToReadableString(durationTimeSpan) }; processor.Render(progress => { var s = new UDPSocket(); s.Server("127.0.0.1", 878, progress); while (startTime.Add(durationTimeSpan) > DateTime.Now) { } progress.ReportStatus("Paused."); progress.ReportStatus("Refresh to resume live tail."); // Reset socket to stop sending messages. s.Stop(); }); return(Content("")); }
public ActionResult Demo() { var processor = new Html5WebConsole(Response); processor.Title = "MVC Demo"; processor.Render(progress => { progress.ReportStatus("WebConsole MVC Demo starting..."); for (int i = 0; i <= 100; i++) { // slight delay to see loading time System.Threading.Thread.Sleep(50); // advance the progress bar status (you can use x % as well as x of y total items) progress.Report(i); // demonstrate setting a substatus of the progress bar (e.g. "making database backup") if (i % 10 == 0) progress.ReportTransientStatus(string.Format("{0}/{1}", i, 100)); // write some stuff to the console to demonstrate detailed output progress.ReportStatus("At {0}", MessageType.Info, i); if (i == 90) progress.ReportStatus("Oops, fake error", MessageType.Error); if (i == 91) progress.ReportStatus("Warning: this can be harmful if misused.", MessageType.Warning); if (i == 92) { progress.ReportStatus("You can also {0} {1}", MessageType.Debug, "use", "string formatting"); } if (i == 95) { progress.ReportStatus("I'm about to throw an exception and write its data to the console!"); // code that can throw an exception should have it caught and written to the console // normally you might wrap the whole processing in a try-catch block try { throw new BadJokeException("I'm giving it all she's got Jim!", new Exception("Warp core breach")); } catch (Exception ex) { progress.ReportException(ex); } } } progress.ReportStatus("Completed MVC demo."); }); return Content(""); }
public ActionResult ScalingDemo() { var processor = new Html5WebConsole(Response); processor.Title = "MVC Scaling Demo"; // drops multithreaded 70,000 entries into the console :) int scale = 70000; processor.Render(progress => { progress.ReportStatus("WebConsole MVC Scaling Demo starting..."); Enumerable.Range(0, scale).AsParallel().ForAll(i => { Thread.Sleep(1); progress.ReportStatus($"LOL {i}"); progress.Report((int)(((double)i / scale) * 100)); }); }); return(Content("")); }
public ActionResult Demo() { var processor = new Html5WebConsole(Response); processor.Title = "MVC Demo"; processor.Render(progress => { progress.ReportStatus("WebConsole MVC Demo starting..."); for (int i = 0; i <= 100; i++) { // slight delay to see loading time System.Threading.Thread.Sleep(50); // advance the progress bar status (you can use x % as well as x of y total items) progress.Report(i); // demonstrate setting a substatus of the progress bar (e.g. "making database backup") if (i % 10 == 0) { progress.ReportTransientStatus($"{i}/{100}"); } // write some stuff to the console to demonstrate detailed output progress.ReportStatus("At {0}", MessageType.Info, i); if (i == 90) { progress.ReportStatus("Oops, fake error", MessageType.Error); } if (i == 91) { progress.ReportStatus("Warning: this can be harmful if misused.", MessageType.Warning); } if (i == 92) { progress.ReportStatus("You can also {0} {1}", MessageType.Debug, "use", "string formatting"); } if (i == 95) { progress.ReportStatus("I'm about to throw an exception and write its data to the console!"); // code that can throw an exception should have it caught and written to the console // normally you might wrap the whole processing in a try-catch block try { throw new BadJokeException("I'm giving it all she's got Jim!", new Exception("Warp core breach")); } catch (Exception ex) { progress.ReportException(ex); } } } progress.ReportStatus("Completed MVC demo."); }); return(Content("")); }