Пример #1
0
        protected override object Execute(object value, out bool isHandled)
        {
            isHandled = false;
            if (ScriptFilePath.IsNullOrWhiteSpace())
            {
                return(value);
            }

            string scriptFilePath   = ResolveText(ScriptFilePath);
            string arguments        = !Arguments.IsNullOrWhiteSpace() ? "{0} {1}".FormatString(value.ToNString(), ResolveText(Arguments)) : value.ToNString();
            string workingDirectory = WorkingDirectory.IsNullOrWhiteSpace() ? ChoApplication.ApplicationBaseDirectory : ResolveText(WorkingDirectory);

            //Create temp script file
            _tmpFileName = ResolveFileText(ref scriptFilePath);

            using (ChoProcess p = new ChoProcess("cscript.exe", "{0} {1} //Nologo".FormatString(scriptFilePath, arguments)))
            {
                p.WorkingDirectory = workingDirectory;
                return(p.Execute().StdOut);
            }
        }
Пример #2
0
        protected override object Execute(object value, out bool isHandled)
        {
            isHandled = false;
            if (Script.IsNullOrWhiteSpace())
            {
                return(value);
            }

            string script           = ResolveText(Script);
            string arguments        = !Arguments.IsNullOrWhiteSpace() ? "{0} {1}".FormatString(value.ToNString(), ResolveText(Arguments)) : value.ToNString();
            string workingDirectory = WorkingDirectory.IsNullOrWhiteSpace() ? ChoApplication.ApplicationBaseDirectory : ResolveText(WorkingDirectory);

            //Create temp script file
            _tmpFileName = Path.ChangeExtension(ChoPath.GetTempFileName(), ChoReservedFileExt.JS);
            File.WriteAllText(_tmpFileName, script);
            ChoTrace.DebugFormat("{0}: Temp file created at '{1}'", Name, _tmpFileName);

            using (ChoProcess p = new ChoProcess("cscript.exe", "{0} {1} //Nologo".FormatString(_tmpFileName, arguments)))
            {
                p.WorkingDirectory = workingDirectory;

                return(p.Execute().StdOut);
            }
        }