Update 20250107
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using API_NetFramework.Controllers;
|
||||
using API_NetFramework.Models;
|
||||
using Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
@@ -8,8 +9,11 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Http;
|
||||
using System.Web.Management;
|
||||
using System.Configuration;
|
||||
using SecuringWebApiUsingApiKey.Middleware;
|
||||
|
||||
namespace OnDocAPI_NetFramework.Controllers
|
||||
{
|
||||
@@ -19,23 +23,64 @@ namespace OnDocAPI_NetFramework.Controllers
|
||||
|
||||
[HttpGet]
|
||||
[Route("API/SendMail")]
|
||||
public IHttpActionResult SendMail(string empfaenger, string betreff, string message, string dokumentid, string ondoclink)
|
||||
public IHttpActionResult SendMail(string MailID, string empfaenger, string betreff, string message, string dokumentid, string ondoclink)
|
||||
{
|
||||
string connectionstring = StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString, "i%!k!7pab%bNLdA5hE4pkR4XaB%E^jB3d9tHuQ4pbF&BZjF7SB#WBWit5#HrbJiLrLVm");
|
||||
string URI = "";
|
||||
|
||||
APILogging.Log((HttpRequestMessage)Request, "Mailversand: " + empfaenger+""+betreff, LogLevelType.Debug);
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
if (!empfaenger.ToUpper().Contains("@TKB.CH"))
|
||||
|
||||
if (Regex.IsMatch(empfaenger, @"^\d+$") == false &&!empfaenger.ToUpper().Contains("@TKB.CH"))
|
||||
{
|
||||
return Content(HttpStatusCode.Forbidden, empfaenger + ": Email nicht bei der TKB - Mail nicht versandt");
|
||||
}
|
||||
string s = "";
|
||||
DB db = new DB(connectionstring);
|
||||
try
|
||||
{
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@mailid", MailID.ToString());
|
||||
db.add_parameter("@empf",empfaenger);
|
||||
db.add_parameter("@dokid",dokumentid);
|
||||
db.Get_Tabledata("sp_ondoc_maildaten", true, false);
|
||||
if (message == null) { message = ""; }
|
||||
if (betreff == null) { betreff = ""; }
|
||||
if (betreff == "") { betreff = db.dsdaten.Tables[0].Rows[0][1].ToString(); }
|
||||
if (message == "") { message = db.dsdaten.Tables[0].Rows[0][2].ToString(); }
|
||||
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"];
|
||||
|
||||
|
||||
s = s.Replace("$$empfaenger$$", empfaenger);
|
||||
s = s.Replace("$$betreff$$", betreff);
|
||||
s = s.Replace("$$body$$", message);
|
||||
|
||||
Reference in New Issue
Block a user