public static void Main(string[] args) { var bootstrapper = Bootstrapper.BootstrapSystem ( new ConsoleClientModule(), new CoreModule() ); var consoleClient = new ConsoleClient.ConsoleClient(bootstrapper.Resolve <ISimRunner>()); consoleClient.Run(args); }
static void Main(string[] args) { Console.Write("\n CoreConsoleClient"); Console.Write("\n ===================\n"); if (!parseCommandLine(args)) { return; } Console.Write("Press key to start: "); Console.ReadKey(); string url = args[0]; ConsoleClient client = new ConsoleClient(url); showCommandLine(args); Console.Write("\n sending request to {0}\n", url); switch (args[1]) { case "/get": Task <IEnumerable <string> > comml = client.GetCommList(); var resultfl = comml.Result; foreach (var item in resultfl) { Console.Write("\n {0}", item); } break; case "/post": Task <HttpResponseMessage> tup = client.PostComm(args[2], args[3]); Console.Write(tup.Result); break; case "/get/id": int get_id = Int32.Parse(args[2]); Task <HttpResponseMessage> tdn = client.GetComment(get_id); Console.Write(tdn.Result); break; case "/delete/id": int id = Int32.Parse(args[2]); Task <HttpResponseMessage> res = client.DeleteComm(id); Console.Write(res.Result); break; } Console.WriteLine("\n Press Key to exit: "); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Press key to start: "); Console.ReadKey(); string url = "https://localhost:44342/api/Files"; ConsoleClient client = new ConsoleClient(url); Task <HttpResponseMessage> t = client.SendFile("../../../ConsoleClient.cs"); var result = t.Result; Console.WriteLine("\n result = \"{0}\"", result); Console.WriteLine("Press Key to exit: "); Console.ReadKey(); }
public static void Main(string[] args) { // check if command is -v (print version information) if (args.Length == 1) { if (args[0].ToLower() == "-v") { Console.WriteLine("Version: " + RepoVer.VER); Environment.Exit(0); } } // args[0]=<orch-endpoint> args[1]=<command> args[2..n]=optional args if (args.Length < 2) { printUsageAndExit(); } string orchEndpoint = args[0]; string command = args[1]; // commands start with a leading '-' if (!command.StartsWith("-")) { printUsageAndExit(); } command = command.Substring(1); // check that command is actually a command if (!Commands.ContainsKey(command)) { printUsageAndExit(); } string[] commandArgs; // copy optional command arguments if (args.Length > 2) { // copy everything after the command commandArgs = new string[args.Length - 2]; Array.Copy(args, 2, commandArgs, 0, commandArgs.Length); } else { commandArgs = new string[0]; } // print command specific help if (commandArgs.Length >= 1 && commandArgs[0].StartsWith("h")) { printUsageAndExit(command); } ConsoleClient cc = new ConsoleClient(); if (command == "ls") DoTrackerDatas(cc); else if (command == "s") DoSubmitJob(cc, commandArgs); }
private static void DoTrackerDatas(ConsoleClient cc) { cc.Init(); List<TrackerData> data = new List<TrackerData>(cc.GetTrackerData()); if (data.Count == 0) { Console.WriteLine("No Trackers"); } else { int running = data.Count(td => td.Status == TrackerStatus.RUNNING); int down = data.Count(td => td.Status == TrackerStatus.NO_RESPONSE || td.Status == TrackerStatus.UNKNOWN); int idle = data.Count(td => td.Status == TrackerStatus.IDLE); Console.WriteLine(data.Count + " registered trackers."); Console.WriteLine(running + " running."); Console.WriteLine(down + " down."); Console.WriteLine(idle+ " idle."); foreach (TrackerData td in data) { string jobName = td.CurrentJob.FriendlyName == string.Empty ? td.CurrentJob.Guid : td.CurrentJob.FriendlyName; string msg = string.Format("{0} {1}\t{2}", td.HostName, td.Status, jobName); Console.WriteLine(msg); } } }
private static void DoSubmitJob(ConsoleClient cc, string[] cmdArgs) { if (cmdArgs.Length <= 3) { usage(Commands["s"].Cmd); } else { string friendlyName = cmdArgs[0]; string envxName = cmdArgs[1]; string sourceUri = cmdArgs[2]; string resultsUri = cmdArgs[3]; int[] scenarios; if (cmdArgs.Length <= 4) { scenarios = new int[] { 0 }; } else { string scenariosString = cmdArgs[4]; scenarios = scenariosString.Split(',') .Select(numStr => { int a; Int32.TryParse(numStr, out a); return a; } ).ToArray(); } cc.Init(); cc.SubmitJob(envxName, sourceUri, resultsUri, friendlyName, scenarios); } }
private static void DoJobList(ConsoleClient cc) { cc.Init(); List<TrackerData> data = new List<TrackerData>(cc.GetTrackerData()); if (data.Count==0) { Console.WriteLine("No Jobs."); } else { } }
static void Main(string[] args) { Console.Write("\n CoreConsoleClient"); Console.Write("\n ===================\n"); if (!parseCommandLine(args)) { return; } //Console.ReadKey(); string val; string url = args[0]; ConsoleClient client = new ConsoleClient(url); //showCommandLine(args); // Console.Write("\n sending request to {0}\n", url); bool flag = true; while (flag == true) { Console.WriteLine("Press 1 to send a file from Client to Server"); Console.WriteLine("Press 2 to get list of files in Server: "); Console.WriteLine("Press 3 to Exit Client"); val = Console.ReadLine(); Console.WriteLine(); switch (val) { case "1": DirectoryInfo d = new DirectoryInfo("../ClientFileStorage/"); FileInfo[] Files = d.GetFiles(); //Getting Text files Console.WriteLine("Files in the Client"); Console.WriteLine("========================"); foreach (FileInfo file in Files) { Console.WriteLine(file.Name); } Console.WriteLine("========================"); Console.WriteLine("Enter Complete file name"); string test; test = Console.ReadLine(); string path = "../ClientFileStorage/"; bool f = false; foreach (FileInfo file in Files) { if (test == file.Name) { path = path + test; Task <HttpResponseMessage> Send = client.SendFile(path); Console.WriteLine("=================================="); Console.WriteLine(Send.Result); Console.WriteLine("=================================="); f = true; break; } else { f = false; } } if (f == false) { Console.WriteLine(">-----------------------< Incorrect File Name >-----------------<"); } Console.WriteLine(); Console.WriteLine(); break; case "2": Task <IEnumerable <string> > tfl = client.GetFileList(); var resultfl = tfl.Result; Console.WriteLine("============================"); foreach (var item in resultfl) { Console.Write("\n {0}", item); } Console.WriteLine(); Console.WriteLine("============================"); Console.WriteLine(); break; case "3": flag = false; break; default: Console.WriteLine(">----------------------< Error! >--------------< Incorrect Input >------------<"); break; } } //Console.WriteLine("\n Press Key to exit: "); //Console.ReadKey(); }