public async Task <ServerCommandResult> Execute(RequestCommand cmd, ExpandoObject dataToExec)
        {
            var r    = new ServerCommandResult();
            var qm   = _messaging.CreateQueuedMessage();
            var prms = cmd.parameters;

            qm.Key      = prms.Get <String>("key");
            qm.Template = prms.Get <String>("template");
            qm.TargetId = Int64.Parse(cmd.Id);
            qm.Source   = "ServerCommand";
            qm.Parameters.Append(dataToExec);
            bool immediately = true;

            if (prms.HasProperty(nameof(immediately)))
            {
                immediately = prms.Get <Boolean>(nameof(immediately));
            }
            long msgId = await _messaging.QueueMessageAsync(qm, immediately);

            if (immediately)
            {
                await _messaging.SendMessageAsync(msgId);
            }
            r.Data = $"{{\"status\":\"success\", \"id\":{msgId}}}";
            return(r);
        }
        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);
        }