/// <summary> /// Konstruktor, holt entsprechende Variablen aus der Konfigurationsdatei, /// und initialisiert die Klassen CheckForUSB und Timer. /// </summary> /// <param name="mainW"></param> /// <param name="_DbLevel"></param> public USB_Identification(MainWindow mainW = null, string _DbLevel = "backup") { InitializeComponent(); // Überprüfe CheckForUSB und Timer. Wenn ein Fehler durch die Konfigurationsdatei verursacht wurde, // beende den dezeitigen Zustand. try { this._Cusb = new CheckForUSB(); this._Timer = new Timer(); } catch (Exception ex) { MessageBoxEnhanced.Error(ex.Message); this.Close(); return; } this._MainWindowObj = mainW; // Zuornung aller relevanten Werte aus der Konfiguationsdatei. try { this._USB_FOLDER_NAME = IniParser.GetSetting("USB", "USB_FOLDER_NAME"); this._TIME_FACTOR_TO_ENABLED_BACKUP_CANCEL_BUTTON = Convert.ToInt32(IniParser.GetSetting("USB", "TIME_FACTOR_TO_ENABLED_BACKUP_CANCEL_BUTTON")); this._FILENAME_DB_EXTENSION = IniParser.GetSetting("USB", "FILENAME_DB_EXTENSION").ToLower(); // __FILENAME_DB_EXTENSION darf nicht null sein. if (this._FILENAME_DB_EXTENSION == "") { throw new Exception("FAIL"); } } // Wenn ein Fehler durch die Konfigurationsdatei verursacht wurde, beende den // dezeitigen Zustand catch(Exception){ KöTaf.WPFApplication.Helper.MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "configFileError")); this.Close(); return; } this._DbLevel = _DbLevel; this.Topmost = true; // Lese das aktuelle Datum aus XML Datei. Entscheide dann, ob ein Backup notwendig ist. (beim schließen des Programms) liste = _Timer.readXML(Environment.CurrentDirectory + @"\TimeStamp.xml","backup","date","iswrite"); if (liste[0] == DateTime.Now.ToShortDateString().ToString() && liste[1] == "True" && _DbLevel != "restore") { this._DbLevel = "backupExist"; } switch (this._DbLevel) { case "backupExist": this.Close(); break; default: startApplication(); break; } }