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); } }
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); } }