update 20241201
This commit is contained in:
127
Client - Kopie/Backup/UIControls/DocPreview.cs
Normal file
127
Client - Kopie/Backup/UIControls/DocPreview.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using DOCGEN;
|
||||
using OnDoc.Klassen;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OnDoc.UIControls
|
||||
{
|
||||
public partial class DocPreview : UserControl
|
||||
{
|
||||
public DocPreview()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public DocPreview(bool Show_Editfunctions)
|
||||
{
|
||||
InitializeComponent();
|
||||
if (Show_Editfunctions)
|
||||
{
|
||||
this.pnlEdit.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pnlEdit.Visible = false;
|
||||
}
|
||||
|
||||
}
|
||||
public void Show_Editbuttons()
|
||||
{
|
||||
this.pnlEdit.Visible= true;
|
||||
}
|
||||
|
||||
public void Hide_Editbuttons()
|
||||
{
|
||||
this.pnlEdit.Visible = false;
|
||||
}
|
||||
public void Show_Doc(string dokumentid)
|
||||
{
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
dok = GetDoc(true, dokumentid);
|
||||
var stream = new MemoryStream(Convert.FromBase64String(dok.dokument));
|
||||
|
||||
|
||||
//clsGetDoc gd = new clsGetDoc(AppParams.connectionstring);
|
||||
|
||||
if (stream.Length > 0)
|
||||
{
|
||||
this.pdfViewerControl1.Load(stream);
|
||||
this.pdfViewerControl1.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
private clsdok GetDoc(bool AsPDF, string dokumentid)
|
||||
{
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
if (dokumentid == "")
|
||||
{
|
||||
return dok; ;
|
||||
}
|
||||
if (AppParams.RESTURI != "")
|
||||
{
|
||||
string URL = AppParams.RESTURI + "api/GetDocument?dokid=" + dokumentid;
|
||||
if (AsPDF == true)
|
||||
{
|
||||
URL = AppParams.RESTURI + "api/GetDocumentPDF?dokid=" + dokumentid;
|
||||
}
|
||||
|
||||
HttpWebRequest webRequest = HttpWebRequest.Create(URL) as HttpWebRequest;
|
||||
webRequest.Method = WebRequestMethods.Http.Get;
|
||||
//webRequest.Credentials = new NetworkCredential(Username, Password);
|
||||
//webRequest.ContentType = "application/x-www-form-urlencoded";
|
||||
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
|
||||
{
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
StreamReader reader = new StreamReader(response.GetResponseStream());
|
||||
string responseContent = reader.ReadToEnd();
|
||||
|
||||
dok = Newtonsoft.Json.JsonConvert.DeserializeObject<clsdok>(responseContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Logging.Error(URL + ": " + response.StatusCode.ToString() + " / " + response.StatusDescription, "Clinet - DokList GetDocument", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DocGet gd = new DocGet(AppParams.connectionstring);
|
||||
if (AsPDF == true)
|
||||
{
|
||||
dok = gd.GetDocAsPDF(dokumentid);
|
||||
}
|
||||
else
|
||||
{
|
||||
dok = gd.GetDoc(dokumentid);
|
||||
}
|
||||
}
|
||||
|
||||
if (dok.extension.ToString() == "")
|
||||
{
|
||||
|
||||
return dok;
|
||||
}
|
||||
return dok;
|
||||
|
||||
}
|
||||
|
||||
private void pdfViewerControl1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user