Example #1
0
        public CodeResponse ExecuteCode(CodeRequest input)
        {
            var sw = new Stopwatch();

            sw.Start();
            var newInput = _fragmentService.Fix(input.Text);

            var assmName = Guid.NewGuid().ToIdentifierWithPrefix("a");
            var implName = Guid.NewGuid().ToIdentifierWithPrefix("UserCodeImpl");

            var programSource = CodeTemplate
                                .Replace("##SOURCE##", newInput.Text)
                                .Replace("##NS##", assmName)
                                .Replace("##IMPLNAME##", implName);

            var compileResult = _hostService.StartGenerated(input.Id, programSource, assmName);

            return(new CodeResponse
            {
                Id = Guid.NewGuid(),
                Created = DateTime.Now,
                Diagnostics = compileResult.Diagnostics,
                Code = compileResult.Code
            });
        }
Example #2
0
        public async Task <QueryResponse> ExecuteQuery(QueryRequest input)
        {
            var newInput      = _fragmentService.Fix(input.Text);
            var contextResult = await _databaseContextService.GetDatabaseContext(input.ConnectionString, input.ServerType);

            if (contextResult.Code != Api.StatusCode.Ok)
            {
                return(new QueryResponse {
                    Code = contextResult.Code, Message = contextResult.Message
                });
            }
            var assmName      = Guid.NewGuid().ToIdentifierWithPrefix("a");
            var implName      = Guid.NewGuid().ToIdentifierWithPrefix("UserCodeImpl");
            var programSource = CodeTemplate
                                .Replace("##NS##", assmName)
                                .Replace("##SCHEMA##", "") // schema is linked
                                .Replace("##DB##", contextResult.Type.ToString())
                                .Replace("##IMPLNAME##", implName)
                                .Replace("##SOURCE##", newInput.Text);

            var compileResult = _hostService.StartGenerated(input.Id, programSource, assmName, contextResult.Reference);

            return(new QueryResponse
            {
                Id = Guid.NewGuid(),
                Created = DateTime.Now,
                Diagnostics = compileResult.Diagnostics,
                Code = compileResult.Code
            });
        }