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.
131 lines
5.5 KiB
131 lines
5.5 KiB
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;
|
|
|
|
|
|
namespace API_NetFramework.Controllers
|
|
{
|
|
public class TestParam
|
|
{
|
|
public string param1 { get; set; }
|
|
public string param2 { get; set; }
|
|
}
|
|
public class DocumentController : ApiController
|
|
{
|
|
|
|
string connectionstring = ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString;
|
|
[HttpGet]
|
|
[Route("API/GetDocument")]
|
|
public IHttpActionResult GetDocument(string dokid)
|
|
{
|
|
|
|
DOCGEN.DocGet gd = new DocGet(connectionstring);
|
|
clsdok dok = new clsdok("", "", "");
|
|
dok = gd.GetDoc(dokid);
|
|
return Ok(dok);
|
|
}
|
|
|
|
public object pageCollection { get; set; }
|
|
[HttpPost]
|
|
[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)
|
|
{
|
|
DOCGEN.DocGet gd = new DocGet(connectionstring);
|
|
clsdok dok = new clsdok("", "", "");
|
|
dok = gd.GetDocAsPDF(dokid);
|
|
dok.extension = "pdf";
|
|
dok.doktype = "P";
|
|
return Ok(dok);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("API/SendToOnBase")]
|
|
public IHttpActionResult SendToOnBase(string dokid)
|
|
{
|
|
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;
|
|
return BadRequest("Dokument " + dokid + " not found");
|
|
}
|
|
else
|
|
{
|
|
db.Exec_SQL("Update dokument set loeschgrund='Archiviert' where dokumentid='"+dokid + "'");
|
|
db = null;
|
|
return Ok("Archivierung ausgelöst");
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("API/GenDoc")]
|
|
public IHttpActionResult GenDoc(string Partnernr, String Dokumenttypnr, string TGCreator="", string TGResp="", string TGUL="", string TGUR="", string Faksimile="", string FoU="")
|
|
{
|
|
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"); }
|
|
|
|
string dokumentid = "";
|
|
return Ok(dokumentid);
|
|
}
|
|
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;
|
|
default:
|
|
return false;
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|