Auf SSL umgestellt
Bug behoben der es ermöglicht hat mehere Besucher ohne Namen einzutragen
This commit is contained in:
Marcus 2025-07-28 13:18:36 +02:00
parent 12474f99be
commit a67950371c
4 changed files with 82 additions and 22 deletions

View File

@ -12,6 +12,8 @@
</StackPanel> </StackPanel>
<Button x:Name="btnAdd" Content="" ToolTip="Begleitperson hinzufügen" ToolTipService.InitialShowDelay="200" FontFamily="Segoe UI Symbol" FontSize="12" Padding="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,0,0,10" Click="btnAdd_Click" Width="30" Height="30"/> <Button x:Name="btnAdd" Content="" ToolTip="Begleitperson hinzufügen" ToolTipService.InitialShowDelay="200" FontFamily="Segoe UI Symbol" FontSize="12" Padding="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="10,0,0,10" Click="btnAdd_Click" Width="30" Height="30"/>
<Button x:Name="btnRemove" Content="" ToolTip="Begleitperson entfernen" ToolTipService.InitialShowDelay="200" FontFamily="Segoe UI Symbol" FontSize="12" Padding="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="50,0,0,10" Click="btnRemove_Click" Width="30" Height="30"/>
<Button x:Name="btnSend" Content="Eintragen" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10" Click="btnSend_Click"/> <Button x:Name="btnSend" Content="Eintragen" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10" Click="btnSend_Click"/>
</Grid> </Grid>
</mah:MetroWindow> </mah:MetroWindow>

View File

@ -106,11 +106,11 @@ namespace ZKuP
private async void btnSend_Click(object sender, RoutedEventArgs e) private async void btnSend_Click(object sender, RoutedEventArgs e)
{ {
await SendIt(); var legit = await SendIt();
this.Close(); if(legit) this.Close();
} }
private async Task SendIt() private async Task<bool> SendIt()
{ {
var visitors = ""; var visitors = "";
@ -121,7 +121,7 @@ namespace ZKuP
if (t.Text.ToList<char>().Distinct().Count() < 4) if (t.Text.ToList<char>().Distinct().Count() < 4)
{ {
MessageBox.Show("Personen müssen qualifiziert angegeben werden!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Exclamation); MessageBox.Show("Personen müssen qualifiziert angegeben werden!", "Fehler", MessageBoxButton.OK, MessageBoxImage.Exclamation);
return; return false;
} }
else else
visitors += t.Text + ";"; visitors += t.Text + ";";
@ -175,7 +175,7 @@ namespace ZKuP
}); });
} }
} }
else return; else return false;
else else
{ {
if (SQL.RowExists(MainWindow.table.ToString() + ".besucherGroups", "idbesucher", _idBesucher.ToString()).Result) if (SQL.RowExists(MainWindow.table.ToString() + ".besucherGroups", "idbesucher", _idBesucher.ToString()).Result)
@ -221,7 +221,9 @@ namespace ZKuP
} }
else else
{ {
if (MessageBoxResult.OK == MessageBox.Show("Es wurden keine Personen angegeben!\nDie Anzahl der Personen wird somit auf 0 gesetzt", "Keine Angaben", MessageBoxButton.OKCancel, MessageBoxImage.Error)) var msgResult = MessageBox.Show("Es wurden keine Personen angegeben!\nDie Anzahl der Personen wird somit auf 0 gesetzt\nEs wird dann nur die Person die bei 'Name des Besuchers' eingetragen wurde eingelassen!", "Keine Angaben", MessageBoxButton.OKCancel, MessageBoxImage.Error);
if (MessageBoxResult.OK == msgResult)
{ {
if (SQL.RowExists(MainWindow.table.ToString() + ".besucherGroups", "idbesucher", _idBesucher.ToString()).Result) if (SQL.RowExists(MainWindow.table.ToString() + ".besucherGroups", "idbesucher", _idBesucher.ToString()).Result)
{ {
@ -233,16 +235,21 @@ namespace ZKuP
}); });
} }
} }
else if (MessageBoxResult.Cancel == msgResult)
{
return false;
}
} }
//GroupID = Convert.ToInt32(SQL.ReadSingleValue($"SELECT LAST_INSERT_ID()")); //GroupID = Convert.ToInt32(SQL.ReadSingleValue($"SELECT LAST_INSERT_ID()"));
this.DialogResult = true; this.DialogResult = true;
return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.WriteLog(ex.ToString()); Log.WriteLog(ex.ToString());
MessageBox.Show("Es ist ein Fehler beim hinzufügen der Besucher aufgetreten, bitte erneut versuchen", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show("Es ist ein Fehler beim hinzufügen der Besucher aufgetreten, bitte erneut versuchen", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
} }
} }
@ -289,6 +296,16 @@ namespace ZKuP
//width = (columnCount * 320) + 10; //width = (columnCount * 320) + 10;
} }
private void btnRemove_Click(object sender, RoutedEventArgs e)
{
if ((spGroup.Children[0] as WrapPanel).Children.Count > 0)
{
(spGroup.Children[0] as WrapPanel).Children.RemoveAt((spGroup.Children[0] as WrapPanel).Children.Count - 1);
this.Height = this.Height - 60;
}
}
private void Window_LocationChanged(object sender, EventArgs e) private void Window_LocationChanged(object sender, EventArgs e)
{ {
@ -297,7 +314,8 @@ namespace ZKuP
private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
await SendIt(); var legit = await SendIt();
if (!legit) e.Cancel = true;
} }
} }
} }

View File

@ -43,7 +43,7 @@ namespace ZKuP
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
public const string Version = "5.0.5.8"; public const string Version = "5.1.0.0";
public static Roles LoggedInRole { get; private set; } = Roles.None; public static Roles LoggedInRole { get; private set; } = Roles.None;
@ -279,6 +279,8 @@ namespace ZKuP
{ {
await Task.Run(() => AuthenticateUser()); await Task.Run(() => AuthenticateUser());
SQL.GetCipher();
//#if !DEBUG //#if !DEBUG
Helper.CheckIfMultipleInstances(); Helper.CheckIfMultipleInstances();
//#endif //#endif

View File

@ -20,6 +20,7 @@ namespace ZKuP
private static string p = "fNZG8bO+b8lbajxNUCPCIRNBap4/T5N5Qoa0Rec3P9b2EiwC5eNIwfEMjR5Fvc/W"; private static string p = "fNZG8bO+b8lbajxNUCPCIRNBap4/T5N5Qoa0Rec3P9b2EiwC5eNIwfEMjR5Fvc/W";
private static string s = "KYgjkRVn0edFDca2GbZq/A=="; private static string s = "KYgjkRVn0edFDca2GbZq/A==";
private static string u = "F/u2njMf6aE4krZGTjzgZw=="; private static string u = "F/u2njMf6aE4krZGTjzgZw==";
private static string uSSL = "miSRZrFLxAAWlzRLx9B6Ww==";
private static string d = "xWb4X9gPEzwe76zqpysF3w=="; private static string d = "xWb4X9gPEzwe76zqpysF3w==";
private static string dTest = "e+tv3ZaP+cewOJgE7jNNlA=="; private static string dTest = "e+tv3ZaP+cewOJgE7jNNlA==";
//static MySqlConnection conn = new MySqlConnection(GetConnstr()); //static MySqlConnection conn = new MySqlConnection(GetConnstr());
@ -108,23 +109,36 @@ namespace ZKuP
internal static string GetConnstr(bool withTimeout = false) internal static string GetConnstr(bool withTimeout = false)
{ {
#if !DEBUG #if !DEBUG
//Mit SSL
return $"Server={GetIP()};" + return $"Server={GetIP()};" +
$"Uid={Crypto.Decrypt(Crypto.GetHashKey("990C535389C3A18FFD44951DAA291161"), u)};" + $"Uid={Crypto.Decrypt(Crypto.GetHashKey("8734FCD0D69756D3AE7154E69F8042CA"), uSSL)};" +
$"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" +
$"database={Crypto.Decrypt(Crypto.GetHashKey("8EB0CC56E502BFC5C19F6A0A0A53D543"), d)}" +
$";{(withTimeout ? "Connection Timeout = 10" : "")}";
#elif DEBUG
return $"Server={GetIP()};" +
$"Uid={Crypto.Decrypt(Crypto.GetHashKey("990C535389C3A18FFD44951DAA291161"), u)};" +
$"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" + $"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" +
$"database={Crypto.Decrypt(Crypto.GetHashKey("B79DE37BC846D9B1054EE837AAA45D83"), dTest)}" + $"database={Crypto.Decrypt(Crypto.GetHashKey("B79DE37BC846D9B1054EE837AAA45D83"), dTest)}" +
$";{(withTimeout ? "Connection Timeout = 10" : "")}"; $";SslMode=Required;{(withTimeout ? "Connection Timeout = 10" : "")}";
// string serv = $"Server={GetIP()};" + //Ohne SSL
//return $"Server={GetIP()};" +
// $"Uid={Crypto.Decrypt(Crypto.GetHashKey("990C535389C3A18FFD44951DAA291161"), u)};" + // $"Uid={Crypto.Decrypt(Crypto.GetHashKey("990C535389C3A18FFD44951DAA291161"), u)};" +
// $"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" + // $"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" +
//$"database={Crypto.Decrypt(Crypto.GetHashKey("8EB0CC56E502BFC5C19F6A0A0A53D543"), d)}"; // $"database={Crypto.Decrypt(Crypto.GetHashKey("8EB0CC56E502BFC5C19F6A0A0A53D543"), d)}" +
// return serv; // $";{(withTimeout ? "Connection Timeout = 10" : "")}";
#elif DEBUG
//Ohne SSL
//return $"Server={GetIP()};" +
// $"Uid={Crypto.Decrypt(Crypto.GetHashKey("990C535389C3A18FFD44951DAA291161"), u)};" +
// $"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" +
// $"database={Crypto.Decrypt(Crypto.GetHashKey("B79DE37BC846D9B1054EE837AAA45D83"), dTest)}" +
// $";{(withTimeout ? "Connection Timeout = 10" : "")}";
//Mit SSL
return $"Server={GetIP()};" +
$"Uid={Crypto.Decrypt(Crypto.GetHashKey("8734FCD0D69756D3AE7154E69F8042CA"), uSSL)};" +
$"Pwd={Crypto.Decrypt(Crypto.GetHashKey("71A209CC81FDB2F458C4EC8DF7090154"), p)};" +
$"database={Crypto.Decrypt(Crypto.GetHashKey("B79DE37BC846D9B1054EE837AAA45D83"), dTest)}" +
$";SslMode=Required;{(withTimeout ? "Connection Timeout = 10" : "")}";
#endif #endif
} }
public static MySqlDataAdapter GetAdapter() public static MySqlDataAdapter GetAdapter()
@ -138,6 +152,29 @@ namespace ZKuP
return new MySqlConnection(GetConnstr()); return new MySqlConnection(GetConnstr());
} }
internal static void GetCipher()
{
#if DEBUG
using (var conn = GetConnection())
{
conn.Open();
var cmd = new MySqlCommand("SHOW STATUS LIKE 'Ssl_cipher'", conn);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
string varName = reader.GetString(0); // Variable_name
string varValue = reader.GetString(1); // Value
Console.WriteLine($"{varName}: {varValue}");
}
}
conn.Close();
}
#endif
}
public static bool TestConnection() public static bool TestConnection()
{ {
if (!CheckDeviceConnection()) return false; if (!CheckDeviceConnection()) return false;
@ -486,6 +523,7 @@ namespace ZKuP
} }
list.DefaultView.RowFilter = filter; list.DefaultView.RowFilter = filter;
} }
catch (Exception ex) catch (Exception ex)
{ {