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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AV-ToolV3/MainWindow.xaml.cs b/AV-ToolV3/MainWindow.xaml.cs
new file mode 100644
index 0000000..c331a10
--- /dev/null
+++ b/AV-ToolV3/MainWindow.xaml.cs
@@ -0,0 +1,2467 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Data.Common;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Windows.Threading;
+
+
+#pragma warning disable CS4014 // Da dieser Aufruf nicht abgewartet wird, wird die Ausführung der aktuellen Methode fortgesetzt, bevor der Aufruf abgeschlossen ist
+#pragma warning disable CC0001 // Use var instead
+
+namespace PEP_Tool
+{
+ ///
+ /// Interaktionslogik für MainWindow.xaml
+ ///
+ public partial class MainWindow : Window, INotifyPropertyChanged
+ {
+ public static MainWindow main;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ FileSystemWatcher fs = new FileSystemWatcher(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\", "*.json");
+
+ //DispatcherTimer jsonTimer = new DispatcherTimer();
+ DispatcherTimer bemerkungTimer = new DispatcherTimer();
+ DispatcherTimer telefonTimer = new DispatcherTimer();
+ DispatcherTimer newVersionTimer = new DispatcherTimer();
+ DispatcherTimer lastChangeTimer = new DispatcherTimer();
+
+ bool checkForChange = false;
+
+ #region Properties
+
+ public List ZuweisungsMoeglichkeiten { get; set; }
+ public Dictionary> AbteilungsNamen { get; set; }
+
+ private List userList;
+ public List UserList
+ {
+ get { return userList; }
+ set
+ {
+ if (propertyChangeAllowed)
+ {
+ userList = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ public List DefaultUserList { get; set; }
+
+ private List bemerkungen = new List();
+ public List Bemerkungen
+ {
+ get { return bemerkungen; }
+ set
+ {
+ if (propertyChangeAllowed)
+ {
+ bemerkungen = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ private bool bemerkungIsEnabled = true;
+ public bool BemerkungIsEnabled
+ {
+ get { return bemerkungIsEnabled; }
+ set
+ {
+ if (propertyChangeAllowed)
+ {
+ bemerkungIsEnabled = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ private List zuweisungen = new List();
+ public List Zuweisungen
+ {
+ get
+ {
+ return zuweisungen;
+ }
+ set
+ {
+ zuweisungen = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private List telefon = new List();
+ public List TelefonList
+ {
+ get
+ {
+ return telefon;
+ }
+ set
+ {
+ telefon = value;
+ OnPropertyChanged();
+ }
+ }
+
+ private bool telefonIsEnabled = true;
+ public bool TelefonIsEnabled
+ {
+ get { return telefonIsEnabled; }
+ set
+ {
+ if (propertyChangeAllowed)
+ {
+ telefonIsEnabled = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+
+ private string lastChangeTime;
+ public string LastChangeTime
+ {
+ get
+ {
+ return lastChangeTime;
+ }
+ set
+ {
+ if (lastChangeTime != value)
+ {
+ lastChangeTime = value;
+
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ if (checkForChange)
+ {
+ lblLastChange.Text = lastChangeTime;
+ lblLastChange.Foreground = new SolidColorBrush(Colors.Red);
+ }
+ }));
+ }
+ }
+ }
+
+
+ #endregion
+
+ public MainWindow()
+ {
+ if (Properties.Settings.Default.newVersionString != Properties.Settings.Default.Version)
+ {
+ Properties.Settings.Default.newVersionScreen = true;
+ Properties.Settings.Default.newVersionString = Properties.Settings.Default.Version;
+ Properties.Settings.Default.Save();
+ }
+
+ if (System.IO.File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Version.txt"))
+ {
+ main = this;
+ PreStart(1);
+ }
+#if !DEBUG
+ else if (System.IO.File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Maintenance.txt"))
+ {
+ main = this;
+ PreStart(2);
+ }
+#endif
+ else if(Environment.CurrentDirectory == @"\\bku\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung")
+ {
+ MessageBox.Show($"Achtung:{Environment.NewLine}Dieses Programm darf nicht mehr aus dem Gruppenlaufwerk gestartet werden!{Environment.NewLine}Bitte die PEP-Tool.exe auf den Desktop kopieren und von dort starten", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Error);
+ Application.Current.Shutdown();
+ }
+ else
+ {
+ if (Properties.Settings.Default.newVersionScreen)
+ {
+ InitializeComponent();
+
+ NewVersionScreen nVs = new NewVersionScreen();
+ nVs.ShowDialog();
+
+ GetDesktopShortcuts();
+
+ main = this;
+
+ Start();
+ }
+ else
+ {
+ InitializeComponent();
+
+ GetDesktopShortcuts();
+
+ main = this;
+
+ Start();
+ }
+ }
+
+
+ this.Title += Properties.Settings.Default.Version;
+ }
+
+ public static bool MessageShown { get; set; } = false;
+ public static bool propertyChangeAllowed { get; set; } = true;
+ //public static bool PersonalNummerIsEnabled { get; set; } = true;
+
+ ///
+ ///
+ ///
+ /// 1: Neue Version, 2: Wartungsarbeiten
+ private async void PreStart(int VersionOrMaintenance)
+ {
+
+ onStartup = true;
+ if (VersionOrMaintenance == 1)
+ {
+ Task.Run(() =>
+ {
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ NewVersionMessageBox nVMB = new NewVersionMessageBox("Es ist eine neue Version verfügbar\nDie Anwendung kann bis zur Aktualisierung nicht gestartet werden.\n\nDie neue Version sollte in wenigen Minuten verfügbar sein.", 10, true);
+ nVMB.Show();
+ }));
+ });
+
+ Task.Run(() =>
+ {
+ while (!MessageShown) { }
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ main.Close();
+ }));
+ });
+ }
+ else if (VersionOrMaintenance == 2)
+ {
+ Task.Run(() =>
+ {
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ NewVersionMessageBox nVMB = new NewVersionMessageBox("Die Anwendung kann wegen Wartungsarbeiten nicht gestartet werden.\n\nDas System sollte in wenigen Minuten wieder verfügbar sein.", 10, true);
+ nVMB.Show();
+ }));
+ });
+
+ Task.Run(() =>
+ {
+ while (!MessageShown) { }
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ main.Close();
+ }));
+ });
+ }
+ }
+
+ private async void Start()
+ {
+ //jsonTimer.Interval = TimeSpan.FromSeconds(3);
+ //jsonTimer.Tick += JsonTimer_Tick;
+
+ bemerkungTimer.Interval = TimeSpan.FromSeconds(10);
+ bemerkungTimer.Tick += BemerkungTimer_Tick;
+
+ telefonTimer.Interval = TimeSpan.FromSeconds(10);
+ telefonTimer.Tick += TelefonTimer_Tick;
+
+ newVersionTimer.Interval = TimeSpan.FromSeconds(10);
+ newVersionTimer.Tick += NewVersionTimer_Tick;
+
+ Tracker.Init_Track();
+ //bar.Visibility = Visibility.Visible;
+ //li.IsActive = true;
+ li.Visibility = Visibility.Visible;
+
+ await Task.Run(() =>
+ {
+ ZuweisungsMoeglichkeiten = Reader.ReadZuweisungsMoeglichkeiten();
+ AbteilungsNamen = Reader.ReadAbteilungsNamen();
+ UserList = Reader.ReadUserList();
+ DefaultUserList = UserList;
+ });
+
+
+
+ var abtFilterList = DefaultUserList.Select(p => p.Abteilung).Distinct().ToList();
+ abtFilterList.Insert(0, "");
+ abtFilterList.Sort();
+ cBFilterAbteilung.ItemsSource = cBFilterAbteilung2.ItemsSource = cBFilterAbteilung3.ItemsSource = abtFilterList;
+
+ //flowDocu.ItemsSource = UserList;
+
+ btnFrueh.IsEnabled = true;
+ btnSpaet.IsEnabled = true;
+ btnNacht.IsEnabled = true;
+
+ //bar.Visibility = Visibility.Collapsed;
+ //li.Visibility = Visibility.Collapsed;
+ //li.IsActive = false;
+
+ //jsonTimer.Start();
+
+ FileWatcher();
+ newVersionTimer.Start();
+ }
+
+
+ bool versionMessage = false;
+ private void NewVersionTimer_Tick(object sender, EventArgs e)
+ {
+ if (System.IO.File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Version.txt"))
+ {
+ if (!versionMessage)
+ {
+ //Task.Run(() => MessageBox.Show("Es ist eine neue Version verfügbar\nDie Anwendung wird in 60 Sekunden automatisch beendet.", "Neue Version", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification));
+ NewVersionMessageBox nVMB = new NewVersionMessageBox("Es ist eine neue Version verfügbar\nDie Anwendung wird in 60 Sekunden automatisch beendet.\n\n" +
+ "Die neue Version sollte in wenigen Minuten verfügbar sein.\n\n" +
+ "Sie können während der nächsten 60 Sekunden weitere Eintragungen vornehmen, die Liste drucken oder exportieren.\n\n\n", 60, false);
+ nVMB.ShowDialog();
+ versionMessage = true;
+ }
+ }
+
+ if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Maintenance.txt"))
+ {
+ if (!versionMessage)
+ {
+ //Task.Run(() => MessageBox.Show("Es ist eine neue Version verfügbar\nDie Anwendung wird in 60 Sekunden automatisch beendet.", "Neue Version", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification));
+ NewVersionMessageBox nVMB = new NewVersionMessageBox("Die Anwendung muss aufgrund von Wartungsarbeiten geschlossen werden\nDie Anwendung wird in 30 Sekunden automatisch beendet.\n\n" +
+ "Das System wird in wenigen Minuten wieder verfügbar sein.\n\n" +
+ "Sie können während der nächsten 30 Sekunden die Liste drucken oder exportieren.\n\n\n", 30, false);
+ nVMB.ShowDialog();
+ versionMessage = true;
+ }
+ }
+ }
+
+
+ private async void FileWatcher()
+ {
+ FileSystemWatcher fs = new FileSystemWatcher(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\", "*.json");
+ fs.EnableRaisingEvents = true;
+ fs.IncludeSubdirectories = false;
+
+ fs.Changed += Fs_Changed;
+
+ li.Visibility = Visibility.Collapsed;
+ }
+
+ bool checkOldJsonData = true;
+ private async void Fs_Changed(object sender, FileSystemEventArgs e)
+ {
+ if(e.Name == "Zuweisungen.json")
+ {
+ await Task.Run(async () =>
+ {
+ try
+ {
+ var zuweisungenList = await Reader.CreateZuweisungenList();
+
+ if (zuweisungenList != null && Zuweisungen != null)
+ {
+ if (!Enumerable.SequenceEqual(zuweisungenList, Zuweisungen))
+ {
+ if (checkForChange)
+ {
+ var items = Zuweisungen.Except(zuweisungenList);
+
+ foreach (var item in items)
+ {
+ if (UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ {
+ //Debug.WriteLine(Zuweisungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung);
+ string z = "";
+ if (Zuweisungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ z = string.IsNullOrEmpty(Zuweisungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung) ? " leer" : " " + Zuweisungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung;
+ else
+ z = " leer";
+
+ string y = "";
+ if (zuweisungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ y = string.IsNullOrEmpty(zuweisungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung) ? " leer" : " " + zuweisungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung;
+ else
+ y = " leer";
+
+ string x = "";
+ x = UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().FilePath ?? "";
+
+ if (x.CountSubstring("\n") > 6)
+ {
+ var i = x.CountSubstring("\n");
+ x = x.Substring(0, x.IndexOf("\n")) + x.Substring(x.IndexOfNth("\n", i - 4));
+ }
+
+ var str = "";
+ var sub = $"{x.Substring(x.IndexOf("\n") + 1).TrimStart("\n".ToCharArray())}";
+
+ if (x.StartsWith("l, Bemerkung wurde geändert"))
+ str = "l, Bemerkung und Zuweisung wurden geändert\n\n" + $"{sub}\nZuweisung:{z} -> {y}";
+
+ else if (x.StartsWith("l, Zuweisung wurde geändert"))
+ str = "l, Zuweisung wurde geändert\n\n" + $"{sub}\nZuweisung:{z} -> {y}";
+
+ else if (x.StartsWith("l, Zuweisung und Bemerkung wurden geändert"))
+ str = "l, Bemerkung und Zuweisung wurden geändert\n\n" + $"{sub}\nZuweisung:{z} -> {y}";
+
+ else if (x.StartsWith("l, Bemerkung und Zuweisung wurden geändert"))
+ str = "l, Bemerkung und Zuweisung wurden geändert\n\n" + $"{sub}\nZuweisung:{z} -> {y}";
+
+ else
+ str = $"l, Zuweisung wurde geändert\n\nZuweisung:{z} -> {y}";
+
+ str = str.AddLineNumbers(2);
+ UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().FilePath = str;
+ }
+ }
+ }
+
+ foreach (var user in UserList)
+ {
+ if (zuweisungenList != null)
+ {
+ if (UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0 && zuweisungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0)
+ {
+ UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Zuweisung = zuweisungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Zuweisung;
+ //UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum && p.FilePath == ".").First().FilePath = "●";
+ }
+ }
+ }
+ Zuweisungen = zuweisungenList;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ });
+ }
+
+ if(e.Name == "Bemerkungen.json")
+ {
+ await Task.Run(async () =>
+ {
+ try
+ {
+ var bemerkungenList = await Reader.CreateBemerkungenList();
+
+
+ if (bemerkungenList != null && Bemerkungen != null)
+ {
+ if (!Enumerable.SequenceEqual(bemerkungenList, Bemerkungen))
+ {
+ if (checkForChange)
+ {
+ var items = Bemerkungen.Except(bemerkungenList);
+
+ foreach (var item in items)
+ {
+ if (UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ {
+ string z = "";
+ if (Bemerkungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ z = string.IsNullOrEmpty(Bemerkungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Bemerkung) ? " leer" : " " + Bemerkungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Bemerkung;
+ else
+ z = " leer";
+
+ string y = "";
+ if (bemerkungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ y = string.IsNullOrEmpty(bemerkungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Bemerkung) ? " leer" : " " + bemerkungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Bemerkung;
+ else
+ y = " leer";
+
+ string x = "";
+ x = UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().FilePath ?? "";
+
+ if (x.CountSubstring("\n") > 6)
+ {
+ var i = x.CountSubstring("\n");
+ x = x.Substring(0, x.IndexOf("\n")) + x.Substring(x.IndexOfNth("\n", i - 4));
+ }
+
+ var str = "";
+ var sub = $"{x.Substring(x.IndexOf("\n") + 1).TrimStart("\n".ToCharArray())}";
+
+ if (x.StartsWith("l, Zuweisung wurde geändert"))
+ str = "l, Zuweisung und Bemerkung wurden geändert\n\n" + $"{sub}\nBemerkung:{z} -> {y}";
+
+ else if (x.StartsWith("l, Bemerkung wurde geändert"))
+ str = "l, Bemerkung wurde geändert\n\n" + $"{sub}\nBemerkung:{z} -> {y}";
+
+ else if (x.StartsWith("l, Bemerkung und Zuweisung wurden geändert"))
+ str = "l, Zuweisung und Bemerkung wurden geändert\n\n" + $"{sub}\nBemerkung:{z} -> {y}";
+
+ else if (x.StartsWith("l, Zuweisung und Bemerkung wurden geändert"))
+ str = "l, Zuweisung und Bemerkung wurden geändert\n\n" + $"{sub}\nBemerkung:{z} -> {y}";
+
+ else
+ str = $"l, Bemerkung wurde geändert\n\nBemerkung Alter Wert:{z} -> {y}";
+
+ str = str.AddLineNumbers(2);
+ UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().FilePath = str;
+ }
+ }
+ }
+
+ foreach (var user in UserList)
+ {
+ if (bemerkungenList != null)
+ {
+ if (UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0 && bemerkungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0)
+ UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Bemerkung = bemerkungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Bemerkung;
+
+ }
+ }
+ Bemerkungen = bemerkungenList;
+
+
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ });
+ }
+
+ if(e.Name == "Telefon.json")
+ {
+ await Task.Run(async () =>
+ {
+ try
+ {
+ var telefonList = await Reader.CreateTelefonList();
+
+
+ if (telefonList != null && TelefonList != null)
+ {
+ if (!Enumerable.SequenceEqual(telefonList, TelefonList))
+ {
+
+ foreach (var user in UserList)
+ {
+ if (telefonList != null)
+ {
+ if (UserList.Where(p => p.PersNummer == user.PersNummer).Count() > 0 && telefonList.Where(p => p.PersNummer == user.PersNummer).Count() > 0)
+ {
+ UserList.Where(p => p.PersNummer == user.PersNummer).First().Telefon = telefonList.Where(p => p.PersNummer == user.PersNummer).First().Telefon;
+ //UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum && p.FilePath == ".").First().FilePath = "●";
+ }
+
+ }
+ }
+ TelefonList = telefonList;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ });
+ }
+
+ checkForChange = true;
+
+ if (checkOldJsonData)
+ {
+ Bemerkungen = Reader.CreateBemerkungenList().Result;
+ Zuweisungen = Reader.CreateZuweisungenList().Result;
+
+ var u = UserList.Min(p => p.Datum) - TimeSpan.FromDays(10);
+
+ Bemerkungen = Bemerkungen.Except(Bemerkungen.Where(p => p.Datum < u)).ToList();
+ Zuweisungen = Zuweisungen.Except(Zuweisungen.Where(p => p.Datum < u)).ToList();
+
+
+ var json = Newtonsoft.Json.JsonConvert.SerializeObject(Zuweisungen);
+ json = await Crypto.EncryptString(json);
+ byte[] jsonB = new UTF8Encoding(true).GetBytes(json);
+
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Zuweisungen.json", FileMode.Open, FileAccess.Write, FileShare.None)) //FileShare.Read geändert 18.02.19
+ {
+ if (fs != null)
+ {
+ fs.SetLength(0);
+ await fs.WriteAsync(jsonB, 0, jsonB.Length);
+ }
+ else fs.Dispose();
+ }
+
+ var jsonBem = Newtonsoft.Json.JsonConvert.SerializeObject(Bemerkungen);
+ jsonBem = await Crypto.EncryptString(jsonBem);
+ byte[] jsonByte = new UTF8Encoding(true).GetBytes(jsonBem);
+
+
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Bemerkungen.json", FileMode.Open, FileAccess.Write, FileShare.None)) //FileShare.Read geändert 18.02.19
+ {
+ if (fs != null)
+ {
+ fs.SetLength(0);
+ await fs.WriteAsync(jsonByte, 0, jsonByte.Length);
+ }
+ else fs.Dispose();
+ }
+
+ checkOldJsonData = false;
+ }
+ }
+
+ //private async void JsonTimer_Tick(object sender, EventArgs e)
+ //{
+ // await Task.Run(async () =>
+ // {
+ // try
+ // {
+ // var zuweisungenList = await Reader.CreateZuweisungenList();
+
+
+ // if (zuweisungenList != null && Zuweisungen != null)
+ // {
+ // if (!Enumerable.SequenceEqual(zuweisungenList, Zuweisungen))
+ // {
+ // if (checkForChange)
+ // {
+ // //zuweisungenList.OrderBy(p => p.PersNummer);
+ // //Zuweisungen.OrderBy(p => p.PersNummer);
+ // var items = zuweisungenList.Except(Zuweisungen);
+
+ // foreach (var item in items)
+ // {
+ // if (UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ // {
+ // //Debug.WriteLine(Zuweisungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung);
+ // string z = "";
+ // if (Zuweisungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ // z = string.IsNullOrEmpty(Zuweisungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung) ? " leer" : " " + Zuweisungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung;
+ // else
+ // z = " leer";
+
+ // string y = "";
+ // if (zuweisungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ // y = string.IsNullOrEmpty(zuweisungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung) ? " leer" : " " + zuweisungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Zuweisung;
+ // else
+ // y = " leer";
+
+ // string x = "";
+ // x = UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().FilePath ?? "";
+
+ // if (x.CountSubstring("\n") > 6)
+ // {
+ // var i = x.CountSubstring("\n");
+ // x = x.Substring(0, x.IndexOf("\n")) + x.Substring(x.IndexOfNth("\n", i - 4));
+ // }
+
+ // var str = "";
+ // var sub = $"{x.Substring(x.IndexOf("\n") + 1).TrimStart("\n".ToCharArray())}";
+
+ // if (x.StartsWith("l, Bemerkung wurde geändert"))
+ // str = "l, Bemerkung und Zuweisung wurden geändert\n\n" + $"{sub}\nZuweisung:{z} -> {y}";
+
+ // else if (x.StartsWith("l, Zuweisung wurde geändert"))
+ // str = "l, Zuweisung wurde geändert\n\n" + $"{sub}\nZuweisung:{z} -> {y}";
+
+ // else if (x.StartsWith("l, Zuweisung und Bemerkung wurden geändert"))
+ // str = "l, Bemerkung und Zuweisung wurden geändert\n\n" + $"{sub}\nZuweisung:{z} -> {y}";
+
+ // else if (x.StartsWith("l, Bemerkung und Zuweisung wurden geändert"))
+ // str = "l, Bemerkung und Zuweisung wurden geändert\n\n" + $"{sub}\nZuweisung:{z} -> {y}";
+
+ // else
+ // str = $"l, Zuweisung wurde geändert\n\nZuweisung:{z} -> {y}";
+
+ // str = str.AddLineNumbers(2);
+ // UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().FilePath = str;
+ // }
+ // }
+ // }
+
+ // foreach (var user in UserList)
+ // {
+ // if (zuweisungenList != null)
+ // {
+ // if (PersonalNummerIsEnabled)
+ // {
+ // if (UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0 && zuweisungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0)
+ // {
+ // UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Zuweisung = zuweisungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Zuweisung;
+ // //UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum && p.FilePath == ".").First().FilePath = "●";
+ // }
+
+ // //var a = UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count();
+ // //var b = zuweisungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum && p.Zuweisung != user.Zuweisung).Count();
+ // //var c = zuweisungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count();
+
+ // //if (UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0 && zuweisungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0)
+ // //{
+ // // if (zuweisungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Zuweisung != user.Zuweisung)
+ // // UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().FilePath = "●";
+ // // //UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum && p.FilePath == ".").First().FilePath = "●";
+ // //}
+ // }
+ // else
+ // {
+ // if (UserList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).Count() > 0 && zuweisungenList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).Count() > 0)
+ // UserList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).First().Zuweisung = zuweisungenList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).First().Zuweisung;
+ // }
+
+
+ // //flowDocu.ItemsSource = UserList;
+ // }
+ // }
+ // Zuweisungen = zuweisungenList;
+ // }
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // LogFile.WriteLine(ex.ToString());
+ // LogFile.WriteLine("Message: " + ex.Message);
+ // if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ // }
+
+ // try
+ // {
+ // var bemerkungenList = await Reader.CreateBemerkungenList();
+
+
+ // if (bemerkungenList != null && Bemerkungen != null)
+ // {
+ // if (!Enumerable.SequenceEqual(bemerkungenList, Bemerkungen))
+ // {
+ // if (checkForChange)
+ // {
+ // //zuweisungenList.OrderBy(p => p.PersNummer);
+ // //Zuweisungen.OrderBy(p => p.PersNummer);
+ // var items = bemerkungenList.Except(Bemerkungen);
+
+ // foreach (var item in items)
+ // {
+ // if (UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ // {
+ // string z = "";
+ // if (Bemerkungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ // z = string.IsNullOrEmpty(Bemerkungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Bemerkung) ? " leer" : " " + Bemerkungen.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Bemerkung;
+ // else
+ // z = " leer";
+
+ // string y = "";
+ // if (bemerkungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).Count() > 0)
+ // y = string.IsNullOrEmpty(bemerkungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Bemerkung) ? " leer" : " " + bemerkungenList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().Bemerkung;
+ // else
+ // y = " leer";
+
+ // string x = "";
+ // x = UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().FilePath ?? "";
+
+ // if (x.CountSubstring("\n") > 6)
+ // {
+ // var i = x.CountSubstring("\n");
+ // x = x.Substring(0, x.IndexOf("\n")) + x.Substring(x.IndexOfNth("\n", i - 4));
+ // }
+
+ // var str = "";
+ // var sub = $"{x.Substring(x.IndexOf("\n") + 1).TrimStart("\n".ToCharArray())}";
+
+ // if (x.StartsWith("l, Zuweisung wurde geändert"))
+ // str = "l, Zuweisung und Bemerkung wurden geändert\n\n" + $"{sub}\nBemerkung:{z} -> {y}";
+
+ // else if (x.StartsWith("l, Bemerkung wurde geändert"))
+ // str = "l, Bemerkung wurde geändert\n\n" + $"{sub}\nBemerkung:{z} -> {y}";
+
+ // else if (x.StartsWith("l, Bemerkung und Zuweisung wurden geändert"))
+ // str = "l, Zuweisung und Bemerkung wurden geändert\n\n" + $"{sub}\nBemerkung:{z} -> {y}";
+
+ // else if (x.StartsWith("l, Zuweisung und Bemerkung wurden geändert"))
+ // str = "l, Zuweisung und Bemerkung wurden geändert\n\n" + $"{sub}\nBemerkung:{z} -> {y}";
+
+ // else
+ // str = $"l, Bemerkung wurde geändert\n\nBemerkung Alter Wert:{z} -> {y}";
+
+ // str = str.AddLineNumbers(2);
+ // UserList.Where(p => p.PersNummer == item.PersNummer && p.Datum == item.Datum).First().FilePath = str;
+ // }
+ // }
+ // }
+
+ // foreach (var user in UserList)
+ // {
+ // if (bemerkungenList != null)
+ // {
+ // if (PersonalNummerIsEnabled)
+ // {
+ // if (UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0 && bemerkungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0)
+ // UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Bemerkung = bemerkungenList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Bemerkung;
+ // }
+ // else
+ // {
+ // if (UserList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).Count() > 0 && bemerkungenList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).Count() > 0)
+ // UserList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).First().Bemerkung = bemerkungenList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).First().Bemerkung;
+ // }
+
+
+ // //flowDocu.ItemsSource = UserList;
+ // }
+ // }
+ // Bemerkungen = bemerkungenList;
+
+
+ // }
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // LogFile.WriteLine(ex.ToString());
+ // LogFile.WriteLine("Message: " + ex.Message);
+ // if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ // }
+
+
+ // try
+ // {
+ // var telefonList = await Reader.CreateTelefonList();
+
+
+ // if (telefonList != null && TelefonList != null)
+ // {
+ // if (!Enumerable.SequenceEqual(telefonList, TelefonList))
+ // {
+
+ // foreach (var user in UserList)
+ // {
+ // if (telefonList != null)
+ // {
+ // if (PersonalNummerIsEnabled)
+ // {
+ // //if (UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0 && telefonList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).Count() > 0)
+ // //{
+ // // UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Telefon = telefonList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum).First().Telefon;
+ // // //UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum && p.FilePath == ".").First().FilePath = "●";
+ // //}
+ // if (UserList.Where(p => p.PersNummer == user.PersNummer).Count() > 0 && telefonList.Where(p => p.PersNummer == user.PersNummer).Count() > 0)
+ // {
+ // UserList.Where(p => p.PersNummer == user.PersNummer).First().Telefon = telefonList.Where(p => p.PersNummer == user.PersNummer).First().Telefon;
+ // //UserList.Where(p => p.PersNummer == user.PersNummer && p.Datum == user.Datum && p.FilePath == ".").First().FilePath = "●";
+ // }
+
+ // }
+ // else
+ // {
+ // if (UserList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).Count() > 0 && telefonList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).Count() > 0)
+ // UserList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).First().Telefon = telefonList.Where(p => p.Name == user.Name && p.Vorname == user.Vorname && p.Datum == user.Datum).First().Telefon;
+ // }
+
+
+ // //flowDocu.ItemsSource = UserList;
+ // }
+ // }
+ // TelefonList = telefonList;
+ // }
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // LogFile.WriteLine(ex.ToString());
+ // LogFile.WriteLine("Message: " + ex.Message);
+ // if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ // }
+
+
+ // });
+
+
+ // //if (!checkForChange) this.Width = flowDocu.ActualWidth + 20;
+
+ // //jsonTimer.Stop();
+
+ //}
+
+
+
+ private async void btnOpenFile_Click(object sender, RoutedEventArgs e)
+ {
+ //bar.Visibility = Visibility.Visible;
+ //li.IsActive = true;
+ li.Visibility = Visibility.Visible;
+
+ await Task.Run(() =>
+ {
+ ZuweisungsMoeglichkeiten = Reader.ReadZuweisungsMoeglichkeiten();
+ AbteilungsNamen = Reader.ReadAbteilungsNamen();
+ UserList = Reader.ReadUserList(true);
+ DefaultUserList = UserList;
+ });
+
+ var abtFilterList = DefaultUserList.Select(p => p.Abteilung).Distinct().ToList();
+ abtFilterList.Insert(0, "");
+ abtFilterList.Sort();
+ cBFilterAbteilung.ItemsSource = cBFilterAbteilung2.ItemsSource = cBFilterAbteilung3.ItemsSource = abtFilterList;
+
+ //flowDocu.ItemsSource = UserList;
+
+ btnFrueh.IsEnabled = true;
+ btnSpaet.IsEnabled = true;
+ btnNacht.IsEnabled = true;
+
+ //bar.Visibility = Visibility.Collapsed;
+ li.Visibility = Visibility.Collapsed;
+ //li.IsActive = false;
+
+ //jsonTimer.Start();
+
+ FileWatcher();
+ newVersionTimer.Start();
+ }
+
+
+ private async void ComboBox_DropDownClosed(object sender, EventArgs e)
+ {
+ li.Visibility = Visibility.Visible;
+ await Task.Delay(30);
+
+ try
+ {
+ var box = sender as ComboBox;
+ DataGridRow dataGridRow = FindParent(box);
+ int index = dataGridRow.GetIndex();
+
+ TextBlock persnummer = null;
+
+ var name = flowDocu.Columns[0].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ var vorname = flowDocu.Columns[1].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ var datum = flowDocu.Columns[2].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+ var Zuweisungen = await Reader.CreateZuweisungenList();
+ if (Zuweisungen != null)
+ {
+ if (!Zuweisungen.Select(p => p.PersNummer).Contains(persnummer.Text))
+ {
+ if (cBzuweisungFullDataset.IsChecked.Value)
+ {
+ foreach (var user in DefaultUserList)
+ {
+ if (user.PersNummer == persnummer.Text)
+ {
+ Zuweisungen.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = user.Datum,
+ Zuweisung = box.SelectedItem == null ? "" : box.SelectedItem.ToString()
+ });
+ }
+ }
+ }
+ else
+ {
+ Zuweisungen.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Zuweisung = box.SelectedItem == null ? "" : box.SelectedItem.ToString()
+ });
+ }
+ }
+ else
+ {
+ if (Zuweisungen.Where(p => (p.PersNummer == persnummer.Text && p.Datum == DateTime.Parse(datum.Text))).Count() > 0 && box.SelectedItem != null)
+ {
+ if (cBzuweisungFullDataset.IsChecked.Value)
+ {
+ foreach (var user in Zuweisungen.Where(p => (p.PersNummer == persnummer.Text)))
+ {
+ Zuweisungen.Where(p => (p == user)).First().Zuweisung = box.SelectedItem.ToString();
+ }
+ }
+ else
+ Zuweisungen.Where(p => (p.PersNummer == persnummer.Text && p.Datum == DateTime.Parse(datum.Text))).First().Zuweisung = box.SelectedItem.ToString();
+ }
+ else
+ {
+ if (cBzuweisungFullDataset.IsChecked.Value)
+ {
+ foreach (var user in DefaultUserList)
+ {
+ if (user.PersNummer == persnummer.Text)
+ {
+ Zuweisungen.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = user.Datum,
+ Zuweisung = box.SelectedItem == null ? "" : box.SelectedItem.ToString()
+ });
+ }
+ }
+ }
+ else
+ {
+ Zuweisungen.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Zuweisung = box.SelectedItem == null ? "" : box.SelectedItem.ToString()
+ });
+ }
+ }
+ }
+ }
+ else Zuweisungen.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Zuweisung = box.SelectedItem == null ? "" : box.SelectedItem.ToString()
+ });
+
+ if (cBzuweisungFullDataset.IsChecked.Value)
+ {
+ if (box.SelectedItem != null)
+ {
+ foreach (var user in DefaultUserList.Where(p => (p.PersNummer == persnummer.Text)))
+ DefaultUserList.Where(p => (p == user)).First().Zuweisung = box.SelectedItem.ToString();
+ }
+ }
+ else
+ {
+ if (UserList.Where(p => (p.PersNummer == persnummer.Text && p.Datum == DateTime.Parse(datum.Text))).Count() > 0 && box.SelectedItem != null)
+ UserList.Where(p => (p.PersNummer == persnummer.Text && p.Datum == DateTime.Parse(datum.Text))).First().Zuweisung = box.SelectedItem.ToString();
+ }
+
+ var json = Newtonsoft.Json.JsonConvert.SerializeObject(Zuweisungen);
+ json = await Crypto.EncryptString(json);
+ byte[] jsonB = new UTF8Encoding(true).GetBytes(json);
+
+
+
+
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Zuweisungen.json", FileMode.Open, FileAccess.Write, FileShare.None)) //FileShare.Read geändert 18.02.19
+ {
+ if (fs != null)
+ {
+ fs.SetLength(0);
+ await fs.WriteAsync(jsonB, 0, jsonB.Length);
+ }
+ else fs.Dispose();
+ }
+
+ li.Visibility = Visibility.Collapsed;
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+
+ //li.Visibility = Visibility.Collapsed;
+ }
+ }
+
+#region Bemerkung
+
+ List BemerkungenChanges = new List();
+ TextBox bemerkungTextbox = null;
+ //TextBox lastTextChangedTextbox = null;
+ private void Bemerkung_KeyDown(object sender, KeyEventArgs e)
+ {
+ try
+ {
+ var box = sender as TextBox;
+
+ if (!Helper.keyIsSpecialKey(e.Key))
+ {
+ if (box.Text.ToLower().Contains("krank")) MessageBox.Show("Bitte nicht \"Krank\" eintragen (Datenschutz)\nWenn möglich stattdessen Zuweisung auf \"nicht Anwesend\" stellen", "Achtung!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
+ e.Handled = false;
+ //lastTextChangedTextbox = box;
+ //Debug.WriteLine("NonSpecialKey");
+ bemerkungTextbox = box;
+ bemerkungTimer.Stop();
+ bemerkungTimer.Start();
+
+ DisableFilterChange();
+ }
+ else e.Handled = true;
+
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.ToString());
+ }
+ }
+
+ private void Bemerkung_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ try
+ {
+ if (bemerkungTextbox != null)
+ {
+ DataGridRow dataGridRow = FindParent(bemerkungTextbox);
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+
+ if (BemerkungenChanges.Where(p => p.sender == bemerkungTextbox).Count() == 0)
+ BemerkungenChanges.Add(new ChangesQueue.BemerkungenChanges() { sender = bemerkungTextbox, index = index });
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.ToString());
+ }
+ }
+
+ private void BemerkungTimer_Tick(object sender, EventArgs e)
+ {
+ try
+ {
+ var bembox = bemerkungTextbox;
+ if (bembox != null)
+ {
+ DataGridRow dataGridRow = FindParent(bembox);
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+
+ if (BemerkungenChanges.Where(p => p.sender == bembox).Count() == 0)
+ BemerkungenChanges.Add(new ChangesQueue.BemerkungenChanges() { sender = bembox, index = index });
+ }
+ }
+
+ //BemerkungIsEnabled = false;
+ SaveBemerkung(BemerkungenChanges);
+ bemerkungTimer.Stop();
+ EnableFilterChange();
+
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.ToString());
+ }
+ }
+
+
+
+ private async void SaveBemerkung(List bemerkungenChanges)
+ {
+ var Bemerkungen = await Reader.CreateBemerkungenList();
+
+ foreach (var change in bemerkungenChanges)
+ {
+ try
+ {
+ var box = change.sender as TextBox;
+ int index = change.index;
+
+ TextBlock persnummer = null;
+
+ var name = flowDocu.Columns[0].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ var vorname = flowDocu.Columns[1].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ var datum = flowDocu.Columns[2].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+
+ if (Bemerkungen != null && persnummer != null)
+ {
+ if (!Bemerkungen.Select(p => p.PersNummer).Contains(persnummer.Text))
+ {
+ Bemerkungen.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Bemerkung = box.Text == null ? "" : box.Text.ToString()
+ });
+ }
+ else
+ {
+ if (Bemerkungen.Where(p => (p.PersNummer == persnummer.Text && p.Datum == DateTime.Parse(datum.Text))).Count() > 0 && box != null)
+ Bemerkungen.Where(p => (p.PersNummer == persnummer.Text && p.Datum == DateTime.Parse(datum.Text))).First().Bemerkung = box.Text.ToString();
+ else
+ Bemerkungen.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Bemerkung = box == null ? "" : box.Text.ToString()
+ });
+ }
+ }
+ else Bemerkungen.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Bemerkung = box.Text == null ? "" : box.Text.ToString()
+ });
+
+ if (UserList.Where(p => (p.PersNummer == persnummer.Text && p.Datum == DateTime.Parse(datum.Text))).Count() > 0 && box != null)
+ UserList.Where(p => (p.PersNummer == persnummer.Text && p.Datum == DateTime.Parse(datum.Text))).First().Bemerkung = box.Text.ToString();
+
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ MessageBox.Show("Bemerkung konnte nicht gespeichert werden\nBitte die Bemerkung neu eingeben", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ CreateList();
+ BemerkungIsEnabled = true;
+ }
+
+
+ }
+
+ try
+ {
+ var json = Newtonsoft.Json.JsonConvert.SerializeObject(Bemerkungen);
+ json = await Crypto.EncryptString(json);
+ byte[] jsonB = new UTF8Encoding(true).GetBytes(json);
+
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Bemerkungen.json", FileMode.Create, FileAccess.Write, FileShare.None)) //Test 25.07.19 FileShare.ReadWrite | FileShare.Delete
+ {
+ await fs.WriteAsync(jsonB, 0, jsonB.Length);
+ }
+
+ BemerkungenChanges.Clear();
+ //box.CaretIndex = box.Text.Length;
+ BemerkungIsEnabled = true;
+ //lastTextChangedTextbox = null;
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ MessageBox.Show("Bemerkung konnte nicht gespeichert werden\nBitte die Bemerkung neu eingeben", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ CreateList();
+ BemerkungIsEnabled = true;
+ }
+ }
+
+
+ private void Bemerkung_GotFocus(object sender, RoutedEventArgs e)
+ {
+ var row = sender as TextBox;
+ //DataGridRow dataGridRow = FindParent(row);
+ DataGridCell dataGridCell = FindParent(row);
+
+ row.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
+ //dataGridRow.Height = 55;
+ dataGridCell.Height = 55;
+ row.Height = 50;
+ }
+
+ private void Bemerkung_LostFocus(object sender, RoutedEventArgs e)
+ {
+ var row = sender as TextBox;
+ //DataGridRow dataGridRow = FindParent(row);
+ DataGridCell dataGridCell = FindParent(row);
+
+ row.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
+ //dataGridRow.Height = 30;
+ if(dataGridCell != null) dataGridCell.Height = 30;
+ row.Height = 30;
+
+ //bemerkungTimer.Interval = TimeSpan.FromSeconds(1.5);
+ }
+
+
+ //private void Bemerkung_MouseLeave(object sender, MouseEventArgs e)
+ //{
+ // bemerkungTextbox = sender as TextBox;
+ // if (bemerkungTextbox.IsKeyboardFocused && lastTextChangedTextbox == bemerkungTextbox && bemerkungTimer.IsEnabled)
+ // {
+ // bemerkungTimer.Stop();
+ // SaveBemerkung(bemerkungTextbox);
+ // EnableFilterChange();
+ // }
+
+ // //if ((sender as TextBox).IsMouseOver == false && (sender as TextBox).IsKeyboardFocused)
+ // // bemerkungTimer.Interval = TimeSpan.FromSeconds(0.5);
+ //}
+
+ //private void Bemerkung_MouseEnter(object sender, MouseEventArgs e)
+ //{
+ // //if ((sender as TextBox).IsMouseOver == true && (sender as TextBox).IsKeyboardFocused)
+ // // bemerkungTimer.Interval = TimeSpan.FromSeconds(1.5);
+ //}
+
+
+
+
+ private void DisableFilterChange()
+ {
+ btnFrueh.IsEnabled = false;
+ btnSpaet.IsEnabled = false;
+ btnNacht.IsEnabled = false;
+ cBFrueh.IsEnabled = false;
+ cBSpaet.IsEnabled = false;
+ cBNacht.IsEnabled = false;
+
+ btnAllDays.IsEnabled = false;
+ btnDatePickerToday.IsEnabled = false;
+ dPDatum.IsEnabled = false;
+ btnSearch.IsEnabled = false;
+ btnMinusDay.IsEnabled = false;
+ btnPlusDay.IsEnabled = false;
+ }
+
+ private void EnableFilterChange()
+ {
+ btnFrueh.IsEnabled = true;
+ btnSpaet.IsEnabled = true;
+ btnNacht.IsEnabled = true;
+ cBFrueh.IsEnabled = true;
+ cBSpaet.IsEnabled = true;
+ cBNacht.IsEnabled = true;
+
+ btnAllDays.IsEnabled = true;
+ btnDatePickerToday.IsEnabled = true;
+ dPDatum.IsEnabled = true;
+ btnSearch.IsEnabled = true;
+ btnMinusDay.IsEnabled = true;
+ btnPlusDay.IsEnabled = true;
+ }
+#endregion
+
+#region Telefon
+
+ List TelefonChanges = new List();
+ TextBox telefonTextbox = null;
+ //TextBox lastTextChangedTelbox = null;
+ private void Telefon_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (Helper.isTelNumber(e.Key))
+ {
+ //lastTextChangedTelbox = sender as TextBox;
+ //Debug.WriteLine("NonSpecialKey");
+ e.Handled = false;
+ telefonTextbox = sender as TextBox;
+ telefonTimer.Stop();
+ telefonTimer.Start();
+
+ DisableFilterChange();
+ }
+ else e.Handled = true;
+ }
+
+ private void TelefonTimer_Tick(object sender, EventArgs e)
+ {
+ if (telefonTextbox != null)
+ {
+ DataGridRow dataGridRow = FindParent(telefonTextbox);
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+
+ var persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+ foreach (var user in DefaultUserList.Where(p => (p.PersNummer == persnummer.Text)))
+ DefaultUserList.Where(p => (p.PersNummer == user.PersNummer && p.Datum == user.Datum)).First().Telefon = telefonTextbox.Text.ToString();
+
+ if (TelefonChanges.Where(p => p.sender == telefonTextbox).Count() == 0)
+ TelefonChanges.Add(new ChangesQueue.TelefonChanges() { sender = telefonTextbox, index = index });
+ }
+ }
+
+ TelefonIsEnabled = false;
+ SaveTelefon(TelefonChanges);
+ //SaveTelefon(telefonTextbox);
+ telefonTimer.Stop();
+ EnableFilterChange();
+ }
+
+ private void Telefon_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ Debug.WriteLine("jo");
+ var telbox = sender as TextBox;
+
+ if (telbox != null)
+ {
+ DataGridRow dataGridRow = FindParent(telbox);
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+
+ var persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+ foreach (var user in DefaultUserList.Where(p => (p.PersNummer == persnummer.Text)))
+ DefaultUserList.Where(p => (p.PersNummer == user.PersNummer && p.Datum == user.Datum)).First().Telefon = telbox.Text.ToString();
+
+ if (TelefonChanges.Where(p => p.sender == telbox).Count() == 0)
+ TelefonChanges.Add(new ChangesQueue.TelefonChanges() { sender = telbox, index = index });
+ }
+ }
+ }
+
+ private async void SaveTelefon(List telefonChanges)
+ {
+ TelefonList = await Reader.CreateTelefonList();
+
+ foreach (var change in telefonChanges)
+ {
+ try
+ {
+ var telbox = change.sender as TextBox;
+ var index = change.index;
+
+ TextBlock persnummer = null;
+
+ var name = flowDocu.Columns[0].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ var vorname = flowDocu.Columns[1].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ var datum = flowDocu.Columns[2].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+ if (string.IsNullOrEmpty(telbox.Text) || string.IsNullOrWhiteSpace(telbox.Text))
+ TelefonList.RemoveAll(p => p.PersNummer == persnummer.Text);
+ else
+ {
+ if (TelefonList != null && persnummer.Text != null)
+ {
+ if (!TelefonList.Select(p => p.PersNummer).Contains(persnummer.Text))
+ {
+ foreach (var user in DefaultUserList.Where(p => p.PersNummer == persnummer.Text))
+ {
+ TelefonList.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Telefon = telbox.Text == null ? "" : telbox.Text.ToString()
+ });
+ }
+ }
+ else
+ {
+ if (TelefonList.Where(p => (p.PersNummer == persnummer.Text)).Count() > 0 && telbox != null)
+ {
+ foreach (var user in TelefonList.Where(p => (p.PersNummer == persnummer.Text)))
+ {
+ var t = TelefonList.Where(p => (p.PersNummer == persnummer.Text && p.Telefon != telbox.Text.ToString())).FirstOrDefault();
+ if (t != null) t.Telefon = telbox.Text.ToString();
+ }
+ }
+ else
+ {
+ foreach (var user in DefaultUserList.Where(p => p.PersNummer == persnummer.Text))
+ {
+ TelefonList.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Telefon = telbox == null ? "" : telbox.Text.ToString()
+ });
+ }
+ }
+ }
+ }
+ else TelefonList.Add(new TableInfo()
+ {
+ PersNummer = persnummer.Text ?? "",
+ Name = name.Text,
+ Vorname = vorname.Text,
+ Datum = DateTime.Parse(datum.Text),
+ Telefon = telbox.Text == null ? "" : telbox.Text.ToString()
+ });
+ }
+
+
+ //foreach (var user in DefaultUserList.Where(p => (p.PersNummer == persnummer.Text)))
+ // DefaultUserList.Where(p => (p.PersNummer == user.PersNummer && p.Datum == user.Datum)).First().Telefon = telbox.Text.ToString();
+
+
+
+ //lastTextChangedTelbox = null;
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ MessageBox.Show("Telefon konnte nicht gespeichert werden\nBitte die Nummer neu eingeben", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Warning);
+ CreateList();
+ //TelefonIsEnabled = true;
+ }
+ }
+
+ try
+ {
+ var json = Newtonsoft.Json.JsonConvert.SerializeObject(TelefonList);
+ json = await Crypto.EncryptString(json);
+ byte[] jsonT = new UTF8Encoding(true).GetBytes(json);
+
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Telefon.json", FileMode.Create, FileAccess.Write, FileShare.None))//ReadWrite | FileShare.Delete
+ {
+ await fs.WriteAsync(jsonT, 0, jsonT.Length);
+ }
+
+ TelefonChanges.Clear();
+ //telbox.CaretIndex = telbox.Text.Length;
+ //TelefonIsEnabled = true;
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
+ }
+
+
+#endregion
+
+#region Filter
+
+ string abtFilter = "";
+ string abtFilter2 = "";
+ string abtFilter3 = "";
+ private async void cBFilterAbteilung_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ try
+ {
+ abtFilter = cBFilterAbteilung.SelectedItem == null ? "" : cBFilterAbteilung.SelectedItem.ToString();
+
+ CreateList();
+
+ if (cBFilterAbteilung.SelectedItem != null && cBFilterAbteilung.SelectedItem.ToString() != "") cBFilterAbteilung2.IsEnabled = true;
+ else if (cBFilterAbteilung.SelectedItem == null || cBFilterAbteilung.SelectedItem.ToString() == "")
+ {
+ cBFilterAbteilung2.IsEnabled = cBFilterAbteilung3.IsEnabled = false;
+ cBFilterAbteilung2.SelectedIndex = cBFilterAbteilung3.SelectedIndex = 0;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private async void cBFilterAbteilung2_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ try
+ {
+ abtFilter = cBFilterAbteilung.SelectedItem == null ? "" : cBFilterAbteilung.SelectedItem.ToString();
+ abtFilter2 = cBFilterAbteilung2.SelectedItem == null ? "" : cBFilterAbteilung2.SelectedItem.ToString();
+
+ CreateList();
+
+ if (cBFilterAbteilung2.SelectedItem != null && cBFilterAbteilung2.SelectedItem.ToString() != "") cBFilterAbteilung3.IsEnabled = true;
+ else if (cBFilterAbteilung2.SelectedItem == null || cBFilterAbteilung2.SelectedItem.ToString() == "")
+ {
+ cBFilterAbteilung3.IsEnabled = false;
+ cBFilterAbteilung3.SelectedIndex = 0;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private async void cBFilterAbteilung3_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ try
+ {
+ abtFilter = cBFilterAbteilung.SelectedItem == null ? "" : cBFilterAbteilung.SelectedItem.ToString();
+ abtFilter2 = cBFilterAbteilung2.SelectedItem == null ? "" : cBFilterAbteilung2.SelectedItem.ToString();
+ abtFilter3 = cBFilterAbteilung3.SelectedItem == null ? "" : cBFilterAbteilung3.SelectedItem.ToString();
+
+ CreateList();
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ string lastButton = "";
+ private async void btnFrueh_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ lastButton = "MT;MF";
+
+ uncheck_Boxes();
+
+ btnFrueh.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989"));
+ btnSpaet.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnNacht.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+
+ CreateList();
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private async void btnSpaet_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ lastButton = "MS";
+
+ uncheck_Boxes();
+
+ btnFrueh.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnSpaet.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989"));
+ btnNacht.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+
+ CreateList();
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private async void btnNacht_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ lastButton = "MN";
+
+ uncheck_Boxes();
+
+ btnFrueh.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnSpaet.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnNacht.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989"));
+
+ CreateList();
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private void cBFrueh_Checked(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (((lastButton == "MS" || lastButton == "MN") && !cBSpaet.IsChecked.Value && !cBNacht.IsChecked.Value)) lastButton = "";
+ if (!lastButton.Contains("MT;MF")) lastButton = lastButton + ";MT;MF";
+ lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
+
+ btnFrueh.Background = cBFrueh.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnSpaet.Background = cBSpaet.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnNacht.Background = cBNacht.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+
+ CreateList();
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private void cBSpaet_Checked(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (((lastButton == "MT;MF" || lastButton == "MN") && !cBFrueh.IsChecked.Value && !cBNacht.IsChecked.Value)) lastButton = "";
+ if (!lastButton.Contains("MS")) lastButton = lastButton + ";MS";
+ lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
+
+ btnFrueh.Background = cBFrueh.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnSpaet.Background = cBSpaet.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnNacht.Background = cBNacht.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+
+ CreateList();
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private void cBNacht_Checked(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (((lastButton == "MT;MF" || lastButton == "MS") && !cBSpaet.IsChecked.Value && !cBFrueh.IsChecked.Value)) lastButton = "";
+ if (!lastButton.Contains("MN")) lastButton = lastButton + ";MN";
+ lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
+
+ btnFrueh.Background = cBFrueh.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnSpaet.Background = cBSpaet.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+ btnNacht.Background = cBNacht.IsChecked.Value ? (SolidColorBrush)(new BrushConverter().ConvertFrom("#4C898989")) : (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+
+ CreateList();
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private void cBFrueh_Unchecked(object sender, RoutedEventArgs e)
+ {
+ lastButton = lastButton.Replace("MT;MF", "");
+ lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
+ btnFrueh.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+
+ CreateList();
+ }
+
+ private void cBSpaet_Unchecked(object sender, RoutedEventArgs e)
+ {
+ lastButton = lastButton.Replace("MS", "");
+ lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
+ btnSpaet.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+
+ CreateList();
+ }
+
+ private void cBNacht_Unchecked(object sender, RoutedEventArgs e)
+ {
+ lastButton = lastButton.Replace("MN", "");
+ lastButton = lastButton.Replace(";;", ";").TrimStart(';').TrimEnd(';');
+ btnNacht.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4CDDDDDD"));
+
+ CreateList();
+ }
+
+ private void uncheck_Boxes()
+ {
+ cBFrueh.Unchecked -= cBFrueh_Unchecked;
+ cBSpaet.Unchecked -= cBSpaet_Unchecked;
+ cBNacht.Unchecked -= cBNacht_Unchecked;
+ cBFrueh.IsChecked = false;
+ cBSpaet.IsChecked = false;
+ cBNacht.IsChecked = false;
+ cBFrueh.Unchecked += cBFrueh_Unchecked;
+ cBSpaet.Unchecked += cBSpaet_Unchecked;
+ cBNacht.Unchecked += cBNacht_Unchecked;
+ }
+
+
+
+
+
+ private async void tbSearch_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Return)
+ {
+ btnSearch.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
+ }
+ }
+
+ private void btnSearch_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ CreateList(tbSearch.Text, true, cBSearchWithFilters.IsChecked.Value);
+ tbSearch.Text = "";
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private void dPDatum_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+ {
+ try
+ {
+ CreateList();
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+ private void btnDatePickerToday_Click(object sender, RoutedEventArgs e)
+ {
+ dPDatum.SelectedDate = DateTime.Now.Date;
+ }
+
+ private void btnAllDays_Click(object sender, RoutedEventArgs e)
+ {
+ dPDatum.SelectedDate = null;
+ }
+
+
+ private void BtnMinusDay_Click(object sender, RoutedEventArgs e)
+ {
+ if (dPDatum.SelectedDate != null)
+ dPDatum.SelectedDate = dPDatum.SelectedDate - TimeSpan.FromDays(1);
+ else
+ dPDatum.SelectedDate = DateTime.Now.Date;
+ }
+
+ private void BtnPlusDay_Click(object sender, RoutedEventArgs e)
+ {
+ if (dPDatum.SelectedDate != null)
+ dPDatum.SelectedDate = dPDatum.SelectedDate + TimeSpan.FromDays(1);
+ else
+ dPDatum.SelectedDate = DateTime.Now.Date + TimeSpan.FromDays(1);
+ }
+
+#endregion
+
+#region Print and Export
+
+ private async void btnPrint_Click(object sender, RoutedEventArgs e)
+ {
+ propertyChangeAllowed = false;
+
+ Print print = new Print();
+
+ bar.IsIndeterminate = true;
+ bar.Visibility = Visibility.Visible;
+
+ List printList = new List();
+ printList = userList;
+
+ DataGrid grid = new DataGrid();
+
+ grid = print.CreatePrintGrid(printList);
+
+ if (printList.Count > 100) lblBar.Visibility = Visibility.Visible;
+
+ string listTitle = "";
+ switch (lastButton)
+ {
+ case "MT;MF":
+ listTitle = " für Früh- / Tagschicht";
+ break;
+ case "MS":
+ listTitle = " für Spätschicht";
+ break;
+ case "MN":
+ listTitle = " für Nachtschicht";
+ break;
+ default:
+ listTitle = "";
+ break;
+ }
+
+ print.printDG(grid, "Personaleinsatzplanung" + listTitle);
+
+ bar.Visibility = Visibility.Collapsed;
+ lblBar.Visibility = Visibility.Collapsed;
+ //PrintDialog pd = new PrintDialog();
+ //print.PrintDataGrid(null, grid, null, pd);
+ propertyChangeAllowed = true;
+ }
+
+ private void btnExport_Click(object sender, RoutedEventArgs e)
+ {
+ Export.ExportCSV(UserList);
+ }
+
+ private Visibility barVisibility;
+ public Visibility BarVisibility
+ {
+ get { return barVisibility; }
+ set
+ {
+ barVisibility = value;
+ bar.Visibility = value;
+ }
+ }
+
+ private bool barIsIndeterminate;
+ public bool BarIsIndeterminate
+ {
+ get { return barIsIndeterminate; }
+ set
+ {
+ barIsIndeterminate = value;
+ bar.IsIndeterminate = value;
+ }
+ }
+
+ private double barMax;
+ public double BarMax
+ {
+ get { return barMax; }
+ set
+ {
+ barMax = value;
+ bar.Maximum = value;
+ }
+ }
+
+ private double barValue;
+ public double BarValue
+ {
+ get { return barValue; }
+ set
+ {
+ barValue = value;
+ bar.Value = value;
+ }
+ }
+
+
+#endregion
+
+#region LastChange Funktionen
+
+
+ private void flowDocu_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (this.IsMouseOver && this.IsKeyboardFocusWithin)
+ {
+ int selectedRow = flowDocu.SelectedIndex;
+
+ if (selectedRow >= 0)
+ {
+ DispatcherTimer ChangeTimer = new DispatcherTimer();
+ ChangeTimer.Interval = TimeSpan.FromSeconds(3);
+ ChangeTimer.Tick += (s, ev) => { ChangeTimer_Tick(sender, e, selectedRow, selectedRow, ChangeTimer); };
+ ChangeTimer.Start();
+ }
+ }
+ }
+
+
+ int lastVisibleFirstRow;
+
+ void DataGrid_ScrollChanged(object sender, RoutedEventArgs e)
+ {
+ var scroll = Helper.FindVisualChild((DependencyObject)sender);
+
+ int firstRow = (int)scroll.VerticalOffset;
+ int lastRow = (int)scroll.VerticalOffset + (int)scroll.ViewportHeight - 1;
+
+ if (firstRow != lastVisibleFirstRow)
+ {
+ lastVisibleFirstRow = firstRow;
+ DispatcherTimer ChangeTimer = new DispatcherTimer();
+ ChangeTimer.Interval = TimeSpan.FromSeconds(10);
+ ChangeTimer.Tick += (s, ev) => { ChangeTimer_Tick(sender, e, firstRow, lastRow, ChangeTimer); };
+ ChangeTimer.Start();
+ }
+ }
+
+ private void ChangeTimer_Tick(object sender, EventArgs e, int firstRow, int lastRow, DispatcherTimer timer)
+ {
+ try
+ {
+ for (var i = firstRow; i <= lastRow; i++)
+ {
+ DataGridRow dataGridRow = flowDocu.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow;
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+ var change = flowDocu.Columns[11].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+ if (!string.IsNullOrEmpty(change.Text))
+ {
+ var datum = flowDocu.Columns[2].GetCellContent(flowDocu.Items[index]) as TextBlock;
+ var pers = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+ if (UserList.Where(p => (p.PersNummer == pers.Text && p.Datum == DateTime.Parse(datum.Text) && p.FilePath != "")).Count() > 0)
+ UserList.Where(p => (p.PersNummer == pers.Text && p.Datum == DateTime.Parse(datum.Text))).First().FilePath = "";
+ }
+ }
+ }
+
+ if (UserList != null)
+ {
+ //Debug.WriteLine(UserList.Where(p => !string.IsNullOrEmpty(p.FilePath)).Count());
+ if (UserList.Where(p => !string.IsNullOrEmpty(p.FilePath)).Count() <= 0) lblLastChange.Foreground = new SolidColorBrush(Colors.Black);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.ToString());
+ }
+
+ timer.Stop();
+ }
+
+#endregion
+
+
+ private async void CreateList(string search = "", bool isSearch = false, bool searchWithFilter = false)
+ {
+ try
+ {
+ var date = dPDatum.SelectedDate.HasValue ? dPDatum.SelectedDate.ToString() : "";
+
+ var newList = await Task.Run(() => TableCreator.CreateList(DefaultUserList, abtFilter, abtFilter2, abtFilter3, lastButton, date, search, searchWithFilter, isSearch));
+
+ if (newList != null) UserList = newList;
+
+ //flowDocu.ItemsSource = UserList;
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ LogFile.WriteLine("UserList: " + UserList.Count + " Items");
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+ }
+
+
+
+#region Extensions
+
+ public static Parent FindParent(DependencyObject child)
+ where Parent : DependencyObject
+ {
+ DependencyObject parentObject = child;
+
+ //We are not dealing with Visual, so either we need to fnd parent or
+ //get Visual to get parent from Parent Heirarchy.
+ while (!((parentObject is System.Windows.Media.Visual)
+ || (parentObject is System.Windows.Media.Media3D.Visual3D)))
+ {
+ if (parentObject is Parent || parentObject == null)
+ {
+ return parentObject as Parent;
+ }
+ else
+ {
+ parentObject = (parentObject as FrameworkContentElement).Parent;
+ }
+ }
+
+ //We have not found parent yet , and we have now visual to work with.
+ parentObject = VisualTreeHelper.GetParent(parentObject);
+
+ //check if the parent matches the type we're looking for
+ if (parentObject is Parent || parentObject == null)
+ {
+ return parentObject as Parent;
+ }
+ else
+ {
+ //use recursion to proceed with next level
+ return FindParent(parentObject);
+ }
+ }
+
+ public ScrollViewer GetScrollViewer(UIElement element)
+ {
+ //Dispatcher.BeginInvoke(new Action(() => {
+ if (element == null) return null;
+
+ ScrollViewer retour = null;
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element) && retour == null; i++)
+ {
+ if (VisualTreeHelper.GetChild(element, i) is ScrollViewer)
+ {
+ retour = (ScrollViewer)(VisualTreeHelper.GetChild(element, i));
+ }
+ else
+ {
+ retour = GetScrollViewer(VisualTreeHelper.GetChild(element, i) as UIElement);
+ }
+ }
+ return retour;
+ //}));
+ }
+
+
+#endregion
+
+#region Settings
+
+ private void btnSettings_Click(object sender, RoutedEventArgs e)
+ {
+ tBAbtTranslatePath.Text = Properties.Settings.Default.AbteilungsnamenPath;
+ tBLicenseFilePath.Text = Properties.Settings.Default.LizenzenPath;
+ tBZuweisungenPath.Text = Properties.Settings.Default.ZuweisungenPath;
+
+
+ gridSettings.Visibility = Visibility.Visible;
+ canvasSettings.Visibility = Visibility.Visible;
+
+ gridToolbar.Visibility = Visibility.Collapsed;
+ gridTable.Visibility = Visibility.Collapsed;
+ }
+
+ private void btnCloseSettings_Click(object sender, RoutedEventArgs e)
+ {
+ canvasSettings.Visibility = Visibility.Collapsed;
+ gridSettings.Visibility = Visibility.Collapsed;
+ gridToolbar.Visibility = Visibility.Visible;
+ gridTable.Visibility = Visibility.Visible;
+ Properties.Settings.Default.AbteilungsnamenPath = tBAbtTranslatePath.Text;
+ Properties.Settings.Default.LizenzenPath = tBLicenseFilePath.Text;
+ Properties.Settings.Default.ZuweisungenPath = tBZuweisungenPath.Text;
+ Properties.Settings.Default.Save();
+ }
+
+ private void btnCancelSettings_Click(object sender, RoutedEventArgs e)
+ {
+ canvasSettings.Visibility = Visibility.Collapsed;
+ gridSettings.Visibility = Visibility.Collapsed;
+ gridToolbar.Visibility = Visibility.Visible;
+ gridTable.Visibility = Visibility.Visible;
+ }
+
+ private void btnSelectLicenseFile_Click(object sender, RoutedEventArgs e)
+ {
+ var p = Reader.OpenFile("Lizenzen");
+ var lines = System.IO.File.ReadAllLines(p);
+
+ if (lines[0].StartsWith("Name;") || lines[0].StartsWith("Personalnummer;0001")) tBLicenseFilePath.Text = p;
+ else
+ {
+ var x = MessageBox.Show("Keine gültige Lizenzdatei ausgewählt!", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
+ btnSelectLicenseFile.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
+ }
+ }
+
+ private void btnSelectAbtTranslateFile_Click(object sender, RoutedEventArgs e)
+ {
+ var p = Reader.OpenFile("Abteilungsnamen");
+ var lines = System.IO.File.ReadAllLines(p);
+
+ if (lines[0].StartsWith("Abteilung;")) tBAbtTranslatePath.Text = p;
+ else
+ {
+ var x = MessageBox.Show("Keine gültige Abteilungsliste ausgewählt!", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
+ btnSelectAbtTranslateFile.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
+ }
+ }
+
+ private void btnSelectZuweisungenFile_Click(object sender, RoutedEventArgs e)
+ {
+ var p = Reader.OpenFile("Zuweisungen");
+ var lines = System.IO.File.ReadAllLines(p);
+
+ if (!lines.Contains(";")) tBZuweisungenPath.Text = p;
+ else
+ {
+ var x = MessageBox.Show("Keine gültige Zuweisungen-Liste ausgewählt!", "Fehler!", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
+ btnSelectZuweisungenFile.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
+ }
+ }
+
+ private void btnImpressum_Click(object sender, RoutedEventArgs e)
+ {
+ canvasImpressum.Visibility = Visibility.Visible;
+ }
+
+ private void btnCloseImpressum_Click(object sender, RoutedEventArgs e)
+ {
+ canvasImpressum.Visibility = Visibility.Collapsed;
+ }
+
+
+ private void btnVersionInfo_Click(object sender, RoutedEventArgs e)
+ {
+ canvasVersionInfo.Visibility = Visibility.Visible;
+ }
+
+ private void btnCloseVersionInfo_Click(object sender, RoutedEventArgs e)
+ {
+ canvasVersionInfo.Visibility = Visibility.Collapsed;
+ }
+
+
+#endregion
+
+
+
+ private void Window_Deactivated(object sender, EventArgs e)
+ {
+ Debug.WriteLine("jo2");
+ var telbox = telefonTextbox;
+
+ if (telbox != null)
+ {
+ DataGridRow dataGridRow = FindParent(telbox);
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+
+ var persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+ foreach (var user in DefaultUserList.Where(p => (p.PersNummer == persnummer.Text)))
+ DefaultUserList.Where(p => (p.PersNummer == user.PersNummer && p.Datum == user.Datum)).First().Telefon = telbox.Text.ToString();
+
+ if (TelefonChanges.Where(p => p.sender == telbox).Count() == 0)
+ TelefonChanges.Add(new ChangesQueue.TelefonChanges() { sender = telbox, index = index });
+ }
+ }
+
+ var bembox = bemerkungTextbox;
+
+ try
+ {
+ if (bembox != null)
+ {
+ DataGridRow dataGridRow = FindParent(bembox);
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+
+ if (BemerkungenChanges.Where(p => p.sender == bembox).Count() == 0)
+ BemerkungenChanges.Add(new ChangesQueue.BemerkungenChanges() { sender = bembox, index = index });
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.ToString());
+ }
+ }
+
+
+ private void btnHideToolbar_Click(object sender, RoutedEventArgs e)
+ {
+ if (gridToolbar.Height == 184)
+ {
+ gridToolbar.Height = 14;
+ btnHideToolbar.Content = "˅˅";
+ flowDocu.Height = ActualHeight + 170;
+ btnHideToolbar.ToolTip = "Toolbar öffnen";
+ }
+ else
+ {
+ gridToolbar.Height = 184;
+ btnHideToolbar.Content = "^^";
+ flowDocu.Height = ActualHeight - 170;
+ btnHideToolbar.ToolTip = "Toolbar schließen";
+ }
+
+ gridTable.Height = main.ActualHeight - gridToolbar.Height - 40;
+ flowDocu.Height = gridTable.Height;
+ }
+
+ bool onStartup = false;
+ private async void Window_Closing(object sender, CancelEventArgs e)
+ {
+ await Tracker.SaveTrack(false);
+ await Task.Delay(1000);
+
+
+ var telbox = telefonTextbox;
+
+ if (telbox != null)
+ {
+ DataGridRow dataGridRow = FindParent(telbox);
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+
+ var persnummer = flowDocu.Columns[9].GetCellContent(flowDocu.Items[index]) as TextBlock;
+
+ foreach (var user in DefaultUserList.Where(p => (p.PersNummer == persnummer.Text)))
+ DefaultUserList.Where(p => (p.PersNummer == user.PersNummer && p.Datum == user.Datum)).First().Telefon = telbox.Text.ToString();
+
+ if (TelefonChanges.Where(p => p.sender == telbox).Count() == 0)
+ TelefonChanges.Add(new ChangesQueue.TelefonChanges() { sender = telbox, index = index });
+ }
+ }
+
+ var bembox = bemerkungTextbox;
+
+ if (bembox != null)
+ {
+ DataGridRow dataGridRow = FindParent(bembox);
+ if (dataGridRow != null)
+ {
+ int index = dataGridRow.GetIndex();
+
+ if (BemerkungenChanges.Where(p => p.sender == bembox).Count() == 0)
+ BemerkungenChanges.Add(new ChangesQueue.BemerkungenChanges() { sender = bembox, index = index });
+ }
+ }
+
+ if (TelefonChanges.Count > 0)
+ SaveTelefon(TelefonChanges);
+
+ if (BemerkungenChanges.Count > 0)
+ SaveBemerkung(BemerkungenChanges);
+
+ if (!onStartup) Application.Current.Shutdown();
+
+
+ }
+
+ private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ gridTable.Height = main.ActualHeight - gridToolbar.Height - 40;
+ flowDocu.Height = gridTable.Height;
+
+ }
+
+ private void Window_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var scroll = Helper.FindVisualChild((DependencyObject)sender);
+
+ int firstRow = (int)scroll.VerticalOffset;
+ int lastRow = (int)scroll.VerticalOffset + (int)scroll.ViewportHeight - 1;
+
+ if (firstRow != lastVisibleFirstRow)
+ {
+ lastVisibleFirstRow = firstRow;
+ DispatcherTimer ChangeTimer = new DispatcherTimer();
+ ChangeTimer.Interval = TimeSpan.FromSeconds(10);
+ ChangeTimer.Tick += (s, ev) => { ChangeTimer_Tick(sender, e, firstRow, lastRow, ChangeTimer); };
+ ChangeTimer.Start();
+ }
+ }
+
+
+ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ var combo = sender as ComboBox;
+ combo.SelectedIndex = 0;
+ }
+
+
+
+
+ private static void GetDesktopShortcuts()
+ {
+ if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdatePEP.bat") || File.GetLastWriteTime(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdatePEP.bat") != File.GetLastWriteTime(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\UpdatePEP.bat"))
+ {
+ File.Copy(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\UpdatePEP.bat", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdatePEP.bat", true);
+ GetDesktopShortcuts();
+ }
+ else
+ {
+ if (File.GetLastWriteTime(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\PEP-Tool.exe") < File.GetLastWriteTime(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\PEP-Tool.exe"))
+ {
+ Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\UpdatePEP.bat");
+ Application.Current.Shutdown();
+ }
+ }
+
+ foreach (var link in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)))
+ {
+ if (System.IO.Path.GetExtension(link) == ".lnk")
+ {
+ var target = ResolveShortcut(link);
+
+ if (target.EndsWith("AV-Tool.exe"))
+ {
+ ChangeShortcutTarget(link);
+ }
+ }
+ }
+ }
+
+ static string ResolveShortcut(string filePath)
+ {
+ // IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model"
+ IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
+
+ try
+ {
+ IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
+ return shortcut.TargetPath;
+ }
+ catch (System.Runtime.InteropServices.COMException)
+ {
+ // A COMException is thrown if the file is not a valid shortcut (.lnk) file
+ return null;
+ }
+ }
+
+ [System.Runtime.InteropServices.DllImport("Shell32.dll")]
+ private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
+
+ static void ChangeShortcutTarget(string filePath)
+ {
+ File.Delete(filePath);
+ //// IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model"
+ //IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
+
+ //try
+ //{
+ // IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
+ // shortcut.TargetPath = shortcut.TargetPath.Replace("AV-Tool.exe", "PEP-Tool.exe");
+ // shortcut.Save();
+
+ // File.Move(filePath, filePath.Substring(0, filePath.LastIndexOf("\\")) + "\\PEP-Tool.lnk");
+
+ // SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
+ //}
+ //catch (System.Runtime.InteropServices.COMException ex)
+ //{
+ // // A COMException is thrown if the file is not a valid shortcut (.lnk) file
+ // LogFile.WriteLine(ex);
+ //}
+ }
+
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ Debug.WriteLine("PropertyChanged " + propertyName);
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ }
+}
diff --git a/AV-ToolV3/NewVersionMessageBox.xaml b/AV-ToolV3/NewVersionMessageBox.xaml
new file mode 100644
index 0000000..22c6493
--- /dev/null
+++ b/AV-ToolV3/NewVersionMessageBox.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/AV-ToolV3/NewVersionMessageBox.xaml.cs b/AV-ToolV3/NewVersionMessageBox.xaml.cs
new file mode 100644
index 0000000..50e2211
--- /dev/null
+++ b/AV-ToolV3/NewVersionMessageBox.xaml.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace PEP_Tool
+{
+ ///
+ /// Interaktionslogik für NewVersionMessageBox.xaml
+ ///
+ public partial class NewVersionMessageBox : Window
+ {
+ System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
+ MainWindow mw = MainWindow.main;
+
+ public NewVersionMessageBox(string Message, int TimeOut, bool onStart)
+ {
+ InitializeComponent();
+ MainWindow.MessageShown = true;
+
+ lblMessage.Text = Message;
+ Time = TimeOut;
+ onStartup = onStart;
+
+ if (!onStartup) this.Height += 50;
+
+ timer.Interval = TimeSpan.FromSeconds(1);
+ timer.Tick += Timer_Tick;
+ timer.Start();
+
+ Properties.Settings.Default.newVersionScreen = true;
+ Properties.Settings.Default.Save();
+
+ mw.newVersionCounter.Visibility = Visibility.Visible;
+ }
+
+ int versionCount = 0;
+ int Time = 0;
+ private void Timer_Tick(object sender, EventArgs e)
+ {
+ versionCount++;
+ btnNewVersionMessageBoxOK.Content = $"OK ({Time - versionCount})";
+ mw.newVersionCounter.Text = $"Achtung - Noch {Time - versionCount} Sekunden bis das Programm geschlossen wird...";
+
+ if (Time - versionCount <= 0) Application.Current.Shutdown();
+ }
+
+ bool onStartup = false;
+ private void btnNewVersionMessageBoxOK_Click(object sender, RoutedEventArgs e)
+ {
+ if (onStartup) Application.Current.Shutdown();
+ else this.Visibility = Visibility.Collapsed;
+ }
+ }
+}
diff --git a/AV-ToolV3/NewVersionScreen.xaml b/AV-ToolV3/NewVersionScreen.xaml
new file mode 100644
index 0000000..a2ce7b4
--- /dev/null
+++ b/AV-ToolV3/NewVersionScreen.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
diff --git a/AV-ToolV3/NewVersionScreen.xaml.cs b/AV-ToolV3/NewVersionScreen.xaml.cs
new file mode 100644
index 0000000..5f8d293
--- /dev/null
+++ b/AV-ToolV3/NewVersionScreen.xaml.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace PEP_Tool
+{
+ ///
+ /// Interaktionslogik für NewVersionScreen.xaml
+ ///
+ public partial class NewVersionScreen : Window
+ {
+ public NewVersionScreen()
+ {
+ InitializeComponent();
+ }
+
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ Properties.Settings.Default.newVersionScreen = false;
+ Properties.Settings.Default.Save();
+ }
+
+ }
+}
diff --git a/AV-ToolV3/PEP_Tool.csproj b/AV-ToolV3/PEP_Tool.csproj
new file mode 100644
index 0000000..900571c
--- /dev/null
+++ b/AV-ToolV3/PEP_Tool.csproj
@@ -0,0 +1,211 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {4E161CEA-E5E0-4E4A-9923-64CD9D2BD1F0}
+ WinExe
+ PEP_Tool
+ PEP-Tool
+ v4.5
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+
+
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ icon.ico
+
+
+
+ ..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll
+ False
+
+
+ ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll
+
+
+ False
+ bin\Debug\LoadingIndicators.WPF.dll
+
+
+ ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+
+
+
+ NewVersionMessageBox.xaml
+
+
+ NewVersionScreen.xaml
+
+
+
+
+
+
+
+ ucSpinnerPiston.xaml
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+ Designer
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+ {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}
+ 1
+ 0
+ 0
+ tlbimp
+ False
+ True
+
+
+
+
+
+ Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AV-ToolV3/Print.cs b/AV-ToolV3/Print.cs
new file mode 100644
index 0000000..55c2a11
--- /dev/null
+++ b/AV-ToolV3/Print.cs
@@ -0,0 +1,480 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Printing;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Xps;
+
+namespace PEP_Tool
+{
+ class Print
+ {
+ public DataGrid CreatePrintGrid(List List)
+ {
+ var aktuellesGrid = List;
+ DataGrid grid = new DataGrid();
+
+
+ DataGridTextColumn nameColumn = new DataGridTextColumn();
+ nameColumn.Header = "Name";
+ nameColumn.Binding = new Binding("Name");
+ nameColumn.Width = 180;
+ grid.Columns.Add(nameColumn);
+
+ DataGridTextColumn prenameColumn = new DataGridTextColumn();
+ prenameColumn.Header = "Vorname";
+ prenameColumn.Binding = new Binding("Vorname");
+ prenameColumn.Width = 180;
+ grid.Columns.Add(prenameColumn);
+
+ DataGridTextColumn dateColumn = new DataGridTextColumn();
+ dateColumn.Header = "Datum";
+ dateColumn.Binding = new Binding
+ {
+ Path = new PropertyPath("Datum"),
+ StringFormat = "dd.MM.yyyy"
+ };
+ dateColumn.Width = 100;
+ grid.Columns.Add(dateColumn);
+
+ DataGridTextColumn abtColumn = new DataGridTextColumn();
+ abtColumn.Header = "Abteilung";
+ abtColumn.Binding = new Binding
+ {
+ Path = new PropertyPath("Abteilung")
+ };
+ abtColumn.Width = 120;
+ grid.Columns.Add(abtColumn);
+
+ DataGridTextColumn zuweisungenColumn = new DataGridTextColumn();
+ zuweisungenColumn.Header = "Zuweisung";
+ zuweisungenColumn.Binding = new Binding("Zuweisung");
+ zuweisungenColumn.Width = 180;
+ grid.Columns.Add(zuweisungenColumn);
+
+ DataGridTextColumn bemerkungColumn = new DataGridTextColumn();
+ bemerkungColumn.Header = "Bemerkung";
+ bemerkungColumn.Binding = new Binding("Bemerkung");
+ bemerkungColumn.Width = 320;
+ grid.Columns.Add(bemerkungColumn);
+
+ grid.Width = nameColumn.Width.Value + prenameColumn.Width.Value + dateColumn.Width.Value + abtColumn.Width.Value + zuweisungenColumn.Width.Value + bemerkungColumn.Width.Value;
+
+ grid.ItemsSource = aktuellesGrid;
+
+ return grid;
+ }
+
+
+ public void printDG(DataGrid dataGridParam, string title)
+ {
+ var dataGrid = dataGridParam;
+
+ PrintDialog printDialog = new PrintDialog();
+ if (printDialog.ShowDialog() == true)
+ {
+ FlowDocument fd = new FlowDocument();
+
+ Paragraph p = new Paragraph(new Run(title));
+ p.FontStyle = dataGrid.FontStyle;
+ p.FontFamily = dataGrid.FontFamily;
+ p.FontSize = 18;
+ fd.Blocks.Add(p);
+
+ Table table = new Table();
+ TableRowGroup tableRowGroup = new TableRowGroup();
+ TableRow r = new TableRow();
+ fd.PageWidth = printDialog.PrintableAreaWidth;
+ fd.PageHeight = printDialog.PrintableAreaHeight;
+ fd.BringIntoView();
+ fd.TextAlignment = TextAlignment.Center;
+ fd.ColumnWidth = 500;
+
+ table.CellSpacing = 0;
+
+ var headerList = dataGrid.Columns.Select(e => e.Header.ToString()).ToList();
+ List bindList = new List();
+
+
+ for (int j = 0; j < headerList.Count; j++)
+ {
+ int span = 0;
+ switch (j)
+ {
+ case 0:
+ span = 4;
+ break;
+ case 1:
+ span = 4;
+ break;
+ case 2:
+ span = 3;
+ break;
+ case 3:
+ span = 4;
+ break;
+ case 4:
+ span = 4;
+ break;
+ case 5:
+ span = 5;
+ break;
+ default:
+ span = 4;
+ break;
+ }
+
+ r.Cells.Add(new TableCell(new Paragraph(new Run(headerList[j]))));
+ r.Cells[j].ColumnSpan = span;//4;
+ r.Cells[j].Padding = new Thickness(4);
+
+
+
+ r.Cells[j].BorderBrush = Brushes.Black;
+ r.Cells[j].FontWeight = FontWeights.Bold;
+ r.Cells[j].Background = Brushes.DarkGray;
+ r.Cells[j].Foreground = Brushes.White;
+ r.Cells[j].BorderThickness = new Thickness(1, 1, 1, 1);
+ var binding = (dataGrid.Columns[j] as DataGridBoundColumn).Binding as Binding;
+
+ bindList.Add(binding.Path.Path);
+ }
+ tableRowGroup.Rows.Add(r);
+ table.RowGroups.Add(tableRowGroup);
+ for (int i = 0; i < dataGrid.Items.Count; i++)
+ {
+ //System.Diagnostics.Debug.WriteLine(dataGrid.ItemsSource.ToString().ToLower());
+ dynamic row;
+ if (dataGrid.ItemsSource.ToString().ToLower() == "system.data.linqdataview")
+ { row = (DataRowView)dataGrid.Items.GetItemAt(i); }
+ else
+ {
+ row = dataGrid.Items.GetItemAt(i);
+ }
+
+ table.BorderBrush = Brushes.Gray;
+ table.BorderThickness = new Thickness(1, 1, 0, 0);
+ table.FontStyle = dataGrid.FontStyle;
+ table.FontFamily = dataGrid.FontFamily;
+ table.FontSize = 13;
+ tableRowGroup = new TableRowGroup();
+ r = new TableRow();
+ for (int j = 1; j <= 6; j++)
+ {
+ if (row.GetType() == typeof(TableInfo))
+ {
+ var x = row.GetPropertyValueForID(j, row) != null ? row.GetPropertyValueForID(j, row).ToString() : "";
+ if (j == 3) x = x.ToString().Split(' ')[0];
+
+ r.Cells.Add(new TableCell(new Paragraph(new Run(x))));
+
+ int span = 0;
+ switch (j - 1)
+ {
+ case 0:
+ span = 4;
+ break;
+ case 1:
+ span = 4;
+ break;
+ case 2:
+ span = 3;
+ break;
+ case 3:
+ span = 4;
+ break;
+ case 4:
+ span = 4;
+ break;
+ case 5:
+ span = 5;
+ break;
+ default:
+ span = 4;
+ break;
+ }
+
+ r.Cells[j - 1].ColumnSpan = span;// 4;
+ r.Cells[j - 1].Padding = new Thickness(4);
+
+ r.Cells[j - 1].BorderBrush = Brushes.DarkGray;
+ r.Cells[j - 1].BorderThickness = new Thickness(0, 0, 1, 1);
+ }
+ }
+
+ tableRowGroup.Rows.Add(r);
+ table.RowGroups.Add(tableRowGroup);
+
+ }
+ fd.Blocks.Add(table);
+
+
+ printDialog.PrintDocument(((IDocumentPaginatorSource)fd).DocumentPaginator, "");
+
+ }
+ }
+
+
+
+ //public const double cm = 37;
+ //public double Margin = 0.5 * cm;
+ //public double PageWidth = 21 * cm;
+ //public double PageHeight = 29 * cm;
+ //public double RowHeight = 0.7 * cm;
+ //public bool PageNumberVisibility = true;
+ //public bool DateVisibility = true;
+ //public double FontSize = 14;
+ //public double HeaderFontSize = 14;
+ //public bool IsBold = false;
+ //public void PrintDataGrid(FrameworkElement header, DataGrid grid, FrameworkElement footer, PrintDialog printDialog)
+ //{
+ // if (header == null) { header = new FrameworkElement(); header.Width = 1; header.Height = 1; }
+ // if (footer == null) { footer = new FrameworkElement(); footer.Width = 1; footer.Height = 1; }
+ // if (grid == null) return;
+
+ // Size pageSize = new Size(PageWidth, PageHeight);
+
+ // FixedDocument fixedDoc = new FixedDocument();
+ // fixedDoc.DocumentPaginator.PageSize = pageSize;
+
+ // double GridActualWidth = grid.ActualWidth == 0 ? grid.Width : grid.ActualWidth;
+
+ // double PageWidthWithMargin = pageSize.Width - Margin * 2;
+ // double PageHeightWithMargin = pageSize.Height - Margin * 2;
+
+
+
+ // // scale the header
+ // double headerScale = (header?.Width ?? 0) / PageWidthWithMargin;
+ // double headerWidth = PageWidthWithMargin;
+ // double headerHeight = (header?.Height ?? 0) * headerScale;
+ // header.Height = headerHeight;
+ // header.Width = headerWidth;
+ // // scale the footer
+ // double footerScale = (footer?.Width ?? 0) / PageWidthWithMargin;
+ // double footerWidth = PageWidthWithMargin;
+ // double footerHeight = (footer?.Height ?? 0) * footerScale;
+ // footer.Height = footerHeight;
+ // footer.Width = footerWidth;
+
+ // int pageNumber = 1;
+ // string Now = DateTime.Now.ToShortDateString();
+
+ // //add the header
+ // FixedPage fixedPage = new FixedPage();
+ // fixedPage.Background = Brushes.White;
+ // fixedPage.Width = pageSize.Width;
+ // fixedPage.Height = pageSize.Height;
+
+ // FixedPage.SetTop(header, Margin);
+ // FixedPage.SetLeft(header, Margin);
+
+ // fixedPage.Children.Add(header);
+ // // its like cursor for current page Height to start add grid rows
+ // double CurrentPageHeight = headerHeight + 1 * cm;
+ // int lastRowIndex = 0;
+ // bool IsFooterAdded = false;
+
+ // for (; ; )
+ // {
+ // int AvaliableRowNumber;
+
+
+ // var SpaceNeededForRestRows = (CurrentPageHeight + (grid.Items.Count - lastRowIndex) * RowHeight);
+
+ // //To avoid printing the footer in a separate page
+ // if (SpaceNeededForRestRows > (pageSize.Height - footerHeight - Margin) && (SpaceNeededForRestRows < (pageSize.Height - Margin)))
+ // AvaliableRowNumber = (int)((pageSize.Height - CurrentPageHeight - Margin - footerHeight) / RowHeight);
+ // // calc the Avaliable Row acording to CurrentPageHeight
+ // else AvaliableRowNumber = (int)((pageSize.Height - CurrentPageHeight - Margin) / RowHeight);
+
+ // // create new page except first page cause we created it prev
+ // if (pageNumber > 1)
+ // {
+ // fixedPage = new FixedPage();
+ // fixedPage.Background = Brushes.White;
+ // fixedPage.Width = pageSize.Width;
+ // fixedPage.Height = pageSize.Height;
+ // }
+
+ // // create new data grid with columns width and binding
+ // DataGrid gridToAdd;
+ // gridToAdd = GetDataGrid(grid, GridActualWidth, PageWidthWithMargin);
+
+
+ // FixedPage.SetTop(gridToAdd, CurrentPageHeight); // top margin
+ // FixedPage.SetLeft(gridToAdd, Margin); // left margin
+
+ // // add the avaliable rows to the cuurent grid
+ // for (int i = lastRowIndex; i < grid.Items.Count && i < AvaliableRowNumber + lastRowIndex; i++)
+ // {
+ // gridToAdd.Items.Add(grid.Items[i]);
+ // }
+ // lastRowIndex += gridToAdd.Items.Count + 1;
+
+ // // add date
+ // TextBlock dateText = new TextBlock();
+ // if (DateVisibility) dateText.Visibility = Visibility.Visible;
+ // else dateText.Visibility = Visibility.Hidden;
+ // dateText.Text = Now;
+
+ // // add page number
+ // TextBlock PageNumberText = new TextBlock();
+ // if (PageNumberVisibility) PageNumberText.Visibility = Visibility.Visible;
+ // else PageNumberText.Visibility = Visibility.Hidden;
+ // PageNumberText.Text = "Page : " + pageNumber;
+
+ // FixedPage.SetTop(dateText, PageHeightWithMargin);
+ // FixedPage.SetLeft(dateText, Margin);
+
+ // FixedPage.SetTop(PageNumberText, PageHeightWithMargin);
+ // FixedPage.SetLeft(PageNumberText, PageWidthWithMargin - PageNumberText.Text.Length * 10);
+
+ // fixedPage.Children.Add(gridToAdd);
+ // fixedPage.Children.Add(dateText);
+ // fixedPage.Children.Add(PageNumberText);
+
+ // // calc Current Page Height to know the rest Height of this page
+ // CurrentPageHeight += gridToAdd.Items.Count * RowHeight;
+
+ // // all grid rows added
+ // if (lastRowIndex >= grid.Items.Count)
+ // {
+ // // if footer have space it will be added to the same page
+ // if (footerHeight < (PageHeightWithMargin - CurrentPageHeight))
+ // {
+ // FixedPage.SetTop(footer, CurrentPageHeight + Margin);
+ // FixedPage.SetLeft(footer, Margin);
+
+ // fixedPage.Children.Add(footer);
+ // IsFooterAdded = true;
+ // }
+ // }
+
+ // fixedPage.Measure(pageSize);
+ // fixedPage.Arrange(new Rect(new Point(), pageSize));
+ // fixedPage.UpdateLayout();
+
+ // PageContent pageContent = new PageContent();
+ // ((IAddChild)pageContent).AddChild(fixedPage);
+ // fixedDoc.Pages.Add(pageContent);
+
+ // pageNumber++;
+ // // go to start position : New page Top
+ // CurrentPageHeight = Margin;
+
+ // // this mean that lastRowIndex >= grid.Items.Count and the footer dont have enough space
+ // if (lastRowIndex >= grid.Items.Count && !IsFooterAdded)
+ // {
+ // FixedPage ffixedPage = new FixedPage();
+ // ffixedPage.Background = Brushes.White;
+ // ffixedPage.Width = pageSize.Width;
+ // ffixedPage.Height = pageSize.Height;
+
+ // FixedPage.SetTop(footer, Margin);
+ // FixedPage.SetLeft(footer, Margin);
+
+ // TextBlock fdateText = new TextBlock();
+ // if (DateVisibility) fdateText.Visibility = Visibility.Visible;
+ // else fdateText.Visibility = Visibility.Hidden;
+ // dateText.Text = Now;
+
+ // TextBlock fPageNumberText = new TextBlock();
+ // if (PageNumberVisibility) fPageNumberText.Visibility = Visibility.Visible;
+ // else fPageNumberText.Visibility = Visibility.Hidden;
+ // fPageNumberText.Text = "Page : " + pageNumber;
+
+ // FixedPage.SetTop(fdateText, PageHeightWithMargin);
+ // FixedPage.SetLeft(fdateText, Margin);
+
+ // FixedPage.SetTop(fPageNumberText, PageHeightWithMargin);
+ // FixedPage.SetLeft(fPageNumberText, PageWidthWithMargin - PageNumberText.ActualWidth);
+
+ // ffixedPage.Children.Add(footer);
+ // ffixedPage.Children.Add(fdateText);
+ // ffixedPage.Children.Add(fPageNumberText);
+
+ // ffixedPage.Measure(pageSize);
+ // ffixedPage.Arrange(new Rect(new Point(), pageSize));
+ // ffixedPage.UpdateLayout();
+
+ // PageContent fpageContent = new PageContent();
+ // ((IAddChild)fpageContent).AddChild(ffixedPage);
+ // fixedDoc.Pages.Add(fpageContent);
+ // IsFooterAdded = true;
+ // }
+
+ // if (IsFooterAdded)
+ // {
+ // break;
+ // }
+ // }
+
+ // PrintFixedDocument(fixedDoc, printDialog);
+ //}
+ //private DataGrid GetDataGrid(DataGrid grid, double GridActualWidth, double PageWidthWithMargin)
+ //{
+ // DataGrid printed = new DataGrid();
+
+
+ // // styling the grid
+ // Style rowStyle = new Style(typeof(DataGridRow));
+ // rowStyle.Setters.Add(new Setter(Control.BackgroundProperty, Brushes.White));
+ // rowStyle.Setters.Add(new Setter(Control.FontSizeProperty, FontSize));
+ // if (IsBold) rowStyle.Setters.Add(new Setter(Control.FontWeightProperty, FontWeights.Bold));
+ // rowStyle.Setters.Add(new Setter(Control.HeightProperty, RowHeight));
+
+
+ // Style columnStyle = new Style(typeof(DataGridColumnHeader));
+ // columnStyle.Setters.Add(new Setter(Control.FontSizeProperty, HeaderFontSize));
+ // columnStyle.Setters.Add(new Setter(Control.HorizontalContentAlignmentProperty, HorizontalAlignment.Center));
+ // columnStyle.Setters.Add(new Setter(Control.BorderThicknessProperty, new Thickness(0, 0.5, 0, 1.5)));
+ // columnStyle.Setters.Add(new Setter(Control.BackgroundProperty, Brushes.White));
+ // columnStyle.Setters.Add(new Setter(Control.BorderBrushProperty, Brushes.Black));
+ // columnStyle.Setters.Add(new Setter(Control.FontWeightProperty, FontWeights.SemiBold));
+
+
+ // printed.RowStyle = rowStyle;
+
+ // printed.VerticalGridLinesBrush = Brushes.Black;
+ // printed.HorizontalGridLinesBrush = Brushes.Black;
+ // printed.FontFamily = new FontFamily("Arial");
+
+ // printed.RowBackground = Brushes.White;
+ // printed.Background = Brushes.White;
+ // printed.Foreground = Brushes.Black;
+ // // get the columns of grid
+ // foreach (var column in grid.Columns)
+ // {
+ // if (column.Visibility != Visibility.Visible) continue;
+
+ // DataGridTextColumn textColumn = new DataGridTextColumn();
+ // textColumn.HeaderStyle = columnStyle;
+ // textColumn.Header = column.Header;
+ // textColumn.Width = column.ActualWidth / GridActualWidth * PageWidthWithMargin;
+ // textColumn.Binding = ((DataGridTextColumn)column).Binding;
+ // printed.Columns.Add(textColumn);
+ // }
+
+ // printed.BorderBrush = Brushes.Black;
+
+
+ // return printed;
+ //}
+
+ //public void PrintFixedDocument(FixedDocument fixedDoc, PrintDialog printDialog)
+ //{
+ // XpsDocumentWriter writer = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
+ // writer.Write(fixedDoc, printDialog.PrintTicket);
+ //}
+ }
+}
diff --git a/AV-ToolV3/Properties/AssemblyInfo.cs b/AV-ToolV3/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..6ef0a09
--- /dev/null
+++ b/AV-ToolV3/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die einer Assembly zugeordnet sind.
+[assembly: AssemblyTitle("PEP-Tool")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("PEP-Tool")]
+[assembly: AssemblyCopyright("Copyright © 2018 - 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
+// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
+[assembly: ComVisible(false)]
+
+//Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie
+//ImCodeVerwendeteKultur in der .csproj-Datei
+//in einer fest. Wenn Sie in den Quelldateien beispielsweise Deutsch
+//(Deutschland) verwenden, legen Sie auf \"de-DE\" fest. Heben Sie dann die Auskommentierung
+//des nachstehenden NeutralResourceLanguage-Attributs auf. Aktualisieren Sie "en-US" in der nachstehenden Zeile,
+//sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
+ //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
+ // oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
+ ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
+ //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
+ // designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
+)]
+
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("3.0.0.0")]
+[assembly: AssemblyFileVersion("3.0.0.0")]
diff --git a/AV-ToolV3/Properties/Resources.Designer.cs b/AV-ToolV3/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..731b155
--- /dev/null
+++ b/AV-ToolV3/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace PEP_Tool.Properties {
+ using System;
+
+
+ ///
+ /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+ ///
+ // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
+ // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
+ // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
+ // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PEP_Tool.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
+ /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/AV-ToolV3/Properties/Resources.resx b/AV-ToolV3/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/AV-ToolV3/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/AV-ToolV3/Properties/Settings.Designer.cs b/AV-ToolV3/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..022f6be
--- /dev/null
+++ b/AV-ToolV3/Properties/Settings.Designer.cs
@@ -0,0 +1,278 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace PEP_Tool.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string LizenzenPath {
+ get {
+ return ((string)(this["LizenzenPath"]));
+ }
+ set {
+ this["LizenzenPath"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string AbteilungsnamenPath {
+ get {
+ return ((string)(this["AbteilungsnamenPath"]));
+ }
+ set {
+ this["AbteilungsnamenPath"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string ZuweisungenPath {
+ get {
+ return ((string)(this["ZuweisungenPath"]));
+ }
+ set {
+ this["ZuweisungenPath"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool newVersionScreen {
+ get {
+ return ((bool)(this["newVersionScreen"]));
+ }
+ set {
+ this["newVersionScreen"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1.0")]
+ public string newVersionString {
+ get {
+ return ((string)(this["newVersionString"]));
+ }
+ set {
+ this["newVersionString"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("2.0.4")]
+ public string Version {
+ get {
+ return ((string)(this["Version"]));
+ }
+ set {
+ this["Version"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public double WindowPosLeft {
+ get {
+ return ((double)(this["WindowPosLeft"]));
+ }
+ set {
+ this["WindowPosLeft"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Normal")]
+ public global::System.Windows.WindowState WindowState {
+ get {
+ return ((global::System.Windows.WindowState)(this["WindowState"]));
+ }
+ set {
+ this["WindowState"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public double WindowPosTop {
+ get {
+ return ((double)(this["WindowPosTop"]));
+ }
+ set {
+ this["WindowPosTop"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("681")]
+ public double WindowHeight {
+ get {
+ return ((double)(this["WindowHeight"]));
+ }
+ set {
+ this["WindowHeight"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1323")]
+ public double WindowWidth {
+ get {
+ return ((double)(this["WindowWidth"]));
+ }
+ set {
+ this["WindowWidth"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthBemerkung {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthBemerkung"]));
+ }
+ set {
+ this["WidthBemerkung"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthZuweisung {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthZuweisung"]));
+ }
+ set {
+ this["WidthZuweisung"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthLizenzen {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthLizenzen"]));
+ }
+ set {
+ this["WidthLizenzen"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthAbteilung {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthAbteilung"]));
+ }
+ set {
+ this["WidthAbteilung"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthGehen {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthGehen"]));
+ }
+ set {
+ this["WidthGehen"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthKommen {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthKommen"]));
+ }
+ set {
+ this["WidthKommen"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthDatum {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthDatum"]));
+ }
+ set {
+ this["WidthDatum"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthVorname {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthVorname"]));
+ }
+ set {
+ this["WidthVorname"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthName {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthName"]));
+ }
+ set {
+ this["WidthName"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public global::System.Windows.Controls.DataGridLength WidthTelefon {
+ get {
+ return ((global::System.Windows.Controls.DataGridLength)(this["WidthTelefon"]));
+ }
+ set {
+ this["WidthTelefon"] = value;
+ }
+ }
+ }
+}
diff --git a/AV-ToolV3/Properties/Settings.settings b/AV-ToolV3/Properties/Settings.settings
new file mode 100644
index 0000000..c9b4bed
--- /dev/null
+++ b/AV-ToolV3/Properties/Settings.settings
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/Reader.cs b/AV-ToolV3/Reader.cs
new file mode 100644
index 0000000..5b1ca99
--- /dev/null
+++ b/AV-ToolV3/Reader.cs
@@ -0,0 +1,863 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PEP_Tool
+{
+ public static class Reader
+ {
+ public static bool PersonalNummerIsEnabled { get; set; } = true;
+
+ public static string OpenFile(string Dialogname = "Datei")
+ {
+ OpenFileDialog dialog = new OpenFileDialog();
+ dialog.RestoreDirectory = true;
+
+ dialog.Title = $"{Dialogname} öffnen";
+
+ dialog.Filter = "Excel Arbeitsblatt CSV|*.csv";
+ dialog.ShowDialog();
+
+ var result = dialog.FileName;
+
+ if (string.IsNullOrEmpty(result))
+ return OpenFile(Dialogname);
+ else
+ return result;
+ }
+
+ private static List CreateLizenzList()
+ {
+ var path = "";
+ if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Lizenzen.csv")) path = @"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Lizenzen.csv";
+ else
+ path = Properties.Settings.Default.LizenzenPath == "" ? OpenFile("Lizenzen") : Properties.Settings.Default.LizenzenPath;
+
+ if (!File.Exists(path)) path = OpenFile("Lizenzen");
+
+
+ if (File.ReadAllLines(path).First().StartsWith("Name;") || File.ReadAllLines(path).First().StartsWith("Personalnummer;0001"))
+ {
+ if (path != Properties.Settings.Default.LizenzenPath)
+ {
+ Properties.Settings.Default.LizenzenPath = path;
+ Properties.Settings.Default.Save();
+ }
+
+ var lizenzen = File.ReadAllLines(path, Encoding.GetEncoding(850));
+ var LizenzName = lizenzen.First().Split(';');
+ var lizenzList = new List();
+ var sa = new List();
+
+
+ for (var j = 1; j < lizenzen.Count(); j++)
+ {
+ string fLine = "";
+ var x = lizenzen[j].Split(';');
+ for (var i = 0; i < x.Length; i++)
+ {
+ var word = x[i];
+ if (word == "vorhanden" || word.Contains("."))
+ word = LizenzName[i];
+
+ if (word == "nicht mehr benötigt" || word == "verfallen") word = "";
+
+ fLine += word + ";";
+ }
+
+ lizenzList.Add(new TableInfo()
+ {
+ PersNummer = fLine.Split(';')[0],
+ Lizenzen = fLine.Split(';').Slice(1, fLine.Split(';').Count()).ToList().Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList()
+ });
+ }
+
+ return lizenzList;
+ }
+ else
+ {
+ MessageBox.Show("Keine korrekte Lizenzen-Datei ausgewählt", "Fehler", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
+ return CreateLizenzList();
+ }
+ }
+
+ static bool exceptionBemerkungen = false;
+ static List lastBemerkungenList = new List();
+ static DateTime lastWriteBemerkungen = DateTime.Now;
+ public static async Task> CreateBemerkungenList()
+ {
+ if (MainWindow.propertyChangeAllowed)
+ {
+ try
+ {
+ var list = new List();
+ list = null;
+
+ var tNew = File.GetLastWriteTime(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Bemerkungen.json");
+
+ if (tNew != lastWriteBemerkungen)
+ {
+ if (Convert.ToDateTime(MainWindow.main.LastChangeTime) < tNew) MainWindow.main.LastChangeTime = tNew.ToString();
+
+ if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Bemerkungen.json"))
+ {
+ try
+ {
+ //var jsonBemerkungen = File.ReadAllText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Bemerkungen.json");
+
+ for (var i = 0; list == null; i++)
+ {
+ if (i >= 50)
+ {
+ throw new StackOverflowException("Anzahl der Versuche 'ReadBemerkungenJSON' überschritten (i >= 50)");
+ break;
+ }
+
+ await Task.Delay(100);
+ list = await ReadBemerkungenJSON();
+ //if (list != null) break;
+ }
+
+
+ if (exceptionBemerkungen)
+ {
+ LogFile.WriteLine("Successfully created BemerkungenList");
+ exceptionBemerkungen = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ exceptionBemerkungen = true;
+
+ return await CreateBemerkungenList();
+ }
+ }
+ else File.CreateText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Bemerkungen.json");
+
+ lastWriteBemerkungen = tNew;
+
+ if (list != null)
+ {
+ lastBemerkungenList = list;
+ return list;
+ }
+ else
+ {
+ LogFile.WriteLine("B-list is null");
+ return await CreateBemerkungenList();
+ }
+ }
+ else return lastBemerkungenList;
+
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ return lastBemerkungenList;
+ }
+ }
+ else if (lastBemerkungenList != null) return lastBemerkungenList;
+ else return await CreateBemerkungenList();
+ }
+
+ private static async Task> ReadBemerkungenJSON()
+ {
+ var fail = false;
+
+ try
+ {
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Bemerkungen.json", FileMode.Open, FileAccess.Read, FileShare.Read)) //Write | FileShare.Delete
+ {
+ if (fs != null)
+ {
+ byte[] json = new byte[fs.Length];
+ await fs.ReadAsync(json, 0, (int)fs.Length);
+ var jsonBemerkungen = Encoding.UTF8.GetString(json);
+
+ if (!Helper.IsBase64String(jsonBemerkungen) || jsonBemerkungen == "")
+ return null;
+
+ var jsonBemerkungenDecrypted = "%%";
+ for (var i = 0; jsonBemerkungenDecrypted == "%%" || i <= 10; i++)
+ {
+ jsonBemerkungenDecrypted = await Crypto.DecryptString(jsonBemerkungen);
+
+ if (jsonBemerkungenDecrypted == "%%")
+ {
+ if (i > 0)
+ {
+ LogFile.WriteLine($"Decrypt Bemerkungen failed - for the {i}. Time - Trying again...");
+ fail = true;
+ }
+
+ using (var fs1 = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Bemerkungen.json", FileMode.Open, FileAccess.Read, FileShare.Read))//Write | FileShare.Delete
+ {
+ json = new byte[fs1.Length];
+ await fs1.ReadAsync(json, 0, (int)fs1.Length);
+ jsonBemerkungen = Encoding.UTF8.GetString(json);
+
+ await Task.Delay(100);
+ }
+ }
+ else break;
+ }
+
+ if (fail) LogFile.WriteLine("Decrypt Bemerkungen succeeded");
+ fail = false;
+
+ //jsonBemerkungen = Crypto.DecryptString(jsonBemerkungen);
+ var list = Newtonsoft.Json.JsonConvert.DeserializeObject>(jsonBemerkungenDecrypted);
+
+ //jsonLength = json == null ? 111111 : json.Length;
+ //jsonBemerkungenLength = jsonBemerkungen == null ? 111111 : jsonBemerkungen.Length;
+
+ return list;
+ }
+ else
+ {
+ fs.Dispose();
+ return null;
+ }
+ }
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
+ static bool exceptionZuweisungen = false;
+ static List lastZuweisungenList = new List();
+ public static DateTime lastWriteZuweisungen = DateTime.Now;
+ public static async Task> CreateZuweisungenList()
+ {
+ if (MainWindow.propertyChangeAllowed)
+ {
+ try
+ {
+ var list = new List();
+ list = null;
+
+ var tNew = File.GetLastWriteTime(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Zuweisungen.json");
+
+
+ if (tNew != lastWriteZuweisungen)
+ {
+ if (Convert.ToDateTime(MainWindow.main.LastChangeTime) < tNew) MainWindow.main.LastChangeTime = tNew.ToString();
+
+ if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Zuweisungen.json"))
+ {
+ var jsonLength = 0;
+ var jsonZuweisungenLength = 0;
+
+
+ try
+ {
+ //var jsonZuweisungen = File.ReadAllText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Zuweisungen.json");
+
+ for (var i = 0; list == null; i++)
+ {
+ await Task.Delay(100);
+ list = await ReadZuweisungenJSON();
+
+ //if (list != null) break;
+ if (i >= 50)
+ {
+ LogFile.WriteLine("Anzahl der Versuche 'ReadZuweisungenJSON' überschritten (i >= 50)");
+ i = 0;
+ break;
+ }
+ }
+
+ if (exceptionZuweisungen)
+ {
+ LogFile.WriteLine("Successfully created ZuweisungenList");
+ exceptionZuweisungen = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+
+ LogFile.WriteLine("json.Length: " + jsonLength);
+ LogFile.WriteLine("jsonZuweisungen.Length " + jsonZuweisungenLength);
+
+
+ exceptionZuweisungen = true;
+
+ return await CreateZuweisungenList();
+ }
+ }
+ else File.CreateText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Zuweisungen.json");
+
+ lastWriteZuweisungen = tNew;
+
+ if (list != null)
+ {
+ lastZuweisungenList = list;
+ return list;
+ }
+ else
+ {
+ LogFile.WriteLine("list is null");
+ return lastZuweisungenList;//await CreateZuweisungenList();
+ }
+ }
+ else return lastZuweisungenList;
+
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ return lastZuweisungenList;
+ }
+ }
+ else if (lastZuweisungenList != null) return lastZuweisungenList;
+ else return await CreateZuweisungenList();
+ }
+
+ private static async Task> ReadZuweisungenJSON()
+ {
+ var fail = false;
+ try
+ {
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Zuweisungen.json", FileMode.Open, FileAccess.Read, FileShare.Read)) //Test 25.07.19 FileShare.ReadWrite | FileShare.Delete
+ {
+ if (fs != null)
+ {
+ byte[] json = new byte[fs.Length];
+ await fs.ReadAsync(json, 0, (int)fs.Length);
+ var jsonZuweisungen = Encoding.UTF8.GetString(json);
+
+ if (!Helper.IsBase64String(jsonZuweisungen) || jsonZuweisungen == "")
+ return null;
+
+ var jsonZuweisungenDecrypted = "%%";
+ for (var i = 0; jsonZuweisungenDecrypted == "%%" || i <= 10; i++)
+ {
+ jsonZuweisungenDecrypted = await Crypto.DecryptString(jsonZuweisungen);
+
+ if (jsonZuweisungenDecrypted == "%%")
+ {
+ if (i > 0)
+ {
+ LogFile.WriteLine($"Decrypt Zuweisungen failed - for the {i}. Time - Trying again...");
+
+ fail = true;
+ }
+
+ using (var fs1 = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Zuweisungen.json", FileMode.Open, FileAccess.Read, FileShare.Read))//Write | FileShare.Delete
+ {
+ json = new byte[fs1.Length];
+ await fs1.ReadAsync(json, 0, (int)fs1.Length);
+ jsonZuweisungen = Encoding.UTF8.GetString(json);
+
+ await Task.Delay(1000);
+ }
+ }
+ else break;
+ }
+
+ if (fail) LogFile.WriteLine("Decrypt Zuweisungen succeeded");
+ fail = false;
+
+ var list = Newtonsoft.Json.JsonConvert.DeserializeObject>(jsonZuweisungenDecrypted);
+ //var items = Enumerable.SequenceEqual(list, lastZuweisungenList);
+ //jsonLength = json == null ? 111111 : json.Length;
+ //jsonZuweisungenLength = jsonZuweisungen == null ? 111111 : jsonZuweisungen.Length;
+
+ return list;
+ }
+ else
+ {
+ fs.Dispose();
+
+ return null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ LogFile.WriteLine(ex.ToString());
+ return null;
+ }
+
+ }
+
+
+ static bool exceptionTelefon = false;
+ static List lastTelefonList = new List();
+ public static DateTime lastWriteTelefon = DateTime.Now;
+ public static async Task> CreateTelefonList()
+ {
+ if (MainWindow.propertyChangeAllowed)
+ {
+ try
+ {
+ var list = new List();
+ list = null;
+
+ var tNew = File.GetLastWriteTime(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Telefon.json");
+
+
+ if (tNew != lastWriteTelefon)
+ {
+ if (Convert.ToDateTime(MainWindow.main.LastChangeTime) < tNew) MainWindow.main.LastChangeTime = tNew.ToString();
+
+ if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Telefon.json"))
+ {
+ var jsonLength = 0;
+ var jsonTelefonLength = 0;
+
+
+ try
+ {
+ //var jsonTelefon = File.ReadAllText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Telefon.json");
+
+ for (var i = 0; list == null; i++)
+ {
+ list = await ReadTelefonJSON();
+ await Task.Delay(100);
+ //if (list != null) break;
+ if (i >= 50)
+ {
+ LogFile.WriteLine("Anzahl der Versuche 'ReadTelefonJSON' überschritten (i >= 50)");
+ i = 0;
+ break;
+ }
+ }
+
+ if (exceptionTelefon)
+ {
+ LogFile.WriteLine("Successfully created TelefonList");
+ exceptionTelefon = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+
+ LogFile.WriteLine("json.Length: " + jsonLength);
+ LogFile.WriteLine("jsonTelefon.Length " + jsonTelefonLength);
+
+
+ exceptionTelefon = true;
+
+ return await CreateTelefonList();
+ }
+ }
+ else File.CreateText(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Telefon.json");
+
+ lastWriteTelefon = tNew;
+
+ if (list != null)
+ {
+ lastTelefonList = list;
+ return list;
+ }
+ else
+ {
+ LogFile.WriteLine("list is null");
+ return lastTelefonList;//await CreateTelefonList();
+ }
+ }
+ else return lastTelefonList;
+
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ return lastTelefonList;
+ }
+ }
+ else if (lastTelefonList != null) return lastTelefonList;
+ else return await CreateTelefonList();
+ }
+
+ private static async Task> ReadTelefonJSON()
+ {
+ var fail = false;
+ try
+ {
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Telefon.json", FileMode.Open, FileAccess.Read, FileShare.Read)) //Write | FileShare.Delete
+ {
+ if (fs != null)
+ {
+ byte[] json = new byte[fs.Length];
+ await fs.ReadAsync(json, 0, (int)fs.Length);
+ var jsonTelefon = Encoding.UTF8.GetString(json);
+
+ if (!Helper.IsBase64String(jsonTelefon) || jsonTelefon == "")
+ return null;
+
+ var jsonTelefonDecrypted = "%%";
+ for (var i = 0; jsonTelefonDecrypted == "%%" || i <= 10; i++)
+ {
+ jsonTelefonDecrypted = await Crypto.DecryptString(jsonTelefon);
+
+ if (jsonTelefonDecrypted == "%%")
+ {
+ if (i > 0)
+ {
+ LogFile.WriteLine($"Decrypt Telefon failed - for the {i}. Time - Trying again...");
+
+ fail = true;
+ }
+
+ using (var fs1 = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\JSON\Telefon.json", FileMode.Open, FileAccess.Read, FileShare.Read))//Write | FileShare.Delete
+ {
+ json = new byte[fs1.Length];
+ await fs1.ReadAsync(json, 0, (int)fs1.Length);
+ jsonTelefon = Encoding.UTF8.GetString(json);
+
+ await Task.Delay(1000);
+ }
+ }
+ else break;
+ }
+
+ if (fail) LogFile.WriteLine("Decrypt Telefon succeeded");
+ fail = false;
+
+ var list = Newtonsoft.Json.JsonConvert.DeserializeObject>(jsonTelefonDecrypted);
+ //var items = Enumerable.SequenceEqual(list, lastTelefonList);
+ //jsonLength = json == null ? 111111 : json.Length;
+ //jsonTelefonLength = jsonTelefon == null ? 111111 : jsonTelefon.Length;
+
+ return list;
+ }
+ else
+ {
+ fs.Dispose();
+ return null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex.ToString());
+ return null;
+ }
+
+ }
+
+
+ public static List LizenzList { get; set; }
+
+
+ public static List ReadUserList(bool FilePicker = false)
+ {
+ var lizenzList = CreateLizenzList();
+ LizenzList = lizenzList;
+ var bemerkungenList = CreateBemerkungenList();
+ var zuweisungenList = CreateZuweisungenList();
+ var telefonList = CreateTelefonList();
+ List list = new List();
+ var users = OpenUserList(FilePicker);
+
+ foreach (var user in users)
+ {
+ if (user.StartsWith("0"))
+ {
+ var liz = new TableInfo();
+ if (PersonalNummerIsEnabled)
+ {
+ var li = lizenzList.Where(p => p.PersNummer == user.Split(';')[0]);
+
+ if (li.Count() > 0)
+ {
+ liz = li.First();
+ }
+ }
+ else
+ {
+ var li = lizenzList.Where(p => p.Name == user.Split(';')[1] && p.Vorname == user.Split(';')[2]);
+
+ if (li.Count() > 0) liz = li.First();
+ }
+
+ var bem = new TableInfo();
+ if (bemerkungenList.Result != null)
+ {
+ if (PersonalNummerIsEnabled)
+ {
+ var be = bemerkungenList.Result.Where(p => p.PersNummer == user.Split(';')[0] && p.Datum == DateTime.Parse(user.Split(';')[3]));
+ if (be.Count() > 0) bem = be.First();
+ }
+ else
+ {
+ var be = bemerkungenList.Result.Where(p => p.Name == user.Split(';')[1] && p.Vorname == user.Split(';')[2] && p.Datum == DateTime.Parse(user.Split(';')[3]));
+ if (be.Count() > 0) bem = be.First();
+ }
+ }
+
+ var zuw = new TableInfo();
+ if (zuweisungenList.Result != null)
+ {
+ if (PersonalNummerIsEnabled)
+ {
+ var zu = zuweisungenList.Result.Where(p => p.PersNummer == user.Split(';')[0] && p.Datum == DateTime.Parse(user.Split(';')[3]));
+ if (zu.Count() > 0) zuw = zu.First();
+ }
+ else
+ {
+ var zu = zuweisungenList.Result.Where(p => p.Name == user.Split(';')[1] && p.Vorname == user.Split(';')[2] && p.Datum == DateTime.Parse(user.Split(';')[3]));
+ if (zu.Count() > 0) zuw = zu.First();
+ }
+ }
+
+ var tele = new TableInfo();
+ if (telefonList.Result != null)
+ {
+ if (PersonalNummerIsEnabled)
+ {
+ var tel = telefonList.Result.Where(p => p.PersNummer == user.Split(';')[0]);// && p.Datum == DateTime.Parse(user.Split(';')[3]));
+ if (tel.Count() > 0) tele = tel.First();
+ }
+ else
+ {
+ var tel = telefonList.Result.Where(p => p.Name == user.Split(';')[1] && p.Vorname == user.Split(';')[2] && p.Datum == DateTime.Parse(user.Split(';')[3]));
+ if (tel.Count() > 0) tele = tel.First();
+ }
+ }
+
+
+
+ Tuple abtName = null;
+ if (MainWindow.main.AbteilungsNamen.TryGetValue(user.Split(';')[10], out abtName)) ;
+ else abtName = new Tuple(user.Split(';')[10].Split(';')[0], user.Split(';')[10].Split(';')[1]);
+
+
+
+ list.Add(new TableInfo()
+ {
+ PersNummer = user.Split(';')[0],
+ Name = user.Split(';')[1],
+ Vorname = user.Split(';')[2],
+ Datum = DateTime.Parse(user.Split(';')[3]),
+ Gehen = user.Split(';')[6],
+ Arbeitsmuster = user.Split(';')[4],
+ Abteilung = abtName.Item2 == "" ? abtName.Item1 : abtName.Item2,
+ Tagescode = user.Split(';')[12],
+ Beginn = user.Split(';')[5],
+ Zuweisung = zuw.Zuweisung,
+ ZuweisungsMoeglichkeiten = MainWindow.main.ZuweisungsMoeglichkeiten,
+ Lizenzen = liz.Lizenzen,
+ Bemerkung = bem.Bemerkung,
+ Telefon = tele.Telefon
+ });
+ }
+ }
+
+ var last = 0;
+ foreach (var entry in list)
+ {
+ if (last != Convert.ToInt32(entry.PersNummer))
+ {
+ if (entry.Lizenzen != null) entry.Lizenzen.Insert(0, $"{entry.Lizenzen.Count} Lizenzen");
+ else
+ {
+ entry.Lizenzen = new List();
+ entry.Lizenzen.Add("keine Lizenzen");
+ }
+ }
+ else if (entry.Lizenzen == null)
+ {
+ entry.Lizenzen = new List();
+ entry.Lizenzen.Add("keine Lizenzen");
+ }
+
+ last = Convert.ToInt32(entry.PersNummer);
+ }
+
+ list = list.Where(p => p.Tagescode == "" || p.Tagescode.All(char.IsDigit)).ToList();
+ list = list.Where(p => p.Arbeitsmuster.ToLower() != "frei").ToList();
+ //list.Sort((a, b) => a.Name.CompareTo(b.Name));
+ list = list.OrderBy(name => name.Name).ThenBy(vorname => vorname.Vorname).ThenBy(abteilung => abteilung.Abteilung).ThenBy(datum => datum.Datum).ToList();
+
+ return list;
+ }
+
+ private static string[] OpenUserList(bool FilePicker = false)
+ {
+ var path = "";
+
+ if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\DTIME.csv") && !FilePicker) path = @"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\DTIME.csv";
+ else
+ path = OpenFile("Mitarbeiterliste");
+
+ var users = System.IO.File.ReadAllLines(path, Encoding.GetEncoding(65001));
+
+ if (users[0].StartsWith("Personalnummer;Nachname")) users = users;
+ else
+ {
+ var x = System.Windows.MessageBox.Show("Keine gültige Mitarbeiterliste ausgewählt!", "Fehler!", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation, System.Windows.MessageBoxResult.OK, System.Windows.MessageBoxOptions.ServiceNotification);
+ return OpenUserList();
+ }
+
+ return users;
+ }
+
+ internal static List ReadZuweisungsMoeglichkeiten()
+ {
+ var path = "";
+
+ if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Zuweisungen.csv")) path = @"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Zuweisungen.csv";
+ else
+ path = Properties.Settings.Default.ZuweisungenPath == "" ? OpenFile("Zuweisungen") : Properties.Settings.Default.ZuweisungenPath;
+
+ if (!File.Exists(path)) path = OpenFile("Zuweisungen");
+
+ if (!File.ReadAllText(path, Encoding.GetEncoding(1250)).Contains(";"))
+ {
+ if (path != Properties.Settings.Default.ZuweisungenPath)
+ {
+ Properties.Settings.Default.ZuweisungenPath = path;
+ Properties.Settings.Default.Save();
+ }
+
+ var list = File.ReadAllLines(path, Encoding.GetEncoding(1250)).ToList();
+ list.Insert(0, "");
+
+ return list;
+ }
+ else
+ {
+ MessageBox.Show("Keine korrekte Zuweisungen-Datei ausgewählt", "Fehler", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
+ return ReadZuweisungsMoeglichkeiten();
+ }
+
+ }
+
+
+ internal static Dictionary> ReadAbteilungsNamen()
+ {
+ var path = "";
+
+ if (File.Exists(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\DKEYS.csv")) path = @"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\DKEYS.csv";
+ else
+ path = Properties.Settings.Default.AbteilungsnamenPath == "" ? OpenFile("Abteilungsnamen") : Properties.Settings.Default.AbteilungsnamenPath;
+
+ if (!File.Exists(path)) path = OpenFile("Abteilungsnamen");
+
+ if (File.ReadAllLines(path).First().StartsWith("Abteilung;"))
+ {
+ if (path != Properties.Settings.Default.AbteilungsnamenPath)
+ {
+ Properties.Settings.Default.AbteilungsnamenPath = path;
+ Properties.Settings.Default.Save();
+ }
+
+
+ Dictionary> list = new Dictionary>();
+ foreach (var line in File.ReadAllLines(path))
+ {
+ list.Add(line.Split(';')[0], new Tuple(line.Split(';')[1], line.Split(';')[2]));
+ }
+ return list;
+ }
+ else
+ {
+ MessageBox.Show("Keine korrekte Abteilungsnamen-Datei ausgewählt", "Fehler", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
+ return ReadAbteilungsNamen();
+ }
+ }
+
+
+
+
+
+
+ public static async Task ReadTime(Dictionary> keyValuePairs)
+ {
+ var client = await Crypto.EncryptString(Environment.MachineName);
+ KeyValuePair output = new KeyValuePair();
+
+
+ if (keyValuePairs != null && keyValuePairs.Where(p => p.Key == client).Count() > 0)
+ {
+ var o = keyValuePairs.Where(p => p.Key == client).First();
+ output = new KeyValuePair(o.Key, o.Value.Item1);
+
+ }
+ else return 0;
+
+ return output.Value;
+ }
+
+ public static async Task>> ReadTimeJSON()
+ {
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Track.json", FileMode.Open, FileAccess.Read, FileShare.Read)) //Write | FileShare.Delete
+ {
+ byte[] json = new byte[fs.Length];
+ await fs.ReadAsync(json, 0, (int)fs.Length);
+ var jsonTrack = Encoding.UTF8.GetString(json);
+
+ //if (!Helper.IsBase64String(jsonTrack) || jsonTrack == "")
+ // return null;
+
+ //var enc = "%%";
+
+ //enc = await Crypto.DecryptString(jsonTrack);
+ try
+ {
+ var keyValuePairs = Newtonsoft.Json.JsonConvert.DeserializeObject>>(jsonTrack);
+ return keyValuePairs;
+ }
+ catch (Exception)
+ {
+ fs.Dispose();
+ return await ReadTimeJSON();
+ }
+ }
+ }
+
+ }
+
+
+
+ public static class Extensions
+ {
+ ///
+ /// Get the array slice between the two indexes.
+ /// ... Inclusive for start index, exclusive for end index.
+ ///
+ public static T[] Slice(this T[] source, int start, int end)
+ {
+ // Handles negative ends.
+ if (end < 0)
+ {
+ end = source.Length + end;
+ }
+ int len = end - start;
+
+ // Return new array.
+ T[] res = new T[len];
+ for (int i = 0; i < len; i++)
+ {
+ res[i] = source[i + start];
+ }
+ return res;
+ }
+ }
+
+}
diff --git a/AV-ToolV3/SQL.cs b/AV-ToolV3/SQL.cs
new file mode 100644
index 0000000..63adb2e
--- /dev/null
+++ b/AV-ToolV3/SQL.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SQLite;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PEP_Tool
+{
+ public static class SQL
+ {
+ private static SQLiteConnection dbConnection;
+ public static SQLiteConnection DBConnection
+ {
+ get
+ {
+ if (dbConnection == null) ConnectDB();
+ return dbConnection;
+ }
+ set
+ {
+ dbConnection = value;
+ }
+ }
+
+
+
+ public static async Task ConnectDB()
+ {
+ DBConnection = new SQLiteConnection("Data Source = PEP_DB.sqlite; Version = 3;");
+ DBConnection.Open();
+ }
+
+
+
+ public static async Task WriteDB(string WriteString)
+ {
+ if (DBConnection.State != System.Data.ConnectionState.Open) await ConnectDB();
+
+ SQLiteCommand command = new SQLiteCommand(WriteString, DBConnection);
+ await command.ExecuteNonQueryAsync();
+ }
+
+
+
+ public static void ReadDB()
+ {
+
+ }
+
+
+
+ public static void CloseDB()
+ {
+ dbConnection.Close();
+ }
+
+
+ public static async Task CreateDataAdapter()
+ {
+ SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter("SELECT * FROM serial", DBConnection);
+ DataSet ds = new DataSet();
+
+ dataAdapter.FillSchema(ds, System.Data.SchemaType.Mapped);
+ return dataAdapter;
+ }
+
+
+
+ public static async void CreateDB()
+ {
+ SQLiteConnection.CreateFile("PEP_DB.sqlite");
+
+ await ConnectDB();
+
+ string tableinfo = "CREATE TABLE TableInfo(" +
+ "PersNummer TEXT, " +
+ "FilePath TEXT, " +
+ "Datum TEXT, " +
+ "Zuweisung TEXT," +
+ "Bemerkung TEXT, " +
+ "Telefon TEXT)";
+
+ SQLiteCommand Command = new SQLiteCommand(tableinfo, DBConnection);
+ Command.ExecuteNonQuery();
+
+ //Lizenzen list string
+ //Zuweisungsmöglichkeiten list string
+ }
+ }
+
+ public class SQLtoDataGrid
+ {
+ public DataView UserListView;
+ public DataView ZuweisungsMoeglichkeiten;
+
+ public SQLtoDataGrid()
+ {
+ SQLiteConnection con = new SQLiteConnection("Data Source = PEP_DB.sqlite; Version = 3;");
+ try
+ {
+ con.Open();
+ string Query = "select * from UserList";
+ SQLiteCommand cmdp = new SQLiteCommand(Query, con);
+ DataTable UserList = new DataTable();
+ using (SQLiteDataAdapter ap = new SQLiteDataAdapter(cmdp))
+ {
+ ap.Fill(UserList);
+ }
+ UserListView = UserList.DefaultView;
+
+ SQLiteCommand cmdc = new SQLiteCommand("select * from ZuweisungsMoeglichkeiten", con);
+ DataTable ZWDT = new DataTable();
+ using (SQLiteDataAdapter ac = new SQLiteDataAdapter(cmdc))
+ {
+ ac.Fill(ZWDT);
+ }
+ ZuweisungsMoeglichkeiten = ZWDT.DefaultView;
+ }
+ catch (Exception ex)
+ {
+ System.Diagnostics.Debug.WriteLine(ex);
+ }
+ }
+ }
+}
diff --git a/AV-ToolV3/TableCreator.cs b/AV-ToolV3/TableCreator.cs
new file mode 100644
index 0000000..4578a6d
--- /dev/null
+++ b/AV-ToolV3/TableCreator.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+
+namespace PEP_Tool
+{
+ class TableCreator
+ {
+ static int errCount = 0;
+
+ public static async Task> CreateList(List userList, string filterAbteilung = "%", string filterAbteilung2 = "%", string filterAbteilung3 = "%", string Arbeitsmuster = "", string Datum = "", string Search = "", bool searchWithFilter = false, bool isSearch = false)
+ {
+ errCount++;
+ //System.Diagnostics.Debug.WriteLine($"{filterAbteilung}, {filterAbteilung2}, {filterAbteilung3}, {Arbeitsmuster}, {Datum}, {Search}, {isSearch}, {searchWithFilter}");
+ try
+ {
+ var list = ((filterAbteilung == "%" || filterAbteilung == "") && (filterAbteilung2 == "%" || filterAbteilung2 == "") && (filterAbteilung3 == "%" || filterAbteilung3 == "")) ? MainWindow.main.DefaultUserList : userList.Where(p => (p.Abteilung == filterAbteilung || p.Abteilung == filterAbteilung2 || p.Abteilung == filterAbteilung3)).ToList();
+
+
+ if (Arbeitsmuster.Contains(";"))
+ {
+ switch (Arbeitsmuster.Count(t => t == ';'))
+ {
+ case 1:
+ if (list != null) list = list.Where(p => (p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[0]) || p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[1]))).ToList();
+ break;
+
+ case 2:
+ if (list != null) list = list.Where(p => (p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[0]) || p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[1]) || p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[2]))).ToList();
+ break;
+
+ case 3:
+ if (list != null) list = list.Where(p => (p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[0]) || p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[1]) || p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[2]) || p.Arbeitsmuster.StartsWith(Arbeitsmuster.Split(';')[3]))).ToList();
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if (list != null)
+ list = Arbeitsmuster != "" ? list.Where(p => p.Arbeitsmuster.StartsWith(Arbeitsmuster)).ToList() : list;
+ }
+
+ if(list != null) list = Datum != "" ? list.Where(p => p.Datum == DateTime.Parse(Datum)).ToList() : list;
+
+ if (!searchWithFilter && Search == "" && isSearch) list = MainWindow.main.DefaultUserList;
+ else if ((searchWithFilter && Search == "" && isSearch) || !isSearch) list = list;
+ else if (!searchWithFilter && Search != "" && isSearch) list = userList.Where(p => (p.Name.ToLower().Contains(Search.ToLower()) || p.Vorname.ToLower().Contains(Search.ToLower()))).ToList();
+ else if (searchWithFilter && Search != "" && isSearch) if (list != null) list = list.Where(p => (p.Name.ToLower().Contains(Search.ToLower()) || p.Vorname.ToLower().Contains(Search.ToLower()))).ToList();
+
+ if (list != null) list = list.OrderBy(name => name.Name).ThenBy(vorname => vorname.Vorname).ThenBy(abteilung => abteilung.Abteilung).ThenBy(datum => datum.Datum).ToList();
+
+
+ if (list != null)
+ {
+ errCount = 0;
+ return list;
+ }
+ else return new List();
+ }
+ catch (Exception ex)
+ {
+ if (errCount > 1)
+ {
+ LogFile.WriteLine(ex.ToString());
+ LogFile.WriteLine("Message: " + ex.Message);
+ if (ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ }
+
+ if (errCount < 5) return await Task.Run(() => CreateList(userList, filterAbteilung, filterAbteilung2, filterAbteilung3, Arbeitsmuster, Datum, Search, searchWithFilter, isSearch));
+ else return new List();
+ }
+ }
+ }
+}
diff --git a/AV-ToolV3/TableInfo.cs b/AV-ToolV3/TableInfo.cs
new file mode 100644
index 0000000..374ec58
--- /dev/null
+++ b/AV-ToolV3/TableInfo.cs
@@ -0,0 +1,226 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PEP_Tool
+{
+ public class TableInfo : INotifyPropertyChanged, IEquatable
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private string filePath;
+
+ public string FilePath
+ {
+ get { return filePath; }
+ set {
+ filePath = value;
+ OnPropertyChanged();
+ }
+ }
+
+ //public string FilePath { get; set; }
+ public string Name { get; set; }
+ public string Vorname { get; set; }
+ public string Schicht { get; set; }
+ public DateTime Datum { get; set; }
+ public string PersNummer { get; set; }
+ public string Gehen { get; set; }
+ public string Abteilung { get; set; }
+ public string Tagescode { get; set; }
+ public string Arbeitsmuster { get; set; }
+ public string Beginn { get; set; }
+ public List Lizenzen { get; set; }
+
+ private string zuweisung;
+ public string Zuweisung
+ {
+ get { return zuweisung; }
+ set
+ {
+ zuweisung = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public List ZuweisungsMoeglichkeiten { get; set; }
+
+ private string bemerkung;
+ public string Bemerkung
+ {
+ get { return bemerkung; }
+ set
+ {
+ bemerkung = value;
+ OnPropertyChanged();
+ }
+ }
+
+
+ private string telefon;
+ public string Telefon
+ {
+ get { return telefon; }
+ set
+ {
+ telefon = value;
+ OnPropertyChanged();
+ }
+ }
+
+
+
+ public void Clear()
+ {
+ FilePath = "";
+ //Count = 0;
+ //Row = 0;
+ //Column = 0;
+ Name = "";
+ Vorname = "";
+ Schicht = "";
+ Datum = DateTime.Parse("01.01.1900 00:00");
+ PersNummer = "0";
+ Gehen = "";
+ Abteilung = "";
+ Tagescode = "";
+ Arbeitsmuster = "";
+ Beginn = "";// TimeSpan.FromSeconds(0);
+ Lizenzen = null;
+ }
+
+ public object GetPropertyValueForID(int ID, TableInfo type)
+ {
+ //System.Diagnostics.Debug.WriteLine(type.GetType().GetProperty("Name").GetValue(type, null));
+ switch (ID)
+ {
+ case 1:
+ return type.GetType().GetProperty("Name").GetValue(type, null);
+ break;
+ case 2:
+ return type.GetType().GetProperty("Vorname").GetValue(type, null);
+ break;
+ case 3:
+ return type.GetType().GetProperty("Datum").GetValue(type, null);
+ break;
+ case 4:
+ return type.GetType().GetProperty("Abteilung").GetValue(type, null);
+ break;
+ case 5:
+ return type.GetType().GetProperty("Zuweisung").GetValue(type, null);
+ break;
+ case 6:
+ return type.GetType().GetProperty("Bemerkung").GetValue(type, null);
+ break;
+
+ case 7:
+ return type.GetType().GetProperty("FilePath").GetValue(type, null);
+ break;
+ case 8:
+ return type.GetType().GetProperty("Schicht").GetValue(type, null);
+ break;
+ case 9:
+ return type.GetType().GetProperty("PersNummer").GetValue(type, null);
+ break;
+ case 10:
+ return type.GetType().GetProperty("Gehen").GetValue(type, null);
+ break;
+
+ case 11:
+ return type.GetType().GetProperty("Tagescode").GetValue(type, null);
+ break;
+ case 12:
+ return type.GetType().GetProperty("Arbeitsmuster").GetValue(type, null);
+ break;
+ case 13:
+ return type.GetType().GetProperty("Beginn").GetValue(type, null);
+ break;
+ case 14:
+ return type.GetType().GetProperty("Lizenzen").GetValue(type, null);
+ break;
+
+ }
+
+ return null;
+ }
+
+
+ #region EqualityComparer
+ // Overriding Equals member method, which will call the IEquatable implementation
+ // if appropriate.
+
+
+
+ // This is the method that must be implemented to conform to the
+ // IEquatable contract
+
+ public bool Equals(TableInfo other)
+ {
+ if (other == null)
+ {
+ return false;
+ }
+
+ //if (ReferenceEquals(this, other))
+ //{
+ // return true;
+ //}
+
+ if (this.PersNummer != other.PersNummer)
+ return false;
+
+ if (this.Datum != other.Datum)
+ {
+ return false;
+ }
+
+ if (this.Zuweisung != other.Zuweisung)
+ {
+ return false;
+ }
+
+ if (this.Bemerkung != other.Bemerkung)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public override bool Equals(object obj) => Equals(obj as TableInfo);
+ public override int GetHashCode() => (PersNummer + Datum.ToString()).GetHashCode();
+
+
+ //public class TableInfoZuweisungComparer : IEqualityComparer
+ //{
+ // public bool Equals(TableInfo x, TableInfo y)
+ // {
+ // if ((x.PersNummer == y.PersNummer)
+ // && (x.Datum == y.Datum)
+ // && (x.Zuweisung == y.Zuweisung))
+ // return true;
+ // else return false;
+ // }
+
+ // public int GetHashCode(TableInfo obj)
+ // {
+ // return obj.PersNummer.GetHashCode();
+ // }
+ //}
+
+ #endregion
+
+
+
+
+ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
+
diff --git a/AV-ToolV3/Tracker.cs b/AV-ToolV3/Tracker.cs
new file mode 100644
index 0000000..0f6f848
--- /dev/null
+++ b/AV-ToolV3/Tracker.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Threading;
+
+namespace PEP_Tool
+{
+ class Tracker
+ {
+ static DispatcherTimer timer = new DispatcherTimer();
+ //public double time = 0;
+ static string client = "";
+ public static double time { get; set; }
+ private static int count = 0;
+
+ public static async void Init_Track()
+ {
+ client = await Crypto.EncryptString(Environment.MachineName);
+ time = await Reader.ReadTime(await Reader.ReadTimeJSON());
+ SaveTrack(true);
+
+ timer.Interval = TimeSpan.FromSeconds(1);
+ timer.Tick += Timer_Tick;
+
+ timer.Start();
+ }
+
+ private static void Timer_Tick(object sender, EventArgs e)
+ {
+ //var t = time.Item1;
+ time += 1;
+ count++;
+ if(count >= 30)
+ {
+ SaveTrack(true);
+ count = 0;
+ }
+ }
+
+
+ public static async Task SaveTrack(bool Online)
+ {
+ var save = await Reader.ReadTimeJSON();
+ //var save = new Dictionary();
+
+ if (save == null)
+ save = new Dictionary>();
+
+ if (save.ContainsKey(client))
+ save[client] = new Tuple(time, Online, Properties.Settings.Default.Version);
+ else save.Add(client, new Tuple(time, Online, Properties.Settings.Default.Version));
+
+ if (client == "") return;
+
+ try
+ {
+ var json = Newtonsoft.Json.JsonConvert.SerializeObject(save);
+ //json = await Crypto.EncryptString(json);
+ byte[] jsonB = new UTF8Encoding(true).GetBytes(json);
+
+
+ using (var fs = Writer.WaitForFile(@"\\bku.db.de\db\DB_006\GLW_11\ICE-Fertigung\M2\Personaleinsatzplanung\Log\Track.json", System.IO.FileMode.Open, System.IO.FileAccess.Write, System.IO.FileShare.Read))//Write | System.IO.FileShare.Delete
+ {
+ if (fs != null)
+ {
+ fs.SetLength(0);
+ await fs.WriteAsync(jsonB, 0, jsonB.Length);
+ }
+ else fs.Dispose();
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFile.WriteLine(ex);
+ }
+
+ }
+ }
+}
diff --git a/AV-ToolV3/Writer.cs b/AV-ToolV3/Writer.cs
new file mode 100644
index 0000000..2f4a073
--- /dev/null
+++ b/AV-ToolV3/Writer.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PEP_Tool
+{
+ public static class Writer
+ {
+ static int errCount = 0;
+
+ public static FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share)
+ {
+ var err = false;
+ FileStream fs = null;
+
+ for (int numTries = 0; numTries < 50; numTries++)
+ {
+ fs = null;
+ try
+ {
+ if(err && errCount > 5) LogFile.WriteLine(access.ToString() + "error #" + errCount + ": " + Path.GetFileName(fullPath));
+ fs = new FileStream(fullPath, mode, access, share);
+
+ if (err && errCount > 5) LogFile.WriteLine(access.ToString() + " done" + ": " + Path.GetFileName(fullPath));
+
+ err = false;
+
+ errCount = 0;
+ return fs;
+ }
+ catch (IOException ex)
+ {
+ errCount++;
+ //LogFile.WriteLine($"{Environment.MachineName}: {access.ToString()} denied: {Path.GetFileName(fullPath)}\n\nDies ist das {errCount}. vorkommen\n\n");
+ //LogFile.WriteLine(ex.ToString());
+ //LogFile.WriteLine("Message: " + ex.Message);
+ //if(ex.InnerException != null) LogFile.WriteLine("InnerException: " + ex.InnerException);
+ err = true;
+ if (fs != null)
+ {
+ fs.Dispose();
+ }
+ System.Threading.Thread.Sleep(500);
+ }
+ catch(Exception exc)
+ {
+ //LogFile.WriteLine(Environment.MachineName + ": " + access.ToString() + " denied" + ": " + Path.GetFileName(fullPath));
+ //LogFile.WriteLine(exc.ToString());
+ //LogFile.WriteLine("Message: " + exc.Message);
+ //if (exc.InnerException != null) LogFile.WriteLine("InnerException: " + exc.InnerException);
+ err = true;
+ if (fs != null)
+ {
+ fs.Dispose();
+ }
+ System.Threading.Thread.Sleep(500);
+ }
+
+ }
+
+ fs.Dispose();
+ if (err) System.Windows.MessageBox.Show("Daten konnten nicht geschrieben werden!\nBitte erneut versuchen\n\nWenn dieser Fehler mehrmals direkt hintereinander auftritt, bitte an Marcus Bachler wenden.", "Fehler", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning, System.Windows.MessageBoxResult.OK);
+ return null;
+ }
+ }
+}
diff --git a/AV-ToolV3/icon.ico b/AV-ToolV3/icon.ico
new file mode 100644
index 0000000..c7d6eb5
Binary files /dev/null and b/AV-ToolV3/icon.ico differ
diff --git a/AV-ToolV3/packages.config b/AV-ToolV3/packages.config
new file mode 100644
index 0000000..f1012d2
--- /dev/null
+++ b/AV-ToolV3/packages.config
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AV-ToolV3/ucSpinnerPiston.xaml b/AV-ToolV3/ucSpinnerPiston.xaml
new file mode 100644
index 0000000..003517c
--- /dev/null
+++ b/AV-ToolV3/ucSpinnerPiston.xaml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AV-ToolV3/ucSpinnerPiston.xaml.cs b/AV-ToolV3/ucSpinnerPiston.xaml.cs
new file mode 100644
index 0000000..949938f
--- /dev/null
+++ b/AV-ToolV3/ucSpinnerPiston.xaml.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PEP_Tool
+{
+ ///
+ /// Interaction logic for ucSpinnerPiston.xaml
+ ///
+ public partial class ucSpinnerPiston : UserControl
+ {
+ public ucSpinnerPiston()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/PEP_ToolProject.sln b/PEP_ToolProject.sln
new file mode 100644
index 0000000..99bc8fc
--- /dev/null
+++ b/PEP_ToolProject.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27703.2026
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PEP_Tool", "AV-ToolV3\PEP_Tool.csproj", "{4E161CEA-E5E0-4E4A-9923-64CD9D2BD1F0}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4E161CEA-E5E0-4E4A-9923-64CD9D2BD1F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4E161CEA-E5E0-4E4A-9923-64CD9D2BD1F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4E161CEA-E5E0-4E4A-9923-64CD9D2BD1F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4E161CEA-E5E0-4E4A-9923-64CD9D2BD1F0}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {3991FC1E-BC37-4EA1-9E13-6C8F3993AF15}
+ EndGlobalSection
+EndGlobal