Beispiel #1
0
        /// <summary>
        /// 运行脚本
        /// </summary>
        /// <param name="script"></param>
        public bool Run(string script)
        {
            ContextManager.SetTaskInvokerContext(this.Context);
            this._innerSE.Execute(script);
            this._innerSE.Execute(@"function ______tryParse(){ 
try{
    var result = parse();
    if(result == undefined || result == 1 || result == true){
        return 'OK';
    }
    else{
        return 'parse is not return 1 or true';
    }     
}catch(e){
    return e.message;
}}");
            // 执行任务
            var execRest = this._innerSE.Invoke("______tryParse");

            if (execRest.ToString() == "OK")
            {
                return(true);
            }
            LoggerProxy.Error("taskTester", "执行任务失败," + execRest.ToString());
            return(false);
        }
 /// <summary>
 /// 绑定任务执行上下文
 /// </summary>
 private void BindContext()
 {
     if (!this._boundContxt)
     {
         ContextManager.SetTaskInvokerContext(this.Context);
         this._boundContxt = true;
     }
 }