Пример #1
0
        // Called for user events or special UI interaction
        public static bool ShellUserEvent(string filename, string arguments, bool waitEnd)
        {
            /* <2.17.3
             * List<string> args = UtilsString.StringToList(arguments, " ", true, true, false, false);
             * Shell(path, args.ToArray(), waitEnd);
             */

            if (ShellExternalManager.CheckAllow(filename) == false)
            {
                return(false);
            }

            return(Platform.Instance.ShellExecuteCore(filename, arguments, waitEnd));
        }
Пример #2
0
        public bool Run()
        {
            m_id++;

            if (Path == "")
            {
                return(false);
            }

            if (ShellExternalManager.CheckAllow(Path) == false)
            {
                return(false);
            }


            string path = Path;

            string[] args = Arguments.ToArray();

            if (WaitEnd)
            {
                bool log = ((NoDebugLog == false) && (Engine.Instance != null) && (Engine.Instance.Storage != null) && (Engine.Instance.Storage.GetBool("log.level.debug")));

                if (log)
                {
                    string message = "Shell(" + m_id + ") of '" + path + "'";
                    if (Arguments.Count > 0)
                    {
                        message += ", " + Arguments.Count.ToString() + " args: ";
                        foreach (string arg in args)
                        {
                            message += "'" + arg + "';";
                        }
                    }
                    message = message.RegExReplace("[a-zA-Z0-9+/]{30,}=", "{base64-omissis}");
                    Engine.Instance.Logs.Log(LogType.Verbose, message);
                }

                int startTime = Environment.TickCount;

                Platform.Instance.ShellSyncCore(path, args, AutoWriteStdin, out StdOut, out StdErr, out ExitCode);

                int endTime = Environment.TickCount;

                if (log)
                {
                    int    deltaTime = endTime - startTime;
                    string message   = "Shell(" + m_id + ") done in " + deltaTime.ToString() + " ms";
                    message += ", exit: " + ExitCode.ToString();
                    if (StdOut != "")
                    {
                        message += ", out: '" + StdOut + "'";
                    }
                    if (StdErr != "")
                    {
                        message += ", err: '" + StdErr + "'";
                    }
                    message = message.RegExReplace("[a-zA-Z0-9+/]{30,}=", "{base64-omissis}");
                    Engine.Instance.Logs.Log(LogType.Verbose, message);
                }

                if (ExceptionIfFail)
                {
                    if (ExitCode != 0)
                    {
                        if (StdErr != "")
                        {
                            throw new Exception(StdErr);
                        }
                        else
                        {
                            throw new Exception(LanguageManager.GetText("Failed"));
                        }
                    }
                }

                return(ExitCode == 0);
            }
            else
            {
                Platform.Instance.ShellASyncCore(path, args);
                return(true);
            }
        }