update 20251210
This commit is contained in:
@@ -114,6 +114,7 @@
|
||||
<HintPath>..\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Diagnostics.Tracing" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Pipelines, Version=9.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Pipelines.9.0.3\lib\net462\System.IO.Pipelines.dll</HintPath>
|
||||
@@ -260,6 +261,7 @@
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Helper\Helper.cs" />
|
||||
<Compile Include="Models\StaticParams.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Startup.cs" />
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
44
API_NetFramework/Helper/Helper.cs
Normal file
44
API_NetFramework/Helper/Helper.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace OnDocAPI_NetFramework.Helper
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
public static void CopyProperties(object source, object target)
|
||||
{
|
||||
var sourceProps = source.GetType().GetProperties();
|
||||
var targetProps = target.GetType().GetProperties();
|
||||
|
||||
foreach (var prop in sourceProps)
|
||||
{
|
||||
var targetProp = targetProps.FirstOrDefault(p => p.Name == prop.Name && p.PropertyType == prop.PropertyType);
|
||||
if (targetProp != null && targetProp.CanWrite)
|
||||
{
|
||||
targetProp.SetValue(target, prop.GetValue(source));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Random _random = new Random();
|
||||
|
||||
public static string RandomString(int size, bool lowerCase = false)
|
||||
{
|
||||
var builder = new StringBuilder(size);
|
||||
|
||||
char offset = lowerCase ? 'a' : 'A';
|
||||
const int lettersOffset = 26; // A...Z or a..z: length=26
|
||||
|
||||
for (var i = 0; i < size; i++)
|
||||
{
|
||||
var @char = (char)_random.Next(offset, offset + lettersOffset);
|
||||
builder.Append(@char);
|
||||
}
|
||||
|
||||
return lowerCase ? builder.ToString().ToLower() : builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,15 @@ namespace API_NetFramework.Models
|
||||
Logging.DocLog.IntUserID = db.dsdaten.Tables[0].Rows[0]["LogUserID"].ToString();
|
||||
Logging.DocLog.connectionstring= journalconnectionstring;
|
||||
Logging.DocLog.init_logger();
|
||||
|
||||
db.Get_Tabledata("Select * from nlog_parameter WHERE ID=2", false, true);
|
||||
Logging.APIDocLog.IntLogLevel = db.dsdaten.Tables[0].Rows[0]["LogLevel"].ToString();
|
||||
Logging.APIDocLog.IntUserID = db.dsdaten.Tables[0].Rows[0]["LogUserID"].ToString();
|
||||
Logging.APIDocLog.connectionstring = journalconnectionstring;
|
||||
Logging.APIDocLog.init_logger();
|
||||
// Logging.DocLog.init_logger();
|
||||
//Logging.DocLog.connectionstring = connectionstring;
|
||||
|
||||
|
||||
db = null;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -36,6 +36,17 @@
|
||||
<parameter name="@partnernr" layout="${gdc:Partnernr}"/>
|
||||
<parameter name="@aktion" layout="${gdc:Aktion}"/>
|
||||
</target>
|
||||
<target type="Database" name="APIDocLog" connectionstring="Server=SHU01\SHU00;Database=edoka_journale;User ID=sa;Password=*shu29">
|
||||
<commandText>
|
||||
sp_insert_nlog_APIDocLog @Origin,@Message,@LogLevel,@UserID, @zusatz, @guid
|
||||
</commandText>
|
||||
<parameter name="@Origin" layout="${gdc:Herkunft}"/>
|
||||
<parameter name="@LogLevel" layout="${level}"/>
|
||||
<parameter name="@message" layout="${message}"/>
|
||||
<parameter name="@UserID" layout="${environment-user}"/>
|
||||
<parameter name="@guid" layout="${gdc:GUID}"/>
|
||||
<parameter name="@zusatz" layout="${gdc:zusatz}"/>
|
||||
</target>
|
||||
</targets>
|
||||
<rules>
|
||||
<!--<logger name="*" levels="Info,Error,Debug,Warn,Trace,Fail" writeTo="console" />-->
|
||||
@@ -43,6 +54,7 @@
|
||||
<logger name="*" levels="Info,Debug,Error" writeTo="file" />
|
||||
<logger name="*" levels="Info,Debug,Error" writeTo="Database" />
|
||||
<logger name="DocLog" levels="Info,Debug,Error,Warning,Trace" writeTo="DocLog" />
|
||||
<logger name="APIDocLog" levels="Info,Debug,Error,Warning,Trace" writeTo="APIDocLog" />
|
||||
<!-- <logger name="*" levels="Error" writeTo="email" /> -->
|
||||
</rules>
|
||||
</nlog>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1 +1 @@
|
||||
0b546d3bbc077b6ec0c5327406ca9ea50b932fac31e916c5372589b1bdf6d542
|
||||
f4edd25b59965f3aba1dd0fe3be0134c23fa88f0d01526b0e52d3378a785bf89
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user