update 20241128
This commit is contained in:
83
Client/Helper/APIHelper.cs
Normal file
83
Client/Helper/APIHelper.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user