Exemplo n.º 1
0
        public async Task <ServerCommandResult> Execute(RequestCommand cmd, ExpandoObject dataToExec)
        {
            if (String.IsNullOrEmpty(cmd.procedure))
            {
                throw new RequestModelException("A procedure must be specified for sql-type command");
            }
            IDataModel model = await _dbContext.LoadModelAsync(cmd.CurrentSource, cmd.CommandProcedure, dataToExec, cmd.commandTimeout);

            //_host.CheckTypes(cmd.Path, cmd.checkTypes, model);

            String invokeTarget = cmd.GetInvokeTarget();

            if (invokeTarget != null)
            {
                var clr = new ClrInvoker();
                clr.EnableThrow();
                clr.Invoke(invokeTarget, dataToExec);                 // after execute
            }
            var r = new ServerCommandResult();

            if (model == null)
            {
                r.Data = "{}";
            }
            else
            {
                r.Data = JsonConvert.SerializeObject(model.Root, JsonHelpers.StandardSerializerSettings);
            }
            return(r);
        }
Exemplo n.º 2
0
        async Task ExecuteSqlCommand(RequestCommand cmd, ExpandoObject dataToExec, TextWriter writer)
        {
            if (String.IsNullOrEmpty(cmd.procedure))
            {
                throw new RequestModelException("A procedure must be specified for sql-type command");
            }
            IDataModel model = await _dbContext.LoadModelAsync(cmd.CurrentSource, cmd.CommandProcedure, dataToExec, cmd.commandTimeout);

            String invokeTarget = cmd.GetInvokeTarget();

            if (invokeTarget != null)
            {
                var clr = new ClrInvoker();
                clr.EnableThrow();
                clr.Invoke(invokeTarget, dataToExec);                 // after execute
            }
            WriteDataModel(model, writer);
        }