//public static string Default_LanguagePreference //{ // get // { // if (AppConfigHelper.m_Default_LanguagePreference == string.Empty) // { // AppConfigHelper.m_Default_LanguagePreference = // (string)AppConfigHelper.GetValueFromConfig( // Preferences.KEY_DEFAULT_LANGUAGE_PREFERENCE, typeof(string), "English"); // } // return AppConfigHelper.m_Default_LanguagePreference; // } // set { AppConfigHelper.m_Default_LanguagePreference = value; } //} #endregion Properties #region Public Static Functions #region XML Documentation GetValueFromConfig /// <summary> /// Given a key this function retrieves the value associated with the key /// </summary> /// <param name="key">key denotes the key in a application configuration file</param> /// <param name="type">type of the value to be retrieved</param> /// <param name="defaultValue">value to be returned if the function fails to retrieve the value from the configuration file</param> /// <returns>Returns value associated with the specified key</returns> #endregion public static object GetValueFromConfig(string key, Type type, object defaultValue) { string strValue = ConfigurationManager.AppSettings[key]; object objValue = null; try { if (string.IsNullOrEmpty(strValue)) { //OMETrace.WriteLine(Helper.GetResourceString(KEY_MISSING_MESSAGE) + key); strValue = defaultValue.ToString(); } objValue = Convert.ChangeType(strValue, type); if (objValue == null) { objValue = defaultValue; } } catch (OMEException objAIException) { OMETrace.WriteLine(objAIException.Message); objValue = defaultValue; } catch (Exception objException) { OMETrace.WriteLine(objException.Message); objValue = defaultValue; } return(objValue); }
/// <summary> /// Log the custom/user exception to the specified log sink /// </summary> /// <param name="objectException"></param> public static void HandleException(OMEException objectException) { string str = string.Empty; string message = string.Empty; str = ExceptionHandler.HandleException(objectException, 1); message = objectException.Message.ToString(); if (String.IsNullOrEmpty(objectException.ErrorCode)) { message = objectException.ExMessage; } OMETrace.WriteLine(string.Empty); OMETrace.WriteLine(message); OMETrace.WriteLine(objectException.StackTrace); }
/// <summary> /// Show error messege /// </summary> /// <param name="objException"></param> public static void ShowOMEMessage(OMEException objException) { string str = string.Empty; string message = string.Empty; str = ExceptionHandler.HandleException(objException, 1); message = objException.Message.ToString(); if (String.IsNullOrEmpty(objException.ErrorCode)) { message = objException.ExMessage; } OMETrace.WriteLine(string.Empty); OMETrace.WriteLine(message); OMETrace.WriteLine(objException.StackTrace); MessageBox.Show(str, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); }