From 540d021e27e7003d64f1ce85be8278cfe2780ea7 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 10 Mar 2020 16:33:28 +0100 Subject: [PATCH] WIP: ZugferdRESTService --- DDMonorepo.sln | 9 ++++ .../ZugferdValidationController.cs | 53 ++++++++++++++++++ .../IZugferdValidationDataService.cs | 11 ++++ .../ZUGFeRDRESTService/Pages/Index.cshtml | 16 ++++++ .../ZUGFeRDRESTService/Pages/Index.cshtml.cs | 17 ++++++ WEBSERVICES/ZUGFeRDRESTService/Program.cs | 26 +++++++++ .../Properties/launchSettings.json | 30 +++++++++++ WEBSERVICES/ZUGFeRDRESTService/Startup.cs | 54 +++++++++++++++++++ .../ZUGFeRDRESTService.csproj | 13 +++++ .../ZugferdValidationDataService.cs | 11 ++++ .../appsettings.Development.json | 9 ++++ .../ZUGFeRDRESTService/appsettings.json | 10 ++++ 12 files changed, 259 insertions(+) create mode 100644 WEBSERVICES/ZUGFeRDRESTService/Controllers/ZugferdValidationController.cs create mode 100644 WEBSERVICES/ZUGFeRDRESTService/IZugferdValidationDataService.cs create mode 100644 WEBSERVICES/ZUGFeRDRESTService/Pages/Index.cshtml create mode 100644 WEBSERVICES/ZUGFeRDRESTService/Pages/Index.cshtml.cs create mode 100644 WEBSERVICES/ZUGFeRDRESTService/Program.cs create mode 100644 WEBSERVICES/ZUGFeRDRESTService/Properties/launchSettings.json create mode 100644 WEBSERVICES/ZUGFeRDRESTService/Startup.cs create mode 100644 WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj create mode 100644 WEBSERVICES/ZUGFeRDRESTService/ZugferdValidationDataService.cs create mode 100644 WEBSERVICES/ZUGFeRDRESTService/appsettings.Development.json create mode 100644 WEBSERVICES/ZUGFeRDRESTService/appsettings.json diff --git a/DDMonorepo.sln b/DDMonorepo.sln index 84d2659d..14eaac25 100644 --- a/DDMonorepo.sln +++ b/DDMonorepo.sln @@ -104,6 +104,10 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GUIs.Test.DocumentViewerTes EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DDEmailService", "DDEmailService\DDEmailService.vbproj", "{83ED2617-B398-4859-8F59-B38F8807E83E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebServices", "WebServices", "{D3BAE68E-406E-493D-A4E5-DB6EDDFFB371}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZUGFeRDRESTService", "WEBSERVICES\ZUGFeRDRESTService\ZUGFeRDRESTService.csproj", "{FD50590A-59C1-4798-AD90-419A588DCE76}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -270,6 +274,10 @@ Global {83ED2617-B398-4859-8F59-B38F8807E83E}.Debug|Any CPU.Build.0 = Debug|Any CPU {83ED2617-B398-4859-8F59-B38F8807E83E}.Release|Any CPU.ActiveCfg = Release|Any CPU {83ED2617-B398-4859-8F59-B38F8807E83E}.Release|Any CPU.Build.0 = Release|Any CPU + {FD50590A-59C1-4798-AD90-419A588DCE76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD50590A-59C1-4798-AD90-419A588DCE76}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD50590A-59C1-4798-AD90-419A588DCE76}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD50590A-59C1-4798-AD90-419A588DCE76}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -315,6 +323,7 @@ Global {609B09B4-AD1E-40F7-8899-A6685924621C} = {CC368D6A-6AC4-4EB9-A092-14700FABEF7A} {F9CCEFCD-21B3-4319-9DB1-A0756DA5BA1C} = {CC368D6A-6AC4-4EB9-A092-14700FABEF7A} {83ED2617-B398-4859-8F59-B38F8807E83E} = {7AF3F9C2-C939-4A08-95C1-0453207E298A} + {FD50590A-59C1-4798-AD90-419A588DCE76} = {D3BAE68E-406E-493D-A4E5-DB6EDDFFB371} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} diff --git a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ZugferdValidationController.cs b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ZugferdValidationController.cs new file mode 100644 index 00000000..5e1114b5 --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ZugferdValidationController.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace ZUGFeRDRESTService.Controllers +{ + public class ZugferdValidationResponse + { + public string status; + public string message; + public List errors; + + public static string RESPONSE_OK = "OK"; + public static string RESPONSE_ERROR = "ERROR"; + + public ZugferdValidationResponse() + { + status = RESPONSE_OK; + message = String.Empty; + errors = new List(); + } + } + + [Route("api/[controller]")] + [ApiController] + public class ZugferdValidationController : ControllerBase + { + private readonly IZugferdValidationDataService _dataService; + + public ZugferdValidationController(IZugferdValidationDataService dataService) + { + _dataService = dataService; + } + + // POST: api/ZugferdValidation + [HttpPost] + public ZugferdValidationResponse Post(List files) + { + var oFiles = files; + var oResponse = new ZugferdValidationResponse + { + message = "You uploaded " + oFiles.Count + " files." + }; + + return oResponse; + } + } +} diff --git a/WEBSERVICES/ZUGFeRDRESTService/IZugferdValidationDataService.cs b/WEBSERVICES/ZUGFeRDRESTService/IZugferdValidationDataService.cs new file mode 100644 index 00000000..181a091a --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/IZugferdValidationDataService.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace ZUGFeRDRESTService +{ + public interface IZugferdValidationDataService + { + } +} diff --git a/WEBSERVICES/ZUGFeRDRESTService/Pages/Index.cshtml b/WEBSERVICES/ZUGFeRDRESTService/Pages/Index.cshtml new file mode 100644 index 00000000..b98ed0e6 --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/Pages/Index.cshtml @@ -0,0 +1,16 @@ +@page +@{ + ViewData["Title"] = "UploadTest"; +} + +

UploadTest

+ +
+

+ PDF Datei: + +

+ + +
+ diff --git a/WEBSERVICES/ZUGFeRDRESTService/Pages/Index.cshtml.cs b/WEBSERVICES/ZUGFeRDRESTService/Pages/Index.cshtml.cs new file mode 100644 index 00000000..60608930 --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/Pages/Index.cshtml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace ZUGFeRDRESTService +{ + public class UploadTestModel : PageModel + { + public void OnGet() + { + + } + } +} \ No newline at end of file diff --git a/WEBSERVICES/ZUGFeRDRESTService/Program.cs b/WEBSERVICES/ZUGFeRDRESTService/Program.cs new file mode 100644 index 00000000..5a4e487d --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace ZUGFeRDRESTService +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/WEBSERVICES/ZUGFeRDRESTService/Properties/launchSettings.json b/WEBSERVICES/ZUGFeRDRESTService/Properties/launchSettings.json new file mode 100644 index 00000000..06475a99 --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:52235", + "sslPort": 44388 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/zugferdvalidation", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "ZUGFeRDRESTService": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/zugferdvalidation", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/WEBSERVICES/ZUGFeRDRESTService/Startup.cs b/WEBSERVICES/ZUGFeRDRESTService/Startup.cs new file mode 100644 index 00000000..22e70f10 --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/Startup.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace ZUGFeRDRESTService +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers().AddNewtonsoftJson(); + services.AddRazorPages(); + services.AddTransient(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + endpoints.MapRazorPages(); + }); + } + } +} diff --git a/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj b/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj new file mode 100644 index 00000000..a7b78335 --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp3.1 + + + + + + + + + diff --git a/WEBSERVICES/ZUGFeRDRESTService/ZugferdValidationDataService.cs b/WEBSERVICES/ZUGFeRDRESTService/ZugferdValidationDataService.cs new file mode 100644 index 00000000..045f481f --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/ZugferdValidationDataService.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace ZUGFeRDRESTService +{ + public class ZugferdValidationDataService: IZugferdValidationDataService + { + } +} diff --git a/WEBSERVICES/ZUGFeRDRESTService/appsettings.Development.json b/WEBSERVICES/ZUGFeRDRESTService/appsettings.Development.json new file mode 100644 index 00000000..8983e0fc --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/WEBSERVICES/ZUGFeRDRESTService/appsettings.json b/WEBSERVICES/ZUGFeRDRESTService/appsettings.json new file mode 100644 index 00000000..d9d9a9bf --- /dev/null +++ b/WEBSERVICES/ZUGFeRDRESTService/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +}