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.
84 lines
2.9 KiB
84 lines
2.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace OnDoc.Helper
|
|
{
|
|
public class APIHelper
|
|
{
|
|
private string resturi = "";
|
|
private string apikey = "";
|
|
|
|
public APIHelper(string iRestURI, string iApiKey)
|
|
{
|
|
resturi = iRestURI;
|
|
apikey = iApiKey;
|
|
}
|
|
public string get_image(int imageid, int width, int height)
|
|
|
|
{
|
|
string URL = resturi + "API/GetImageAsBase64?imageid=" + imageid.ToString() + "&ImageWidth=" + width.ToString() + "&ImageHeight=" + height.ToString();
|
|
HttpWebRequest webRequest = HttpWebRequest.Create(URL) as HttpWebRequest;
|
|
webRequest.Method = WebRequestMethods.Http.Get;
|
|
webRequest.Headers["Authorization"] = "Bearer " + apikey;
|
|
try
|
|
{
|
|
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
|
|
{
|
|
if (response.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
StreamReader reader = new StreamReader(response.GetResponseStream());
|
|
string responseContent = reader.ReadToEnd();
|
|
|
|
return responseContent;
|
|
}
|
|
else
|
|
{
|
|
Logging.Logging.Error(URL + ": " + response.StatusCode.ToString() + " / " + response.StatusDescription, "Client - GetImage", "");
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
public string get_unterschrift(string MaNr)
|
|
{
|
|
|
|
string URL = resturi + "API/GetUnterschriftAsBase64ByMitarbeiternr?MaNr=" + MaNr;
|
|
|
|
HttpWebRequest webRequest = HttpWebRequest.Create(URL) as HttpWebRequest;
|
|
webRequest.Method = WebRequestMethods.Http.Get;
|
|
webRequest.Headers["Authorization"] = "Bearer " + apikey;
|
|
try
|
|
{
|
|
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
|
|
{
|
|
if (response.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
StreamReader reader = new StreamReader(response.GetResponseStream());
|
|
string responseContent = reader.ReadToEnd();
|
|
|
|
return responseContent;
|
|
}
|
|
else
|
|
{
|
|
Logging.Logging.Error(URL + ": " + response.StatusCode.ToString() + " / " + response.StatusDescription, "Clinet - DokList GetDocument", "");
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
}
|