public void Process(string tableName) { _tableName = tableName; _tables.Clear(); var procOutput = new StringOutput(); var proc = new ProcessRunner(); proc.CaptureOutput = true; proc.CaptureError = false; var ret = proc.CaptureProcess("pst", "/v " + tableName, ProbeEnvironment.ExeDir, procOutput); if (ret != 0) throw new ProbeException(string.Concat("PST returned error code ", ret, ".")); _parser = new TokenParser.Parser(StripImplicitComments(procOutput.Text)); while (_parser.Read()) { if (_parser.TokenText == "create") { if (ReadCreateTable()) { } else if (ReadCreateIndex()) { } else if (ReadCreateRelationship()) { } else if (ReadCreateTimeRelationship()) { } else { ProbeNppPlugin.Instance.Output.WriteLine(OutputStyle.Warning, "Unknown token '{0}' in PST output for table '{1}'.", _parser.TokenText, tableName); } } } }
public void PstTable() { try { using (PromptForm dlg = new PromptForm()) { string selected = SelectedText; if (!string.IsNullOrEmpty(selected) && ProbeEnvironment.IsProbeTable(selected)) { dlg.Value = selected; } dlg.Text = "PST Table"; dlg.Prompt = "Enter the name of the table to PST:"; if (dlg.ShowDialog(_nppWindow) == DialogResult.OK) { string tableName = dlg.Value; ProcessRunner pr = new ProcessRunner(); StringOutput output = new StringOutput(); int exitCode = pr.CaptureProcess("pst.exe", tableName, ProbeEnvironment.TempDir, output); if (exitCode != 0) { Errors.ShowExtended(_nppWindow, string.Format("PST returned exit code {0}.", exitCode), output.Text); } else { string tempFileName = TempManager.GetNewTempFileName(tableName, ".pst"); File.WriteAllText(tempFileName, output.Text); OpenFile(tempFileName); } } } } catch (Exception ex) { Errors.Show(_nppWindow, ex); } }
public void FecFile() { try { string baseFileName = ProbeEnvironment.FindBaseFile(ActiveFileName); if (string.IsNullOrEmpty(baseFileName)) { MessageBox.Show("Base file could not be found."); return; } string fileName; using (TempFileOutput output = new TempFileOutput( Path.GetFileNameWithoutExtension(baseFileName) + "_fec", Path.GetExtension(baseFileName))) { ProcessRunner pr = new ProcessRunner(); int exitCode = pr.CaptureProcess("fec.exe", "/p \"" + baseFileName + "\"", Path.GetDirectoryName(baseFileName), output); if (exitCode != 0) { Errors.Show(NppWindow, "FEC returned exit code {0}.", exitCode); return; } fileName = output.FileName; } OpenFile(fileName); } catch (Exception ex) { Errors.Show(NppWindow, ex); } }
public void CompileToVisualC() { try { string baseFileName = ProbeEnvironment.FindBaseFile(ActiveFileName); if (string.IsNullOrEmpty(baseFileName)) { MessageBox.Show("Base file could not be found."); return; } var pr = new ProcessRunner(); int exitCode = pr.ExecuteProcess("fec.exe", string.Concat("\"", baseFileName, "\""), Path.GetDirectoryName(baseFileName), true); if (exitCode != 0) { Errors.Show(NppWindow, "FEC returned exit code {0}.", exitCode); return; } var cFileName = Path.Combine(Path.GetDirectoryName(baseFileName), string.Concat(Path.GetFileNameWithoutExtension(baseFileName), ".c")); if (!File.Exists(cFileName)) { Errors.Show(NppWindow, "Unable to find .c file produced by FEC."); return; } OpenFile(cFileName); } catch (Exception ex) { Errors.Show(NppWindow, ex); } }
private bool RunSam() { if (_plugin.Settings.RunSamCam.SetDbDate) { ProcessRunner pr = new ProcessRunner(); int exitCode = pr.ExecuteProcess("setdbdat", "today force", ProbeEnvironment.TempDir, true); if (exitCode != 0) { Errors.Show(this, "\"setdbdat today force\" returned exit code {0}.\n\n" + "(The SAM will still start, but the dbdate may be incorrect)", exitCode); } } StringBuilder args = new StringBuilder(); args.Append(string.Format("/N{0}", CleanSamName(string.Concat(ProbeEnvironment.CurrentApp, "_", System.Environment.UserName)))); args.Append(string.Format(" /p{0}", ProbeEnvironment.SamPort)); args.Append(" /o0"); args.Append(string.Format(" /y{0:00}{1:00}", _plugin.Settings.RunSamCam.TransReportTimeout, _plugin.Settings.RunSamCam.TransAbortTimeout)); args.Append(string.Format(" /z{0}", _plugin.Settings.RunSamCam.MinChannels)); args.Append(string.Format(" /Z{0}", _plugin.Settings.RunSamCam.MaxChannels)); if (_plugin.Settings.RunSamCam.Diags) args.Append(" /d2"); using (Process proc = new Process()) { ProcessStartInfo info = new ProcessStartInfo("sam", args.ToString()); info.UseShellExecute = false; info.RedirectStandardOutput = false; info.RedirectStandardError = false; info.CreateNoWindow = false; info.WorkingDirectory = ProbeEnvironment.ExeDir; proc.StartInfo = info; if (!proc.Start()) { Errors.Show(this, "Unable to start the SAM."); return false; } } if (_plugin.Settings.RunSamCam.LoadSam && !_plugin.Settings.RunSamCam.Diags) RunLoadSam(); return true; }
private static void ReloadTableList() { // The function that calls this already has _lock locked. try { _tables.Clear(); _autoCompletionTables = null; ProcessRunner pr = new ProcessRunner(); CallbackOutput output = new CallbackOutput(GetTableList_Callback); int exitCode = pr.CaptureProcess("ptd.exe", "", TempDir, output); } catch (Exception ex) { Plugin.Output.WriteLine(OutputStyle.Error, "Exception when reloading Probe table list: {0}", ex); } }
public ProcessRunnerThread(ProcessRunner runner, bool doErrors, Process proc) { _runner = runner; _doErrors = doErrors; _proc = proc; }