示例#1
0
        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);
                    }
                }
            }
        }
示例#2
0
        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);
            }
        }