update 20241003

This commit is contained in:
Stefan Hutter
2024-10-03 16:59:24 +02:00
parent 765a5ef350
commit 4fbeb345ee
237 changed files with 44064 additions and 1107832 deletions

View File

@@ -14,8 +14,7 @@ using System.Net.Http.Headers;
using System.Drawing;
using System.Threading.Tasks;
using System.Threading;
using API_NetFramework.Models;
namespace API_NetFramework.Controllers
@@ -33,26 +32,41 @@ namespace API_NetFramework.Controllers
public class UnterschriftController : ApiController
{
string tokenfunction = "Unterschrift";
string connectionstring = ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString;
[HttpGet]
[Route("API/GetUnterschriftAsBase64")]
public IHttpActionResult GetUnterschriftAsBase64(string TGNummer)
{
string path = System.Configuration.ConfigurationManager.AppSettings["UnterschriftPath"];
string filename = path + TGNummer + ".jpg";
if (!File.Exists(filename))
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
{
return Content(HttpStatusCode.NotFound, "Image " + filename + " not found");
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
}
try
{
byte[] b = System.IO.File.ReadAllBytes(filename);
return Ok(Convert.ToBase64String(b));
} catch (Exception e) {
string path = System.Configuration.ConfigurationManager.AppSettings["UnterschriftPath"];
string filename = path + TGNummer + ".jpg";
if (!File.Exists(filename))
{
return Content(HttpStatusCode.NotFound, "Image " + filename + " not found");
}
try
{
byte[] b = System.IO.File.ReadAllBytes(filename);
return Ok(Convert.ToBase64String(b));
}
catch (Exception e)
{
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
return Content(HttpStatusCode.InternalServerError, e.Message);
}
}
catch (Exception e)
{
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
return Content(HttpStatusCode.InternalServerError, e.Message);
}
}
@@ -60,26 +74,37 @@ namespace API_NetFramework.Controllers
[Route("API/GetUnterschrift")]
public IHttpActionResult GetUnterschrift(string TGNummer)
{
string path = System.Configuration.ConfigurationManager.AppSettings["UnterschriftPath"];
string filename = path + TGNummer + ".jpg";
if (!File.Exists(filename))
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
{
return Content(HttpStatusCode.NotFound, "Image " + filename + " not found");
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
}
try
{
var dataBytes = File.ReadAllBytes(@"x:\docdemo\unterschriften\kube.jpg");
var dataStream = new MemoryStream(dataBytes);
string imageName = TGNummer + ".jpg";
return new unterschriftResult(dataStream, Request, imageName);
string path = System.Configuration.ConfigurationManager.AppSettings["UnterschriftPath"];
string filename = path + TGNummer + ".jpg";
if (!File.Exists(filename))
{
return Content(HttpStatusCode.NotFound, "Image " + filename + " not found");
}
try
{
var dataBytes = File.ReadAllBytes(@"x:\docdemo\unterschriften\kube.jpg");
var dataStream = new MemoryStream(dataBytes);
string imageName = TGNummer + ".jpg";
return new unterschriftResult(dataStream, Request, imageName);
}
catch (Exception e)
{
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
return Content(HttpStatusCode.InternalServerError, e.Message);
}
}
catch (Exception e)
{
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
return Content(HttpStatusCode.InternalServerError, e.Message);
}
}
}