From 91733f4ac1f96720ddd712188c1eff98176cec43 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Mon, 11 Sep 2023 13:38:00 +0200 Subject: [PATCH] Merge tested --- Data/ICF/ICFDAO.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Data/ICF/ICFDAO.cs b/Data/ICF/ICFDAO.cs index ca4c6662e..113a42d4c 100644 --- a/Data/ICF/ICFDAO.cs +++ b/Data/ICF/ICFDAO.cs @@ -22,18 +22,13 @@ namespace BeWo.Data.ICF { try { - string file = ConfigurationManager.AppSettings.Get("ICFFile"); - if (String.IsNullOrEmpty(file) || - !File.Exists(BS.Shared.Core.Utils.CreateSavePath(AppDomain.CurrentDomain.BaseDirectory, @"bin\ICF\" + file))) - { - file = "icf.xml"; - } + var filename = GetFileName(); var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; - file = BS.Shared.Core.Utils.CreateSavePath(AppDomain.CurrentDomain.BaseDirectory, @"bin\ICF\" + file); + var filepath = BS.Shared.Core.Utils.CreateSavePath(AppDomain.CurrentDomain.BaseDirectory, @"bin\ICF\" + filename); //file = @"D:\Projects\beyondSoft\BeWoPlaner\BeWo\Data\ICF\icf.xml"; - _File = XDocument.Load(file); + _File = XDocument.Load(filepath); Debug.WriteLine("Dokument geladen"); _Root = _File.Descendants("Class").Where(x => x.Attribute("code")?.Value == "d" /*|| x.Attribute("code")?.Value == "s" || @@ -54,6 +49,21 @@ namespace BeWo.Data.ICF } } + public static string GetFileName() + { + string filename = ConfigurationManager.AppSettings.Get("ICFFile"); + + if (String.IsNullOrEmpty(filename)) + return "icf.xml"; + + string path = BS.Shared.Core.Utils.CreateSavePath(AppDomain.CurrentDomain.BaseDirectory, @"bin\ICF\" + filename); + + if (File.Exists(path)) + return filename; + + return "icf.xml"; + } + public static IList GetIcf() { if (_Root == null)