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.
179 lines
6.3 KiB
179 lines
6.3 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;
|
|
using API_NetFramework.Models;
|
|
using System.Runtime.Remoting.Messaging;
|
|
using System.IO;
|
|
using System.Web;
|
|
|
|
namespace API_NetFramework.Controllers
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <remarks></remarks>
|
|
public class ArchivController : ApiController
|
|
{
|
|
// GET: OnBase
|
|
string tokenfunction = "Archiv";
|
|
string connectionstring = ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString;
|
|
/// <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 ArchivDoc_From_Database(string DokumentID)
|
|
{
|
|
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
|
{
|
|
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
|
}
|
|
try
|
|
{
|
|
return Ok();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
|
return Content(HttpStatusCode.InternalServerError, e.Message);
|
|
}
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[Route("API/ArchiveDocBase64")]
|
|
/// <summary>
|
|
/// Archiviert das als Base64String übergebene Dokument in OnBase
|
|
/// </summary>
|
|
/// <param name="DokumentID"></param>
|
|
/// <param name="Dokumenttyp"></param>
|
|
/// <returns>
|
|
/// Returncode: 200 (OK)
|
|
/// Dokumenthandle aus OnBase
|
|
/// </returns>
|
|
/// <remarks></remarks>
|
|
//
|
|
public IHttpActionResult ArchivDocBase64(string Dokument, string Dokumenttyp)
|
|
{
|
|
if (SecuringWebApiUsingApiKey.Middleware.ApiKeyMiddleware.Authorized((HttpRequestMessage)Request, tokenfunction) == false)
|
|
{
|
|
return Content(HttpStatusCode.Unauthorized, "Invalid Token or API-Key");
|
|
}
|
|
try
|
|
{
|
|
return Ok();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
|
return Content(HttpStatusCode.InternalServerError, e.Message);
|
|
}
|
|
}
|
|
/// <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
|
|
{
|
|
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);
|
|
}
|
|
return Content(HttpStatusCode.NotFound, DokumentID);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
APILogging.Log((HttpRequestMessage)Request, e.Message, LogLevelType.Error);
|
|
return Content(HttpStatusCode.InternalServerError, e.Message);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
[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
|
|
{
|
|
return Ok();
|
|
}
|
|
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 json = "";
|
|
if (HttpContext.Current.Request.InputStream.Length > 0)
|
|
{
|
|
using (var inputStream = new StreamReader(HttpContext.Current.Request.InputStream))
|
|
{
|
|
json = inputStream.ReadToEnd();
|
|
}
|
|
}
|
|
|
|
string debugfilename = @"X:\\jsontemp\" + sbnr.ToString() + "_" + intid.ToString() + "_"+partnernr.ToString()+".json";
|
|
string SendToOnBase = System.Configuration.ConfigurationManager.AppSettings["SendToOnBase"];
|
|
string SendToFile = System.Configuration.ConfigurationManager.AppSettings["SendToFile"];
|
|
string debugdir = System.Configuration.ConfigurationManager.AppSettings["DebugDir"];
|
|
string jsonstring = json;
|
|
|
|
|
|
//jsonstring = Newtonsoft.Json.JsonConvert.SerializeObject(od);
|
|
if (SendToOnBase != "Yes")
|
|
{
|
|
if (SendToFile == "Yes")
|
|
{
|
|
System.IO.File.WriteAllText(debugfilename, jsonstring);
|
|
}
|
|
}
|
|
return Content(HttpStatusCode.OK, "");
|
|
}
|
|
}
|
|
} |