public MainWindow() { InitializeComponent(); PictureparkService.InnerChannel.OperationTimeout = new TimeSpan(0, 20, 0); //initial check if config exists if (!File.Exists(ConfigPath)) { JSON_Config config = new JSON_Config() { ArchivPfad = "PFAD_WO_ERSETZTE_BILDER_ABGELEGT_WERDEN", ZielPfad = "PFAD_MIT_LOKALEN_ZU_ERSETZENDEN_BILDERN", LogPfad = "PFAD_WO_LOG_DATEIEN_ABGELEGT_WERDEN", PP_CustomerId = 0, PP_ClientGUID = "PP_CLIENT_GUID", PP_Email = "PP_EMAIL", PP_Password = "******" }; string strConfig = JsonConvert.SerializeObject(config, Formatting.Indented); File.WriteAllText(ConfigPath, strConfig); MessageBox.Show("Es scheint es gibt noch keine Konfiguration, bitte konfiguriere zuerst die benötigten Parameter"); System.Diagnostics.Process.Start(ConfigPath); } else { CheckConfiguration(); } }
private static bool CheckConfiguration() { //check if config exists if (!File.Exists(ConfigPath)) { MessageBox.Show("Konfigurationsdatei kann nicht gefunden werden"); return(false); } //check if config is deserializable try { Configuration = JsonConvert.DeserializeObject <JSON_Config>(File.ReadAllText(ConfigPath).Replace("\\", "\\\\")); } catch (Exception ex) { MessageBox.Show("Die Konfigurationsdatei ist fehlerhaft, bitte korrigiere den Fehler oder lösche die Datei um eine neue anzulegen."); return(false); } //check proxy parameters try { if (ConfigurationManager.AppSettings["address"] != "") { var proxy = new WebProxy(ConfigurationManager.AppSettings["address"], true); proxy.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["user"], ConfigurationManager.AppSettings["password"]); WebRequest.DefaultWebProxy = proxy; } } catch (Exception ex) { MessageBox.Show("Die Proxy Parameter sind fehlerhaft, bitte prüfe die Angaben in KMB_Image_Sync_Client.exe.config"); return(false); } if (!Directory.Exists(Configuration.ZielPfad)) { MessageBox.Show("Der in der Konfiguration eingetragene Zielpfad existiert nicht"); return(false); } if (!Directory.Exists(Configuration.ArchivPfad)) { MessageBox.Show("Der in der Konfiguration eingetragene Archivpfad existiert nicht"); return(false); } if (!Directory.Exists(Configuration.LogPfad)) { MessageBox.Show("Der in der Konfiguration eingetragene Logpfad existiert nicht"); return(false); } return(true); }