Exemple #1
0
        internal static string GetConfigInfo(string affiliateApplication, bool enableRemoteAccess)
        {
            int ssoFlag = (enableRemoteAccess ? SSOFlag.SSO_FLAG_NONE : SSOFlag.SSO_FLAG_RUNTIME);

            object         propertyValue;
            SSOPropertyBag bag = new SSOPropertyBag();

            ISSOConfigStore ssoConfigStore = new ISSOConfigStore();

            ssoConfigStore.GetConfigInfo(affiliateApplication, InfoIdentifier, ssoFlag, bag);

            bag.Read(PropName, out propertyValue, 0);

            return((string)propertyValue);
        }
Exemple #2
0
        /// <summary>
        /// Saves the config info.
        /// </summary>
        internal static void SaveConfigInfo(string affiliateApplication, string settings)
        {
            object settingsObj = (object)settings;

            SSOPropertyBag bag = new SSOPropertyBag();

            bag.Write(PropName, ref settingsObj);

            int retryCounter = 5;

            ISSOConfigStore ssoConfigStore = new ISSOConfigStore();

            while (retryCounter >= 0)
            {
                try
                {
                    ssoConfigStore.SetConfigInfo(affiliateApplication, InfoIdentifier, bag);
                    break;
                }
                catch (System.Runtime.InteropServices.COMException ex)
                {
                    // Error Code = 'The external credentials in the SSO database are more recent.'
                    // This error occurs randomly and in virtually all cases, an immediate retry succeeds.
                    // Tried just about everything to prevent it with no luck, so retry seems to be the best option.
                    if (ex.ErrorCode != -1073731008)
                    {
                        throw;  // All other errors just rethrow
                    }

                    Trace.Write("Caught 'The external credentials in the SSO database are more recent' exception. ");

                    if (retryCounter == 0)
                    {
                        Trace.WriteLine("Exhausted retries.");
                        throw;
                    }
                    else
                    {
                        Trace.WriteLine("Retries remaining: " + retryCounter.ToString());
                    }
                }

                retryCounter--;
            }
        }