diff --git a/AV-ToolV3/App.config b/AV-ToolV3/App.config new file mode 100644 index 0000000..8d4fccb --- /dev/null +++ b/AV-ToolV3/App.config @@ -0,0 +1,98 @@ + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + + + 1.0 + + + 2.0.4 + + + 0 + + + Normal + + + 0 + + + 681 + + + 1323 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + \ No newline at end of file diff --git a/AV-ToolV3/App.xaml b/AV-ToolV3/App.xaml new file mode 100644 index 0000000..e1cd521 --- /dev/null +++ b/AV-ToolV3/App.xaml @@ -0,0 +1,442 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AV-ToolV3/App.xaml.cs b/AV-ToolV3/App.xaml.cs new file mode 100644 index 0000000..06a717d --- /dev/null +++ b/AV-ToolV3/App.xaml.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace PEP_Tool +{ + /// + /// Interaktionslogik für "App.xaml" + /// + public partial class App : Application + { + void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) + { + // Process unhandled exception + LogFile.WriteLine($"{Environment.NewLine} UnhandledException: {Environment.NewLine + e.Exception}"); + + e.Handled = true; + } + + private void Application_Startup(object sender, StartupEventArgs e) + { + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + + //FirstChanceEx(); + + } + + void FirstChanceEx() + { + AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) => + { + LogFile.WriteLine(eventArgs.Exception.ToString()); + }; + } + + void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + Exception ex = e.ExceptionObject as Exception; + LogFile.WriteLine($"{Environment.NewLine} UnhandledException: {Environment.NewLine + ex.ToString()}"); + + //MessageBox.Show(ex.Message, "Uncaught Thread Exception", MessageBoxButton.OK, MessageBoxImage.Error); + + } + + static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) + { + // Log the exception, display it, etc + LogFile.WriteLine(e.Exception.Message); + + } + + + + private void Application_Exit(object sender, ExitEventArgs e) + { + PEP_Tool.Properties.Settings.Default.Save(); + } + + } +} diff --git a/AV-ToolV3/ChangesQueue.cs b/AV-ToolV3/ChangesQueue.cs new file mode 100644 index 0000000..2502e50 --- /dev/null +++ b/AV-ToolV3/ChangesQueue.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PEP_Tool +{ + public class ChangesQueue + { + public class BemerkungenChanges + { + public object sender { get; set; } + public int index { get; set; } + } + + public class TelefonChanges + { + public object sender { get; set; } + public int index { get; set; } + } + } +} diff --git a/AV-ToolV3/Crypto.cs b/AV-ToolV3/Crypto.cs new file mode 100644 index 0000000..fe700eb --- /dev/null +++ b/AV-ToolV3/Crypto.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace PEP_Tool +{ + public static class Crypto + { + static string CryptoString = @"]VQr$gOKG_19m~p:9y0+DD{6?hL}##l_'^?M)>}OI&EIC~8thwY7YG<\d2[NdKA"; + + public static async Task EncryptString(string Message) + { + await Task.Delay(100); + byte[] Results = null; + System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding(); + MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider(); + byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(CryptoString)); + TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider(); + TDESAlgorithm.Key = TDESKey; + TDESAlgorithm.Mode = CipherMode.ECB; + TDESAlgorithm.Padding = PaddingMode.PKCS7; + byte[] DataToEncrypt = UTF8.GetBytes(Message); + try + { + ICryptoTransform Encryptor = TDESAlgorithm.CreateEncryptor(); + Results = Encryptor.TransformFinalBlock(DataToEncrypt, 0, DataToEncrypt.Length); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex); + } + finally + { + TDESAlgorithm.Clear(); + HashProvider.Clear(); + + } + + return Convert.ToBase64String(Results); + + } + + public static async Task DecryptString(string Message) + { + await Task.Delay(100); + byte[] Results; + System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding(); + MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider(); + byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(CryptoString)); + TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider(); + TDESAlgorithm.Key = TDESKey; + TDESAlgorithm.Mode = CipherMode.ECB; + TDESAlgorithm.Padding = PaddingMode.PKCS7; + byte[] DataToDecrypt = Convert.FromBase64String(Message); + try + { + ICryptoTransform Decryptor = TDESAlgorithm.CreateDecryptor(); + Results = Decryptor.TransformFinalBlock(DataToDecrypt, 0, DataToDecrypt.Length); + } + catch(Exception ex) + { + LogFile.WriteLine(ex.Message.ToString() + $" Datenlänge: {DataToDecrypt.Length}"); + return "%%"; + } + finally + { + TDESAlgorithm.Clear(); + HashProvider.Clear(); + } + return UTF8.GetString(Results); + } + } +} diff --git a/AV-ToolV3/Download.png b/AV-ToolV3/Download.png new file mode 100644 index 0000000..ac8d711 Binary files /dev/null and b/AV-ToolV3/Download.png differ diff --git a/AV-ToolV3/Export.cs b/AV-ToolV3/Export.cs new file mode 100644 index 0000000..ccecf29 --- /dev/null +++ b/AV-ToolV3/Export.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PEP_Tool +{ + public static class Export + { + public static void ExportCSV(List list) + { + string[] arr = new string[list.Count]; + StringBuilder sb = new StringBuilder(); + + MainWindow.main.BarIsIndeterminate = false; + MainWindow.main.BarVisibility = System.Windows.Visibility.Visible; + MainWindow.main.BarMax = list.Count; + + sb.AppendLine($"Name;Vorname;Datum;Zuweisung;Bemerkung;" + Environment.NewLine); + + int count = 0; + foreach(var user in list) + { + count++; + sb.AppendLine($"{user.Name};{user.Vorname};{user.Datum.ToString("dd.MM.yyyy")};{user.Zuweisung};{user.Bemerkung};"); + MainWindow.main.BarValue = count; + } + + MainWindow.main.BarIsIndeterminate = true; + MainWindow.main.BarVisibility = System.Windows.Visibility.Collapsed; + + + Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); + dialog.AddExtension = true; + dialog.DefaultExt = "csv"; + dialog.Filter = "Excel Arbeitsblatt CSV|*.csv"; + dialog.OverwritePrompt = true; + dialog.RestoreDirectory = true; + dialog.Title = "Liste exportieren"; + + dialog.ShowDialog(); + + + if (dialog.FileName != "") + System.IO.File.WriteAllText(dialog.FileName, sb.ToString()); + } + + + } +} diff --git a/AV-ToolV3/FodyWeavers.xml b/AV-ToolV3/FodyWeavers.xml new file mode 100644 index 0000000..c6e1b7c --- /dev/null +++ b/AV-ToolV3/FodyWeavers.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/AV-ToolV3/Helper.cs b/AV-ToolV3/Helper.cs new file mode 100644 index 0000000..a925ba4 --- /dev/null +++ b/AV-ToolV3/Helper.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PEP_Tool +{ + public static class Helper + { + public static string RemoveSpecialCharacters(string str) + { + StringBuilder sb = new StringBuilder(); + foreach (char c in str) + { + if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '.' || c == '_') + { + sb.Append(c); + } + } + return sb.ToString(); + } + + public static bool keyIsSpecialKey(System.Windows.Input.Key key) + { + var b = false; + + if (key == System.Windows.Input.Key.Escape || key == System.Windows.Input.Key.Tab || + key == System.Windows.Input.Key.CapsLock || key == System.Windows.Input.Key.LWin || + key == System.Windows.Input.Key.Left || key == System.Windows.Input.Key.Up || + key == System.Windows.Input.Key.Down || key == System.Windows.Input.Key.Right || + key == System.Windows.Input.Key.End || key == System.Windows.Input.Key.Home || + key == System.Windows.Input.Key.PageUp || key == System.Windows.Input.Key.PageDown || + key == System.Windows.Input.Key.PrintScreen || key == System.Windows.Input.Key.Print || + (key >= System.Windows.Input.Key.F1 && key <= System.Windows.Input.Key.LaunchApplication2) || + key == System.Windows.Input.Key.System || key == System.Windows.Input.Key.Play) + b = true; + else + b = false; // the key will sappressed + + return b; + } + + public static bool isTelNumber(System.Windows.Input.Key Char) + { + return ((Char >= System.Windows.Input.Key.D0 && Char <= System.Windows.Input.Key.D9) || + (Char >= System.Windows.Input.Key.NumPad0 && Char <= System.Windows.Input.Key.NumPad9) || + (Char == System.Windows.Input.Key.Delete || + Char == System.Windows.Input.Key.Divide || + Char == System.Windows.Input.Key.Space || + Char == System.Windows.Input.Key.Back || + Char == System.Windows.Input.Key.Add)); + } + + + + public static bool IsBase64String(this string s) + { + s = s.Trim(); + return (s.Length % 4 == 0) && System.Text.RegularExpressions.Regex.IsMatch(s, @"^[a-zA-Z0-9\+/]*={0,3}$", System.Text.RegularExpressions.RegexOptions.None); + } + + + public static T FindVisualChild(System.Windows.DependencyObject depObj) where T : System.Windows.DependencyObject + { + if (depObj != null) + { + for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(depObj); i++) + { + System.Windows.DependencyObject child = System.Windows.Media.VisualTreeHelper.GetChild(depObj, i); + if (child != null && child is T) + { + return (T)child; + } + + T childItem = FindVisualChild(child); + if (childItem != null) return childItem; + } + } + return null; + } + + + public static int IndexOfNth(this string str, string value, int nth = 1) + { + if (nth <= 0) + throw new ArgumentException("Can not find the zeroth index of substring in string. Must start with 1"); + int offset = str.IndexOf(value); + for (int i = 1; i < nth; i++) + { + if (offset == -1) return -1; + offset = str.IndexOf(value, offset + 1); + } + return offset; + } + + public static int CountSubstring(this string text, string value) + { + int count = 0, minIndex = text.IndexOf(value, 0); + while (minIndex != -1) + { + minIndex = text.IndexOf(value, minIndex + value.Length); + count++; + } + return count; + } + + public static string AddLineNumbers(this string text, int startLine = 1) + { + var i = text.CountSubstring("\n"); + var strArr = text.Split("\n".ToCharArray()); + + for(var j = startLine; j <= i; j++) + { + strArr[j] = $"{j - startLine + 1}. " + strArr[j].TrimStart("1234567890. ".ToCharArray()); + } + + text = string.Join("\n", strArr); + return text; + } + } + + public class ReplaceDotConverter : System.Windows.Data.IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + if (value != null) + { + string original = value.ToString(); + return original.Replace("l, ", ""); + } + else return ""; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/AV-ToolV3/Info.png b/AV-ToolV3/Info.png new file mode 100644 index 0000000..4c65138 Binary files /dev/null and b/AV-ToolV3/Info.png differ diff --git a/AV-ToolV3/LogFile.cs b/AV-ToolV3/LogFile.cs new file mode 100644 index 0000000..a4e60c3 --- /dev/null +++ b/AV-ToolV3/LogFile.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PEP_Tool +{ + public static class LogFile + { + public static void WriteLine(string Text) + { + Debug.WriteLine(DateTime.Now + " v" + Properties.Settings.Default.Version + " " + Text); + try + { + byte[] t = Encoding.ASCII.GetBytes(Text); + if (!Directory.Exists(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt"))) Directory.CreateDirectory(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt")); + + //using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete)) + //{ + // fs.WriteAsync(t, (int)fs.Length, t.Count()); + //} + + File.AppendAllText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt", $"{DateTime.Now} v{Properties.Settings.Default.Version} {Environment.MachineName} {Environment.UserDomainName}:{Environment.NewLine}{Environment.NewLine} {Text.ToString()}{Environment.NewLine}{Environment.NewLine}"); + } + catch (Exception) + { + } + } + + public static void WriteLine(double Text) + { + Debug.WriteLine(DateTime.Now + " v" + Properties.Settings.Default.Version + " " + Text); + try + { + if (!Directory.Exists(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt"))) Directory.CreateDirectory(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt")); + File.AppendAllText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt", $"{DateTime.Now} v{Properties.Settings.Default.Version} {Environment.MachineName} {Environment.UserDomainName}:{Environment.NewLine}{Environment.NewLine} {Text.ToString()}{Environment.NewLine}{Environment.NewLine}"); + } + catch (Exception) + { + } + } + + public static void WriteLine(int Text) + { + Debug.WriteLine(DateTime.Now + " v" + Properties.Settings.Default.Version + " " + Text); + try + { + if (!Directory.Exists(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt"))) Directory.CreateDirectory(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt")); + File.AppendAllText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt", $"{DateTime.Now} v{Properties.Settings.Default.Version} {Environment.MachineName} {Environment.UserDomainName}:{Environment.NewLine}{Environment.NewLine} {Text.ToString()}{Environment.NewLine}{Environment.NewLine}"); + } + catch (Exception) + { + } + } + + public static void WriteLine(bool Text) + { + Debug.WriteLine(DateTime.Now + " v" + Properties.Settings.Default.Version + " " + Text); + try + { + if (!Directory.Exists(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt"))) Directory.CreateDirectory(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt")); + File.AppendAllText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt", $"{DateTime.Now} v{Properties.Settings.Default.Version} {Environment.MachineName} {Environment.UserDomainName}:{Environment.NewLine}{Environment.NewLine} {Text.ToString()}{Environment.NewLine}{Environment.NewLine}"); + } + catch (Exception) + { + } + } + + public static void WriteLine(Exception Text) + { + Debug.WriteLine(DateTime.Now + " v" + Properties.Settings.Default.Version + " " + Text); + try + { + if (!Directory.Exists(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt"))) Directory.CreateDirectory(Path.GetDirectoryName(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt")); + File.AppendAllText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Log.txt", $"{DateTime.Now} v{Properties.Settings.Default.Version} {Environment.MachineName} {Environment.UserDomainName}:{Environment.NewLine}{Environment.NewLine} {Text.ToString()}{Environment.NewLine}{Environment.NewLine}"); + } + catch (Exception) + { + } + } + } +} diff --git a/AV-ToolV3/MainWindow.xaml b/AV-ToolV3/MainWindow.xaml new file mode 100644 index 0000000..071ccfe --- /dev/null +++ b/AV-ToolV3/MainWindow.xaml @@ -0,0 +1,505 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Column + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +