Exemplo n.º 1
0
 private void RunInput(object sender, EventArgs e)
 {
     TMain.Text = TMain.Text.Replace(" ", "");
     TMain.Select(TMain.Text.Length, 0);
     if (TMain.Text.Length < SearchAfterHowManyCharInputed)
     {
         LFileName.Text  = "";
         LPath.Text      = "";
         LArguments.Text = "";
         InputResult     = new List <string[]>();
         return;
     }
     try {
         string sql = $@"
             select * from (
                 select 
                     '[CMD]' || c.name as c0,
                     c.code as c1,
                     c.discrib as c2
                 from customizeCommand c
                 where c.name like '%{ TMain.Text }%'
                 union all
                 select
                     f.fileMainName as c0,
                     f.path as c1,
                     (select a.args from arguments a where a.fileMainName = f.fileMainName and a.path = f.path) as c2
                 from files f
                 where (
                         f.fileMainName like '%{ TMain.Text }%'
                         or f.fileDiscrib like '%{ TMain.Text }%'
                         or f.pinyin like '%{ TMain.Text }%'
                     )
                     and f.fileExtension like '%{ FileType }%'
             ) g
             order by (select count(l.runTime) from runLog l where l.fileMainName = g.c0 and l.path = g.c1 ) desc;
         ";
         InputResult = DBLinker.ExecuteToList(sql);
         if (InputResult.Count == 0)
         {
             LFileName.Text  = "NO FILE";
             LPath.Text      = ENABLE_WEB_SEARCH ? "Ctrl + Enter Search on Web." : "Try to reload the dictionary.";
             LArguments.Text = "";
             return;
         }
         LFileName.Text  = InputResult[0][0];
         LPath.Text      = InputResult[0][1];
         LArguments.Text = InputResult[0][2] == "" ? "(No Args)" : "(" + InputResult[0][2] + ")";
     } catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }