public static RESTServiceConfiguration GetCustomClientConfiguration(string restwebrefSSKey, int eSpaceId) { Func <RESTServiceConfiguration> fetchFromDb = () => { using (var tran = DatabaseAccess.ForSystemDatabase.GetReadOnlyTransaction()) { using (IDataReader reader = GetCustomClientConfigFields(tran, restwebrefSSKey, eSpaceId)) { if (reader.Read()) { var traceErrors = reader.SafeGet <bool>("TraceErrors", false); var traceAll = reader.SafeGet <bool>("TraceAll", false); return(new RESTServiceConfiguration(traceErrors, traceAll)); } return(new RESTServiceConfiguration()); } } }; return(ConfigurationCache.GetESpaceCachedValue(restwebrefSSKey, "RestConfigCache", eSpaceId, _ => fetchFromDb())); }
public static RESTServiceConfiguration GetMobileLoggingLevelConfiguration(int eSpaceId) { Func <RESTServiceConfiguration> fetchLoggingLevelFromDb = () => { using (var tran = DatabaseAccess.ForSystemDatabase.GetReadOnlyTransaction()) { using (IDataReader reader = GetLoggingLevelConfig(tran, eSpaceId)) { if (reader.Read()) { var traceErrors = reader.SafeGet <bool>("TraceErrors", false); var traceAll = reader.SafeGet <bool>("TraceAll", false); return(new RESTServiceConfiguration(traceErrors, traceAll)); } return(new RESTServiceConfiguration()); } } }; return(ConfigurationCache.GetESpaceCachedValue("", "MobileLoggingLevelConfigCache", eSpaceId, _ => fetchLoggingLevelFromDb())); }
public static SapConfiguration GetCustomClientConfiguration(string sapWebRefSSKey, int eSpaceId, string eSpaceKey, string defaultSapRouterStringOverride = null, string defaultApplicationServerOverride = null, string defaultInstanceNumberOverride = null, string defaultSystemIdOverride = null, string defaultUsernameOverride = null, string defaultPasswordOverride = null, string defaultClientOverride = null, string defaultLanguageOverride = null ) { Func <SapConfiguration> fetchSettings = () => { var pluginName = "SAP"; // get effective url, username and password var sapRouterString = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "Effective_SapRouterString", defaultSapRouterStringOverride ?? String.Empty).GetValue().Trim(); var applicationServer = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "Effective_ApplicationServer", defaultApplicationServerOverride ?? String.Empty).GetValue().Trim(); var instanceNumber = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "Effective_InstanceNumber", defaultInstanceNumberOverride ?? String.Empty).GetValue().Trim(); var systemId = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "Effective_SystemId", defaultSystemIdOverride ?? String.Empty).GetValue(); var username = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "Effective_Username", defaultUsernameOverride ?? String.Empty).GetValue(); var password = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "Effective_Password", defaultPasswordOverride ?? String.Empty, isEncrypted: true).GetValue(); var client = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "Effective_Client", defaultClientOverride ?? String.Empty).GetValue(); var language = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "Effective_Language", defaultLanguageOverride ?? String.Empty).GetValue(); var defaultSapRouterString = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "sapRouterString", String.Empty).GetValue(); var defaultApplicationServer = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "applicationServer", String.Empty).GetValue(); var defaultInstanceNumber = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "instanceNumber", String.Empty).GetValue(); var defaultSystemId = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "systemId", String.Empty).GetValue(); var defaultUsername = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "username", String.Empty).GetValue(); var defaultPassword = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "password", String.Empty, isEncrypted: true).GetValue(); var defaultClient = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "client", String.Empty).GetValue(); var defaultLanguage = RuntimePlatformSettings.Plugin.GetSetting <string>(pluginName, eSpaceKey, sapWebRefSSKey, "language", String.Empty).GetValue(); var traceAll = RuntimePlatformSettings.Plugin.GetSetting <bool>(pluginName, eSpaceKey, sapWebRefSSKey, "TraceAll", false).GetValue(); return(new SapConfiguration(sapRouterString, applicationServer, instanceNumber, systemId, username, password, client, language, defaultSapRouterString, defaultApplicationServer, defaultInstanceNumber, defaultSystemId, defaultUsername, defaultPassword, defaultClient, defaultLanguage, traceAll)); }; return(ConfigurationCache.GetESpaceCachedValue(sapWebRefSSKey, "SAPConfigCache", eSpaceId, _ => fetchSettings())); }
/// <summary> /// Return a previously defined REST API Configuration, based on its Service Studio key and eSpace Id. /// </summary> /// <param name="restwebrefSSKey">The Service Studio key of the REST API source.</param> /// <param name="eSpaceId">The eSpace Id.</param> /// <returns>The corresponding Configuration.</returns> public static Configuration GetCustomClientConfiguration(string restwebrefSSKey, int eSpaceId) { Func <Configuration> fetchFromDb = () => { using (var tran = DatabaseAccess.ForSystemDatabase.GetReadOnlyTransaction()) { using (IDataReader reader = GetCustomClientConfigFields(tran, restwebrefSSKey, eSpaceId)) { if (reader.Read()) { // get effective url, username and password var effectiveUrl = reader.SafeGet <string>("Effective_URL", string.Empty).Trim(); var effectiveUsername = reader.SafeGet <string>("Effective_Username", string.Empty).Trim(); var effectivePassword = reader.SafeGet <string>("Effective_Password", string.Empty).Trim(); var traceErrors = reader.SafeGet <bool>("TraceErrors", false); var traceAll = reader.SafeGet <bool>("TraceAll", false); return(new Configuration(effectiveUrl, effectiveUsername, effectivePassword, traceErrors, traceAll)); } return(new Configuration()); } } }; return(ConfigurationCache.GetESpaceCachedValue(restwebrefSSKey, "RestConfigCache", eSpaceId, _ => fetchFromDb())); }
/// <summary> /// Return a previously defined REST API Configuration, based on its Service Studio key and eSpace Id. /// </summary> /// <param name="clientSSKey">The Service Studio key of the REST API source.</param> /// <param name="eSpaceId">The eSpace Id.</param> /// <param name="eSpaceKey">The eSpace Key.</param> /// <param name="defaultUrlOverride"></param> /// <param name="defaultUserNameOverride"></param> /// <param name="defaultPasswordOverride"></param> /// <returns>The corresponding Configuration.</returns> public static Configuration GetClientConfiguration(string clientSSKey, int eSpaceId, string eSpaceKey, string defaultUrlOverride = null, string defaultUserNameOverride = null, string defaultPasswordOverride = null) { Func <Configuration> fetchSettings = () => { var urlSetting = RuntimePlatformSettings.Plugin.GetSetting <string>(ConfigPluginName, eSpaceKey, clientSSKey, "Effective_URL", String.Empty); var usernameSetting = RuntimePlatformSettings.Plugin.GetSetting <string>(ConfigPluginName, eSpaceKey, clientSSKey, "Effective_Username", String.Empty); var passwordSetting = RuntimePlatformSettings.Plugin.GetSetting <string>(ConfigPluginName, eSpaceKey, clientSSKey, "Effective_Password", String.Empty, isEncrypted: true); var traceErrorsSetting = RuntimePlatformSettings.Plugin.GetSetting <bool>(ConfigPluginName, eSpaceKey, clientSSKey, "TraceErrors", false); var traceAllSetting = RuntimePlatformSettings.Plugin.GetSetting <bool>(ConfigPluginName, eSpaceKey, clientSSKey, "TraceAll", false); var url = urlSetting.GetValue(); var username = usernameSetting.GetValue(); var password = passwordSetting.GetValue(); if (defaultUrlOverride != null && String.IsNullOrEmpty(url)) { url = defaultUrlOverride; } if (defaultUserNameOverride != null && String.IsNullOrEmpty(username)) { username = defaultUserNameOverride; } if (defaultPasswordOverride != null && String.IsNullOrEmpty(password)) { // Can't be done directly in the setting defaults since it's still encrypted. password = passwordSetting.LoadFromString(defaultPasswordOverride); } var traceErrors = traceErrorsSetting.GetValue(); var traceAll = traceAllSetting.GetValue(); return(new Configuration(url, username, password, traceErrors, traceAll)); }; return(ConfigurationCache.GetESpaceCachedValue(clientSSKey, "RestConfigCache", eSpaceId, _ => fetchSettings())); }