update 20241201
This commit is contained in:
83
Client - Kopie/Helper/APIHelper.cs
Normal file
83
Client - Kopie/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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
Client - Kopie/Helper/ConvertHelper.cs
Normal file
56
Client - Kopie/Helper/ConvertHelper.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
public static class ConvertHelper
|
||||
{
|
||||
//public static MemoryStream Base64ToMemoryStram(string Base64String)
|
||||
//{
|
||||
// //data:image/gif;base64,
|
||||
// //this image is a single pixel (black)
|
||||
// byte[] bytes = Convert.FromBase64String(Base64String);
|
||||
|
||||
// using (MemoryStream ms = new MemoryStream(bytes))
|
||||
// {
|
||||
// image = Image.FromStream(ms);
|
||||
// }
|
||||
|
||||
// return image;
|
||||
//}
|
||||
|
||||
public enum DateTimeFormat{
|
||||
datumshort,
|
||||
datummedium,
|
||||
datumlong,
|
||||
|
||||
}
|
||||
public static string Datum(DateTime date, DateTimeFormat format) {
|
||||
switch (format)
|
||||
{
|
||||
case DateTimeFormat.datumshort:
|
||||
return date.ToShortDateString();
|
||||
break;
|
||||
case DateTimeFormat.datummedium:
|
||||
return date.ToString("dd.MMMM yyyy");
|
||||
break;
|
||||
case DateTimeFormat.datumlong:
|
||||
return date.ToLongDateString();
|
||||
break;
|
||||
default:
|
||||
return date.ToShortDateString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return date.ToString("dd.mm.yyyy");
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Client - Kopie/Helper/FileHelper.cs
Normal file
42
Client - Kopie/Helper/FileHelper.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
public class FileHelper
|
||||
{
|
||||
public bool SaveBase64ToFile(string Base64String, string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(Base64String));
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Stream GenerateStreamFromString(string s)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var writer = new StreamWriter(stream);
|
||||
writer.Write(s);
|
||||
writer.Flush();
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
|
||||
public String Base64FromFile(string filename)
|
||||
{
|
||||
Byte[] bytes = File.ReadAllBytes(filename);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
111
Client - Kopie/Helper/Security.cs
Normal file
111
Client - Kopie/Helper/Security.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using OnDoc.Klassen;
|
||||
using Syncfusion.Pdf.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI;
|
||||
using System.Windows.Forms;
|
||||
using Windows.UI.Core.Preview;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
public class Security
|
||||
{
|
||||
|
||||
DataTable secdata = new DataTable();
|
||||
public void set_security(System.Windows.Forms.Control c)
|
||||
{
|
||||
Database.DB db = new Database.DB(AppParams.connectionstring);
|
||||
db.Get_Tabledata("select * from ondoc_funktionen where aktiv=1", false, true);
|
||||
secdata = db.dsdaten.Tables[0];
|
||||
foreach (System.Windows.Forms.Control control in c.Controls)
|
||||
{
|
||||
Type typ = control.GetType();
|
||||
Console.WriteLine(typ.Name);
|
||||
|
||||
if (typ.Name == "Ribbon")
|
||||
{
|
||||
Ribbon tmpribbon = (Ribbon)control;
|
||||
foreach (RibbonTab tab in tmpribbon.Tabs)
|
||||
{
|
||||
switch (Update_Item(tab, tab.Name)) { case 1: tab.Enabled = false; break; case 2: tab.Visible = false; break; default:break; } ;
|
||||
foreach (RibbonPanel panel in tab.Panels)
|
||||
{
|
||||
|
||||
switch (Update_Item(panel,panel.Name)) { case 1: panel.Enabled = false; break; case 2: panel.Visible = false; break; default: break; };
|
||||
|
||||
foreach (RibbonItem item in panel.Items)
|
||||
{
|
||||
switch (Update_Item(item, item.Name)) { case 1: item.Enabled = false; break; case 2: item.Visible = false; break; default: break; };
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typ.Name == "Label")
|
||||
{
|
||||
if (typ.Name == "lblToApprove")
|
||||
{
|
||||
Label lbl = (Label)control;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
get_all_controls(control);
|
||||
}
|
||||
}
|
||||
|
||||
private int Update_Item(object sender, string name)
|
||||
{
|
||||
foreach (DataRow dr in secdata.Rows)
|
||||
{
|
||||
if (dr["Objectname"].ToString() == name)
|
||||
{
|
||||
switch (dr["ObjektStatus"].ToString())
|
||||
{
|
||||
case "1":
|
||||
return 1;
|
||||
break;
|
||||
case "2":
|
||||
return 2;
|
||||
break;
|
||||
case "3":
|
||||
return 3;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void get_all_controls(System.Windows.Forms.Control c)
|
||||
{
|
||||
foreach (System.Windows.Forms.Control subc in c.Controls)
|
||||
{
|
||||
Type typ = c.GetType();
|
||||
Console.WriteLine(typ.Name);
|
||||
if (typ.Name == "Label")
|
||||
{
|
||||
if (typ.Name== "lblToApprove")
|
||||
{
|
||||
Label lbl = (Label)subc;
|
||||
}
|
||||
Ribbon tmpribbon = (Ribbon)c;
|
||||
}
|
||||
get_all_controls(subc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
29
Client - Kopie/Helper/Strings.cs
Normal file
29
Client - Kopie/Helper/Strings.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
public static class Strings
|
||||
{
|
||||
public static string Right(this string value, int length)
|
||||
{
|
||||
if (String.IsNullOrEmpty(value)) return string.Empty;
|
||||
|
||||
return value.Length <= length ? value : value.Substring(value.Length - length);
|
||||
}
|
||||
|
||||
public static string Left(this string value, int maxLength)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return value;
|
||||
maxLength = Math.Abs(maxLength);
|
||||
|
||||
return (value.Length <= maxLength
|
||||
? value
|
||||
: value.Substring(0, maxLength)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
95
Client - Kopie/Helper/TableHelper.cs
Normal file
95
Client - Kopie/Helper/TableHelper.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using OnDoc.Klassen;
|
||||
using Syncfusion.WinForms.DataGrid;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Database;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
|
||||
|
||||
public static class TableHelper
|
||||
{
|
||||
public static void SetColumnsOrder(this DataTable dtbl, params String[] columnNames)
|
||||
{
|
||||
List<string> listColNames = columnNames.ToList();
|
||||
|
||||
//Remove invalid column names.
|
||||
foreach (string colName in columnNames)
|
||||
{
|
||||
if (!dtbl.Columns.Contains(colName))
|
||||
{
|
||||
listColNames.Remove(colName);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string colName in listColNames)
|
||||
{
|
||||
dtbl.Columns[colName].SetOrdinal(listColNames.IndexOf(colName));
|
||||
}
|
||||
}
|
||||
|
||||
public static void FormatTable(ref DataTable tbl, string tablename, ref SfDataGrid grid)
|
||||
{
|
||||
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
db.Get_Tabledata("Select * from spalten where aktiv=1 and tabelle='" + tablename + "'", false, true);
|
||||
foreach (System.Data.DataRow dr in db.dsdaten.Tables[0].Rows)
|
||||
{
|
||||
foreach (DataColumn dc in tbl.Columns)
|
||||
{
|
||||
if (dr["tabellenspalte"].ToString() == dc.ColumnName)
|
||||
{
|
||||
dc.SetOrdinal(Convert.ToInt32(dr["reihenfolge"].ToString()));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
tbl.AcceptChanges();
|
||||
}
|
||||
grid.DataSource = tbl;
|
||||
foreach (System.Data.DataRow dr in db.dsdaten.Tables[0].Rows)
|
||||
{
|
||||
foreach (GridColumn col in grid.Columns)
|
||||
{
|
||||
if (col.HeaderText.ToString() == dr["tabellenspalte"].ToString())
|
||||
{
|
||||
col.HeaderText = dr["spalte"].ToString();
|
||||
if (Convert.ToInt32(dr["Breite"].ToString()) > 0 )
|
||||
{
|
||||
col.Width = Convert.ToInt32(dr["Breite"].ToString());
|
||||
}
|
||||
if (Convert.ToBoolean(dr["Readonly"]) == true)
|
||||
{
|
||||
col.AllowEditing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static string GetCellCValue(ref SfDataGrid grid,string columname)
|
||||
{
|
||||
try {
|
||||
var selectedItem = grid.CurrentItem as DataRowView;
|
||||
var dataRow = (selectedItem as DataRowView).Row;
|
||||
var cellValue = dataRow[columname].ToString();
|
||||
return cellValue;
|
||||
}
|
||||
catch { return ""; }
|
||||
}
|
||||
public static DataTable resort(DataTable dt, string colName, string direction)
|
||||
{
|
||||
dt.DefaultView.Sort = colName + " " + direction;
|
||||
dt = dt.DefaultView.ToTable();
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Client - Kopie/Helper/xmlhelper.cs
Normal file
12
Client - Kopie/Helper/xmlhelper.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
internal class xmlhelper
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user