static private void StartUploadFileDemo(ApiClient ApiClient) { var shouldStartDemo = ConsoleInteractions.AskWithBoolResponse("Start UDC File Uploading Demo? (type 'yes' / 'no')"); if (!shouldStartDemo) { return; } var shouldDoAgain = true; while (shouldDoAgain) { var filePath = ConsoleInteractions.AskFilePath("Please type path to file! (Type empty to exit)"); var schemeName = ConsoleInteractions.AskWithStringResponse("Please type Scheme Name"); try { var result = ApiClient.UserDefinedCollections.BulkUploadFile(schemeName, filePath); System.Console.WriteLine($"File was uploaded! Total Number of Rows - {result.Total}, Failed - {result.TotalFailed}"); } catch (Exception e) { System.Console.WriteLine("Looks like something goes wrong. Error Message - " + (e.Message ?? "No Message")); } shouldDoAgain = ConsoleInteractions.AskWithBoolResponse("Should do file upload again? (type 'yes' / 'no')"); } }
private static void DecideLogging() { Func <string, string> __decideLogging = (dirChecking) => { string mutingVar = null; if (Directory.Exists(dirChecking) && ConsoleInteractions.Ask(string.Format("Directory \"{0}\" found in {1} - do you want to use it", dirChecking, WORK_ABS_DIR), Console.In, Console.Out)) { mutingVar = dirChecking; } if (mutingVar == null) { mutingVar = ConsoleInteractions.RequireChild(WORK_ABS_DIR, "Logs directory", ConsoleTextMessages.DirectoryNotFound, dirChecking, Console.In, Console.Out); Directory.CreateDirectory(WORK_ABS_DIR_SEPARATED + mutingVar); } return(mutingVar); }; if (ConsoleInteractions.Ask("Enable any kinds of logging", Console.In, Console.Out)) { Console.WriteLine(); if (USER_DIR_LOGS == null && ConsoleInteractions.Ask("Store any kinds of log files in separate directory in " + WORK_ABS_DIR, Console.In, Console.Out)) { USER_DIR_LOGS = __decideLogging(DEFAULT_DIR_LOGS); USER_ABS_DIR_LOGS = WORK_ABS_DIR_SEPARATED + USER_DIR_LOGS; Console.WriteLine(); } if (USER_DIR_CONSOLE_LOGS == null && ConsoleInteractions.Ask("Enable console logging", Console.In, Console.Out)) { USER_DIR_CONSOLE_LOGS = __decideLogging(Path.Combine(USER_DIR_LOGS, DEFAULT_DIR_CONSOLE_LOGS)); USER_ABS_DIR_CONSOLE_LOGS = WORK_ABS_DIR_SEPARATED + USER_DIR_CONSOLE_LOGS; Console.WriteLine(); } if (USER_DIR_SOLUTION_LOGS == null && ConsoleInteractions.Ask("Enable solution logging", Console.In, Console.Out)) { USER_DIR_SOLUTION_LOGS = __decideLogging(Path.Combine(USER_DIR_LOGS, DEFAULT_DIR_SOLUTION_LOGS)); USER_ABS_DIR_SOLUTION_LOGS = WORK_ABS_DIR_SEPARATED + USER_DIR_SOLUTION_LOGS; Console.WriteLine(); } } }
public override uint MakeInitialBet() { uint result = ConsoleInteractions.MakeInitialBet(Money); checked { Money -= result; } return(result); }
static public void StartDemo(ApiClient ApiClient) { var shouldStartDemo = ConsoleInteractions.AskWithBoolResponse("Enter 'yes' to start UDC Demo or 'no' to skip it.\nPlease note, that this requires additional addons to be installed!"); if (!shouldStartDemo) { return; } StartUploadFileDemo(ApiClient); }
private static void Main() { Console.Title = Assembly.GetExecutingAssembly().GetName().Name; Console.CursorVisible = true; Console.WriteLine(ConsoleTextBlocks.ShowWelcome("Welcome to Sudoku Solver!")); Console.WriteLine(); GetAvailableSudokuGrids(); Console.WriteLine(); while (true) { SudokuGrid grid; using (var selectedFile = ConsoleInteractions.ShowListAndSelectItem(USER_ABS_DIR_AVAILABLE_GRIDS, SudokuGridFile.Extension, Console.In, Console.Out)) { grid = SudokuGrid.FromBinary(selectedFile); } Console.WriteLine(); var solvingTask = new Task <bool>(() => { var gridSolver = new SudokuSolvingIterationAssumptionTechnique(grid); gridSolver.Solve(); gridSolver.ApplySolutionToGrid(); return(gridSolver.SolutionExists); }); var dottingTaskCTS = new CancellationTokenSource(); var dottingTask = new Task(() => ConsoleTextBlocks.ShowBlinkingDots(dottingTaskCTS.Token, Console.Out)); var outputTask = new Task(() => ShowSolution(grid)); var escapeTask = new Task <bool>(ConsoleInteractions.ShowEscapeQuestion); var checkingCorrectnessTask = new Task <bool>(grid.CheckCorrectness); checkingCorrectnessTask.ContinueWith((fin) => { if (fin.Result) { solvingTask.Start(); } else { Console.WriteLine(ConsoleTextMessages.IncorrectInitialConfiguration + "\n"); escapeTask.Start(); } }, TaskContinuationOptions.OnlyOnRanToCompletion); solvingTask.ContinueWith((fin) => dottingTaskCTS.Cancel(), TaskContinuationOptions.OnlyOnRanToCompletion); dottingTask.ContinueWith((fin) => { if (solvingTask.Result) { outputTask.Start(); } else { Console.WriteLine(ConsoleTextMessages.IncorrectInitialConfiguration + "\n"); escapeTask.Start(); } }, TaskContinuationOptions.OnlyOnRanToCompletion); outputTask.ContinueWith((fin) => escapeTask.Start(), TaskContinuationOptions.OnlyOnRanToCompletion); dottingTask.Start(); checkingCorrectnessTask.Start(); escapeTask.Wait(); if (escapeTask.Result) { break; } } }
public override Action ChooseAction(Dealer dealer, Hand hand) => ConsoleInteractions.ChooseAction(GetPossibleActions(hand));
private static void Main() { Console.Title = Assembly.GetExecutingAssembly().GetName().Name; Console.CursorVisible = true; Console.WriteLine(ConsoleTextBlocks.ShowWelcome("Welcome to Sudoku Grid Files Converter!")); Console.WriteLine(); string dir = ConsoleInteractions.RequireChild(WORK_ABS_DIR, "Sources directory", ConsoleTextMessages.DirectoryNotFound, null, Console.In, Console.Out); SOURCES_ABS_DIR = WORK_ABS_DIR + dir + Path.DirectorySeparatorChar; OUTPUT_ABS_DIR = SOURCES_ABS_DIR; Console.WriteLine("\n" + ConsoleTextBlocks.ShowCharsToLineEnd(Console.CursorLeft)); while (true) { string[] modes = Enum.GetNames(typeof(SudokuConvertionMode)); FileStream selectedFile; string outputFilePath; var selectedMode = (SudokuConvertionMode)ConsoleInteractions.AskMultiple(modes, Console.In, Console.Out); Console.WriteLine("\n"); switch (selectedMode) { case SudokuConvertionMode.Encoding: selectedFile = ConsoleInteractions.ShowListAndSelectItem(SOURCES_ABS_DIR, SOURCE_EXT, Console.In, Console.Out); outputFilePath = OUTPUT_ABS_DIR + Path.GetFileNameWithoutExtension(OUTPUT_ABS_DIR + selectedFile.Name) + "." + CONVERTED_EXT; using (SudokuGridFile.CreateBinaryFromText(selectedFile, outputFilePath, SudokuConvertionAlgorithm.NonUniform)) { selectedFile.Dispose(); } break; case SudokuConvertionMode.Decoding: selectedFile = ConsoleInteractions.ShowListAndSelectItem(SOURCES_ABS_DIR, CONVERTED_EXT, Console.In, Console.Out); outputFilePath = OUTPUT_ABS_DIR + Path.GetFileNameWithoutExtension(OUTPUT_ABS_DIR + selectedFile.Name) + "." + SOURCE_EXT; using (SudokuGridFile.CreateTextFromBinary(selectedFile, outputFilePath)) { selectedFile.Dispose(); } break; } Console.WriteLine(ConsoleTextBlocks.ShowCharsToLineEnd(Console.CursorLeft)); Console.WriteLine(); Console.WriteLine("Finished!"); if (ConsoleInteractions.ShowEscapeQuestion()) { break; } } }