Update 20250204
This commit is contained in:
@@ -0,0 +1,325 @@
|
||||
using Database;
|
||||
using DOCGEN;
|
||||
using Model;
|
||||
using API_NetFramework.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using SecuringWebApiUsingApiKey.Middleware;
|
||||
using Newtonsoft.Json;
|
||||
using System.Web.Http.Results;
|
||||
using Microsoft.Ajax.Utilities;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Web.Helpers;
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
{
|
||||
public class AntwortAdresseController : ApiController
|
||||
{
|
||||
string tokenfunction = "Adresse";
|
||||
string connectionstring = StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString, "i%!k!7pab%bNLdA5hE4pkR4XaB%E^jB3d9tHuQ4pbF&BZjF7SB#WBWit5#HrbJiLrLVm");
|
||||
|
||||
/// <summary>
|
||||
/// GetGetAll liefert alle GAS-Adressen
|
||||
/// </summary>
|
||||
/// <param name="OutFormat">Optional. The default value is "JSON".Optionaler Parameter: "XML"</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks></remarks>
|
||||
[HttpGet]
|
||||
[Route("API/Antwortadresse/GetAll")]
|
||||
|
||||
public IHttpActionResult GetGetAll(string OutFormat = "JSON")
|
||||
{
|
||||
//string a = SecuringWebApiUsingApiKey.Middleware.StringCipher.Encrypt("Adresse", "OnDoc");
|
||||
//a = SecuringWebApiUsingApiKey.Middleware.StringCipher.Decrypt(a, "OnDoc");
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request,tokenfunction) ==false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start Adresse GetAll", LogLevelType.Debug);
|
||||
|
||||
Database.DB db = new Database.DB(connectionstring);
|
||||
string SQL = "Select * from Antwortadresse order by bezeichnung";
|
||||
if (OutFormat == "JSON") { SQL = SQL + " for json path"; }
|
||||
if (OutFormat == "XML") { SQL = SQL + " for xml path"; }
|
||||
db.Get_Tabledata(SQL, false, true);
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Adresse GetAll", LogLevelType.Debug);
|
||||
|
||||
return Ok(JToken.Parse(db.dsdaten.Tables[0].Rows[0][0].ToString()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request,e.Message,LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("API/Antwortadresse/GetByID")]
|
||||
/// <summary>
|
||||
/// GetByID liefert die GAS-Adresse mit der gewünschten ID
|
||||
/// </summary>
|
||||
/// <param name="ID">ID der GAS-Adresse</param>
|
||||
/// <param name="OutFormat">Optional. The default value is "JSON".Optionaler Parameter: "XML"</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks></remarks>
|
||||
|
||||
public IHttpActionResult GetByID(string ID,string OutFormat = "JSON")
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start Adresse GetByID ID:"+ID, LogLevelType.Debug);
|
||||
|
||||
Database.DB db = new Database.DB(connectionstring);
|
||||
string SQL = "Select * from Antwortadresse where id=" + ID;
|
||||
if (OutFormat == "JSON") { SQL = SQL + " for json path"; }
|
||||
if (OutFormat == "XML") { SQL = SQL + " for xml path"; }
|
||||
db.Get_Tabledata(SQL, false, true);
|
||||
if (db.dsdaten.Tables[0].Rows.Count == 0) {
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Adresse GetByID ID:" + ID, LogLevelType.Debug);
|
||||
|
||||
return Ok();
|
||||
} else {
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Adresse GetByID ID:" + ID, LogLevelType.Debug);
|
||||
|
||||
return Ok(JToken.Parse(db.dsdaten.Tables[0].Rows[0][0].ToString()));
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetAllMitarbeiterByTGNummer liefert die persönlichen Adressen eines Mitarbeiters
|
||||
/// </summary>
|
||||
/// <param name="tgnummer">Required. </param>
|
||||
/// <param name="OutFormat">Optional. The default value is "JSON".Optionalier Parameter: "XML"</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks></remarks>
|
||||
[HttpGet]
|
||||
[Route("API/ntwortAdresse/GetAllMitarbeiterByTGNummer")]
|
||||
|
||||
public IHttpActionResult GetAllMitarbeiterByTGNummer(string tgnummer, string OutFormat = "JSON")
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start Adresse GetAllMitarbeiterByTGNummer", LogLevelType.Debug);
|
||||
|
||||
Database.DB db = new Database.DB(connectionstring);
|
||||
string SQL = "Select * from AntwortAdresse_Mitarbeiter where aktiv=1 and tgnummer='" + tgnummer + "' order by bezeichnung ";
|
||||
if (OutFormat == "JSON") { SQL = SQL + " for json path"; }
|
||||
if (OutFormat == "XML") { SQL = SQL + " for xml path"; }
|
||||
db.Get_Tabledata(SQL, false, true);
|
||||
if (db.dsdaten.Tables[0].Rows.Count == 0) {
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Adresse GetAllMitarbeiterByTGNummer", LogLevelType.Debug);
|
||||
|
||||
return Ok();
|
||||
} else {
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Adresse GetAllMitarbeiterByTGNummer", LogLevelType.Debug);
|
||||
|
||||
return Ok(JToken.Parse(db.dsdaten.Tables[0].Rows[0][0].ToString()));
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
[Route("API/AntwortAdresse/GetAllMitarbeiterByMitarbeiterNr")]
|
||||
/// <summary>
|
||||
/// GetAllMitarbeiterByMitarbeiternr liefert die persönlichen Adressen eines Mitarbeiters
|
||||
/// </summary>
|
||||
/// <param name="Mitarbeiternr">Required. </param>
|
||||
/// <param name="OutFormat">Optional. The default value is "JSON".Optionalier Parameter: "XML"</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks></remarks>
|
||||
|
||||
public IHttpActionResult GetAllMitarbeiterByMitarbeiterNr(string Mitarbeiternr, string OutFormat = "JSON")
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start Adresse GetAllMitarbeiterByMitarbeiterNr Ma-Nr:"+Mitarbeiternr, LogLevelType.Debug);
|
||||
|
||||
Database.DB db = new Database.DB(connectionstring);
|
||||
string SQL = "Select * from AntwortAdresse_Mitarbeiter where aktiv=1 and Mitarbeiternr='" + Mitarbeiternr + "' ";
|
||||
if (OutFormat == "JSON") { SQL = SQL + " for json path"; }
|
||||
if (OutFormat == "XML") { SQL = SQL + " for xml path"; }
|
||||
db.Get_Tabledata(SQL, false, true);
|
||||
if (db.dsdaten.Tables[0].Rows.Count == 0) {
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Adresse GetAllMitarbeiterByMitarbeiterNr Ma-Nr:" + Mitarbeiternr, LogLevelType.Debug);
|
||||
return Ok();
|
||||
} else {
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Adresse GetAllMitarbeiterByMitarbeiterNr Ma-Nr:" + Mitarbeiternr, LogLevelType.Debug);
|
||||
return Ok(JToken.Parse(db.dsdaten.Tables[0].Rows[0][0].ToString()));
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[Route("API/AntwortAdresse/GetMitarbeiterByID")]
|
||||
/// <summary>
|
||||
/// GetMitarbeiterByID liefert eine Mitarbeiter-Adrsse mit der ID
|
||||
/// </summary>
|
||||
/// <param name="ID">Required. </param>
|
||||
/// <param name="OutFormat">Optional. The default value is "JSON".Optionalier Parameter: "XML"</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks></remarks>
|
||||
|
||||
public IHttpActionResult GetMitarbeiterByID(string ID, string OutFormat = "JSON")
|
||||
{
|
||||
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start GetMitarbeiterByID ID: "+ID, LogLevelType.Debug);
|
||||
|
||||
Database.DB db = new Database.DB(connectionstring);
|
||||
string SQL = "Select * from AntwortAdresse_Mitarbeiter where id=" + ID;
|
||||
if (OutFormat == "JSON") { SQL = SQL + " for json path"; }
|
||||
if (OutFormat == "XML") { SQL = SQL + " for xml path"; }
|
||||
db.Get_Tabledata(SQL, false, true);
|
||||
if (db.dsdaten.Tables[0].Rows.Count == 0) {
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende GetMitarbeiterByID ID: " + ID, LogLevelType.Debug);
|
||||
return Ok();
|
||||
} else {
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende GetMitarbeiterByID ID: " + ID, LogLevelType.Debug);
|
||||
return Ok(JToken.Parse(db.dsdaten.Tables[0].Rows[0][0].ToString())); };
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
[Route("API/AntwortAdresse/GetMitarbeiterUndStandard")]
|
||||
/// <summary>
|
||||
/// GetMitarbeiterByID liefert eine Mitarbeiter-Adrsse mit der ID
|
||||
/// </summary>
|
||||
/// <param name="ID">Required. </param>
|
||||
/// <param name="OutFormat">Optional. The default value is "JSON".Optionalier Parameter: "XML"</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks></remarks>
|
||||
/// public IHttpActionResult GetMitarbeiterByID(string ID, string OutFormat = "JSON")
|
||||
public IHttpActionResult GetGASAdressen_Einzeilig(string TGNummer, string OutFormat = "JSON")
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start GetGASAdressen_Einzeilig TGNummer: " + TGNummer, LogLevelType.Debug);
|
||||
|
||||
Database.DB db = new Database.DB(connectionstring);
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@tgnummer", TGNummer);
|
||||
db.add_parameter("@format", OutFormat);
|
||||
db.Get_Tabledata("sp_get_gas_einzeilig", true, false);
|
||||
if (db.dsdaten.Tables[0].Rows.Count == 0)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende GetGASAdressen_Einzeilig TGNummer: " + TGNummer, LogLevelType.Debug);
|
||||
return Content(HttpStatusCode.NotFound, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende GetGASAdressen_Einzeilig TGNummer: " + TGNummer, LogLevelType.Debug);
|
||||
//List<adressresponse> adressen = new List<adressresponse>();
|
||||
//foreach (System.Data.DataRow dr in db.dsdaten.Tables[0].Rows)
|
||||
//{
|
||||
// adressen.Add(new adressresponse() {adresse = dr[0].ToString()});
|
||||
//}
|
||||
//var token = JToken.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(adressen));
|
||||
|
||||
return Content(HttpStatusCode.OK, JToken.Parse(db.dsdaten.Tables[0].Rows[0][0].ToString()));
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private string DataTableToJsonObj(DataTable dt)
|
||||
{
|
||||
DataSet ds = new DataSet();
|
||||
ds.Merge(dt);
|
||||
StringBuilder JsonString = new StringBuilder();
|
||||
if (ds != null && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
JsonString.Append("[");
|
||||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
JsonString.Append("{");
|
||||
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
|
||||
{
|
||||
if (j < ds.Tables[0].Columns.Count - 1)
|
||||
{
|
||||
JsonString.Append("\"" + ds.Tables[0].Columns[j].ColumnName.ToString() + "\":" + "\"" + ds.Tables[0].Rows[i][j].ToString() + "\",");
|
||||
}
|
||||
else if (j == ds.Tables[0].Columns.Count - 1)
|
||||
{
|
||||
JsonString.Append("\"" + ds.Tables[0].Columns[j].ColumnName.ToString() + "\":" + "\"" + ds.Tables[0].Rows[i][j].ToString() + "\"");
|
||||
}
|
||||
}
|
||||
if (i == ds.Tables[0].Rows.Count - 1)
|
||||
{
|
||||
JsonString.Append("}");
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonString.Append("},");
|
||||
}
|
||||
}
|
||||
JsonString.Append("]");
|
||||
return JsonString.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
439
API_NetFramework - Kopie (2)/Controllers/ArchivController.cs
Normal file
439
API_NetFramework - Kopie (2)/Controllers/ArchivController.cs
Normal file
@@ -0,0 +1,439 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using DOCGEN;
|
||||
using Model;
|
||||
using Database;
|
||||
using Newtonsoft.Json;
|
||||
using API_NetFramework.Models;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Net.Mime;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using System.Security.Cryptography;
|
||||
using System.Net.Http.Headers;
|
||||
using SecuringWebApiUsingApiKey.Middleware;
|
||||
using DOCGEN.Klassen;
|
||||
using CSVNET;
|
||||
using System.Data;
|
||||
using Helper;
|
||||
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks></remarks>
|
||||
///
|
||||
public class ILResponse
|
||||
{
|
||||
public int StatusCode;
|
||||
public int senderror { get; set; } = 0;
|
||||
public string response { get; set; } = "";
|
||||
}
|
||||
|
||||
public enum uploadtype
|
||||
{
|
||||
fast = 1,
|
||||
slow = 2,
|
||||
docupload = 3
|
||||
}
|
||||
|
||||
public class ArchivController : ApiController
|
||||
{
|
||||
// GET: OnBase
|
||||
string tokenfunction = "Archiv";
|
||||
string connectionstring = StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString, "i%!k!7pab%bNLdA5hE4pkR4XaB%E^jB3d9tHuQ4pbF&BZjF7SB#WBWit5#HrbJiLrLVm");
|
||||
|
||||
private void Update_IL_Log(ref ILResponse ilr, string dokumentid)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start Updaet IL_Log: DokumentID:" + dokumentid, LogLevelType.Debug);
|
||||
|
||||
DB dB = new DB(StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["JournalConnectionstring"].ConnectionString, "i%!k!7pab%bNLdA5hE4pkR4XaB%E^jB3d9tHuQ4pbF&BZjF7SB#WBWit5#HrbJiLrLVm"));
|
||||
string sql = "Insert OnDoc_IL_Log (dokumentid, ilresponse,error, erstellt_am) values ('" + dokumentid + "',";
|
||||
sql = sql + "'" + ilr.response.ToString() + "',";
|
||||
if (ilr.senderror != 0) { sql = sql + "1,"; } else { sql = sql + "0,"; }
|
||||
sql = sql +"getdate() )";
|
||||
dB.Exec_SQL(sql);
|
||||
dB = null;
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Update IL_Log: DokumentID:" + dokumentid, LogLevelType.Debug);
|
||||
}
|
||||
|
||||
private void update_dokumentstatus(string dokumentid)
|
||||
{
|
||||
DB db = new DB(connectionstring);
|
||||
db.dokument_abschliessen(dokumentid);
|
||||
db = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CheckDocID prüft auf eine vorhandene DokumentID in OnDoc (DokumentID OFFEDK... / Barcode-Klenber-Nr)
|
||||
/// </summary>
|
||||
/// <param name="DokumentID"></param>
|
||||
/// <returns>
|
||||
/// 200: OK
|
||||
/// </returns>
|
||||
/// <remarks></remarks>
|
||||
[HttpGet]
|
||||
[Route("API/CheckDocID")]
|
||||
|
||||
public IHttpActionResult CheckDocID(string DokumentID)
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start Check DokumentID: DokumentID:" + DokumentID, LogLevelType.Debug);
|
||||
Database.DB db = new Database.DB(connectionstring);
|
||||
db.Get_Tabledata("Select * from dokument where dokumentid = '" + DokumentID + "'", false, true);
|
||||
if (db.dsdaten.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
return Ok(DokumentID);
|
||||
}
|
||||
db.Get_Tabledata("Select barcodenr from barcodeetikette where dokumentid='" + DokumentID + "'", false, true);
|
||||
if (db.dsdaten.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
return Ok(DokumentID);
|
||||
}
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Check DokumentID: DokumentID:" + DokumentID, LogLevelType.Debug);
|
||||
|
||||
return Content(HttpStatusCode.NotFound, DokumentID);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Archiviert das Dokument aus OnDoc in OnBase
|
||||
/// </summary>
|
||||
/// <param name="DokumentID"></param>
|
||||
/// <returns>
|
||||
/// Returncode: 200 (OK)
|
||||
/// Dokumenthandle aus OnBase
|
||||
/// </returns>
|
||||
/// <remarks></remarks>
|
||||
[HttpGet]
|
||||
[Route("API/ArchiveDocFromDatabase")]
|
||||
|
||||
public IHttpActionResult ArchivDocFromDatabase(string DokumentID)
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
string doktypnr = "";
|
||||
string extension = "";
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start ArchiveDocFromDatabase: DokumentID:" + DokumentID, LogLevelType.Debug);
|
||||
DB db = new DB(connectionstring);
|
||||
|
||||
db.Get_Tabledata("Select dokumenttypnr, dokumentname from dokument where dokumentid='" + DokumentID+"'", false, true);
|
||||
extension = System.IO.Path.GetExtension(db.dsdaten.Tables[0].Rows[0]["dokumentname"].ToString());
|
||||
doktypnr = db.dsdaten.Tables[0].Rows[0][0].ToString();
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@dokumentid", DokumentID);
|
||||
db.Get_Tabledata("[sp_Get_OnDoc_Parameters]", true, false);
|
||||
OnBaseDocUpload.OnBaseDokument onbasedoc = new OnBaseDocUpload.OnBaseDokument();
|
||||
|
||||
DocGet dg = new DocGet(connectionstring);
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
|
||||
string[] officeformat = System.Configuration.ConfigurationManager.AppSettings["ArchivierungOfficeFormat"].ToString().Split(',');
|
||||
string[] excelconvert = System.Configuration.ConfigurationManager.AppSettings["ExcelDokType"].ToString().Split(',');
|
||||
string excelvaluefile = System.Configuration.ConfigurationManager.AppSettings["ExcelValueFile"].ToString();
|
||||
if (excelconvert.Contains(doktypnr))
|
||||
{
|
||||
var settings = new CSVSettings()
|
||||
{
|
||||
FieldDelimiter = ';',
|
||||
TextQualifier = '\'',
|
||||
ForceQualifiers = true
|
||||
};
|
||||
DataTable dt = CSVDataTable.FromFile(excelvaluefile, settings);
|
||||
DataTable dt1 = dt.Copy();
|
||||
dt1.Rows.Clear();
|
||||
foreach (System.Data.DataRow dr in dt.Rows)
|
||||
{
|
||||
if (dr[0].ToString() == doktypnr.ToString()) { dt1.ImportRow(dr); }
|
||||
}
|
||||
dt.Dispose();
|
||||
dt1.Columns.Add("value");
|
||||
|
||||
|
||||
Excel_Reader reader = new Excel_Reader();
|
||||
dok = dg.GetDoc(DokumentID);
|
||||
|
||||
DB db1 = new DB(connectionstring);
|
||||
reader.get_valus_from_excel(ref dt1, dok.dokument);
|
||||
foreach (System.Data.DataRow dr in dt1.Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
db1.clear_parameter();
|
||||
db1.add_parameter("@dokumentid", DokumentID);
|
||||
db1.add_parameter("@vorlagenfeldnr", dr["valuenr"].ToString());
|
||||
db1.add_parameter("@value", dr["bezeichnung"].ToString() + ";" + dr["value"].ToString());
|
||||
db1.Get_Tabledata("dbo.SP_Dokument_Information_Wert", true, false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
db1 = null;
|
||||
dt = null;
|
||||
reader = null;
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@dokumentid", DokumentID);
|
||||
db.Get_Tabledata("[sp_Get_OnDoc_Parameters]", true, false);
|
||||
|
||||
}
|
||||
if (officeformat.Contains(doktypnr) || extension.ToUpper()=="PDF")
|
||||
{
|
||||
dg.GetDoc(DokumentID);
|
||||
extension = extension.ToUpper().Replace(".", "");
|
||||
}
|
||||
else {
|
||||
dok = dg.GetDocAsPDF(DokumentID);
|
||||
extension = "PDF";
|
||||
}
|
||||
|
||||
if (db.dsdaten.Tables[0].Rows[0]["BpNummer"].ToString() == "")
|
||||
{
|
||||
onbasedoc.personNummer = db.dsdaten.Tables[0].Rows[0]["PersonNummer"].ToString();
|
||||
onbasedoc.bpNummer = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
onbasedoc.bpNummer = db.dsdaten.Tables[0].Rows[0]["BpNummer"].ToString();
|
||||
onbasedoc.personNummer = "";
|
||||
}
|
||||
onbasedoc.dokumentDatum = db.dsdaten.Tables[0].Rows[0]["DokumentDatum"].ToString();
|
||||
onbasedoc.dokumentTyp = db.dsdaten.Tables[0].Rows[0]["dokumenttyp"].ToString(); ;
|
||||
onbasedoc.dateiTyp = extension;
|
||||
var Attribute = new List<Model.OnBaseDocUpload.attribute>();
|
||||
onbasedoc.attributes = new List<Model.OnBaseDocUpload.attribute>();
|
||||
foreach (System.Data.DataRow rw in db.dsdaten.Tables[1].Rows)
|
||||
{
|
||||
OnBaseDocUpload.attribute na = new OnBaseDocUpload.attribute(rw["fieldname"].ToString(), rw["fieldvalue"].ToString());
|
||||
onbasedoc.attributes.Add(na);
|
||||
}
|
||||
onbasedoc.dokumentDatei = dok.dokument;
|
||||
db = null;
|
||||
ILResponse ilr = new ILResponse();
|
||||
string debugfilename = System.Configuration.ConfigurationManager.AppSettings["JSONDebugPath"];
|
||||
string SendToOnBase = System.Configuration.ConfigurationManager.AppSettings["SendToOnBase"];
|
||||
string SendToFile = System.Configuration.ConfigurationManager.AppSettings["SendToFile"];
|
||||
string debugdir = System.Configuration.ConfigurationManager.AppSettings["DebugDir"];
|
||||
string jsonstring = Newtonsoft.Json.JsonConvert.SerializeObject(onbasedoc);
|
||||
IHttpActionResult transferResult = null;
|
||||
if (SendToOnBase != "Yes")
|
||||
{
|
||||
transferResult = Transfer_OnBase(uploadtype.fast, ref jsonstring, ref ilr);
|
||||
if (SendToFile == "Yes")
|
||||
{
|
||||
if (debugfilename != "")
|
||||
{
|
||||
debugfilename = debugfilename + DokumentID + ".json";
|
||||
System.IO.File.WriteAllText(debugfilename, jsonstring);
|
||||
debugfilename = debugfilename + ".pdf";
|
||||
Helper.clsFileHelper fh = new Helper.clsFileHelper();
|
||||
fh.SaveBase64ToFile(onbasedoc.dokumentDatei, debugfilename);
|
||||
fh = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende ArchiveDocFromDatabase: DokumentID:" + DokumentID, LogLevelType.Debug);
|
||||
|
||||
//Log nachführen
|
||||
Update_IL_Log(ref ilr,DokumentID);
|
||||
if (ilr.senderror == 1)
|
||||
{
|
||||
return Content(HttpStatusCode.InternalServerError, ilr.response);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_dokumentstatus(DokumentID);
|
||||
return Content(HttpStatusCode.OK, DokumentID + " archiviert");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[Route("API/ArchivDocFromIRIS")]
|
||||
public IHttpActionResult ArchivDocFromIRIS(string dokumentid)
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start ArchivDocFromIRIS DokumentID: " + dokumentid, LogLevelType.Debug);
|
||||
|
||||
if (dokumentid.Substring(0, 9).ToUpper() == "OFFEDK008")
|
||||
{
|
||||
return (ArchivDocFromDatabase(dokumentid));
|
||||
}
|
||||
else
|
||||
{
|
||||
DB db = new DB(connectionstring);
|
||||
db.clear_parameter();
|
||||
db.add_parameter("@dokumentid", dokumentid);
|
||||
db.Get_Tabledata("[OnDoc_IRIS_Archivierung]", true, false);
|
||||
string returnmessage = db.dsdaten.Tables[0].Rows[0][0].ToString();
|
||||
switch (db.dsdaten.Tables[0].Rows[0][1].ToString())
|
||||
{
|
||||
case "1":
|
||||
case "2":
|
||||
case "3":
|
||||
APILogging.Log((HttpRequestMessage)Request, db.dsdaten.Tables[0].Rows[0].ToString() + dokumentid, LogLevelType.Debug);
|
||||
return Content(HttpStatusCode.NotFound, returnmessage);
|
||||
case "0":
|
||||
return (ArchivDocFromDatabase(dokumentid));
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende ArchivDocFromIRIS DokumentID:" + dokumentid, LogLevelType.Debug);
|
||||
return Ok(dokumentid);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("API/ArchivSBDoc")]
|
||||
|
||||
public IHttpActionResult ArchivSBDoc(string sbnr, string intid, int partnernr, string dokumentid )
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start ArchivSBDoc DokumentID: DokumentID:" + dokumentid, LogLevelType.Debug);
|
||||
|
||||
string json = "";
|
||||
if (HttpContext.Current.Request.InputStream.Length > 0)
|
||||
{
|
||||
using (var inputStream = new StreamReader(HttpContext.Current.Request.InputStream))
|
||||
{
|
||||
json = inputStream.ReadToEnd();
|
||||
}
|
||||
}
|
||||
string debugfilename = System.Configuration.ConfigurationManager.AppSettings["JSONDebugPath"];
|
||||
string SendToOnBase = System.Configuration.ConfigurationManager.AppSettings["SendToOnBase"];
|
||||
string SendToFile = System.Configuration.ConfigurationManager.AppSettings["SendToFile"];
|
||||
string debugdir = System.Configuration.ConfigurationManager.AppSettings["DebugDir"];
|
||||
string jsonstring = json;
|
||||
|
||||
ILResponse ilr = new ILResponse();
|
||||
//jsonstring = Newtonsoft.Json.JsonConvert.SerializeObject(od);
|
||||
IHttpActionResult transferResult = null;
|
||||
if (SendToOnBase != "Yes")
|
||||
{
|
||||
transferResult = Transfer_OnBase(uploadtype.slow, ref jsonstring, ref ilr);
|
||||
if (SendToFile == "Yes")
|
||||
{
|
||||
if (debugfilename != "")
|
||||
{
|
||||
debugfilename=debugfilename+ sbnr.ToString() + "_" + intid.ToString() + "_" + partnernr.ToString() + ".json";
|
||||
System.IO.File.WriteAllText(debugfilename, jsonstring);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Log nachführen
|
||||
Update_IL_Log(ref ilr, "SB_" + sbnr.ToString() + "_" + intid.ToString());
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende ArchivSBDoc DokumentID: DokumentID:" + dokumentid, LogLevelType.Debug);
|
||||
return transferResult;
|
||||
//return Content(HttpStatusCode.OK, "");
|
||||
}
|
||||
|
||||
private IHttpActionResult Transfer_OnBase(uploadtype utype, ref string jsonstring, ref ILResponse ilr)
|
||||
{
|
||||
//ILResponse ilr = new ILResponse();
|
||||
string response;
|
||||
WebRequest request;
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start Transfer to OnBase", LogLevelType.Debug);
|
||||
|
||||
string url ="";
|
||||
switch (utype){
|
||||
case uploadtype.fast:
|
||||
url= System.Configuration.ConfigurationManager.AppSettings["ILFast"];
|
||||
break;
|
||||
case uploadtype.slow:
|
||||
url = System.Configuration.ConfigurationManager.AppSettings["ILSlow"];
|
||||
break;
|
||||
case uploadtype.docupload:
|
||||
url = System.Configuration.ConfigurationManager.AppSettings["ILDocupload"];
|
||||
break;
|
||||
}
|
||||
|
||||
var data = Encoding.UTF8.GetBytes(jsonstring);
|
||||
request = WebRequest.Create(url);
|
||||
request.ContentLength = data.Length;
|
||||
request.ContentType = "application/json";
|
||||
request.Method = "POST";
|
||||
try
|
||||
{
|
||||
using (Stream requestStream = request.GetRequestStream())
|
||||
{
|
||||
requestStream.Write(data, 0, data.Length);
|
||||
requestStream.Close();
|
||||
|
||||
using (Stream responseStream = request.GetResponse().GetResponseStream())
|
||||
{
|
||||
using (var reader = new StreamReader(responseStream))
|
||||
{
|
||||
response = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
ilr.StatusCode = 0;
|
||||
ilr.senderror = 0;
|
||||
ilr.response=response;
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende Transfer to OnBase", LogLevelType.Debug);
|
||||
return Content(HttpStatusCode.OK, ilr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ilr.StatusCode = 1;
|
||||
ilr.senderror = 1;
|
||||
ilr.response = ex.Message;
|
||||
return Content(HttpStatusCode.InternalServerError, ilr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
260
API_NetFramework - Kopie (2)/Controllers/DocumentController.cs
Normal file
260
API_NetFramework - Kopie (2)/Controllers/DocumentController.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using DOCGEN;
|
||||
using Model;
|
||||
using Database;
|
||||
using Newtonsoft.Json;
|
||||
using API_NetFramework.Models;
|
||||
using System.Security.Cryptography;
|
||||
using edoka_dms;
|
||||
using SecuringWebApiUsingApiKey.Middleware;
|
||||
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
{
|
||||
public class TestParam
|
||||
{
|
||||
public string param1 { get; set; }
|
||||
public string param2 { get; set; }
|
||||
}
|
||||
public class DocumentController : ApiController
|
||||
{
|
||||
public string tokenfunction = "Dokument";
|
||||
string connectionstring = StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString, "i%!k!7pab%bNLdA5hE4pkR4XaB%E^jB3d9tHuQ4pbF&BZjF7SB#WBWit5#HrbJiLrLVm");
|
||||
[HttpGet]
|
||||
[Route("API/GetDocument")]
|
||||
public IHttpActionResult GetDocument(string dokid)
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start GetDocument DokumentID:"+dokid, LogLevelType.Debug);
|
||||
|
||||
DOCGEN.DocGet gd = new DocGet(connectionstring);
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
dok = gd.GetDoc(dokid);
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende GetDocument DokumentID:" + dokid, LogLevelType.Debug);
|
||||
|
||||
return Ok(dok);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//public object pageCollection { get; set; }
|
||||
//[HttpGet]
|
||||
//[Route("API/GetDocumentJSONBody")]
|
||||
//public IHttpActionResult GetDocumentJSONBody([FromBody] TestParam tp)
|
||||
//{
|
||||
// //JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, PreserveReferencesHandling = PreserveReferencesHandling.None };
|
||||
// //var myObject = JsonConvert.DeserializeObject<TestParam>(pageCollection.ToString(), settings);
|
||||
|
||||
// return Ok(tp.param1);
|
||||
// //return Ok(tp.param1.ToString());
|
||||
//}
|
||||
[Route("API/GetDocumentPDF")]
|
||||
[HttpGet]
|
||||
public IHttpActionResult GetDocumentPDF(string dokid)
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start GetDocumentPDF DokumentID:" + dokid, LogLevelType.Debug);
|
||||
|
||||
DOCGEN.DocGet gd = new DocGet(connectionstring);
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
dok = gd.GetDocAsPDF(dokid);
|
||||
dok.extension = "pdf";
|
||||
dok.doktype = "P";
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende GetDocument DokumentID:" + dokid, LogLevelType.Debug);
|
||||
|
||||
return Ok(dok);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//[HttpGet]
|
||||
//[Route("API/SendToOnBase")]
|
||||
//public IHttpActionResult SendToOnBase(string dokid)
|
||||
//{
|
||||
// if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
// {
|
||||
// return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// APILogging.Log((HttpRequestMessage)Request, "Start SendToOnBase:" + dokid, LogLevelType.Debug);
|
||||
|
||||
// DB db = new DB(connectionstring);
|
||||
// db.Get_Tabledata("Select * from dokument where dokumentid='" + dokid + "'", false, true);
|
||||
// if (db.dsdaten.Tables[0].Rows.Count < 1)
|
||||
// {
|
||||
// db = null;
|
||||
// APILogging.Log((HttpRequestMessage)Request, "Ende GetDocument DokumentID:" + dokid, LogLevelType.Debug);
|
||||
// return BadRequest("Dokument " + dokid + " not found");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// DocGet dg = new DocGet(connectionstring);
|
||||
// clsdok dok = new clsdok("", "", "");
|
||||
|
||||
// dok = dg.GetDocAsPDF(dokid);
|
||||
|
||||
// db.Exec_SQL("Update dokument set loeschgrund='Archiviert' where dokumentid='" + dokid + "'");
|
||||
// db = null;
|
||||
// APILogging.Log((HttpRequestMessage)Request, "Ende GetDocument DokumentID:" + dokid, LogLevelType.Debug);
|
||||
|
||||
// return Ok("Archivierung ausgelöst");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
// return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
[HttpPost]
|
||||
[Route("API/GenDoc")]
|
||||
public IHttpActionResult GenDoc(string Partnernr, String Dokumenttypnr, string TGCreator="", string TGResp="", string TGUL="", string TGUR="", string Faksimile="", string FoU="", string PrintLogo="")
|
||||
{
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
try
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Start GenDoc " , LogLevelType.Debug);
|
||||
|
||||
if (!(ParamCheck("partnernr", Partnernr))) { return BadRequest("Partnernr " + Partnernr + " ist ungültig"); }
|
||||
if (!(ParamCheck("dokumenttyp", Dokumenttypnr))) { return BadRequest("Dokumenttyp " + Dokumenttypnr + " ist ungültig"); }
|
||||
if (!(ParamCheck("tgcreator", TGCreator))) { return BadRequest("TGCreator " + TGCreator + " ist ungültig"); }
|
||||
if (!(ParamCheck("tgresp", TGResp))) { return BadRequest("TGResp " + TGResp + " ist ungültig"); }
|
||||
if (!(ParamCheck("tgul", TGUL))) { return BadRequest("TG Unterschrift links " + TGUL + " ist ungültig"); }
|
||||
if (!(ParamCheck("tgul", TGUR))) { return BadRequest("TG Unterschrift rechts " + TGUR + " ist ungültig"); }
|
||||
if (!(ParamCheck("faksimile", Faksimile))) { return BadRequest("Parameter Faxsimile " + Faksimile + " ist ungültig"); }
|
||||
if (!(ParamCheck("formohneunterschrift", FoU))) { return BadRequest("Parameter Form ohne Unterschrift " + FoU + " ist ungültig"); }
|
||||
if (!(ParamCheck("printlogo", PrintLogo))) { return BadRequest("Parameter PrintLogo " + PrintLogo + " ist ungültig"); }
|
||||
|
||||
Database.DB db = new DB(connectionstring);
|
||||
Model.clsdocgendata docgendata = new Model.clsdocgendata();
|
||||
|
||||
docgendata.partnernr = Partnernr;
|
||||
docgendata.inhaberadresse = "";
|
||||
docgendata.zustelladresse = "";
|
||||
docgendata.dokumenttypnr = Dokumenttypnr;
|
||||
docgendata.unterschriftLinks = db.Get_Mitarbeiternr(TGUL).ToString();
|
||||
docgendata.unterschriftRehts = db.Get_Mitarbeiternr(TGUR).ToString();
|
||||
docgendata.verantwortlich = db.Get_Mitarbeiternr(TGResp).ToString();
|
||||
docgendata.ersteller = db.Get_Mitarbeiternr(TGCreator).ToString();
|
||||
docgendata.team = db.Get_Teamnr(docgendata.ersteller).ToString();
|
||||
docgendata.digitaleunterschrift = false;
|
||||
docgendata.frormularOhneUnterschrift = false;
|
||||
//docgendata.team = "";
|
||||
docgendata.zustaendigkube = db.Get_Mitarbeiternr(TGResp).ToString();
|
||||
docgendata.status = "-1";
|
||||
docgendata.dokumentdatum = DateTime.Now.ToString("dd.MM.yyyy");
|
||||
docgendata.bezeichnung = "";
|
||||
docgendata.erstellungsart = Erstellungsart.DokumentAlsPDF;
|
||||
docgendata.verantwortlich = db.Get_Mitarbeiternr(TGResp).ToString();
|
||||
if (docgendata.verantwortlich == "0") { docgendata.verantwortlich = docgendata.ersteller; }
|
||||
|
||||
clsDocData dokdata = new clsDocData();
|
||||
dokdata.PartnerNr = docgendata.partnernr;
|
||||
dokdata.UseEDOKA_Values = "True";
|
||||
dokdata.DokumenttypNr = docgendata.dokumenttypnr;
|
||||
dokdata.Unterschrift_Links = docgendata.unterschriftLinks;
|
||||
dokdata.Unterschrift_Rechts = docgendata.unterschriftRehts;
|
||||
dokdata.Verantwortlich = docgendata.verantwortlich;
|
||||
dokdata.Team = docgendata.team;
|
||||
dokdata.Zustaendig = docgendata.zustaendigkube;
|
||||
dokdata.Zustaendig = docgendata.zustaendigkube;
|
||||
dokdata.Status = docgendata.status;
|
||||
dokdata.Ersteller = docgendata.ersteller;
|
||||
dokdata.DokumentDatum = docgendata.dokumentdatum;
|
||||
dokdata.Bezeichnung = docgendata.bezeichnung;
|
||||
if (PrintLogo == "Yes") { dokdata.PrintLogo = true; } else { dokdata.PrintLogo = false; }
|
||||
if (docgendata.erstellungsart == Erstellungsart.DokumentAlsPDF) { dokdata.Result_as_PDF = "True"; } else { dokdata.Result_as_PDF = "False"; }
|
||||
if (docgendata.digitaleunterschrift == true) { dokdata.As_Faksimile = "True"; } else { dokdata.As_Faksimile = "False"; }
|
||||
|
||||
string dokumentid = "";
|
||||
dokumentid = db.Create_EDOKA_Doc(dokdata, false, "");
|
||||
|
||||
DOCGEN.Generator.DocGenerator_from_EDOKA Generator = new DOCGEN.Generator.DocGenerator_from_EDOKA(this.connectionstring);
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata);
|
||||
db.Save_To_DB(dokumentid, "", dok.dokument);
|
||||
APILogging.Log((HttpRequestMessage)Request, "Ende GenDoc DokumentID:"+dokumentid, LogLevelType.Debug);
|
||||
|
||||
return Ok(dokumentid);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private bool ParamCheck(string ParamType, string ParamValue)
|
||||
{
|
||||
DB db = new DB(connectionstring);
|
||||
switch (ParamType)
|
||||
{
|
||||
case "partnernr":
|
||||
db.Get_Tabledata("Select count(*) from partner where nrpar00=" + ParamValue, false, true);
|
||||
if (db.dsdaten.Tables[0].Rows[0][0].ToString() == "0") { return false; }
|
||||
break;
|
||||
case "dokumenttyp":
|
||||
db.Get_Tabledata("Select count(*) from dokumenttyp where dokumenttypnr=" + ParamValue, false, true);
|
||||
if (db.dsdaten.Tables[0].Rows[0][0].ToString() == "0") { return false; }
|
||||
break;
|
||||
case "partnerdokumenttyp":
|
||||
//Prüfung Person/Doktyp BP/Doktyp
|
||||
break;
|
||||
case "tgcreator": case "tgresp": case "tgul": case "tgur":
|
||||
if (ParamType == "tgcreator" && ParamValue == "") { return false; } else { if (ParamValue == "") { return true; } };
|
||||
db.Get_Tabledata("Select count(*) from mitarbeiter where tgnummer='" + ParamValue+"'", false, true);
|
||||
if (db.dsdaten.Tables[0].Rows[0][0].ToString() == "0") { return false; }
|
||||
break;
|
||||
case "faksimile":
|
||||
if (ParamValue != "Yes" && ParamValue != "No" && ParamValue !="") { return false; };
|
||||
break;
|
||||
case "formohneunterschrift":
|
||||
if (ParamValue != "Yes" && ParamValue != "No" && ParamValue != "") { return false; };
|
||||
break;
|
||||
case "printlogo":
|
||||
if (ParamValue != "Yes" && ParamValue != "No" && ParamValue != "") { return false; };
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
18
API_NetFramework - Kopie (2)/Controllers/HomeController.cs
Normal file
18
API_NetFramework - Kopie (2)/Controllers/HomeController.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewBag.Title = "Home Page";
|
||||
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
API_NetFramework - Kopie (2)/Controllers/ImageController.cs
Normal file
120
API_NetFramework - Kopie (2)/Controllers/ImageController.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using API_NetFramework.Models;
|
||||
using System.Web.WebPages;
|
||||
using System.IO;
|
||||
|
||||
namespace API_NetFramework.Controllers
|
||||
{
|
||||
public class ImageController : ApiController
|
||||
{
|
||||
string tokenfunction = "Image";
|
||||
|
||||
private System.Drawing.Image ResizeImage(System.Drawing.Image imgToResize, Size size)
|
||||
{
|
||||
// Get the image current width
|
||||
int sourceWidth = imgToResize.Width;
|
||||
// Get the image current height
|
||||
int sourceHeight = imgToResize.Height;
|
||||
float nPercent = 0;
|
||||
float nPercentW = 0;
|
||||
float nPercentH = 0;
|
||||
// Calculate width and height with new desired size
|
||||
nPercentW = ((float)size.Width / (float)sourceWidth);
|
||||
nPercentH = ((float)size.Height / (float)sourceHeight);
|
||||
nPercent = Math.Min(nPercentW, nPercentH);
|
||||
// New Width and Height
|
||||
int destWidth = (int)(sourceWidth * nPercent);
|
||||
int destHeight = (int)(sourceHeight * nPercent);
|
||||
Bitmap b = new Bitmap(destWidth, destHeight);
|
||||
Graphics g = Graphics.FromImage((System.Drawing.Image)b);
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
// Draw image with new width and height
|
||||
g.DrawImage(imgToResize, 0, 0, destWidth, destHeight);
|
||||
g.Dispose();
|
||||
return (System.Drawing.Image)b;
|
||||
}
|
||||
|
||||
private System.Drawing.Image resizeImage(System.Drawing.Image imgToResize, Size size)
|
||||
{
|
||||
return (System.Drawing.Image)(new Bitmap(imgToResize, size));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("API/GetImageAsBase64")]
|
||||
|
||||
public IHttpActionResult GetImageAsBase64(int imageid, int ImageWidth = 0, int ImageHeight = 0)
|
||||
{
|
||||
string path = System.Configuration.ConfigurationManager.AppSettings["ImagePath"];
|
||||
string filename = "";
|
||||
int defaultheigt = 0;
|
||||
int defaultwidth = 0;
|
||||
APILogging.Log((HttpRequestMessage)Request, "Image-Bezug: " + imageid.ToString(), LogLevelType.Info);
|
||||
|
||||
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
||||
{
|
||||
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
||||
}
|
||||
System.Data.DataSet ds = new System.Data.DataSet();
|
||||
ds.ReadXml(path + "imageids.xml");
|
||||
filename = "";
|
||||
foreach (System.Data.DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
if (Convert.ToInt32(row[0]) == imageid)
|
||||
{
|
||||
defaultheigt = Convert.ToInt32(row[3]);
|
||||
defaultwidth = Convert.ToInt32(row[2]);
|
||||
filename = path + row[1].ToString();
|
||||
}
|
||||
}
|
||||
ds.Dispose();
|
||||
if (filename == "")
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Image-Bezug - nicht vorhanden: " + imageid.ToString(), LogLevelType.Info);
|
||||
return Content(HttpStatusCode.NotFound, "Image ID: " + imageid.ToString()+"nicht gefunden");
|
||||
}
|
||||
|
||||
System.Drawing.Image iimg = System.Drawing.Image.FromFile(filename);
|
||||
System.Drawing.Image imgnew = null;
|
||||
|
||||
switch (ImageWidth)
|
||||
{
|
||||
case 0:
|
||||
ImageWidth =defaultwidth;
|
||||
ImageHeight = defaultheigt;
|
||||
Bitmap b = new Bitmap(iimg);
|
||||
imgnew = ResizeImage(b, new Size(ImageHeight, ImageWidth));
|
||||
b = null;
|
||||
break;
|
||||
case -1:
|
||||
imgnew = iimg;
|
||||
break;
|
||||
default:
|
||||
Bitmap b1 = new Bitmap(iimg);
|
||||
imgnew = ResizeImage(b1, new Size(ImageHeight, ImageWidth));
|
||||
b1 = null;
|
||||
break;
|
||||
|
||||
}
|
||||
using (MemoryStream m = new MemoryStream())
|
||||
{
|
||||
string newfilename = path + Guid.NewGuid().ToString() + ".tmp";
|
||||
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);
|
||||
return Ok(Convert.ToBase64String(imageBytes));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
110
API_NetFramework - Kopie (2)/Controllers/MailController.cs
Normal file
110
API_NetFramework - Kopie (2)/Controllers/MailController.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using API_NetFramework.Controllers;
|
||||
using API_NetFramework.Models;
|
||||
using Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.IO;
|
||||
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
|
||||
{
|
||||
public class MailController : ApiController
|
||||
{
|
||||
string tokenfunction = "Mail";
|
||||
|
||||
[HttpGet]
|
||||
[Route("API/SendMail")]
|
||||
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 (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(); }
|
||||
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][3]) == 0)
|
||||
{
|
||||
db = null;
|
||||
return Content(HttpStatusCode.OK, empfaenger + ": Mail gem. MA-Einstelung nicht zugestellt");
|
||||
}
|
||||
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);
|
||||
string debugdir = System.Configuration.ConfigurationManager.AppSettings["DebugDir"];
|
||||
string tmpfile = debugdir + @"\Mail_" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".ps1";
|
||||
StreamWriter writer = new StreamWriter(tmpfile);
|
||||
writer.Write(s);
|
||||
writer.Close();
|
||||
writer.Dispose();
|
||||
System.Diagnostics.Process.Start("powershell.exe", tmpfile);
|
||||
APILogging.Log((HttpRequestMessage)Request, "Mail Versand: " + s, LogLevelType.Debug);
|
||||
//return Content(HttpStatusCode.OK, "Mail versand noch nicht implementiert");
|
||||
return Content(HttpStatusCode.OK, empfaenger + ": Mail versandt");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
APILogging.Log((HttpRequestMessage)Request, "Mail Versand NOK: " + e.Message+" " + s, LogLevelType.Debug);
|
||||
return Content(HttpStatusCode.InternalServerError, e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
API_NetFramework - Kopie (2)/Controllers/TokenController.cs
Normal file
21
API_NetFramework - Kopie (2)/Controllers/TokenController.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace OnDocAPI_NetFramework.Controllers
|
||||
{
|
||||
public class TokenController : ApiController
|
||||
{
|
||||
[HttpGet]
|
||||
[Route("API/Tokengenerator)")]
|
||||
|
||||
public IHttpActionResult TokenGenerator(string function, string pathphrase)
|
||||
{
|
||||
return Ok(SecuringWebApiUsingApiKey.Middleware.StringCipher.Encrypt (function, pathphrase));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
39
API_NetFramework - Kopie (2)/Controllers/ValuesController.cs
Normal file
39
API_NetFramework - Kopie (2)/Controllers/ValuesController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Net;
|
||||
//using System.Net.Http;
|
||||
//using System.Web.Http;
|
||||
|
||||
//namespace API_NetFramework.Controllers
|
||||
//{
|
||||
// public class ValuesController : ApiController
|
||||
// {
|
||||
// // GET api/values
|
||||
// public IEnumerable<string> Get()
|
||||
// {
|
||||
// return new string[] { "value1", "value2" };
|
||||
// }
|
||||
|
||||
// // GET api/values/5
|
||||
// public string Get(int id)
|
||||
// {
|
||||
// return "value";
|
||||
// }
|
||||
|
||||
// // POST api/values
|
||||
// public void Post([FromBody] string value)
|
||||
// {
|
||||
// }
|
||||
|
||||
// // PUT api/values/5
|
||||
// public void Put(int id, [FromBody] string value)
|
||||
// {
|
||||
// }
|
||||
|
||||
// // DELETE api/values/5
|
||||
// public void Delete(int id)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user