update 20251210
This commit is contained in:
1435
API_NetFramework/Controllers/20251127_Documentcontroller_save.txt
Normal file
1435
API_NetFramework/Controllers/20251127_Documentcontroller_save.txt
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -63,29 +63,7 @@ namespace OnDocAPI_NetFramework.Controllers
|
||||
}
|
||||
empfaenger = db.dsdaten.Tables[0].Rows[0][0].ToString();
|
||||
|
||||
//if (Regex.IsMatch(empfaenger, @"^\d+$") == true)
|
||||
//{
|
||||
|
||||
// db.Get_Tabledata("select email from mitarbeiter where mitarbeiternr=" + empfaenger, false, true);
|
||||
// if (db.dsdaten.Tables[0].Rows.Count > 0)
|
||||
// {
|
||||
// empfaenger = db.dsdaten.Tables[0].Rows[0][0].ToString();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return Content(HttpStatusCode.InternalServerError, "Empfäger " + empfaenger + " konnte nicht ermittelt werden");
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (message == null) { message = ""; }
|
||||
//if (betreff == null) { betreff = ""; }
|
||||
//URI = System.Configuration.ConfigurationManager.AppSettings["URI"];
|
||||
//db.Get_Tabledata("Select * from ondoc_mail where id=" + MailID, false, true);
|
||||
//if (betreff == "") { betreff = db.dsdaten.Tables[0].Rows[0][1].ToString(); }
|
||||
//if (message == "") {message= db.dsdaten.Tables[0].Rows[0][2].ToString(); }
|
||||
//betreff = betreff.Replace("&&dokumentid&&", dokumentid);
|
||||
//message = message.Replace("&&dokumentid&&", dokumentid);
|
||||
//message = message.Replace("&&OnDocLink&&", URI);
|
||||
|
||||
db = null;
|
||||
|
||||
s = System.Configuration.ConfigurationManager.AppSettings["MailParam"];
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Drawing.Drawing2D;
|
||||
using Helper;
|
||||
using System.Web.WebPages;
|
||||
using System.Text;
|
||||
using Microsoft.Ajax.Utilities;
|
||||
|
||||
|
||||
|
||||
@@ -137,19 +138,174 @@ namespace API_NetFramework.Controllers
|
||||
return oBitmap;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("API/GetUnterschriftAsBase64New")]
|
||||
public IHttpActionResult GetUnterschriftAsBase64New(string TGNummer, int ImageWidth = 0, int ImageHeight = 0)
|
||||
{
|
||||
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
//return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
APIErrorSimple apireturn = new APIErrorSimple();
|
||||
apireturn.code = "ONDOC-ERR-GetUnterschrift-01";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = "Invalid Token or API-Key";
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
try
|
||||
{
|
||||
return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
finally { apireturn = null; };
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start GetUnterschriftAsBase64 TGNummer: " + TGNummer, LogLevelType.Debug);
|
||||
string path = System.Configuration.ConfigurationManager.AppSettings["UnterschriftPath"];
|
||||
string filename = "";
|
||||
if (System.Configuration.ConfigurationManager.AppSettings["DemoUnterschrift"] == "YES")
|
||||
{
|
||||
filename = path + "1.jpg";
|
||||
}
|
||||
else { filename = path + TGNummer + ".jpg"; }
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Unterschrift-Bezug - nicht vorhanden: " + TGNummer + " DEMO-Unterschrfit verwendet", LogLevelType.Info);
|
||||
APIErrorSimple apireturn = new APIErrorSimple();
|
||||
apireturn.code = "ONDOC-ERR-GetUnterschrift-02";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = "Unterschfit für TGNumemr "+TGNummer+" nicht vorhanden";
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
|
||||
try
|
||||
{
|
||||
return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Content(HttpStatusCode.InternalServerError, "Unterschfit für TGNumemr " + TGNummer + " nicht vorhanden");
|
||||
}
|
||||
finally
|
||||
{
|
||||
apireturn = null;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Unterschrift-Bezug: " + TGNummer, LogLevelType.Info);
|
||||
System.Drawing.Image iimg = System.Drawing.Image.FromFile(filename);
|
||||
System.Drawing.Image imgnew = null;
|
||||
switch (ImageWidth)
|
||||
{
|
||||
case 0:
|
||||
ImageWidth = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DefaultImageWidth"]);
|
||||
ImageHeight = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DefaultImageHeight"]);
|
||||
imgnew = iimg;
|
||||
|
||||
break;
|
||||
case -1:
|
||||
imgnew = iimg;
|
||||
break;
|
||||
default:
|
||||
|
||||
imgnew = iimg;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
using (MemoryStream m = new MemoryStream())
|
||||
{
|
||||
string newfilename = path + Guid.NewGuid().ToString() + ".jpg";
|
||||
imgnew.Save(newfilename);
|
||||
imgnew = System.Drawing.Image.FromFile(newfilename);
|
||||
imgnew.Save(m, imgnew.RawFormat);
|
||||
byte[] imageBytes = m.ToArray();
|
||||
imgnew.Dispose();
|
||||
m.Dispose();
|
||||
System.IO.File.Delete(newfilename);
|
||||
iimg.Dispose();
|
||||
iimg = null;
|
||||
imgnew = null;
|
||||
APIOK apiok = new APIOK();
|
||||
apiok.code = "200";
|
||||
apiok.status = "200";
|
||||
apiok.message = "";
|
||||
apiok.documentid = "";
|
||||
apiok.file=Convert.ToBase64String(imageBytes);
|
||||
try
|
||||
{
|
||||
return Ok(Newtonsoft.Json.JsonConvert.SerializeObject(apiok));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
apiok = null;
|
||||
}
|
||||
return Ok(Convert.ToBase64String(imageBytes));
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
APIErrorSimple apireturn = new APIErrorSimple();
|
||||
apireturn.code = "ONDOC-ERR-GetUnterschrift-02";
|
||||
apireturn.status = "401";
|
||||
apireturn.message = e.Message;
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
|
||||
try
|
||||
{
|
||||
return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
apireturn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
APIErrorSimple apireturn = new APIErrorSimple();
|
||||
apireturn.code = "ONDOC-ERR-GetUnterschrift-03";
|
||||
apireturn.status = "500";
|
||||
apireturn.message = e.Message;
|
||||
apireturn.traceid = "";
|
||||
apireturn.field = "";
|
||||
try
|
||||
{
|
||||
return BadRequest(Newtonsoft.Json.JsonConvert.SerializeObject(apireturn));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
apireturn = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="TGNummer">Required. </param>
|
||||
/// <param name="ImageWidth">Optional. The default value is 0.</param>
|
||||
/// <param name="ImageHeight">Optional. The default value is 0.</param>
|
||||
/// <returns>Unterschriften-Image für die gelieferte TGNummer als Base64</returns>
|
||||
/// <remarks>Parameter ImageWidth<br></br>
|
||||
/// 0: Verwendung der Standardgrösse 140x70<br></br>
|
||||
/// -1: Verwendung der Originalgrösse<br></br>
|
||||
/// Anderer Wert Grössenänderung ImageWidth / ImageHeight
|
||||
/// </remarks>
|
||||
|
||||
[HttpGet]
|
||||
[Route("API/GetUnterschriftAsBase64")]
|
||||
public IHttpActionResult GetUnterschriftAsBase64(string TGNummer, int ImageWidth = 0, int ImageHeight = 0)
|
||||
@@ -222,8 +378,6 @@ namespace API_NetFramework.Controllers
|
||||
return Ok(Convert.ToBase64String(imageBytes));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user