internal static void PushErrorInfo(ErrorInfo singleInfo) { lock (g_ErrInfos) { g_ErrInfos.Push(singleInfo); } }
/// <summary> /// 命令解析执行线程方法. /// </summary> /// <param name="obj">命令对象.</param> private static void StartFindThread(object obj) { CommanderData cmdObj = obj as CommanderData; bool bParsed = false;//命令被解析标志 if (cmdObj == null) return; try { if (cmdObj.IsRunDirectly == true) { //运行时用ParsedCmd cmdObj.ParsedCmd = cmdObj.Cmd; ProgExecuter.Execute(cmdObj); } else { ////大多数情况下都没有空格,如果含有空格,说明可能有参数,该判断为提高性能用 //int iPos = cmdObj.Cmd.IndexOf(" "); //if (iPos != -1) //{ // //解析输入命令、参数 // ParseCommand(cmdObj.Cmd, cmdObj); // //有空格且为完整路径直接执行程序,Cmd无用;如果为快捷命令,则进行提取 // cmdObj.Cmd = cmdObj.ParsedCmd.Substring(0, iPos); // cmdObj.Description = cmdObj.Cmd; // bParsed = true; //} //查找程序 System.Collections.Generic.List<ConfigData> datas = GlobalVar.Instanse.FindCommand(cmdObj.Cmd); if(datas == null) { datas = new System.Collections.Generic.List<ConfigData>(); ConfigData data = new ConfigData(); data.Path = cmdObj.Cmd; data.Title = cmdObj.Description; data.Shortcut = cmdObj.Cmd; datas.Add(data); } else if (datas.Count == 0) { return; } foreach(ConfigData data in datas) { //如果上面已经调用过,还需要将data.Path中的参数解析出来 ParseCommand(data.Path, cmdObj); //bParsed = true; cmdObj.Description = data.Title; //if (bParsed == false) //{ // //解析输入命令、参数 // ParseCommand(cmdObj.Cmd, cmdObj); //} //这里的判断有待改进 if (cmdObj.ParsedCmd != string.Empty && cmdObj.ParsedCmd[0] == INNERSTART && cmdObj.ParsedCmd[cmdObj.ParsedCmd.Length - 1] == INNEREND) { string sExtCmd = ParseExtCmd(cmdObj.ParsedCmd); ProgExecuter.ExecExtCmd(sExtCmd, cmdObj); } else ProgExecuter.Execute(cmdObj); } } } catch (ExtCommandLineBrokenException) { } catch (Exception ex) { ErrorInfo ei = new ErrorInfo(cmdObj.Cmd, ex.Message); GlobalVar.PushErrorInfo(ei); GlobalVar.Instanse.MainVisitor.Visit(ex.Message); } }