Update 20211218

This commit is contained in:
2021-12-18 10:02:42 +01:00
parent 1254540139
commit 3ef1971def
842 changed files with 199916 additions and 17112 deletions

127
WebAPI/Models/Crypto.cs Normal file
View File

@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace DPMService.Models
{
public class Crypto
{
//public static void Main()
//{
// try
// {
// string original = "Here is some data to encrypt!";
// // Create a new instance of the RijndaelManaged
// // class. This generates a new key and initialization
// // vector (IV).
// using (RijndaelManaged myRijndael = new RijndaelManaged())
// {
// myRijndael.GenerateKey();
// myRijndael.GenerateIV();
// // Encrypt the string to an array of bytes.
// byte[] encrypted = EncryptStringToBytes(original, myRijndael.Key, myRijndael.IV);
// // Decrypt the bytes to a string.
// string roundtrip = DecryptStringFromBytes(encrypted, myRijndael.Key, myRijndael.IV);
// //Display the original data and the decrypted data.
// Console.WriteLine("Original: {0}", original);
// Console.WriteLine("Round Trip: {0}", roundtrip);
// }
// }
// catch (Exception e)
// {
// Console.WriteLine("Error: {0}", e.Message);
// }
//}
public byte[] EncryptStringToBytes(string plainText, byte[] Key, byte[] IV)
{
// Check arguments.
if (plainText == null || plainText.Length <= 0)
throw new ArgumentNullException("plainText");
if (Key == null || Key.Length <= 0)
throw new ArgumentNullException("Key");
if (IV == null || IV.Length <= 0)
throw new ArgumentNullException("IV");
byte[] encrypted;
// Create an RijndaelManaged object
// with the specified key and IV.
using (RijndaelManaged rijAlg = new RijndaelManaged())
{
rijAlg.Key = Key;
rijAlg.IV = IV;
// Create an encryptor to perform the stream transform.
ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV);
// Create the streams used for encryption.
using (MemoryStream msEncrypt = new MemoryStream())
{
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
{
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
{
//Write all data to the stream.
swEncrypt.Write(plainText);
}
encrypted = msEncrypt.ToArray();
}
}
}
// Return the encrypted bytes from the memory stream.
return encrypted;
}
public string DecryptStringFromBytes(byte[] cipherText, byte[] Key, byte[] IV)
{
// Check arguments.
if (cipherText == null || cipherText.Length <= 0)
throw new ArgumentNullException("cipherText");
if (Key == null || Key.Length <= 0)
throw new ArgumentNullException("Key");
if (IV == null || IV.Length <= 0)
throw new ArgumentNullException("IV");
// Declare the string used to hold
// the decrypted text.
string plaintext = null;
// Create an RijndaelManaged object
// with the specified key and IV.
using (RijndaelManaged rijAlg = new RijndaelManaged())
{
rijAlg.Key = Key;
rijAlg.IV = IV;
// Create a decryptor to perform the stream transform.
ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV);
// Create the streams used for decryption.
using (MemoryStream msDecrypt = new MemoryStream(cipherText))
{
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
// Read the decrypted bytes from the decrypting stream
// and place them in a string.
plaintext = srDecrypt.ReadToEnd();
}
}
}
}
return plaintext;
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace BWPMService.Models
{
public class ForgotPasswordInputModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
}
public class LoginInputModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
public class RegisterInputModel
{
[Required]
[EmailAddress]
[Display(Name = "Email")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace DPMService.Models
{
public class PatCharge
{
public int ID { get; set; } = 0;
public int? PatientID { get; set; } = 0;
public string CharcheCode { get; set; } = "";
public DateTime? erstellt_am { get; set; } = DateTime.Now;
public DateTime? mutiert_am { get; set; } = DateTime.Now;
public string mutierer { get; set; } = "";
public bool aktiv { get; set; } = true;
}
public class ViewPatCharche
{
public int id { get; set; } = 0;
public int? patid { get; set; } = 0;
public string charge { get; set; } = "";
public string datum { get; set; } = "";
public bool aktiv { get; set; } = true;
}
}

20
WebAPI/Models/Patient.cs Normal file
View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace DPMService.Models
{
public class Patient
{
public int ID { get; set; } = 0;
public string Pat { get; set; } = "";
public DateTime? TransferDateiTime { get; set; } = DateTime.Now;
public int? Transferdirection { get; set; } = 0;
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BWPMModels
{
public class UserModel
{
public int Id { get; set; }
public string PassWord { get; set; }
public string FullName { get; set; }
public string Email { get; set; }
public DateTime CreatedDate { get; set; }
public string Avatar { get; set; }
}
}

279
WebAPI/Models/dbhelper.cs Normal file
View File

@@ -0,0 +1,279 @@
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace DPMService.Models
{
public class dbhelper
{
//SqlConnection con;
string connectionstring;
public DataSet dsdaten = new DataSet();
private SqlDataAdapter dadaten;
public dbhelper()
{
var configuation = GetConfiguration();
connectionstring = configuation.GetSection("ConnectionStrings").GetSection("DBConnection").Value;
}
public static DataTable ObjectToDataTable(object o)
{
DataTable dt = new DataTable();
List<PropertyInfo> properties = o.GetType().GetProperties().ToList();
foreach (PropertyInfo prop in properties)
dt.Columns.Add(prop.Name, prop.PropertyType);
dt.TableName = o.GetType().Name;
return dt;
}
public IConfigurationRoot GetConfiguration()
{
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
return builder.Build();
}
public DataTable Get_Tabledata(string Tablename, bool StoredProc = false, bool is_SQL_String = false)
{
SqlConnection sqlconnect = new SqlConnection();
DataSet ds = new DataSet();
ds.Tables.Clear();
sqlconnect.ConnectionString = this.connectionstring;
sqlconnect.Open();
SqlDataAdapter da = new SqlDataAdapter("", sqlconnect);
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = sqlconnect;
if (StoredProc == true)
{
sqlcmd.CommandType = CommandType.StoredProcedure;
if (Tablename.IndexOf("@@Mandantnr@@") > 0)
Tablename = Tablename.Replace("@@Mandantnr@@", "");
sqlcmd.CommandText = Tablename;
}
else
{
sqlcmd.CommandType = CommandType.Text;
sqlcmd.CommandText = "Select * from " + Tablename;
}
if (is_SQL_String == true)
sqlcmd.CommandText = Tablename;
da.SelectCommand = sqlcmd;
da.Fill(dsdaten, "Daten");
sqlconnect.Close();
return dsdaten.Tables[0];
}
public void Get_Tabeldata_for_Update(string Tablename, bool StoredProc = false, bool is_SQL_String = false)
{
dsdaten.Clear();
dsdaten.Tables.Clear();
dadaten = new SqlDataAdapter(Tablename, this.connectionstring);
dadaten.Fill(dsdaten, Tablename);
}
public void Update_Tabeldata()
{
SqlCommandBuilder cb = new SqlCommandBuilder(dadaten);
dadaten.Update(dsdaten, dsdaten.Tables[0].TableName);
}
public string Get_TablePraefix(string apikey)
{
Get_Tabledata("select tablepraefix from patchargeapi where apikey='" + apikey + "'", false, true);
if (this.dsdaten.Tables[0].Rows.Count == 0)
{
return "";
}
else
{
return this.dsdaten.Tables[0].Rows[0][0].ToString();
}
}
public Dictionary<string, List<object>> DatatableToDictionary(DataTable dataTable)
{
var dict = new Dictionary<string, List<object>>();
foreach (DataColumn dataColumn in dataTable.Columns)
{
var columnValueList = new List<object>();
foreach (DataRow dataRow in dataTable.Rows)
{
columnValueList.Add(dataRow[dataColumn.ColumnName]);
}
dict.Add(dataColumn.ColumnName, columnValueList);
}
return dict;
}
#region "Converters"
public List<T> ConvertDataTable<T>(DataTable dt)
{
List<T> data = new List<T>();
foreach (DataRow row in dt.Rows)
{
T item = GetItem<T>(row);
data.Add(item);
}
return data;
}
private T GetItem<T>(DataRow dr)
{
Type temp = typeof(T);
T obj = Activator.CreateInstance<T>();
foreach (DataColumn column in dr.Table.Columns)
{
foreach (PropertyInfo pro in temp.GetProperties())
{
if (pro.Name == column.ColumnName)
pro.SetValue(obj, dr[column.ColumnName], null/* TODO Change to default(_) if this is not a reference type */);
else
continue;
}
}
return obj;
}
public IEnumerable<T> GetEntities<T>(DataTable dt)
{
if (dt == null)
{
return null;
}
List<T> returnValue = new List<T>();
List<string> typeProperties = new List<string>();
T typeInstance = Activator.CreateInstance<T>();
foreach (DataColumn column in dt.Columns)
{
var prop = typeInstance.GetType().GetProperty(column.ColumnName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
if (prop != null)
{
typeProperties.Add(column.ColumnName);
}
}
foreach (DataRow row in dt.Rows)
{
T entity = Activator.CreateInstance<T>();
foreach (var propertyName in typeProperties)
{
if (row[propertyName] != DBNull.Value)
{
string str = row[propertyName].GetType().FullName;
if (entity.GetType().GetProperty(propertyName).PropertyType == typeof(System.String))
{
object Val = row[propertyName].ToString();
entity.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(entity, Val, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, null, null);
}
else if (entity.GetType().GetProperty(propertyName).PropertyType == typeof(System.Guid))
{
object Val = Guid.Parse(row[propertyName].ToString());
entity.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(entity, Val, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, null, null);
}
else
{
entity.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(entity, row[propertyName], BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, null, null);
}
}
else
{
entity.GetType().GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(entity, null, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, null, null);
}
}
returnValue.Add(entity);
}
return returnValue.AsEnumerable();
}
public string DataTableToJSONWithStringBuilder(DataTable table)
{
var JSONString = new StringBuilder();
if (table.Rows.Count > 0)
{
JSONString.Append("[");
for (int i = 0; i < table.Rows.Count; i++)
{
JSONString.Append("{");
for (int j = 0; j < table.Columns.Count; j++)
{
if (j < table.Columns.Count - 1)
{
JSONString.Append("\"" + table.Columns[j].ColumnName.ToString() + "\":" + "\"" + table.Rows[i][j].ToString() + "\",");
}
else if (j == table.Columns.Count - 1)
{
JSONString.Append("\"" + table.Columns[j].ColumnName.ToString() + "\":" + "\"" + table.Rows[i][j].ToString() + "\"");
}
}
if (i == table.Rows.Count - 1)
{
JSONString.Append("}");
}
else
{
JSONString.Append("},");
}
}
JSONString.Append("]");
}
return JSONString.ToString();
}
public string ConvertDataTableToString(DataTable table)
{
int iColumnCount = table.Columns.Count;
int iRowCount = table.Rows.Count;
int iTempRowCount = 0;
string strColumName = table.Columns[0].ColumnName;
string strOut = "{";
foreach (DataRow row in table.Rows)
{
strOut = strOut + "{";
foreach (DataColumn col in table.Columns)
{
string val = row.Field<string>(col.ColumnName);
strOut = strOut + col.ColumnName + ":" + val;
if (col.Ordinal != iColumnCount - 1)
{
strOut = strOut + ",";
}
}
strOut = strOut + "}";
iTempRowCount++;
if (iTempRowCount != iRowCount)
{
strOut = strOut + ",";
}
}
strOut = strOut + "}";
return strOut;
}
#endregion
}
}