Пример #1
0
        public async Task <IEnumerable <string> > GetDatabases(ConnectionProperties connectionProperties)
        {
            var result = await _scriptService.GetScriptExecutor(connectionProperties)
                         .ExecuteScript <string>("select name from sys.databases");

            return(result.GetResult());
        }
Пример #2
0
        public async Task <ActionResult <ScriptMultipleResult> > ExecuteScript([FromBody] ExecuteScriptDto executeScript)
        {
            var executor =
                await _scriptService.GetScriptExecutor(executeScript.ConnectionId, executeScript.Database);

            var param  = _mapper.Map <IEnumerable <Parameter> >(executeScript.Params);
            var script = await _work.ScriptRepository.Get(executeScript.ScriptId);

            if (script == null)
            {
                return(NotFound());
            }
            var result = await executor.ExecuteScriptMultiple(script.Body, param);

            return(result);
        }
Пример #3
0
        private async Task ExecuteScript(Job job, Script script, JobExecutionContext context)
        {
            var connection = await GetConnection(context.ConnectionId);

            var executor  = _scriptService.GetScriptExecutor(connection);
            var startTime = DateTime.Now;
            var result    = await executor.ExecuteScriptMultiple(script.Body, Job.Parameters);

            var finishTime = DateTime.Now;
            var logRecord  = new JobLog {
                JobId      = Job.Id,
                Context    = context,
                StartTime  = startTime,
                FinishTime = finishTime,
                Result     = result
            };
            await _unitOfWork.JobLogRepository.Insert(logRecord);
        }