private static string GetSettingFromDatabase(string key, string instance)
        {
            try
            {
                using (var settings = new DbClassLibrary.ActiveRecords.ConfigSettings
                {
                    Instance = instance,
                    Query = "select * from config_settings where KEY = :key"
                })
                {
                    settings.AddParameter("key", key);

                    var weakKey    = ErrorLog.GetProcessName().ToUpper();
                    var machineKey = Environment.MachineName.ToUpper();
                    var strongKey  = machineKey + "." + weakKey;

                    var listResults =
                        settings.Results().Where(a => a.Application.ToUpper().Contains(weakKey) ||
                                                 a.Application.ToUpper().Contains(machineKey)).ToList();

                    if (listResults.Count == 0)
                    {
                        return(default(string));
                    }

                    return
                        (listResults
                         .Where(a => a.Application.ToUpper() == strongKey)
                         .Select(a => a.ConfigValue).FirstOrDefault() ??
                         listResults
                         .Where(a => a.Application.ToUpper() == machineKey)
                         .Select(a => a.ConfigValue).FirstOrDefault() ??
                         listResults
                         .Where(a => a.Application.ToUpper() == weakKey)
                         .Select(a => a.ConfigValue).FirstOrDefault());
                }
            }
            catch (Exception ex)
            {
                ErrorLog.DebugLog(ex.Message, "GetAppConfigValue");
                return(default(string));
            }
        }