static void Main(string[] args) { ConsoleAppHelper.PrintHeader("Header.txt"); var bus = Bus.Factory.CreateUsingRabbitMq(sbc => { var host = sbc.Host(new Uri(RabbitMqAddress), h => { h.Username(RabbitUsername); h.Password(RabbitPassword); }); sbc.ReceiveEndpoint(host, "FormatScript", ep => { //ep.Bind(exchangeName); ep.Consumer(() => new FormatScriptConsumer()); }); }); bus.Start(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); bus.Stop(); }
static void Main(string[] args) { Console.SetWindowSize(80, 20); ConsoleAppHelper.PrintHeader("Header.txt"); RunMassTransitReceiverWithRabbit(); }
/// <summary> /// This is the main entry point for the SHRD host service. /// </summary> /// <param name="args"></param> public static void Run(string[] args) { string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; Globals.InitializeProgram(exePath, "Self Hosted Remote Desktop", true); PrivateAccessor.SetStaticFieldValue(typeof(Globals), "errorFilePath", Globals.WritableDirectoryBase + "SHRD_Log.txt"); FileInfo fiExe = new FileInfo(exePath); Environment.CurrentDirectory = fiExe.Directory.FullName; System.Windows.Forms.Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //byte[] buf = new byte[4]; //ByteUtil.WriteFloat(5, buf, 0); //float f = ByteUtil.ReadFloat(buf, 0); //Logger.Info(f.ToString()); if (Environment.UserInteractive) { bool cmd = args.Length > 0 && args[0] == "cmd"; if (cmd || Debugger.IsAttached) { ConsoleAppHelper.AllocateConsole(); Logger.logType = LoggingMode.Console | LoggingMode.File; Logger.Info("Console environment detected. Logging to console is enabled."); ServiceWrapper.Initialize(); ServiceWrapper.Start(); do { Console.WriteLine("Type \"exit\" to close"); }while (Console.ReadLine().ToLower() != "exit"); ServiceWrapper.Stop(); return; } else { Logger.logType = LoggingMode.File; } string Title = "SelfHostedRemoteDesktop " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager"; string ServiceName = "SelfHostedRemoteDesktop"; ButtonDefinition btnStartCmdTest = new ButtonDefinition("Test w/console", btnStartCmdTest_Click); ButtonDefinition[] customButtons = new ButtonDefinition[] { btnStartCmdTest }; System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, customButtons)); } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new SelfHostedRemoteDesktopSvc() }; ServiceBase.Run(ServicesToRun); } }
static void Main(string[] args) { string exchangeName = "Formatting"; string queueName = "FormatScript"; ConsoleAppHelper.PrintHeader("Header.txt"); var bus = Bus.Factory.CreateUsingRabbitMq(sbc => { var host = sbc.Host(new Uri("rabbitmq://localhost"), h => { h.Username("guest"); h.Password("guest"); }); sbc.ReceiveEndpoint(host, queueName, ep => { //ep.Bind(exchangeName); ep.Consumer(() => new FormatScriptConsumer()); }); }); bus.Start(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); bus.Stop(); }
public void _標準入力からの取得をシミュレーション_入力補完あり2(string inPartial, string inExpected) { var dic = ConsoleAppHelper.ListCommands(); var buf = new FakeConsoleReadBuffer(dic, inPartial) { Prompt = "> ", }; Assert.That(buf.InCompleting, Is.False); buf.ReadToEnd(); Assert.That(buf.Current, Is.EqualTo(inPartial)); Assert.That(buf.InCompleting, Is.False); Assert.That(buf.ReadExtraTab(), Is.EqualTo(inExpected.Last())); Assert.That(buf.Current, Is.EqualTo(inExpected)); Assert.That(buf.InCompleting, Is.True); Assert.That(buf.ReadExtraTab(), Is.EqualTo(inExpected.Last())); Assert.That(buf.Current, Is.EqualTo(inExpected)); Assert.That(buf.InCompleting, Is.True); Assert.That(buf.ReadExtraNewLine(), Is.EqualTo('\n')); Assert.That(buf.Current, Is.Null.Or.Empty); Assert.That(buf.History.Any(), Is.True); Assert.That(buf.History.Last(), Is.EqualTo(inExpected)); }
public Task Consume(ConsumeContext <SchemaChanged> context) { ConsoleAppHelper.PrintHeader("Header.txt"); Console.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")); var sensitiveColumnNames = new List <string> { "firstname", "name", "address", "email" }; var atRiskColumns = new List <Column>(); var schema = context.Message.Database; foreach (var table in schema.Tables) { foreach (var tableColumn in table.Columns) { if (sensitiveColumnNames.Contains(tableColumn.Name, StringComparer.OrdinalIgnoreCase)) { atRiskColumns.Add(tableColumn); Console.WriteLine($"Sensitive column name found : {table.Name} - {tableColumn.Name}"); } } } return(Task.CompletedTask); }
static void Main(string[] args) { Console.SetWindowSize(50, 30); ConsoleAppHelper.PrintHeader("Header.txt"); var _rabbitBusControl = Bus.Factory.CreateUsingRabbitMq(sbc => { var host = sbc.Host(new Uri(RabbitMqAddress), h => { h.Username(RabbitUsername); h.Password(RabbitPassword); }); sbc.ReceiveEndpoint(host, "Heartbeat", ep => { ep.Consumer(() => new HeartbeatConsumer()); }); }); _rabbitBusControl.Start(); Timer timer = new Timer(2000); timer.Elapsed += TimerTick; timer.Start(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); timer.Stop(); _rabbitBusControl.Stop(); }
static void Main(string[] args) { //string exchangeName = "_DatabaseRegistry"; Console.SetWindowSize(80, 20); ConsoleAppHelper.PrintHeader("Header.txt"); var bus = Bus.Factory.CreateUsingRabbitMq(sbc => { var host = sbc.Host(new Uri(RabbitMqAddress), h => { h.Username(RabbitUsername); h.Password(RabbitPassword); }); sbc.ReceiveEndpoint(host, "DatabaseRegistered", ep => { // ep.Bind(exchangeName); ep.Consumer(() => new DatabaseRegisteredConsumer()); }); sbc.ReceiveEndpoint(host, "SchemaChanged", ep => { // ep.Bind(exchangeName); ep.Consumer <SchemaUpdateConsumer>(); }); }); bus.Start(); }
public void _ヘルプ表示依頼を処理する_コマンド指定() { var repo = new Ninject.StandardKernel() .BindPurchaseContext() .BindRunnerRepository() .Get <IRunnerRepository>() ; var result = new HelpParseResult { Command = "ins" }; var content = ConsoleAppHelper.ListHelpContents() .Where(c => c.Command == result.Command).FirstOrDefault(); var it = (new string[] { content.Usage, content.Description }).GetEnumerator(); var runner = repo.FindRunner(result, (message) => { Assert.That(it.MoveNext(), Is.True); Assert.That(message, Is.Not.Null.And.Not.Empty); Assert.That(message, Is.EqualTo(it.Current)); }); runner(); Assert.That(it.MoveNext(), Is.False); }
// public FormatScriptConsumer() // { // bus = Bus.Factory.CreateUsingRabbitMq(sbc => // { // var host = sbc.Host(new Uri("rabbitmq://localhost"), h => // { // h.Username("guest"); // h.Password("guest"); // }); // // }); // // bus.Start(); // } public Task Consume(ConsumeContext <FormatScript> context) { ConsoleAppHelper.PrintHeader("Header.txt"); var script = context.Message.Script; Console.WriteLine(script); Console.WriteLine(""); Console.WriteLine("--FORMATTING--"); Console.WriteLine(""); var formattedSql = NSQLFormatter.Formatter.Format(script); Console.WriteLine(formattedSql); var message = new ScriptFormattedMessage { FormattedScript = formattedSql }; bus.Publish <ScriptFormatted>(message); Console.WriteLine($"Formatted script complete"); return(Task.CompletedTask); }
public static IKernel BindRunnerRepository(this IKernel inSelf) { var help = ConsoleAppHelper.ListHelpContents(); inSelf.Bind <IRunnerRepository>().ToMethod(ctx => new CommandRunnerRepository(help)); return(inSelf); }
static void UnsafeMain(string[] args) { LoggingHelper.ChangeFilenamePostfix("executor"); string cwd = AppDomain.CurrentDomain.BaseDirectory; Directory.SetCurrentDirectory(cwd ?? "."); logger.Info("Current directory is {0}", cwd); // log4net - We are using NLog, so we should adapt the following. //XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); if (!IsReleaseVersion && System.Environment.UserInteractive) { ConsoleAppHelper.CatchSpecialConsoleEvents(); } // Disable parser case-sensitivity to allow convertion from string to PlanType - Supported only in CommandLine > 2.0 //CommandLine.Parser.Default.Settings.CaseSensitive = false; if (!CommandLine.Parser.Default.ParseArguments(args, Options)) { return; } PlanExecutor executor = null; try { LoadSettings(); executor = new PlanExecutor(); executor.Run(); LetMeDebugThisBeforeExiting(); } catch (Exception ex) { if (Options.Verbose) { logger.Log(LogLevel.Fatal, ex, "Oops! An unexpected problem happened"); } else { logger.Fatal("Oops! An unexpected problem happened: {0}", ex.Message); } LetMeDebugThisBeforeExiting(); Environment.Exit(1); } if (!IsReleaseVersion && System.Environment.UserInteractive) { // Set this to terminate immediately (if not set, the OS will eventually kill the process) ConsoleAppHelper.TerminationCompletedEvent.Set(); } }
public void Stop() { if (!this.Connection.IsAuthenticated) { return; } this.Connection.Close(); ConsoleAppHelper.WaitDisconnectingTo(this.Connection); }
public static void Main(string[] args) { while (true) { Console.Write(Strings.CmdIndicator); args = ConsoleAppHelper.StringToArgs(Console.ReadLine()); bool verbosity = false; var shouldShowHelp = false; var names = new List <string>(); var options = new OptionSet(); options.Add(new OptionSet.Argument <List <string> >("name", "the name of someone to greet.") { Action = (n) => { if (n != null) { names.AddRange(n); } } }); options.Add(new OptionSet.Argument <bool>('v', "show verbose") { Action = (v) => { verbosity = v; } }); options.Add(new OptionSet.Argument <bool>("help", "show help") { Action = (h) => { shouldShowHelp = h; } }); options.Parse(args); if (!options.ArgumentsInvalid.Any()) { Console.WriteLine("verbosity: " + verbosity); Console.WriteLine("shouldShowHelp: " + shouldShowHelp); Console.WriteLine("names.Count: " + names.Count); } else { Console.WriteLine("error"); } } }
private void TestArgsMappedAuto(IEnumerable <ArgumentMap> maps, string input, bool enablePositionedArgs, string testMethodName) { string testContext = null; var args = ConsoleAppHelper.CommandLineToArgs(input); var argsRaw = CommandParserUtils.ParseArgumentsRaw(args); var argsMappeds = CommandParserUtils.GetArgumentsParsed(argsRaw, enablePositionedArgs, maps.ToArray()); var objectTest = new { input, maps, argsMappeds }; var jsonSerializeConfig = TestHelper.GetJsonConfig(); Assert.True(TestHelper.CompareObjects <TestArgumentMapped>(objectTest, testContext, testMethodName, jsonSerializeConfig)); }
static void Monitor(Object obj, ElapsedEventArgs e) { Console.Clear(); ConsoleAppHelper.PrintHeader("Header.txt"); Console.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")); var storeLocation = $@"C:\dev\Stores\monitor\"; var servers = RetrieveRegisteredServers(storeLocation); AnalyseServers(servers); }
private static string[] GetArguments(App app) { if (Development.IsAttached) { var args = app.Console.Read(Strings.CmdIndicator); return(ConsoleAppHelper.StringToArgs(args)); } var listArgs = Environment.GetCommandLineArgs().ToList(); // remove the app path that added auto by .net listArgs.RemoveAt(0); return(listArgs.ToArray()); }
public Task Consume(ConsumeContext <DatabaseRegistered> context) { ConsoleAppHelper.PrintHeader("Header.txt"); var schema = context.Message.Schema; foreach (var table in schema.Tables) { Console.WriteLine(table.Name); } StorageHelper.StoreDatabaseDefinition(context.Message.Database, schema.Tables, "Dashboard"); return(Task.CompletedTask); }
public static string[] ListExpectedHelpContents() { var len = ConsoleAppHelper.ListHelpContents() .Where(c => !c.Ignored) .Max(c => c.Command.Length) + 2 ; return(new string[] { // "buy", "eject".PadRight(len) + "To eject inserted money is requested.", "help".PadRight(len) + "This message(s) is displayed.", "ins".PadRight(len) + "To insert money is requested.", "show amount".PadRight(len) + "To display the total amount of money inserted is requested.", "show item".PadRight(len) + "To display the layouted items is requested, where blank is unselectable, '*' is selectable, and '-' is soldout.", }); }
static void Main(string[] args) { Console.SetWindowSize(80, 20); ConsoleAppHelper.PrintHeader("Header.txt"); var baseAddress = "http://localhost:9111/api/registry/"; using (WebApp.Start <Startup>(url: baseAddress)) { HttpClient client = new HttpClient(); Console.WriteLine(string.Empty); Console.WriteLine($"The api is live on {baseAddress}"); Console.ReadLine(); } }
public void StartSellingItem() { var id = TestHelper.ToJId( string.Format(ItemIdAsLogin, this.ItemId) ); this.Connection.User = id.User; this.Connection.Server = id.Server; this.Connection.Resource = id.Resource; this.Connection.Password = AuctionPassword; mQueue.AssignEvents(this.Connection); this.Connection.Connect(); ConsoleAppHelper.WaitConnectingTo(this.Connection); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { if (Environment.UserInteractive) { ConsoleAppHelper.AllocateConsole(); Console.WriteLine("Master Server - Self Hosted Remote Desktop"); Console.WriteLine("User-interactive environment detected. Running as a console application."); try { ServiceWrapper.Initialize(); ServiceWrapper.Start(); Console.WriteLine("Type \"exit\" to close or \"web\" to open local web server."); string line; do { line = Console.ReadLine().ToLower(); if (line == "web") { Console.WriteLine("Launching http://127.0.0.1:8088/login"); Process.Start("http://127.0.0.1:8088/login"); } else if (line == "dev") { ServiceWrapper.settings.devMode = !ServiceWrapper.settings.devMode; ServiceWrapper.settings.Save(); Console.WriteLine("Dev mode: " + ServiceWrapper.settings.devMode); } }while (line != "exit"); Console.WriteLine("Stopping..."); } finally { ServiceWrapper.Stop(); } } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new MasterServerSvc() }; ServiceBase.Run(ServicesToRun); } }
public static void PrintTL(string file, ConsoleColor colour) { Console.Clear(); Console.ForegroundColor = ConsoleColor.White; ConsoleAppHelper.PrintHeader("Header.txt"); Console.ForegroundColor = colour; String line; try { //Pass the file path and file name to the StreamReader constructor StreamReader sr = new StreamReader(file); //Read the first line of text line = sr.ReadLine(); //Continue to read until you reach end of file while (line != null) { //write the lie to console window Console.WriteLine(line); //Read the next line line = sr.ReadLine(); } Console.WriteLine(string.Empty); //close the file sr.Close(); } catch (Exception ex) { Console.WriteLine(ex.GetBaseException()); } finally { ///Console.WriteLine("Executing finally block."); } Console.ForegroundColor = ConsoleColor.White; }
static void Main(string[] args) { Console.SetWindowSize(80, 20); ConsoleAppHelper.PrintHeader("Header.txt"); RunMassTransitReceiverWithRabbit(); Monitor(null, null); Pulse(null, null); ConfigureCheckInterval(); ConfigurePulseInterval(); Console.ReadKey(); _checkIntervalTimer.Stop(); _pulseIntervalTimer.Stop(); _rabbitBusControl.Stop(); }
static void Main(string[] args) { Console.SetWindowSize(80, 20); ConsoleAppHelper.PrintHeader("Header.txt"); var _rabbitBusControl = Bus.Factory.CreateUsingRabbitMq(sbc => { var host = sbc.Host(new Uri("rabbitmq://localhost"), h => { h.Username("guest"); h.Password("guest"); }); // sbc.ReceiveEndpoint(host, "ProtectorQueue", ep => // { // ep.Bind("DatabaseRegistered"); // ep.Consumer(() => new DatabaseRegisteredConsumer()); // }); // // sbc.ReceiveEndpoint(host, "ProtectorQueue", ep => // { // ep.Bind("DatabaseRegistered"); // ep.Consumer(() => new DatabaseRegisteredConsumer()); // }); sbc.ReceiveEndpoint(host, "DatabaseRegistered", ep => { ep.Consumer(() => new DatabaseRegisteredConsumer()); }); }); _rabbitBusControl.Start(); Console.WriteLine("Press any key to exit"); Console.ReadKey(); _rabbitBusControl.Stop(); }
public Task Consume(ConsumeContext <RegisterDatabase> context) { ConsoleAppHelper.PrintHeader("Header.txt"); var connectionDetails = context.Message.ConnectionDetails; var schema = Helper.GetSchemaInfo(connectionDetails); StorageHelper.StoreDatabaseDefinition(connectionDetails, schema.Tables, "monitor"); var message = new DatabaseRegisteredMessage { Database = connectionDetails, Schema = schema }; context.Publish <DatabaseRegistered>(message); Console.WriteLine($"Registered database with {schema.Tables.Count} tables at {DateTime.Now}"); return(Task.CompletedTask); }
static void Main(string[] args) { var dialogResult = ConsoleAppHelper.RunDialog(); try { var loginData = new LoginData("https://badoo.com/signin/", ConfigReader.Credentials); var executor = new HandlersExecutor(Logger); executor.RunBadooHandler(dialogResult, loginData); } catch (FileNotFoundException e) { Console.WriteLine(e.Message); } catch (Exception ex) { Logger.Log(ex.Message); Console.WriteLine("There was a problem with this application. Please contact support."); } }
static void Main(string[] args) { Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight); ShowWindow(ThisConsole, MAXIMIZE); ConsoleAppHelper.PrintHeader("Header.txt"); Cleanup(); System.IO.DirectoryInfo di = new DirectoryInfo(@"C:\dev\Stores\"); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in di.GetDirectories()) { Console.WriteLine($"Removing {dir.FullName}"); dir.Delete(true); } Console.WriteLine("Finished"); Console.ReadLine(); }
private void TestActionParsed(IEnumerable <ActionMap> actionMaps, string input, bool enableMultiAction, string testMethodName) { // get raw string testContext = null; string[] args; if (!string.IsNullOrWhiteSpace(input)) { args = ConsoleAppHelper.CommandLineToArgs(input); } else { args = new string[0]; } var argsRaw = CommandParserUtils.ParseArgumentsRaw(args, actionMaps); IEnumerable <ArgumentRaw> initialExtraArguments; var actionsMapped = CommandParserUtils.GetActionsParsed(argsRaw, enableMultiAction, actionMaps, out initialExtraArguments); var objectTest = new { input, actionMaps, actionsMapped }; var jsonSerializeConfig = TestHelper.GetJsonConfig(); Assert.True(TestHelper.CompareObjects <TestAction>(objectTest, testContext, testMethodName, jsonSerializeConfig)); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine(@"Please Provide arguments to run:"); Console.WriteLine(@"all args should be in the form of: [key]=[value] with space between them"); Console.WriteLine(@"Arguments:"); Console.WriteLine(@"----------"); Console.WriteLine(@"problem: problem filename"); Console.WriteLine(@"time-limit: limit run time to X minutes (default 120), 0 for no time limit"); Console.WriteLine(@"alg: [astar/dfbnb/greedy/greedyloops] the solving algorithm"); Console.WriteLine(@"heuristic: [none/untouched/bcc/alternate/altbcc/sepaltbcc] the heuristic being used"); Console.WriteLine(@"prune: [none/bsd/rsd/hbsd] pruning technique"); Console.WriteLine(@"bcc-init: [true/false] remove non-reachable areas from the graph on init"); Console.WriteLine(@"----------"); Console.WriteLine(@"memTest: if set to true, will not solve nothing, only fill memory"); Console.WriteLine(@" allocation to check 64bit issue"); Console.WriteLine(@"-----------------------------[Version:" + VERSION + "]---------------------------------"); Console.WriteLine(@"time-limit & bcc-init can be set in app.config XML file"); return; } Dictionary <string, string> splitedArgs = ConsoleAppHelper.SplitArguments(args); if (splitedArgs.ContainsKey("memtest") && splitedArgs["memtest"].Equals("true")) { MemTest(); } if (!splitedArgs.ContainsKey("time-limit")) //default time limit { splitedArgs.Add("time-limit", TIME_LIMIT); } if (!splitedArgs.ContainsKey("bcc-init")) //default pre-bcc { splitedArgs.Add("bcc-init", BCC_INIT); } int timelimit = Int32.Parse(splitedArgs["time-limit"]); bool bccInit = Boolean.Parse(splitedArgs["bcc-init"]); string problemFileName = splitedArgs["problem"]; IGridHeuristic heuristic; if (splitedArgs["heuristic"] == "none") { heuristic = new NoneHeuristic(); } else if (splitedArgs["heuristic"] == "untouched") { if (splitedArgs["prune"] == "rsd") { heuristic = new RsdUntouchedAroundTheGoalHeuristic(); } else { heuristic = new UntouchedAroundTheGoalHeuristic(); } } else if (splitedArgs["heuristic"] == "bcc") { //TODO: finish impl. + support RSD heuristic = new BiconnectedComponentsHeuristic(); } else if (splitedArgs["heuristic"] == "alternate") { heuristic = new AlternateStepsHeuristic(); } else if (splitedArgs["heuristic"] == "altbcc") { heuristic = new AlternateStepsBiconnectedComponentsHeuristic(); } else if (splitedArgs["heuristic"] == "sepaltbcc") { heuristic = new SeparateAlternateStepsBiconnectedComponentsHeuristic(); } else { throw new NotImplementedException(); } World world = new World(File.ReadAllText(problemFileName), heuristic); IPrunningMethod prune; GridSearchNode initialNode; switch (splitedArgs["prune"]) { case "none": prune = new NoPrunning(); initialNode = world.GetInitialSearchNode <GridSearchNode>(); break; case "bsd": prune = new BasicSymmetryDetectionPrunning(); initialNode = world.GetInitialSearchNode <GridSearchNode>(); break; case "hbsd": prune = new HashedBasicSymmetryDetectionPrunning(); initialNode = world.GetInitialSearchNode <GridSearchNode>(); break; case "rsd": prune = new ReachableSymmetryDetectionPrunning(); initialNode = world.GetInitialSearchNode <RsdGridSearchNode>(); break; default: Log.WriteLineIf("Prunning Method: " + splitedArgs["prune"] + " is not supported!", TraceLevel.Error); return; } Solver solver; switch (splitedArgs["alg"]) { case "astar": solver = new AStarMax(initialNode, prune, new GoalOnLocation(world.Goal)); break; case "dfbnb": solver = new DfBnbMax(initialNode, prune, new GoalOnLocation(world.Goal)); break; case "greedy": solver = new GreedyMax(initialNode, new GoalOnLocation(world.Goal)); if (splitedArgs["prune"] != "none") { Log.WriteLineIf("Greedy doesn't support pruning!", TraceLevel.Error); return; } break; case "greedyloops": solver = new GreedyLoopMax(initialNode, new GoalOnLocation(world.Goal), 50); if (splitedArgs["prune"] != "none") { Log.WriteLineIf("GreedyLoops doesn't support pruning!", TraceLevel.Error); return; } break; default: Log.WriteLineIf("Solver algorithm: " + splitedArgs["alg"] + " is not supported!", TraceLevel.Error); return; } if (splitedArgs["prune"] == "rsd") { //Sorry but RSD must use AStarMax - DFBnB not supported ((ReachableSymmetryDetectionPrunning)prune).setAstarOpenList(((AStarMax)solver).OpenList); } if (bccInit) { world.InitBcc(); } Log.WriteLineIf(@"Solviong 2D-Grid problem from file:", TraceLevel.Off); Log.WriteLineIf(@"[[Folder:" + Path.GetFileName(Environment.CurrentDirectory) + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[Problem:" + problemFileName + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[Algorithm:" + solver.GetType().Name + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[Heuristic:" + heuristic.GetName() + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[Prunning:" + prune.GetName() + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[BccInit:" + bccInit + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[TimeLimit:" + timelimit + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[Width:" + world.Width + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[Height:" + world.Height + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[TotalLocations:" + world.Height * world.Width + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[TotalFreeLocationsPreBcc:" + ((world.Height * world.Width) - world.TotalBlockedPreBccInit) + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[TotalFreeLocationsPostBcc:" + ((world.Height * world.Width) - world.TotalBlockedPostBccInit) + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[BlockedCountPreBccInit:" + world.TotalBlockedPreBccInit + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[BlockedCountPostBccInit:" + world.TotalBlockedPostBccInit + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[NumberOfEvenLocations:" + AlternateStepsHeuristic.GetNumberOfEvenLocations(world.Width, world.Height) + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[NumberOfOddLocations:" + AlternateStepsHeuristic.GetNumberOfOddLocations(world.Width, world.Height) + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[EvenBlockedCount:" + world.EvenBlocked + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[OddBlockedCount:" + world.OddBlocked + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[EvenFreeCount:" + (AlternateStepsHeuristic.GetNumberOfEvenLocations(world.Width, world.Height) - world.EvenBlocked) + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[OddFreeCount:" + (AlternateStepsHeuristic.GetNumberOfOddLocations(world.Width, world.Height) - world.OddBlocked) + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[EvenLocationsPercent:" + (decimal)AlternateStepsHeuristic.GetNumberOfEvenLocations(world.Width, world.Height) / world.LinearSize + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[OddLocationsPercent:" + (decimal)AlternateStepsHeuristic.GetNumberOfOddLocations(world.Width, world.Height) / world.LinearSize + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[EvenBlockedPercent:" + (decimal)world.EvenBlocked / world.LinearSize + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[OddBlockedPercent:" + (decimal)world.OddBlocked / world.LinearSize + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[EvenFreePercent:" + (decimal)(AlternateStepsHeuristic.GetNumberOfEvenLocations(world.Width, world.Height) - world.EvenBlocked) / world.LinearSize + "]]", TraceLevel.Off); Log.WriteLineIf(@"[[OddFreePercent:" + (decimal)(AlternateStepsHeuristic.GetNumberOfOddLocations(world.Width, world.Height) - world.OddBlocked) / world.LinearSize + "]]", TraceLevel.Off); var startTime = DateTime.Now; ulong startCycles = NativeMethods.GetThreadCycles(); var howEnded = solver.Run(timelimit); ulong totalCycles = NativeMethods.GetThreadCycles() - startCycles; var totalTime = DateTime.Now - startTime; var goal = (GridSearchNode)solver.GetMaxGoal(); Log.WriteLineIf("[[TotalTime(MS):" + totalTime.TotalMilliseconds + "]]", TraceLevel.Off); Log.WriteLineIf("[[CPU Cycles:" + totalCycles + "]]", TraceLevel.Off); Log.WriteLineIf("[[Expended:" + solver.Expended + "]]", TraceLevel.Off); Log.WriteLineIf("[[Generated:" + solver.Generated + "]]", TraceLevel.Off); Log.WriteLineIf("[[AlgPruned:" + solver.AlgPruned + "]]", TraceLevel.Off); Log.WriteLineIf("[[ExternalPruned:" + solver.ExternalPruned + "]]", TraceLevel.Off); Log.WriteLineIf("[[TotalPruned:" + solver.ExternalPruned + solver.AlgPruned + "]]", TraceLevel.Off); if (goal != null) { Log.WriteLineIf("[[G-Value:" + goal.g + "]]", TraceLevel.Off); Log.WriteLineIf("[[GoalBits:" + goal.GetBitsString() + "]]", TraceLevel.Off); Log.WriteLineIf("[[Goal:" + goal.GetNodeStringV2() + "]]", TraceLevel.Off); } else { Log.WriteLineIf("[[G-Value:" + -1 + "]]", TraceLevel.Off); Log.WriteLineIf("[[GoalBits:NOGOAL]]", TraceLevel.Off); Log.WriteLineIf("[[Goal:NOGOAL]]", TraceLevel.Off); } Log.WriteLineIf("[[HowEnded:" + Enum.GetName(typeof(State), howEnded) + "]]", TraceLevel.Off); Log.WriteLineIf("[[GridSolverVersion:" + VERSION + "]]", TraceLevel.Off); }