public IActionResult GetReport([FromBody] ReportRequestDto reportRequest) { ReportTemplateLoader loader = new ReportTemplateLoader(); StiReport report = new StiReport(); IDataProvider provider = null; try { loader.Load(report, reportRequest.Report); if (reportRequest.DataProvider.ToLower() == "xml") { provider = new XmlFileDataProvider(reportRequest.Data["filename"].Value <string>()); report.RegData(provider.GetData()); } else if (reportRequest.DataProvider.ToLower() == "database") { StimulsoftRepository repository = new StimulsoftRepository(); ReportSettings reportSettings = repository.GetReportSettings(reportRequest.Report); foreach (var tableName in reportSettings.TableNames) { provider = new DatabaseDataProvider(tableName, reportSettings.ConnectionString, reportRequest.Data); report.RegData(provider.GetData()); } } else if (reportRequest.DataProvider.ToLower() == "url") { provider = new UrlDataProvider("URL"); report.RegData(provider.GetData()); } ExportFormat exporter = new ExportFormat(); return(exporter.ExportReport(report, reportRequest.Output.ToLower())); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
///<Summary>, /// Convert method - NEW ///</Summary> public Response Merge(string[] files, string outputType) { var workingFolder = string.Empty; try { Dictionary <string, string> Params = new Dictionary <string, string>(); Params.Add("inputType", Path.GetExtension(files[0]).Replace(".", "")); Params.Add("outputType", outputType); using (var service = new SVGService()) using (new SVGOperationContextScope(service, Params)) { workingFolder = SVGOperationContextScope.Context.InputFolder; using (var dataProvider = new UrlDataProvider(files)) { var data = dataProvider.GetData(); if (data.Count(x => x.IsValid()) == 0) { return(BadDocumentResponse); } if (data.Count(x => x.IsValid()) > MaximumUploadFiles) { return(MaximumFileLimitsResponse); } // SVGOperationContextScope.Context.DeleteSourceFolder = true; var options = SVGOperationContextScope .Context .ApplicationOptionsFactory .CreateMergerOptions(); var result = service.Merge(dataProvider, options); if (!result.IsValid) { string message; switch (result.ErrorCode) { case ErrorCodes.InvalidInputFormat: message = $"Input type '{options.InputFormat}' is not supported."; break; case ErrorCodes.InvalidOutputFormat: message = $"Output type '{options.InputFormat}' is not supported."; break; case ErrorCodes.MergingIsNotAllowed: message = $"Document merging is not supported for the '{options.OutputFormat}' format."; break; case ErrorCodes.NotEnoughFilesToPerformOperation: message = "Merging is required more than one input file."; break; case ErrorCodes.DocumentLoadError: case ErrorCodes.DocumentRenderingError: default: message = $"Document processing error."; break; } return(new Response { FileName = null, Status = message, StatusCode = 500 }); } return(new Response { FileName = Path.GetFileName(result.DataFiles.First()), FolderName = $"{SVGOperationContextScope.Context.Id}", Status = "OK", StatusCode = 200, }); } } } catch (SecurityException ex) { Console.WriteLine(ex.Message); return(new Response { FileName = null, Status = $"Document processing error.", StatusCode = 500 }); } catch (Exception ex) { Console.WriteLine(ex.Message); return(new Response { FileName = null, Status = $"Document processing error.", StatusCode = 500 }); } }
public Response Merge(InputFiles files, string outputType) { try { List <string> FileNames = new List <string>(); foreach (InputFile inputFile in files) { FileNames.Add(inputFile.LocalFileName); } using (var service = new HTMLService()) using (new HTMLOperationContextScope(service, new HttpRequestMessage())) using (var dataProvider = new UrlDataProvider(FileNames.ToArray())) { var data = dataProvider.GetData(); if (data.Count(x => x.IsValid()) == 0) { return(BadDocumentResponse); } if (data.Count(x => x.IsValid()) > MaximumUploadFiles) { return(MaximumFileLimitsResponse); } // HTMLOperationContextScope.Context.DeleteSourceFolder = true; var options = HTMLOperationContextScope .Context .ApplicationOptionsFactory .CreateMergerOptions(); var result = service.Merge(dataProvider, options); if (!result.IsValid) { string message; switch (result.ErrorCode) { case ErrorCodes.InvalidInputFormat: message = $"Input type '{options.InputFormat}' is not supported."; break; case ErrorCodes.InvalidOutputFormat: message = $"Output type '{options.InputFormat}' is not supported."; break; case ErrorCodes.MergingIsNotAllowed: message = $"Document merging is not supported for the '{options.OutputFormat}' format."; break; case ErrorCodes.NotEnoughFilesToPerformOperation: message = "Merging is required more than one input file."; break; case ErrorCodes.SystemException: message = $"Document processing error."; break; case ErrorCodes.DocumentLoadError: case ErrorCodes.DocumentRenderingError: default: message = $"Document processing error."; break; } return(new Response { FileName = null, Status = message, StatusCode = 500 }); } return(new Response { FileName = Path.GetFileName(result.DataFiles.First()), FolderName = $"{HTMLOperationContextScope.Context.Id}", Status = "OK", StatusCode = 200, }); } } catch (Exception e) { return(new Response { FileName = null, Status = $"Document processing error.", StatusCode = 500 }); } }