public PagedQueryResultModel ProcessSqlScript([FromBody] SavedScriptProcessModel script)
 {
     if (!User.IsInRole("Administrator"))
     {
         script.ConnectionStringName = User.Claims.FirstOrDefault(x => x.Type == "Entity").Value.Substring(0, 3);
     }
     return(dataManager.ProcessSavedSqlScript(script));
 }
Example #2
0
        public async Task Export([FromBody] SavedScriptProcessModel model)
        {
            if (!User.IsInRole("Administrator"))
            {
                model.ConnectionStringName = User.Claims.FirstOrDefault(x => x.Type == "Entity").Value.Substring(0, 3);
            }
            var data          = dataManager.ProcessSavedSqlScript(model, true);
            var bytesInStream = await ConvertResultToByteArray(data);

            if (bytesInStream.Length > 0)
            {
                HttpContext.Response.ContentType = "application/force-download";
                var name = $"attachment; filename=Data-{DateTime.UtcNow:s}.csv";
                HttpContext.Response.Headers.Add("content-disposition", name);
                await HttpContext.Response.Body.WriteAsync(bytesInStream, 0, bytesInStream.Length);
            }
        }
        public PagedQueryResultModel ProcessSavedSqlScript(SavedScriptProcessModel script, bool getAllRecords = false)
        {
            var savedScript = dal.ProcessSavedSqlScript(script.Id);

            savedScript.PaginationModel = script.Pagination;
            if (getAllRecords)
            {
                savedScript.PaginationModel.PageSize   = int.MaxValue;
                savedScript.PaginationModel.PageNumber = 1;
            }
            savedScript.ConnectionStringName = script.ConnectionStringName;
            var scriptModel = new SqlScriptModel
            {
                SqlRequest = savedScript,
                Parameters = script.Parameters
            };
            var result = tableDataManager.ProcessSqlScript(scriptModel);

            return(result);
        }