Ejemplo n.º 1
0
        public void TestPst()
        {
            var dlg = new PromptForm();
            dlg.Prompt = "Table name:";
            if (dlg.ShowDialog(NppWindow) == DialogResult.OK)
            {
                MenuCommand(NppSharp.MenuCommand.FileNew);

                var parser = new PstParser();
                parser.Process(dlg.Value);

                foreach (var table in parser.Tables)
                {
                    Insert("Table: " + table.Name + "\r\n");
                    foreach (var field in table.Fields) Insert("  - " + field.Name + "\r\n");
                }

                if (parser.RelInds.Any())
                {
                    Insert("RelInds:\r\n");
                    foreach (var relind in parser.RelInds) Insert("  - " + relind.Name + "\r\n");
                }

                Insert("\r\n\r\n");
                Insert(parser.Source);
            }
        }
Ejemplo n.º 2
0
 public void TestPstEveryTable()
 {
     foreach (var table in ProbeEnvironment.Tables)
     {
         ProbeNppPlugin.Instance.Output.WriteLine(OutputStyle.NotImportant, "PST-ing table: {0}", table.Name);
         var parser = new PstParser();
         parser.Process(table.Name);
     }
 }
Ejemplo n.º 3
0
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
        //private void LoadFields()
        //{
        //    try
        //    {
        //        _fields = new Dictionary<string, ProbeField>();
        //        var pstFileName = ProbeEnvironment.LocateFileInPath("pst.exe");
        //        if (!string.IsNullOrEmpty(pstFileName))
        //        {
        //            var callbackOutput = new CallbackOutput();
        //            callbackOutput.Callback = (line) =>
        //                {
        //                    // Field Name:   0 -> 39
        //                    // Prompt:      40 -> 79
        //                    // Comment:     80 -> 149
        //                    // DataType:   150 -> end
        //                    if (line.Length < 150) return;
        //                    var name = line.Substring(0, 40).Trim();
        //                    if (string.IsNullOrEmpty(name)) return;
        //                    _fields[name] = new ProbeField(this, name, line.Substring(40, 40).Trim(),
        //                        line.Substring(80, 70).Trim(), line.Substring(150).Trim());
        //                };
        //            var runner = new ProcessRunner();
        //            runner.CaptureProcess(pstFileName, string.Concat("/c ", _name),
        //                Path.GetDirectoryName(pstFileName), callbackOutput);
        //        }
        //    }
        //    catch (Exception)
        //    { }
        //}
        private void LoadFields()
        {
            _fields = new Dictionary<string, ProbeField>();
            var parser = new PstParser();
            parser.Process(_name);
            foreach (var table in parser.Tables)
            {
                if (table.Name == _name)
                {
                    foreach (var field in table.Fields) _fields[field.Name] = field;
                }
            }

            _relInds = new HashSet<string>();
            foreach (var relInd in parser.RelInds) _relInds.Add(relInd.Name);
            ProbeEnvironment.RefreshRelInds();
        }