} // reset /** * Return an array of the installed Languages * @return Array of loaded Languages or null */ public String[] GetLanguages() { if (_languages == null) { return(null); } //make collection of cahce keys IEnumerator <String> iterator = _languages.Keys.GetEnumerator(); //make total array size String[] retValue = new String[_languages.Size()]; //assign array with key name int i = 0; while (iterator.MoveNext()) { retValue[i] = iterator.Current.ToString(); i++; } return(retValue); } // getLanguages
/** * Get Language specific Message Map * @param ad_language Language Key * @return HashMap of Language */ public CCache <String, String> GetMsgMap(String ad_language) { String AD_Language = ad_language; if (AD_Language == null || AD_Language.Length == 0) { AD_Language = Language.GetBaseAD_Language(); } // Do we have the language ? CCache <String, String> retValue = (CCache <String, String>)_languages[AD_Language]; if (retValue != null && retValue.Size() > 0) { return(retValue); } // Load Language retValue = InitMsg(AD_Language); if (retValue != null) { _languages.Add(AD_Language, retValue); return(retValue); } return(retValue); } // getMsgMap
/// <summary> /// Load active Countries (no summary). /// Set Default Language to Client Language /// </summary> /// <param name="ctx">Ctx</param> private static void LoadAllCountries(Ctx ctx) { MClient client = MClient.Get(ctx); MLanguage lang = MLanguage.Get(ctx, client.GetAD_Language()); MCountry usa = null; // int countryID = Util.GetValueOfInt(ctx.Get("P|C_Country_ID")); s_countries = new CCache <String, MCountry>("C_Country", 250); String sql = "SELECT * FROM C_Country WHERE IsActive='Y' AND IsSummary='N'"; try { DataSet ds = DataBase.DB.ExecuteDataset(sql, null, null); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; MCountry c = new MCountry(ctx, dr, null); s_countries.Add(c.GetC_Country_ID().ToString(), c); // Country code of Client Language if (lang != null && lang.GetCountryCode().Equals(c.GetCountryCode()) && _default == null) { _default = c; } else if (countryID == c.GetC_Country_ID()) { _default = c; } if (c.GetC_Country_ID() == 100) // USA { usa = c; } } } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } if (_default == null) { _default = usa; } _log.Fine("#" + s_countries.Size() + " - Default=" + _default); }
} // getMsgMap /** * Init message HashMap. * The initial call is from ALogin (ConfirmPanel init). * The second from Env.verifyLanguage. * @param AD_Language Language * @return Cache HashMap */ private CCache <String, String> InitMsg(String AD_Language) { // Trace.printStack(); CCache <String, String> msg = new CCache <String, String>("AD_Message", MAP_SIZE, 0); // if (!DataBase.DB.IsConnected()) { //s_log.log(Level.SEVERE, "No DB Connection"); // //ErrorLog.FillErrorLog("Msg.InitMsg(String AD_Language)", "No DB Connection ", "", Message.MessageType.ERROR); return(null); } string sqlQry = ""; IDataReader dr = null; try { //PreparedStatement pstmt = null; if (AD_Language == null || AD_Language.Length == 0 || Utility.Env.IsBaseLanguage(AD_Language, "AD_Language")) { sqlQry = "SELECT Value, MsgText, MsgTip FROM AD_Message"; dr = DataBase.DB.ExecuteReader(sqlQry); } else { sqlQry = "SELECT m.Value, t.MsgText, t.MsgTip " + "FROM AD_Message_Trl t, AD_Message m " + "WHERE m.AD_Message_ID=t.AD_Message_ID" + " AND t.AD_Language=@AD_Language"; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@AD_Language", AD_Language); dr = DataBase.DB.ExecuteReader(sqlQry, param); } // get values while (dr.Read()) { String AD_Message = dr[0].ToString(); StringBuilder msgText = new StringBuilder(); String msgTip = null; msgText.Append(dr[1].ToString()); // if (dr.GetString(2) != DBNull.Value.ToString()) // { msgTip = dr[2].ToString(); // } // if (msgTip != null && msgTip.Length != 0) // messageTip on next line, if exists { msgText.Append(" ").Append(SEPARATOR).Append(msgTip); } msg.Add(AD_Message, msgText.ToString()); } dr.Close(); dr = null; //pstmt.close(); } catch (Exception e) { if (dr != null) { dr.Close(); dr = null; } _log.Log(Level.SEVERE, "initMsg", e); ////ErrorLog.FillErrorLog("Msg.InitMsg(String AD_Language)", sqlQry, e.Message, Message.MessageType.ERROR); return(null); } // if (msg.Size() < 100) { _log.Log(Level.SEVERE, "Too few (" + msg.Count + ") Records found for " + AD_Language); return(null); } _log.Info("Records=" + msg.Count + " - " + AD_Language); return(msg); }