private object BuildScriptWebModel(UserScript script)
        {
            if (script == null)
                return null;

            return new
            {
                Id = script.Id,
                Name = script.Name
            };
        }
 /// <summary>
 /// Запуск скриптов (для плагинов)
 /// </summary>
 /// <param name="script"></param>
 /// <param name="args"></param>
 public void ExecuteScript(UserScript script, params object[] args)
 {
     ExecuteScript(script, scriptHost, Logger, args);
 }
        /// <summary>
        /// Запуск скрипта
        /// </summary>
        private static void ExecuteScript(UserScript script, ScriptHost scriptHost, Logger logger, object[] args)
        {
            //Debugger.Launch();
            try
            {
                //var engine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging);
                var engine = new JScriptEngine();
                engine.AddHostObject("host", scriptHost);

                string initArgsScript = string.Format("var arguments = {0};", args.ToJson("[]"));
                engine.Execute(initArgsScript);
                engine.Execute(script.Body);
            }
            catch (Exception ex)
            {
                var messge = string.Format("Error in user script {0}", script.Name);
                logger.Error(ex, messge);
            }
        }
        public object BuildScriptRichWebModel(UserScript script)
        {
            if (script == null)
                return null;

            return new {
                Id = script.Id,
                Name = script.Name,
                Body = script.Body
            };
        }