Example #1
0
        /// <summary>
        /// Writes the configuration data to the SSO Config Store.
        /// </summary>
        /// <param name="appName">The name of the affiliate application to represent the configuration container to access.</param>
        /// <param name="properties">A collection of name/value pairs that represent the configuration settings.</param>
        public static void Write(string appName, IDictionary <string, string> properties)
        {
            Guard.ArgumentNotNullOrEmptyString(appName, "appName");
            Guard.ArgumentNotNull(properties, "properties");

            var callToken = TraceManager.CustomComponent.TraceIn(appName, properties.Count);

            try
            {
                SSOConfigStore ssoStore = new SSOConfigStore();
                SsoConfigurationPropertyBag appMgmtBag = new SsoConfigurationPropertyBag();

                foreach (KeyValuePair <string, string> property in properties)
                {
                    object tempPropValue = property.Value;
                    appMgmtBag.Write(property.Key, ref tempPropValue);
                }

                ((ISSOConfigStore)ssoStore).SetConfigInfo(appName, idenifierGUID, appMgmtBag);
            }
            catch (Exception e)
            {
                TraceManager.CustomComponent.TraceError(e);

                throw;
            }
            finally
            {
                TraceManager.CustomComponent.TraceOut(callToken);
            }
        }
Example #2
0
        /// <summary>
        /// Read method helps get configuration data (based on the current environment value)
        /// </summary>
        /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
        /// <param name="propName">The property name to read</param>
        /// <returns>
        ///  The value of the property stored in the given affiliate application of this component.
        /// </returns>
        public static string Read(string appName, string propName)
        {
            Guid   callToken      = TraceManager.CustomComponent.TraceIn(appName, propName);
            object propertyValue  = null;
            string propNameToRead = string.Format("{0}_{1}", Environment, propName);

            try
            {
                SSOConfigStore           ssoStore   = new SSOConfigStore();
                ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
                ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, IdenifierGuid, SSOFlag.SSO_FLAG_RUNTIME,
                                                          (IPropertyBag)appMgmtBag);
                appMgmtBag.Read(propNameToRead, out propertyValue, 0);
                // In case the result is null, we try to read the property without pre-pending the environment
                if (null == propertyValue)
                {
                    return(ReadInternal(appName, propName));
                }
            }
            catch (Exception e)
            {
                TraceManager.CustomComponent.TraceInfo("Failed to read '{0}' for application '{1}'", propNameToRead,
                                                       appName);
                TraceManager.CustomComponent.TraceError(e);
                throw;
            }
            finally
            {
                TraceManager.CustomComponent.TraceOut(callToken, propertyValue);
            }
            return((string)propertyValue);
        }
Example #3
0
        /// <summary>
        /// Write method helps write configuration data
        /// </summary>
        /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
        /// <param name="propName">The property name to write</param>
        /// <param name="propName">The property value to write</param>
        public static void Write(string appName, string propName, object propValue)
        {
            try
            {
                SSOConfigStore           ssoStore   = new SSOConfigStore();
                ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
                ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
                object tempProp = propValue;

                try
                {
                    appMgmtBag.Remove(propName);
                }
                catch
                {
                }

                appMgmtBag.Write(propName, ref tempProp);
                ((ISSOConfigStore)ssoStore).SetConfigInfo(appName, idenifierGUID, appMgmtBag);
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e.Message);
                throw;
            }
        }
Example #4
0
        /// <summary>
        /// Read method helps get configuration data
        /// </summary>
        /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
        /// <param name="propName">The property name to read</param>
        /// <returns>
        ///  The value of the property stored in the given affiliate application of this component.
        /// </returns>
        public static string SSORead(string appName, string propName)
        {
            try
            {
                //Instantiate SSOConfigStore Object
                SSOConfigStore ssoStore = new SSOConfigStore();

                //Instantiate ConfigurationPropertyBag
                ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();

                //Get value based on appName
                ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);

                //Create propertyValue object
                object propertyValue = null;

                //Read property
                appMgmtBag.Read(propName, out propertyValue, 0);

                //return property value
                return((string)propertyValue);
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e.Message);
                throw;
            }
        }
Example #5
0
        /// <summary>
        /// Reads the configuration data from the SSO Config Store.
        /// </summary>
        /// <param name="appName">The name of the affiliate application to represent the configuration container to access.</param>
        /// <param name="propName">The property name to read.</param>
        /// <returns>The value of the property stored in the given affiliate application of this component.</returns>
        public static string Read(string appName, string propName)
        {
            Guard.ArgumentNotNullOrEmptyString(appName, "appName");
            Guard.ArgumentNotNullOrEmptyString(propName, "propName");

            var callToken = TraceManager.CustomComponent.TraceIn(appName, propName);

            try
            {
                SSOConfigStore ssoStore = new SSOConfigStore();
                SsoConfigurationPropertyBag appMgmtBag = new SsoConfigurationPropertyBag();

                ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);

                object propertyValue = null;
                appMgmtBag.Read(propName, out propertyValue, 0);

                return((string)propertyValue);
            }
            catch (Exception e)
            {
                TraceManager.CustomComponent.TraceError(e);

                throw;
            }
            finally
            {
                TraceManager.CustomComponent.TraceOut(callToken);
            }
        }
Example #6
0
        /// <summary>
        /// Read a key/value pair from an SSO configuration store
        /// </summary>
        /// <param name="appName"></param>
        /// <param name="propName"></param>
        /// <returns></returns>
        public static string ReadFromSSO(string appName, string propName)
        {
            SSOConfigStore ssoStore = new SSOConfigStore();
            SSOConfigurationPropertyBag appMgmtBag = new SSOConfigurationPropertyBag();

            ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, "ConfigProperties", SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
            object propertyValue = null;

            appMgmtBag.Read(propName, out propertyValue, 0);
            return((string)propertyValue);
        }
Example #7
0
 /// <summary>
 /// Write method helps write configuration data
 /// </summary>
 /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
 /// <param name="properties"></param>
 internal static void Write(string appName, ConfigurationPropertyBag properties)
 {
     try
     {
         var ssoStore = new SSOConfigStore();
         ((ISSOConfigStore)ssoStore).SetConfigInfo(appName, IdenifierGuid, properties);
     }
     catch (Exception e)
     {
         System.Diagnostics.Trace.WriteLine(e.Message);
         throw;
     }
 }
Example #8
0
 internal static ConfigurationPropertyBag BuildPropertyBag(string appName)
 {
     try
     {
         SSOConfigStore           ssoStore   = new SSOConfigStore();
         ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
         ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
         return(appMgmtBag);
     }
     catch (Exception e)
     {
         System.Diagnostics.Trace.WriteLine(e.Message);
         throw;
     }
 }
Example #9
0
 /// <summary>
 /// Read method helps get configuration data
 /// </summary>
 /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
 /// <param name="propName">The property name to read</param>
 /// <returns>
 ///  The value of the property stored in the given affiliate application of this component.
 /// </returns>
 public static string Read(string appName, string propName)
 {
     try
     {
         SSOConfigStore           ssoStore   = new SSOConfigStore();
         ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
         ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
         object propertyValue = null;
         appMgmtBag.Read(propName, out propertyValue, 0);
         return((string)propertyValue);
     }
     catch (Exception e)
     {
         System.Diagnostics.Trace.WriteLine(e.Message);
         throw;
     }
 }
Example #10
0
 public static string Read(string appName, string propName)
 {
     try
     {
         SSOConfigStore           ssoConfigStore           = new SSOConfigStore();
         ConfigurationPropertyBag configurationPropertyBag = new ConfigurationPropertyBag();
         ((ISSOConfigStore)ssoConfigStore).GetConfigInfo(appName, SSOConfigHelper.idenifierGUID, 4, (IPropertyBag)configurationPropertyBag);
         object ptrVar = (object)null;
         configurationPropertyBag.Read(propName, out ptrVar, 0);
         return((string)ptrVar);
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
         throw;
     }
 }
Example #11
0
 /// <summary>
 /// Read method helps get configuration data (wihtout taking environment into account)
 /// </summary>
 /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
 /// <param name="propName">The property name to read</param>
 /// <returns>
 ///  The value of the property stored in the given affiliate application of this component.
 /// </returns>
 private static string ReadInternal(string appName, string propName)
 {
     try
     {
         SSOConfigStore           ssoStore   = new SSOConfigStore();
         ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
         ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, IdenifierGuid, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
         object propertyValue = null;
         appMgmtBag.Read(propName, out propertyValue, 0);
         return((string)propertyValue);
     }
     catch (Exception e)
     {
         TraceManager.CustomComponent.TraceInfo("Failed to read '{0}' for application '{1}'", propName, appName);
         TraceManager.CustomComponent.TraceError(e);
         throw;
     }
 }
Example #12
0
 /// <summary>
 /// Writes a set of properties to the configuration store.
 /// </summary>
 /// <param name="appName">The name of the affiliate application.</param>
 /// <param name="configProperties">The configuration properties to write.</param>
 public static void WriteAll(string appName, ConfigurationPropertyBag configProperties)
 {
     try
     {
         lock (syncLock)
         {
             // update property bag in the SSO store
             SSOConfigStore ssoStore = new SSOConfigStore();
             ((ISSOConfigStore)ssoStore).SetConfigInfo(appName, IDENTIFIER_GUID, configProperties);
             // force a refresh of the cached configuration properties for the specified application
             appConfigSettings.Remove(appName);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Trace.WriteLine(e.Message);
         throw;
     }
 }
Example #13
0
        /// <summary>
        /// Read method helps get configuration data
        /// </summary>
        /// <param name="propName">The property name to read</param>
        /// <returns>
        ///  The value of the property stored in the given affiliate application of this component.
        /// </returns>
        public static string Read(string applicationname, string propName)
        {
            try
            {
                SSOConfigStore           ssoStore   = new SSOConfigStore();
                ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
                ((ISSOConfigStore)ssoStore).GetConfigInfo(applicationname, identifierGuid, SSOFlag.SSO_FLAG_RUNTIME, appMgmtBag);
                object propertyValue;

                appMgmtBag.Read(propName, out propertyValue, 0);

                return((string)propertyValue);
            }
            catch (Exception exc)
            {
                System.Diagnostics.Debug.Write(exc.Message);
                throw;
            }
        }
Example #14
0
 /// <summary>
 /// Writes a property to the configuration store.
 /// </summary>
 /// <param name="appName">The name of the affiliate application.</param>
 /// <param name="propName">The property name to write.</param>
 /// <param name="propValue">The property value to write.</param>
 public static void Write(string appName, string propName, string propValue)
 {
     try
     {
         // load configuration info from SSO store
         LoadSSOConfigInfo(appName);
         // get configuration properties for specified application
         ConfigurationPropertyBag configPropertyBag = appConfigSettings[appName];
         // write property value to configuration property bag
         object tempProp = propValue;
         configPropertyBag.Write(propName, ref tempProp);
         // update property bag in the SSO store
         SSOConfigStore ssoStore = new SSOConfigStore();
         ((ISSOConfigStore)ssoStore).SetConfigInfo(appName, IDENTIFIER_GUID, configPropertyBag);
     }
     catch (Exception e)
     {
         System.Diagnostics.Trace.WriteLine(e.Message);
         throw;
     }
 }
Example #15
0
 /// <summary>
 /// Loads the configuration information for the specified affiliate application.
 /// </summary>
 /// <param name="appName">The name of the affiliate application.</param>
 private static void LoadSSOConfigInfo(string appName)
 {
     // NOTE: This is a classic implementation of the double-lock pattern in .NET
     // check if the application settings are in the cache
     if (appConfigSettings.ContainsKey(appName) == false)
     {
         // acquire a lock
         lock (syncLock)
         {
             if (appConfigSettings.ContainsKey(appName) == false)
             {
                 // get the configuration info from the SSO store
                 SSOConfigStore           ssoStore          = new SSOConfigStore();
                 ConfigurationPropertyBag configPropertyBag = new ConfigurationPropertyBag();
                 ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, IDENTIFIER_GUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)configPropertyBag);
                 // add application configuration to cache
                 appConfigSettings.Add(appName, configPropertyBag);
             }
         }
     }
 }
 /// <summary>
 /// Read method helps get configuration data
 /// </summary>        
 /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
 /// <param name="propName">The property name to read</param>
 /// <returns>
 ///  The value of the property stored in the given affiliate application of this component.
 /// </returns>
 public static string Read(string appName, string propName)
 {
     try
     {
         SSOConfigStore ssoStore = new SSOConfigStore();
         ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
         ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
         object propertyValue = null;
         appMgmtBag.Read(propName, out propertyValue, 0);
         return (string)propertyValue;
     }
     catch (Exception e)
     {
         System.Diagnostics.Trace.WriteLine(e.Message);
         throw;
     }
 }
        /// <summary>
        /// Write method helps write configuration data
        /// </summary>        
        /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
        /// <param name="propName">The property name to write</param>
        /// <param name="propName">The property value to write</param>
        public static void Write(string appName, string[] propNames, string[] propValues)
        {
            try
            {
                SSOConfigStore ssoStore = new SSOConfigStore();
                ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();

                for (int i = 0; i < propNames.Length; i++)
                {
                    object currentValue = propValues[i];
                    string currentName = propNames[i].ToString();

                    appMgmtBag.Write(currentName, ref currentValue);
                }

                ((ISSOConfigStore)ssoStore).SetConfigInfo(appName, idenifierGUID, appMgmtBag);
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e.Message);
                throw;
            }
        }
        /// <summary>
        /// CUSTOM
        /// </summary>
        /// <param name="appName"></param>
        /// <returns></returns>
        public static HybridDictionary ReadApp(string appName)
        {
            try
            {
                SSOConfigStore ssoStore = new SSOConfigStore();
                ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
                ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);

                return appMgmtBag.properties;
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e.Message);
                throw;
            }
        }