OpenKeyWord  Version: 426, Datum:
OKW_Docu.cs
1 #region Header
2 /*
3  ==============================================================================
4  Author: Zoltan Hrabovszki <zh@openkeyword.de>
5 
6  Copyright © 2012, 2013, 2014, 2015 IT-Beratung Hrabovszki
7  www.OpenKeyWord.de
8  ==============================================================================
9 
10  This file is part of OpenKeyWord.
11 
12  OpenKeyWord is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  OpenKeyWord is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with OpenKeyWord. If not, see <http://www.gnu.org/licenses/>.
24 
25  Diese Datei ist Teil von OpenKeyWord.
26 
27  OpenKeyWord ist Freie Software: Sie können es unter den Bedingungen
28  der GNU General Public License, wie von der Free Software Foundation,
29  Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
30  veröffentlichten Version, weiterverbreiten und/oder modifizieren.
31 
32  OpenKeyWord wird in der Hoffnung, dass es nützlich sein wird, aber
33  OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
34  Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
35  Siehe die GNU General Public License für weitere Details.
36 
37  Sie sollten eine Kopie der GNU General Public License zusammen mit
38  OpenKeyWord erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
39 */
40 #endregion Header
41 
42 namespace OKW
43 {
44  using System;
45  using System.Collections.Generic;
46  using System.IO;
47  using System.Text;
48  using System.Text.RegularExpressions;
49  using System.Xml.XPath;
50 
51  using OKW.Log;
52 
65  public class OKW_Docu
66  {
67  #region Fields
68 
72  private static readonly OKW_Docu instance = new OKW_Docu();
73 
74  private OKWLanguage AL = OKWLanguage.Instance;
75  private string File_okwdocu_xml = System.IO.Path.Combine(OKW.OKW_Ini.Instance.OKW_Enviroment.Folder_XML, "OKW_Docu.xml");
76 
77 
88  private XPathDocument MyXPathDocument;
89 
104  private XPathNavigator MyXPathNavigator;
105 
106  #endregion Fields
107 
108  #region Constructors
109 
114  private OKW_Docu()
115  {
116  if (!System.IO.File.Exists(this.File_okwdocu_xml))
117  {
118  System.Console.WriteLine("= End Logmessenger.Logmessenger() with exception!");
119  throw new FileNotFoundException("File not found! '" + this.File_okwdocu_xml + "'");
120  }
121  else
122  {
123  this.MyXPathDocument = new XPathDocument(this.File_okwdocu_xml);
124  this.MyXPathNavigator = this.MyXPathDocument.CreateNavigator();
125  }
126  }
127 
128  #endregion Constructors
129 
130  #region Properties
131 
138  public static OKW_Docu Instance
139  {
140  get
141  {
142  return instance;
143  }
144  }
145 
146  #endregion Properties
147 
148  #region Methods
149 
155  public string GetKWForCurrentLanguage(string KeyWord)
156  {
157  string lvs_Return = string.Empty;
158 
159  lvs_Return = this.ReadKeyWordName(KeyWord);
160 
161  return lvs_Return;
162  }
163 
171  private string ReadKeyWordName(string KeyWordSymbol)
172  {
173  Log.Logger.Instance.LogFunctionStartDebug(this.GetType().FullName + ".ReadKeyWordName", "KeyWordSymbol", KeyWordSymbol);
174 
175  string lvs_temp = "!!" + KeyWordSymbol;
176 
177  string lvsXPath = "//okwentry[@keyword='" + KeyWordSymbol + "']//keyword/" + this.AL.Language;
178 
179  Log.Logger.Instance.LogPrintDebug(lvsXPath);
180 
181  XPathNodeIterator iter = this.MyXPathNavigator.Select(lvsXPath);
182 
183  while (iter.MoveNext())
184  {
185  lvs_temp = iter.Current.Value;
186  }
187 
188  Log.Logger.Instance.LogFunctionEndDebug(lvs_temp);
189 
190  return lvs_temp;
191  }
192 
193  #endregion Methods
194  }
195 }
static OKW_Ini Instance
Singelton-Pattern: Instanz gibt die aktuelle, gültige und einzige Innstanz der Klasse zurück...
Definition: OKW_Ini.cs:306
OKW_Docu()
This constructor has no Parameter and uses the default values for the config-file and Actual/default ...
Definition: OKW_Docu.cs:114
http://de.wikipedia.org/wiki/ISO-3166-1-Kodierliste
Definition: OKWLanguage.cs:50
string GetKWForCurrentLanguage(string KeyWord)
Gets the KeyWordName for Language.
Definition: OKW_Docu.cs:155
static T Instance
Holt die einzige Instanz dieser Klasse.
OKW_Enviroment OKW_Enviroment
Dieses Feld hält den Abschnitt OKW_Enviroment der OKW_Ini.xml vor.
Definition: OKW_Ini.cs:219
XPathNavigator MyXPathNavigator
Stellt ein Cursormodell für die Navigation und Bearbeitung von XML-Daten bereit.
Definition: OKW_Docu.cs:104
string ReadKeyWordName(string KeyWordSymbol)
This method gets the Keywordname depending an the Language.
Definition: OKW_Docu.cs:171
XPathDocument MyXPathDocument
Feld enthält den Pfad und den Dateinamen der XML-Datei, die als Datenquelle Dient.
Definition: OKW_Docu.cs:88
string Folder_XML
Property get/set von __Folder_XML.
static OKW_Docu Instance
Holt die einzige Instanz dieser Klasse.
Definition: OKW_Docu.cs:139
Designpattern: Singelton Hier gilt das Highlander Prinzip: "Es kann nur einen geben". D.h. nur eine Instanz dieser Klasse, die für das Lesen der Nachrichten Zuständig ist. Diese Klasse selbst ist eine OKW-Fundametalklasse und gibt keine Nachrichten aus. TODO: Nachricht weiter-Linken auf einen Andren Tag. Ziel: Wiederkehrende Nachrichten werden nur einmal gepflegt.
Definition: OKW_Docu.cs:65
static readonly OKW_Docu instance
Instance des Singelton.
Definition: OKW_Docu.cs:72
OKW.OKW_Ini ist die Klasse zur Konfigurationsdatei OKW_Ini.xml.
Definition: OKW_Ini.cs:188
string Language
Gets or sets a string property.
Definition: OKWLanguage.cs:77
Definition: Core.cs:40