You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
265 lines
12 KiB
265 lines
12 KiB
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;
|
|
|
|
namespace API_NetFramework.Controllers
|
|
{
|
|
public class AntwortAdresseController : ApiController
|
|
{
|
|
string tokenfunction = "Adresse";
|
|
string connectionstring = ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString;
|
|
/// <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(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(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/API/AntwortAdresse/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(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/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(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/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(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/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);
|
|
return Content(HttpStatusCode.OK, 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);
|
|
}
|
|
|
|
}
|
|
}
|
|
} |