/// <summary> /// Gets all items for the given <paramref name="app_form"/> bases on the given culture. /// <para/>If the given culture does not exist the FallBackCulture is used. /// </summary> /// <param name="app_form">A combination of the applications assembly name and /// <para/>the underlying form / window name.</param> /// <param name="ci">A culture to use for getting the form / window items.</param> public void RunDBCachePostgreSQL(string app_form, CultureInfo ci) { // Let's not use database connection if already cached. if (DBCacheHolder.ListContains(app_form, DBCache)) { foreach (GuiObject go in this) { try { DBCacheHolder dc = DBCache.First(first => first.PropertyName == go.PropertyName && first.Item == go.Item && first.AppForm == app_form); if (dc != null) { if (dc.ValueType == "System.String") { go.Value = dc.Value; } } } catch { // something wrong? } } return; } List <string> handled = new List <string>(); using (NpgsqlCommand command = new NpgsqlCommand(SelectDBCache(app_form, ci), PostgreConnection)) { using (NpgsqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { string item = dr.GetString(3); string propertyName = dr.GetString(2); string valueType = dr.GetString(0); string value = dr.GetString(1); foreach (GuiObject go in this) { if (go.PropertyName == propertyName && go.Item == item) { if (handled.Contains(go.PropertyName + "." + go.Item)) { continue; } try { DBCache.Add(new DBCacheHolder(dr)); } catch { // Database connection error or internal logic failure? Well we can't let the application fall. } handled.Add(go.PropertyName + "." + go.Item); if (valueType == "System.String") { go.Value = value; } } } } } } }