示例#1
0
        static void Main(string[] args)
        {
            const string path = @"c:\rnc_list";

            try
            {
                var lines = new List <string>();

                using var streamReader = new StreamReader(path, Encoding.UTF8);
                string line;

                while ((line = streamReader.ReadLine()) != null)
                {
                    lines.Add(line);
                }

                /*
                 * while((line = streamReader.ReadLine()) != null)
                 * {
                 *  foreach(line in streamReader)
                 *      NameEntry entry = new NameEntry(line);
                 * }
                 */
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            PrintMenu();
            CommandPrompt.ShowPrompt();
        }
示例#2
0
        public static bool KillByName(string name, List <int> exclude = null)
        {
            string command;
            string result;

            if (exclude == null)
            {
                exclude = new List <int>();
            }

            command = $"wmic process where(Name = \"{name}\") get ProcessId";
            result  = CommandPrompt.Execute(command);

            List <int> pids = result
                              .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                              .Skip(1)
                              .Select(x => TypeConverter.StringToInteger(x.Trim()))
                              .Where(x => !exclude.Contains(x))
                              .ToList();

            command = $"taskkill /f";
            foreach (int pid in pids)
            {
                command += $" /pid {pid}";
            }
            result = CommandPrompt.Execute(command);

            return(Regex.Matches(result, "SUCCESS").Count == pids.Count);
        }
        public void should_repeatedly_try_to_resolve_multiple_objects()
        {
            var room = Context.Story.Location;

            var red = new RedHat();

            red.Initialize();

            var black = new BlackHat();

            black.Initialize();

            var white = new WhiteHat();

            white.Initialize();

            Objects.Add(red, room);
            Objects.Add(black, room);
            Objects.Add(white, room);

            CommandPrompt.FakeInput("hat");

            Execute("take hat");

            Assert.Contains("Which do you mean, the red hat, the black hat or the white hat?", Line1);
            Assert.Contains("Which do you mean, the red hat, the black hat or the white hat?", Line2);
        }
示例#4
0
        public void should_handle_partial_command_with_preposition()
        {
            var lamp  = Objects.Get <BrassLantern>();
            var fresh = Objects.Get <FreshBatteries>();

            Inventory.Add(fresh);

            lamp.PowerRemaining = 0;

            CommandPrompt.FakeInput("lamp");

            Execute("put batteries in");

            var x = ConsoleOut;

            Assert.Contains($"What do you want to put {fresh} in?", Line1);
            Assert.Contains("I'm taking the liberty of replacing the batteries.", Line2);

            Assert.Equal(2500, lamp.PowerRemaining);


            var old = Objects.Get <OldBatteries>();

            Assert.True(old.InScope);
            Assert.True(fresh.HaveBeenUsed);
        }
        public void should_handle_more_than_two_objects_with_same_name()
        {
            var room = Context.Story.Location;

            var red = new RedHat();

            red.Initialize();

            var black = new BlackHat();

            black.Initialize();

            var white = new WhiteHat();

            white.Initialize();

            Objects.Add(red, room);
            Objects.Add(black, room);
            Objects.Add(white, room);

            CommandPrompt.FakeInput("white");

            Execute("take hat");

            Assert.Contains("Which do you mean, the red hat, the black hat or the white hat?", ConsoleOut);
            Assert.Contains("Taken.", ConsoleOut);
            Assert.Contains(white, Inventory.Items);
        }
示例#6
0
        public async void BuildNextPackage()
        {
            if (!PackagesToBuild.Any())
            {
                Task finishedBuildingTask = Task.Factory.StartNew(() =>
                {
                    FinishedBuilding();
                });

                await finishedBuildingTask;
                return;
            }

            var path = PackagesToBuild.First();

            PackagesToBuild.Remove(path);

            IncrementVersionNumber(path);
            commandPrompt = new CommandPrompt(true);

            string fileNoExt       = path.Substring(0, path.LastIndexOf(".") + 1).Replace("\\", "/");
            string outputDir       = fileNoExt.Substring(0, fileNoExt.LastIndexOf("/") + 1) + "bin/Release";
            string buildPackageCmd = $"\"{nugetExe}\" pack \"{fileNoExt}csproj\" -Build -Prop Configuration=Release -OutputDirectory \"{outputDir}\" -IncludeReferencedProjects";

            commandPrompt.ExecuteCommand(buildPackageCmd);
            commandPrompt.OutputUpdated += CommandPromptBuild_OutputUpdated;
        }
示例#7
0
        bool PerformPost(CommandID command, CommandPrompt prompt, object args)
        {
            IVsUIShell shell = UIShell;

            if (shell != null)
            {
                uint flags;
                switch (prompt)
                {
                case CommandPrompt.Always:
                    flags = (uint)OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER;
                    break;

                case CommandPrompt.Never:
                    flags = (uint)OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER;
                    break;

                default:
                    flags = (uint)OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT;
                    break;
                }

                Guid   set = command.Guid;
                object a   = args;

                return(VSErr.S_OK == shell.PostExecCommand(ref set,
                                                           unchecked ((uint)command.ID), flags, ref a));
            }

            return(false);
        }
        public void should_handle_two_objects_with_same_name_in_except_clause()
        {
            var room = Context.Story.Location;

            var red = new RedHat();

            red.Initialize();

            var black = new BlackHat();

            black.Initialize();

            var white = new WhiteHat();

            white.Initialize();

            Objects.Add(red, room);
            Objects.Add(black, room);
            Objects.Add(white, room);

            CommandPrompt.FakeInput("white");

            Execute("take all except hat");

            // need to for bad responses and stuff

            Assert.DoesNotContain("white hat: Taken.", ConsoleOut);
            Assert.DoesNotContain(white, Inventory.Items);
            Assert.Contains(red, Inventory.Items);
            Assert.Contains(black, Inventory.Items);
        }
        public void should_handle_command_reentry_in_except_clause_that_has_multiple_matching_items()
        {
            var room = Context.Story.Location;

            var red = new RedHat();

            red.Initialize();

            var black = new BlackHat();

            black.Initialize();

            var white = new WhiteHat();

            white.Initialize();

            Objects.Add(red, room);
            Objects.Add(black, room);
            Objects.Add(white, room);

            // this should bail out of the except clause handler
            CommandPrompt.FakeInput("take white hat");

            Execute("take all except hat");

            Assert.DoesNotContain("white hat: Taken.", ConsoleOut);
            Assert.DoesNotContain(white, Inventory.Items);
            Assert.Contains(red, Inventory.Items);
            Assert.Contains(black, Inventory.Items);
        }
示例#10
0
        public static bool ReserveUrlForNonAdministratorUsersAndAccounts(int port, string scheme = "http", string host = "+")
        {
            string command;
            string result;

            command = $"netsh http show urlacl url={scheme}://{host}:{port}/";
            result  = CommandPrompt.Execute(command);
            if (result.Contains("Reserved URL"))
            {
                Logger.Log("Url Reservation", $"Url {scheme}://{host}:{port}/ already has a reservation.");
                return(true);
            }

            command = $"netsh http add urlacl {scheme}://{host}:{port}/ user=$env:UserName";
            try {
                result = PowerShell.Execute(command, administrator: true);
            } catch (UnauthorizedAccessException ex) {
                Logger.Log("Exception", ex.Message);
                Logger.Log("Napaka", "Nimate administratorskih pravic.", toLog: false);
                return(false);
            }

            bool success = result.Contains("URL reservation successfully added");

            if (success)
            {
                Logger.Log("Url Reservation", $"Url {scheme}://{host}:{port}/ reserved.");
            }

            return(success);
        }
示例#11
0
        public void InputSingleText()
        {
            CommandPrompt input = new CommandPrompt();

            input.Read("Quinn");
            Assert.AreEqual(input.LastInput, "Quinn");
        }
        public void should_handle_bad_command_reentry_in_except_clause_that_has_multiple_matching_items()
        {
            var room = Context.Story.Location;

            var red = new RedHat();

            red.Initialize();

            var black = new BlackHat();

            black.Initialize();

            var white = new WhiteHat();

            white.Initialize();

            Objects.Add(red, room);
            Objects.Add(black, room);
            Objects.Add(white, room);

            CommandPrompt.FakeInput("donkey");

            Execute("take all except hat");

            Assert.Equal(Messages.CantSeeObject, Line1);
        }
示例#13
0
        static void Main(string[] args)
        {
            //Example1

            var cmd = new CommandPrompt("dir");

            cmd.Execute();


            //Example2

            /*
             * var cmd = new cs_CommandPrompt();
             * cmd.SetCommand("echo helloworld");
             * cmd.Execute();
             */

            //Example3

            /*
             * var cmd = new cs_CommandPrompt();
             * cmd.Execute("echo hoge");
             */


            System.Console.WriteLine(cmd.ExitCode);
            System.Console.WriteLine(cmd.StdOut);
        }
示例#14
0
        public void should_allow_multiple_partial_commands()
        {
            CommandPrompt.FakeInput("take");

            var result = Execute("take");

            Assert.Equal("What do you want to take?", Line1);
            Assert.Equal("What do you want to take?", Line2);
        }
示例#15
0
        public void should_handle_partial_response()
        {
            CommandPrompt.FakeInput("bottle");

            Execute("take");

            Assert.Contains("What do you want to take?", ConsoleOut);
            Assert.Contains("Taken.", ConsoleOut);
            Assert.Contains(Objects.Get <Bottle>(), Inventory.Items);
        }
示例#16
0
 public BaseTestFixture()
 {
     fakeConsole   = new StringBuilder();
     Context.Story = new ColossalCaveStory();
     Output.Initialize(new StringWriter(fakeConsole), new TestFormatter());
     CommandPrompt.Initialize(new StringWriter(), new StringReader(""));
     Context.Story.Initialize();
     Context.Story.Location = Room <InsideBuilding>();
     Inventory.Clear();
     fakeConsole.Clear();;
 }
        private static bool PublishCoreProject(string solutionPath, string projectPath, string projectDeployPath)
        {
            string command = $"dotnet publish \"{projectPath}\" " +
                             $"--configuration Release " +
                             $"--framework netcoreapp2.0 " +
                             $"--output \"{projectDeployPath}\" " +
                             $"--verbosity normal";
            string result = CommandPrompt.Execute(command);

            return(result.Contains("Build succeeded"));
        }
示例#18
0
        public static int FindProcessPIDByListeningTCPPort(int port)
        {
            string command = $"netstat -ano -p TCP | find /I \"listening\" | find /I \"{port}\"";
            string result  = CommandPrompt.Execute(command);
            var    tokens  = result.Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (tokens.Length > 0)
            {
                return(TypeConverter.StringToInteger(tokens.Last()));
            }

            return(0);
        }
示例#19
0
        public static string GetRegistryValue(string key, string value)
        {
            string response = null;

            string command = $"reg query \"{key}\" /v \"{value}\"";
            string result  = CommandPrompt.Execute(command);

            if (!result.Contains("ERROR: The system was unable to find the specified registry key or value."))
            {
                response = ExtractDataByValue(result, value);
            }

            return(response);
        }
示例#20
0
        public static string GetRegistryValueByPattern(string key, string pattern, string value)
        {
            string response = null;

            string command = $"reg query \"{key}\" /s /f \"{pattern}\"";
            string result  = CommandPrompt.Execute(command);

            if (!result.Contains("End of search: 0 match(es) found."))
            {
                response = ExtractDataByValue(result, value);
            }

            return(response);
        }
示例#21
0
        public void should_allow_multiple_partial_responses()
        {
            CommandPrompt.FakeInput("bottle");

            Execute("take");

            Assert.Contains("What do you want to take?", ConsoleOut);
            Assert.Contains("Taken.", ConsoleOut);
            Assert.Contains(Objects.Get <Bottle>(), Inventory.Items);

            var result = Execute("bottle");

            Assert.Equal(Messages.VerbNotRecognized, result.Output.Single());
        }
        static void Main(string[] args)
        {
            var cmd = new CommandPrompt()
            {
            };

            cmd.OutputDataReceived += OnDataReceived;
            cmd.Exited             += Exited;
            cmd.ErrorDataReceived  += ErrorDataReceived;

            var process = cmd.RunCommand("ping www.google.com");
            // Or if you need wait until the process
            var processButExited = cmd.RunCommandAndWaitForExit("ping www.youtube.com", "./", TimeSpan.FromMilliseconds(100));

            Console.ReadKey();
        }
示例#23
0
        public CommandResult DirectlyExecCommand(AnkhCommand command, object args, CommandPrompt prompt)
        {
            // TODO: Assert that we are in the UI thread

            CommandMapper mapper = GetService <CommandMapper>();

            if (mapper == null)
            {
                return(new CommandResult(false, null));
            }

            CommandEventArgs e  = new CommandEventArgs(command, AnkhContext, args, prompt == CommandPrompt.Always, prompt == CommandPrompt.Never);
            bool             ok = mapper.Execute(command, e);

            return(new CommandResult(ok, e.Result));
        }
示例#24
0
        public void PushPackages()
        {
            string key              = string.Empty;
            string packageServer    = string.Empty;
            bool   pushNotCancelled = false;

            try
            {
                if (Properties.Settings.Default.ApiKey[0] == string.Empty || Properties.Settings.Default.NugetRepositories[0] == string.Empty)
                {
                    new MissingInfoDialog().Show();
                    pushNotCancelled = false;
                }
                else
                {
                    pushNotCancelled = true;
                    key           = Properties.Settings.Default.ApiKey[0];
                    packageServer = Properties.Settings.Default.NugetRepositories[0];
                }
            }
            catch (Exception)
            {
                new MissingInfoDialog().Show();
                pushNotCancelled = false;
            }



            if (pushNotCancelled)
            {
                progressDialogForm.UpdateMessage("Pushing to Server ...");
                progressDialogForm.Show(this);
                foreach (CheckedListBoxItem file in nupkgSearchResults.CheckedItems)
                {
                    commandPrompt = new CommandPrompt(true);

                    string packagePathNoBackslash = file.Tag.Replace("\\", "/");
                    string pushPackageUpdateCmd   = $"\"{nugetExe}\" push \"{packagePathNoBackslash}\" {key} -Source {packageServer}";

                    commandPrompt.ExecuteCommand(pushPackageUpdateCmd);
                    commandPrompt.ExecuteCommand(key);
                    commandPrompt.ExecuteCommand("");

                    commandPrompt.OutputUpdated += CommandPromptPush_OutputUpdated;
                }
            }
        }
示例#25
0
        private void CreateProjectCommands()
        {
            LinkedList <string> commands = new LinkedList <string>();

            commands.AddLast("cd C:/");
            commands.AddLast("cd " + createdDirectory + ";");
            commands.AddLast("git init;");
            commands.AddLast("git add README.md;");
            commands.AddLast("git commit -m \"initial commit\";");
            commands.AddLast("git push -u origin master");

            foreach (var command in commands)
            {
                string output = CommandPrompt.Execute(command);
                TbOutput.Text += output + Environment.NewLine;
            }
        }
示例#26
0
        public bool Expects()
        {
            Output.Print("Where do you want to go?");

            var x = CommandPrompt.GetInput();

            var room = (from r in Rooms.All
                        where r.GetType().Name.Contains(x)
                        select r).FirstOrDefault();

            if (room != null)
            {
                MovePlayer.To(room);
            }

            return(true);
        }
示例#27
0
        public static bool OpenFirewallPort(string name, int port, string dir = "in", string action = "allow", string protocol = "TCP", string profile = "private")
        {
            string command;
            string result;

            command = $"netsh advfirewall firewall show rule name=\"{name}\"";
            result  = CommandPrompt.Execute(command);
            if (!result.Contains("No rules match the specified criteria."))
            {
                if (Regex.IsMatch(result, $"LocalPort:.*{port}{Environment.NewLine}"))
                {
                    Logger.Log("Firewall", $"Port {port} already opened.");
                    return(true);
                }
                else
                {
                    command = $"netsh advfirewall firewall delete rule name=\"{name}\"";
                    try {
                        result = CommandPrompt.Execute(command, administrator: true);
                    } catch (UnauthorizedAccessException ex) {
                        Logger.Log("Exception", ex.Message);
                        Logger.Log("Napaka", "Nimate administratorskih pravic.", toLog: false);
                        return(false);
                    }
                }
            }

            command = $"netsh advfirewall firewall add rule name=\"{name}\" dir=in action={action} protocol={protocol} profile={profile} localport={port}";
            try {
                result = CommandPrompt.Execute(command, administrator: true);
            } catch (UnauthorizedAccessException ex) {
                Logger.Log("Exception", ex.Message);
                Logger.Log("Napaka", "Nimate administratorskih pravic.", toLog: false);
                return(false);
            }

            bool success = result.Contains("Ok.");

            if (success)
            {
                Logger.Log("Firewall", $"Opened port {port}.");
            }

            return(success);
        }
示例#28
0
        public static void RegisterService(string filename, string path, bool unregister = true)
        {
            string command;

            if (unregister)
            {
                string result = GetRegistryValueByPattern(@"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib", filename, "(Default)");

                if (result != null)
                {
                    command = $"regsvr32 /s /u \"{result}\"";
                    CommandPrompt.ExecuteInBackground(command, administrator: true, waitForExit: true);
                }
            }

            command = $"regsvr32 /s \"{Path.Combine(path, filename)}\"";
            CommandPrompt.ExecuteInBackground(command, administrator: true, waitForExit: true);
        }
示例#29
0
        public static bool KillbyPID(int pid, bool recurse = false)
        {
            string command = $"taskkill /f /pid {pid}";

            List <int> children = new List <int>();

            if (recurse)
            {
                children = GetChildren(pid, recurse);
                foreach (int childPid in children)
                {
                    command += $" /pid {childPid}";
                }
            }

            string result = CommandPrompt.Execute(command);

            return(Regex.Matches(result, "SUCCESS").Count == children.Count + 1);
        }
示例#30
0
        private async Task OnCommandPrompt(CommandPrompt x, Random r)
        {
            System.Diagnostics.Debug.WriteLine("OnCommandPrompt " + Thread.CurrentThread.ManagedThreadId);
            System.Diagnostics.Debug.WriteLine($"command : ({x.PlayerId}) {string.Join(", ", x.Hand.Cards)}");

            command.Visibility  = Visibility.Visible;
            command.DataContext = x;

            var indexes = await command.SelectAsync(CancellationToken.None);

            System.Diagnostics.Debug.WriteLine($"selection: ({x.PlayerId}) {string.Join(", ", indexes)}");

            if (indexes.Any())
            {
                x.Redraw(indexes);
            }

            command.Visibility = Visibility.Collapsed;
        }
示例#31
0
 private void InitializeComponent()
 {
     Panel panel = new Panel();
     this._commandPrompt = new CommandPrompt();
     panel.SuspendLayout();
     base.SuspendLayout();
     this._commandPrompt.BorderStyle = BorderStyle.None;
     this._commandPrompt.Dock = DockStyle.Fill;
     this._commandPrompt.ForeColor = Color.Cyan;
     this._commandPrompt.BackColor = Color.Black;
     this._commandPrompt.Font = new Font("Lucida Console", 8f);
     this._commandPrompt.TabIndex = 0;
     panel.BackColor = SystemColors.ControlDark;
     panel.Controls.Add(this._commandPrompt);
     panel.Dock = DockStyle.Fill;
     panel.DockPadding.All = 1;
     panel.TabIndex = 0;
     base.Controls.Add(panel);
     this.Text = "Command Shell";
     base.Icon = new Icon(typeof(CommandToolWindow), "CommandToolWindow.ico");
     panel.ResumeLayout(false);
     base.ResumeLayout(false);
 }
示例#32
0
        private void commandPrompt_Command(object sender, CommandPrompt.CommandEventArgs e)
        {
            if (e.Command == "cls")
            {
                commandPrompt.ClearMessages();
                e.Cancel = true;
                return;
            }

            if (e.Command == "exit")
            {
                Application.Exit();
            }

            if (e.Command == "date")
            {
                e.Message = "  The current date is : " +
                    DateTime.Now.ToLongDateString();
                return;
            }

            if (e.Command == "time")
            {
                e.Message = "  The current time is : " +
                    DateTime.Now.ToLongTimeString();
                return;
            }

            if (e.Command == "dir")
            {
                string msg = "";

                DirectoryInfo[] di = dirInfo.GetDirectories();
                foreach (DirectoryInfo d in di)
                {
                    msg += "  " + d.LastWriteTime.ToShortDateString()
                        + "\t" + d.LastWriteTime.ToShortTimeString()
                        + "\t<DIR>\t"
                        + "\t" + d.Name + "\n";
                }

                FileInfo[] fi = dirInfo.GetFiles();
                foreach (FileInfo f in fi)
                {
                    msg += "  " + f.LastWriteTime.ToShortDateString()
                        + "\t" + f.LastWriteTime.ToShortTimeString()
                        + "\t\t" + f.Length
                        + "\t" + f.Name + "\n";
                }
                e.Message = msg;
                return;
            }

            if (e.Command == "cd..")
            {
                if (dirInfo.Parent != null)
                    dirInfo = dirInfo.Parent;
                commandPrompt.PromptString = dirInfo.FullName + ">";
                return;
            }

            if (e.Command == "cd\\")
            {
                if (dirInfo.Root != null)
                    dirInfo = dirInfo.Root;
                commandPrompt.PromptString = dirInfo.FullName + ">";
                return;
            }

            if (e.Command.Length > 3 && e.Command.Substring(0, 2) == "cd")
            {
                if (e.Parameters.Length > 1)
                {
                    string path = e.Parameters[1];
                    string newDir = dirInfo.FullName + "\\" + path;

                    path = dirInfo.FullName;
                    dirInfo = new DirectoryInfo(newDir);
                    if (dirInfo.Exists == false)
                    {
                        dirInfo = new DirectoryInfo(path);
                        e.Message = "Could not find the specified path";
                    }
                    else
                        commandPrompt.PromptString = dirInfo.FullName + ">";

                    return;
                }
            }

            // Show error message
            e.Message = "'" + e.Command + "' is an unrecognized command";

            // Dont store the command
            e.Record = false;
        }
示例#33
0
        bool PerformPost(CommandID command, CommandPrompt prompt, object args)
        {
            IVsUIShell shell = UIShell;

            if (shell != null)
            {
                uint flags;
                switch (prompt)
                {
                    case CommandPrompt.Always:
                        flags = (uint)OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER;
                        break;
                    case CommandPrompt.Never:
                        flags = (uint)OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER;
                        break;
                    default:
                        flags = (uint)OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT;
                        break;
                }

                Guid set = command.Guid;
                object a = args;

                return VSConstants.S_OK == shell.PostExecCommand(ref set,
                        unchecked((uint)command.ID), flags, ref a);
            }

            return false;
        }
示例#34
0
        public bool PostExecCommand(CommandID command, object args, CommandPrompt prompt)
        {
            if (command == null)
                throw new ArgumentNullException("command");

            lock (_delayTasks)
            {
                if (_delayed)
                {
                    _delayTasks.Add(
                        delegate
                        {
                            PerformPost(command, prompt, args);
                        });

                    return true;
                }
                else if (PerformPost(command, prompt, args))
                {
                    for (int i = 0; i < _delayedCommands.Count; i++)
                    {
                        if (!PerformPost(new CommandID(AnkhId.CommandSetGuid, _delayedCommands[i]), CommandPrompt.DoDefault, null))
                        {
                            _delayedCommands.RemoveRange(0, i);
                            return true;
                        }
                    }
                    _delayedCommands.Clear();
                    return true;
                }
                else
                    return false;
            }
        }
示例#35
0
 public bool PostExecCommand(AnkhCommand command, object args, CommandPrompt prompt)
 {
     return PostExecCommand(new CommandID(AnkhId.CommandSetGuid, (int)command), args, prompt);
 }
示例#36
0
        public CommandResult DirectlyExecCommand(AnkhCommand command, object args, CommandPrompt prompt)
        {
            // TODO: Assert that we are in the UI thread

            CommandMapper mapper = GetService<CommandMapper>();

            if (mapper == null)
                return new CommandResult(false, null);

            CommandEventArgs e = new CommandEventArgs(command, AnkhContext, args, prompt == CommandPrompt.Always, prompt == CommandPrompt.Never);
            bool ok = mapper.Execute(command, e);

            return new CommandResult(ok, e.Result);
        }
示例#37
0
        private void SendRequest()
        {
            //Check for Makefile
            if (!Files.Contains("Makefile"))
            {
                //Prompt for command
                cp = new CommandPrompt();
                cp.Show();
                return;
            }

            Writer.WriteLine(JsonConvert.SerializeObject(new Request(Files.Length > 0)));
            Writer.Flush();

            ReqResp resp = JsonConvert.DeserializeObject<ReqResp>(Reader.ReadLine());

            m_cids.Add(resp.cid);
            cid = resp.cid;

            //Wait for Response to see if Steve can handle the request
            //Todo: actually use objects instead of this way
            string ack = Reader.ReadLine();

            if (ack.Contains("CompAck") && ack.Contains(resp.cid))
            {
                //TODO: Change when security is implemented
                Writer.WriteLine(ack.Replace("CompAck", "CompAccept"));
                Writer.Flush();
            }
            else
            {
                //Dunno
            }

            m_TftpClient = new TFTPClient(resp.port, IP);

            DoFileCreate();
        }