static void Main(string[] args) { Model.Warehouse warehouse = new Model.Warehouse(); List <Item> warehouses = new List <Item>(); Item item = new Item() { Name = "Шампунь", Description = "Шампунь Head'n'Shoulders не шипит глаза", Price = 3000, WhenAdded = DateTime.Now }; ConsoleReporter consoleReporter = new ConsoleReporter(); Serializer serializer = new Serializer(); ConsoleKeyInfo key; while (true) { key = System.Console.ReadKey(true); if (key.Key == ConsoleKey.Enter) { warehouse.AddToWarehouse(warehouses, item); serializer.Serialize(warehouses); } consoleReporter.Report(); } }
static void _applet_Configure(object sender, EventArgs e) { bool quitApplet = false; ConsoleReporter.Report("Enter Config Mode...", ConsoleReporter.ReportStatus.Process, _logEnabled); _currentPageIndex = 2; _inConfigMode = true; AppStart_DBClient.Form1 configForm = new AppStart_DBClient.Form1(Constants.DB_FILEPATH); quitApplet = (configForm.ShowDialog() == System.Windows.Forms.DialogResult.Abort); ConsoleReporter.Report("Config completed!", ConsoleReporter.ReportStatus.Info, _logEnabled); if (quitApplet) { _mustExit = true; return; } InitDB(); InitSettings(); InitGraphics(_device); _currentPageIndex = 0; _inConfigMode = false; }
static void InitSettings() { ConsoleReporter.Report("Loading settings...", ConsoleReporter.ReportStatus.Process, _logEnabled); // Get Settings Preference PREF_4th_openConfigEnabled = _db.GetPreferenceByKey("4th_OpenConfigEnabled"); if (PREF_4th_openConfigEnabled != null) { if (PREF_4th_openConfigEnabled.Type == typeof(bool)) { _configButtonEnabled = (bool)PREF_4th_openConfigEnabled.Value; } else { _configButtonEnabled = false; } } else { _configButtonEnabled = false; } ConsoleReporter.Report(String.Format("4th_OpenConfigEnabled: (BOOL) {0}", _configButtonEnabled), ConsoleReporter.ReportStatus.Error, _logEnabled); ConsoleReporter.Report("Loading settings completed", ConsoleReporter.ReportStatus.Info, _logEnabled); }
public static async Task AnalyseCodeInDirectory(string directoryName) { Console.WriteLine($"DEBUG: {nameof(AnalyserService)}.{nameof(AnalyseCodeInDirectory)} begin"); if (string.IsNullOrWhiteSpace(directoryName)) { throw new ArgumentNullException(nameof(directoryName)); } var project = DirectoryParser.Parse(directoryName); var syntaxTrees = await Task.WhenAll(project.Documents.Select(d => d.GetSyntaxTreeAsync())); var compilationRoots = syntaxTrees.Select(t => t.GetCompilationUnitRoot()); List <AnalyserItem> analyserItems = new List <AnalyserItem>(); foreach (var analyser in Analysers) { Console.WriteLine($"DEBUG: Starting {analyser.GetType().Name}"); foreach (var compilationRoot in compilationRoots) { analyser.Visit(compilationRoot); } Console.WriteLine($"DEBUG: Finished {analyser.GetType().Name}"); analyserItems.AddRange((analyser as IAnalyser).AnalyserItems); } await ConsoleReporter.Report(analyserItems); Console.WriteLine($"DEBUG: {nameof(AnalyserService)}.{nameof(AnalyseCodeInDirectory)} end"); }
static void InitGraphics(LcdDevice device) { ConsoleReporter.Report("Initializing Graphics...", ConsoleReporter.ReportStatus.Process, _logEnabled); pageList = new List <LcdGdiPage>(); Draw(device); device.CurrentPage = pageList[0]; device.SetAsForegroundApplet = true; ConsoleReporter.Report("Initializing Graphics done", ConsoleReporter.ReportStatus.Info, _logEnabled); }
static void Main(string[] args) { var cmdArgsRetriever = new CommandLineArgumentsRetriever(); var sourcePath = cmdArgsRetriever.GetSourcePath(args); //sourcePath = "https://jsonblob.com/api/80a3e281-c4fb-11e9-9e37-89e98d519613"; var factory = new StockQuoteRetrieverFactory(); var retriever = factory.GetTradeRetriever(sourcePath); var trades = retriever.GetStockQuotes(sourcePath).ToList(); var analyzer = new StockQuoteAnalyzer(); analyzer.PivotDownsideFoundEvent += PivotDownsideFoundEventHandler; analyzer.PivotUpsideFoundEvent += PivotUpsideFoundEventHandler; var reversals = analyzer.LocateReversal(trades).AsParallel(); var reporter = new ConsoleReporter(); reporter.Report(reversals); //var timeAnalyzer = new TimeAnalyzer(); //var elapsed = timeAnalyzer.Measure(() => PrimeNumberAnalyzer.FindLargePrimesInParallel(900000, 910000)); //Console.WriteLine(elapsed.TotalMilliseconds); //var date = new List<DateTime>(); //var open = new List<decimal>(); //var high = new List<decimal>(); //var low = new List<decimal>(); //var close = new List<decimal>(); //var provider = CultureInfo.InvariantCulture; //var lines = File.ReadAllLines(args[0]); //for (int i = 1; i < lines.Length; i++) //{ // var data = lines[i].Split(','); // date.Add(DateTime.Parse(data[0], CultureInfo.InvariantCulture)); // open.Add(decimal.Parse(data[1])); // high.Add(decimal.Parse(data[2])); // low.Add(decimal.Parse(data[3])); // close.Add(decimal.Parse(data[4])); //} //for (int i = 0; i < date.Count - 4; i++) //{ // if (open[i] > high[i + 1] && close[i] < low[i + 1]) // { // Console.ForegroundColor = ConsoleColor.Red; // Console.WriteLine("Pivot downside {0}", date[i].ToShortDateString()); // } // if (open[i] < low[i + 1] && close[i] > high[i + 1]) // { // Console.ForegroundColor = ConsoleColor.Green; // Console.WriteLine("Pivot upside {0}", date[i].ToShortDateString()); // } //} }
static void Draw(LcdDevice device) { sview = new DrawPages.ScrollView(appList, _configButtonEnabled); msgBox = new DrawPages.MessageBox_YesNo("QUIT?", "Would you like to quit\nG15 AppStart?"); pageList.Add(sview.GetPage(device)); pageList.Add(msgBox.GetPage(device)); pageList.Add(DrawPages.ConfigScreen.GetPage(device)); AssignUpdateToAllPages(); ConsoleReporter.Report("Drawn", ConsoleReporter.ReportStatus.None, _logEnabled); }
static void Main(string[] args) { if (args.Length >= 1) { _logEnabled = (args[0] == "-debug"); ConsoleReporter.Report(String.Format("Log {0}", (_logEnabled) ? "enabled" : "disabled"), ConsoleReporter.ReportStatus.Info, _logEnabled); } Console.WriteLine("{0}\nVersion {1}\n{2}\n", Constants.APP_NAME.ToUpper(), Constants.APP_VERSION, Constants.APP_COPYRIGHT); InitDB(); InitApp(); InitSettings(); _device = null; _waitAre.WaitOne(); ConsoleReporter.Report("WaitOne done", ConsoleReporter.ReportStatus.None, _logEnabled); do { if (_monoArrived) { ConsoleReporter.Report("Mono Device arrived", ConsoleReporter.ReportStatus.Info, _logEnabled); if (_device == null) { _device = (LcdDeviceMonochrome)_applet.OpenDeviceByType(LcdDeviceType.Monochrome); _device.SoftButtonsChanged += _device_SoftButtonsChanged; InitGraphics(_device); } else { _device.ReOpen(); } _monoArrived = false; } if (_applet.IsEnabled && _device != null && !_device.IsDisposed) { _device.DoUpdateAndDraw(); } } while (!_mustExit); if (_applet.IsEnabled && _device != null && !_device.IsDisposed) { _device.DoUpdateAndDraw(); } ConsoleReporter.Report("Applet done! Quitting...", ConsoleReporter.ReportStatus.Process, _logEnabled); Thread.Sleep(10); }
static void InitApp() { ConsoleReporter.Report("Initializing applet...", ConsoleReporter.ReportStatus.Process, _logEnabled); _applet = new LcdApplet(Constants.APP_NAME, LcdAppletCapabilities.Monochrome); _applet.Configure += _applet_Configure; _applet.DeviceArrival += _applet_DeviceArrival; _applet.DeviceRemoval += _applet_DeviceRemoval; _applet.IsEnabledChanged += _applet_IsEnabledChanged; ConsoleReporter.Report("Applet initialized", ConsoleReporter.ReportStatus.Info, _logEnabled); ConsoleReporter.Report("Connecting applet...", ConsoleReporter.ReportStatus.Process, _logEnabled); _applet.Connect(); ConsoleReporter.Report("Connection completed", ConsoleReporter.ReportStatus.Info, _logEnabled); }
public void Can_run_with_known_counters() { var counter = _fixture.Metrics.Counter(typeof(CounterTests), "Can_run_with_known_counters_counter"); counter.Increment(100); var queue = new Queue <int>(); _fixture.Metrics.Gauge(typeof(GaugeTests), "Can_run_with_known_counters_gauge", () => queue.Count); queue.Enqueue(1); queue.Enqueue(2); var registry = new InMemoryMetricsRegistry(); var reporter = new ConsoleReporter(registry, Microsoft.Extensions.Options.Options.Create(new ConsoleReporterOptions())); reporter.Report(); }
public void ConsoleReporter_ShouldFormatOutputCorrectly(int x, int y, Orientation orientation, string expected) { //Arrange var position = new Position(x, y); //Change the output of the Console so we can analyse the result of Console.WriteLine var consoleOutput = new StringWriter(); Console.SetOut(consoleOutput); IReporter reporter = new ConsoleReporter(); //Act reporter.Report(position, orientation); //Assert Assert.Equal(expected + Environment.NewLine, consoleOutput.ToString()); }
static void InitDB() { ConsoleReporter.Report("Checking availability of database...", ConsoleReporter.ReportStatus.Process, _logEnabled); ConsoleReporter.Report(String.Format("File exists: {0}", File.Exists("apps.db")), ConsoleReporter.ReportStatus.DataReport, _logEnabled); // Init ConsoleReporter.Report("Initializing database...", ConsoleReporter.ReportStatus.Process, _logEnabled); _db = new Database(Constants.DB_FILEPATH); try { _db.InitializeDatabase(); } catch (FileAlreadyExistsException ex) { ConsoleReporter.Report("File does already exists, continue initialisation...", ConsoleReporter.ReportStatus.Error, _logEnabled); } catch (Exception ex) { ConsoleReporter.Report("An error occured!", ConsoleReporter.ReportStatus.Error, _logEnabled); ConsoleReporter.Report(ex.Message); } ConsoleReporter.Report(String.Format("Init of '{0}' completed", _db.FileName), ConsoleReporter.ReportStatus.Info, _logEnabled); ConsoleReporter.Report("Loading apps...", ConsoleReporter.ReportStatus.Process, _logEnabled); // Load Data Exception getData = _db.GetAllApplications(Database.OrderBy.AppName); if (typeof(AppListRecieved) != getData.GetType()) { ConsoleReporter.Report(getData.Message, ConsoleReporter.ReportStatus.Error, _logEnabled); return; } else { ConsoleReporter.Report("Data recieved", ConsoleReporter.ReportStatus.Info, _logEnabled); } appList = ((AppListRecieved)getData).RecievedData; ConsoleReporter.Report(String.Format("{0} app(s) loaded", appList.Count), ConsoleReporter.ReportStatus.Info, _logEnabled); }
private static void Report(IReadOnlyCollection<PackageUpdateSet> updates) { var reporter = new ConsoleReporter(); reporter.Report("ConsoleReport", updates); }
static void _device_SoftButtonsChanged(object sender, LcdSoftButtonsEventArgs e) { if (_inConfigMode) { return; } if ((e.SoftButtons & LcdSoftButtons.Button0) == LcdSoftButtons.Button0) { ConsoleReporter.Report("BUTTON_0 pressed", ConsoleReporter.ReportStatus.Error, _logEnabled); if (_exitQuestion) { _mustExit = true; return; } sview.MoveSelectorUp(); } if ((e.SoftButtons & LcdSoftButtons.Button1) == LcdSoftButtons.Button1) { ConsoleReporter.Report("BUTTON_1 pressed", ConsoleReporter.ReportStatus.Error, _logEnabled); if (_exitQuestion) { return; } sview.MoveSelectorDown(); } if ((e.SoftButtons & LcdSoftButtons.Button2) == LcdSoftButtons.Button2) { ConsoleReporter.Report("BUTTON_2 pressed", ConsoleReporter.ReportStatus.Error, _logEnabled); if (_exitQuestion) { return; } sview.ExecuteSelected(); } if ((e.SoftButtons & LcdSoftButtons.Button3) == LcdSoftButtons.Button3) { ConsoleReporter.Report("BUTTON_3 pressed", ConsoleReporter.ReportStatus.Error, _logEnabled); if (sview.ConfigButtonsEnabled) { ConsoleReporter.Report("Config pressed", ConsoleReporter.ReportStatus.None, _logEnabled); _applet_Configure(null, null); return; } if (_exitQuestion) { _currentPageIndex = 0; _exitQuestion = false; ConsoleReporter.Report("_EXITQUESTION disabled", ConsoleReporter.ReportStatus.None, _logEnabled); return; } else { _currentPageIndex = 1; _exitQuestion = true; ConsoleReporter.Report("_EXITQUESTION enabled", ConsoleReporter.ReportStatus.None, _logEnabled); return; } } }
static void _applet_IsEnabledChanged(object sender, EventArgs e) { ConsoleReporter.Report("Applet got " + ((_applet.IsEnabled) ? "enabled" : "disabled"), ConsoleReporter.ReportStatus.Warning, _logEnabled); }
static void _applet_DeviceRemoval(object sender, LcdDeviceTypeEventArgs e) { ConsoleReporter.Report("Device disconnected!", ConsoleReporter.ReportStatus.Warning, _logEnabled); }