Update 20250204
This commit is contained in:
@@ -18,6 +18,9 @@ using API_NetFramework.Models;
|
||||
using System.Web.Http.Controllers;
|
||||
using SecuringWebApiUsingApiKey.Middleware;
|
||||
using System.Drawing.Drawing2D;
|
||||
using Helper;
|
||||
using System.Web.WebPages;
|
||||
using System.Text;
|
||||
|
||||
|
||||
|
||||
@@ -134,6 +137,7 @@ namespace API_NetFramework.Controllers
|
||||
return oBitmap;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -182,6 +186,7 @@ namespace API_NetFramework.Controllers
|
||||
ImageWidth = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DefaultImageWidth"]);
|
||||
ImageHeight = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DefaultImageHeight"]);
|
||||
imgnew= iimg;
|
||||
|
||||
//Bitmap b = new Bitmap(iimg);
|
||||
//imgnew = AutoSizeImage(b, ImageWidth, ImageHeight, false);
|
||||
//imgnew = ScaleImage(b, ImageHeight);
|
||||
@@ -211,6 +216,9 @@ namespace API_NetFramework.Controllers
|
||||
imgnew.Dispose();
|
||||
m.Dispose();
|
||||
System.IO.File.Delete(newfilename);
|
||||
iimg.Dispose();
|
||||
iimg = null;
|
||||
imgnew = null;
|
||||
return Ok(Convert.ToBase64String(imageBytes));
|
||||
}
|
||||
|
||||
@@ -276,7 +284,73 @@ namespace API_NetFramework.Controllers
|
||||
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("API/CheckSignature")]
|
||||
public IHttpActionResult CheckSignature(string TGNummer)
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
string path = System.Configuration.ConfigurationManager.AppSettings["UnterschriftPath"]+ TGNummer + ".jpg";
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
return Content(HttpStatusCode.OK, TGNummer);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Content(HttpStatusCode.NotFound, TGNummer);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class imageclass
|
||||
{
|
||||
public string tgnummer { get; set;}
|
||||
public string b64 { get; set; }
|
||||
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("API/SaveSignature")]
|
||||
public IHttpActionResult SaveSignature()
|
||||
{
|
||||
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
string result = Request.Content.ReadAsStringAsync().Result;
|
||||
imageclass imageclass = new imageclass();
|
||||
imageclass = JsonConvert.DeserializeObject<imageclass>(result);
|
||||
APILogging.Log((HttpRequestMessage)Request, "Unterschriften-Image gespeichert - " + imageclass.tgnummer, LogLevelType.Info);
|
||||
string path = System.Configuration.ConfigurationManager.AppSettings["UnterschriftPath"];
|
||||
|
||||
byte[] imageByteArray = Convert.FromBase64String(imageclass.b64);
|
||||
File.WriteAllBytes(path + imageclass.tgnummer + ".jpg", imageByteArray);
|
||||
DB dB = new DB(connectionstring);
|
||||
|
||||
return Ok(imageclass.tgnummer);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
//[HttpGet]
|
||||
//[Route("API/GetUnterschrift")]
|
||||
//public IHttpActionResult GetUnterschrift(string TGNummer)
|
||||
|
||||
Reference in New Issue
Block a user