// Copyright (c) 2015-2017 schick Informatik // Zugriff auf SQLite Datenbank mit Report Überschriften using System.Collections.Generic; using System.Data; using System.Data.SQLite; namespace ENI2.Report { /// /// Zugriff auf SQLite Datenbank mit Report Überschriften /// public class LabelStorage { private static readonly SQLiteConnection _con; private const string _locode_DB_NAME = "report.db"; private static Dictionary _collectionLabelDict = null; private static Dictionary _fieldLabelDict = null; static LabelStorage() { _con = new SQLiteConnection(string.Format("data source={0}; Version=3;", _locode_DB_NAME)); _con.Open(); } #region public static properties public static Dictionary CollectionLabelDict { get { if(_collectionLabelDict == null) { _collectionLabelDict = new Dictionary(); string query = "SELECT Name, Value FROM CollectionLabel"; SQLiteCommand cmd = new SQLiteCommand(query, _con); IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (!reader.IsDBNull(0) && !reader.IsDBNull(1)) _collectionLabelDict[reader.GetString(0)] = reader.GetString(1); } reader.Close(); } return _collectionLabelDict; } } public static Dictionary FieldLabelDict { get { if (_fieldLabelDict == null) { _fieldLabelDict = new Dictionary(); string query = "SELECT Name, Value FROM FieldLabel"; SQLiteCommand cmd = new SQLiteCommand(query, _con); IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (!reader.IsDBNull(0) && !reader.IsDBNull(1)) _fieldLabelDict[reader.GetString(0)] = reader.GetString(1); } reader.Close(); } return _fieldLabelDict; } } public static void CloseDB() { _con.Close(); } #endregion } }