public CobrandContext getCobrandContext()
        {
            DateTime now     = DateTime.Now;
            DateTime expired = created.AddMinutes(COBRAND_CONTEXT_TIME_OUT);

            if (now >= expired)
            {
                // System.Console.WriteLine("\t(CobrandContext is old, creating new one...)");

                // Cobrand Context expired, create new one
                cobrandLoginService     = new CobrandLoginService();
                cobrandLoginService.Url = System.Configuration.ConfigurationManager.AppSettings.Get("soapServer") + "/" + cobrandLoginService.GetType().FullName;
                // Get Cobrand Credentials from AppSettings (requires App.config file)
                string cobrandIdStr  = System.Configuration.ConfigurationManager.AppSettings.Get("cobrandId");
                long   cobrandId     = long.Parse(cobrandIdStr);
                string applicationId = System.Configuration.ConfigurationManager.AppSettings.Get("applicationId");
                string username      = System.Configuration.ConfigurationManager.AppSettings.Get("username");
                string password      = System.Configuration.ConfigurationManager.AppSettings.Get("password");
                string tncVersionStr = System.Configuration.ConfigurationManager.AppSettings.Get("tncVersion");
                long   tncVersion    = long.Parse(tncVersionStr);
                // Note you can remove warnings by adding reference 'System.Configuration' from the .NET tab
                // and replacing code "ConfigurationManager.AppSettings.Get" with "ConfigurationManager.AppSettings"
                // This only works with .NET 2.0 or above.  Leaving code as is for now.s

                Locale locale = new Locale();
                locale.country = "US";
                CobrandPasswordCredentials cobrandPasswordCredentials =
                    new CobrandPasswordCredentials();
                cobrandPasswordCredentials.password  = password;
                cobrandPasswordCredentials.loginName = username;

                // authentication of a cobrand in the Yodlee software platform and returns
                // a valid CobrandContext if the authentication is successful. This method takes a generic CobrandCredentials argument as the
                // authentication related credentials of the cobrand.
                cobrandContext = cobrandLoginService.loginCobrand(
                    cobrandId,
                    true,
                    applicationId,
                    locale,
                    tncVersion,
                    true,
                    cobrandPasswordCredentials);

                created = DateTime.Now;
                return(cobrandContext);
            }
            else
            {
                // System.Console.WriteLine("\t(using cached CobrandContext...)");
                return(cobrandContext);
            }
        }
        public CobrandContext GetCobrandContext()
        {
            DateTime now     = DateTime.Now;
            DateTime expired = created.AddMinutes(COBRAND_CONTEXT_TIME_OUT);

            if (now >= expired)
            {
                // Cobrand Context expired, create new one
                cobrandLoginService = new CobrandLoginService();
                string soapServer = CurrentValues.Instance.YodleeSoapServer;
                cobrandLoginService.Url = soapServer + "/" + cobrandLoginService.GetType().FullName;
                // Get Cobrand Credentials from AppSettings (requires App.config file)
                long   cobrandId     = CurrentValues.Instance.YodleeCobrandId;
                string applicationId = CurrentValues.Instance.YodleeApplicationId;
                string username      = CurrentValues.Instance.YodleeUsername;
                string password      = CurrentValues.Instance.YodleePassword;
                string tncVersionStr = CurrentValues.Instance.YodleeTncVersion;
                long   tncVersion    = long.Parse(tncVersionStr);
                // Note you can remove warnings by adding reference 'System.Configuration' from the .NET tab
                // and replacing code "ConfigurationSettings.AppSettings.Get" with "ConfigurationManager.AppSettings"
                // This only works with .NET 2.0 or above.  Leaving code as is for now.s

                var locale = new Locale {
                    country = "US"
                };
                var cobrandPasswordCredentials = new CobrandPasswordCredentials {
                    password = password, loginName = username
                };

                // authentication of a cobrand in the Yodlee software platform and returns
                // a valid CobrandContext if the authentication is successful. This method takes a generic CobrandCredentials argument as the
                // authentication related credentials of the cobrand.
                cobrandContext = cobrandLoginService.loginCobrand(
                    cobrandId,
                    true,
                    applicationId,
                    locale,
                    tncVersion,
                    true,
                    cobrandPasswordCredentials);

                Log.DebugFormat("GetCobrandContext cobrand login successful");

                created = DateTime.Now;
                return(cobrandContext);
            }

            return(cobrandContext);
        }