Example #1
0
        public CrudSvc()
        {
            if (ConnectionPools.getInstance().PoolSource != null)
            {
                return; // already set up the pools!
            }

            _mySession = new MySession();
            SiteTable sites = _mySession.SiteTable;
            IList <AbstractPoolSource> sources     = new List <AbstractPoolSource>();
            ConnectionPoolsSource      poolsSource = new ConnectionPoolsSource();

            poolsSource.CxnSources = new Dictionary <string, ConnectionPoolSource>();
            User user = _mySession.MdwsConfiguration.ApplicationProxy;
            AbstractCredentials creds = new VistaCredentials();

            creds.AccountName                 = user.UserName;
            creds.AccountPassword             = user.Pwd;
            creds.AuthenticationSource        = new DataSource(); // BSE
            creds.AuthenticationSource.SiteId = new SiteId(user.LogonSiteId.Id, user.LogonSiteId.Name);
            creds.AuthenticationToken         = user.LogonSiteId.Id + "_" + user.Uid;
            creds.LocalUid       = user.Uid;
            creds.FederatedUid   = user.SSN.toString();
            creds.SubjectName    = user.Name.getLastNameFirst();
            creds.SubjectPhone   = user.Phone;
            creds.SecurityPhrase = _mySession.MdwsConfiguration.AllConfigs
                                   [conf.MdwsConfigConstants.MDWS_CONFIG_SECTION][conf.MdwsConfigConstants.SECURITY_PHRASE];

            foreach (DataSource source in sites.Sources)
            {
                if (!String.Equals(source.Protocol, "VISTA", StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }
                ConnectionPoolSource newSource = new ConnectionPoolSource()
                {
                    LoadStrategy = (LoadingStrategy)Enum.Parse(typeof(LoadingStrategy),
                                                               _mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_LOAD_STRATEGY]),
                    MaxPoolSize       = Convert.ToInt32(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_MAX_CXNS]),
                    MinPoolSize       = Convert.ToInt32(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_MIN_CXNS]),
                    PoolExpansionSize = Convert.ToInt32(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_EXPAND_SIZE]),
                    WaitTime          = TimeSpan.Parse(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_WAIT_TIME]),
                    Timeout           = TimeSpan.Parse(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_CXN_TIMEOUT]),
                    CxnSource         = source,
                    Credentials       = creds
                };
                newSource.CxnSource.Protocol = "PVISTA";
                poolsSource.CxnSources.Add(source.SiteId.Id, newSource);
            }

            ConnectionPools pools = (ConnectionPools)AbstractResourcePoolFactory.getResourcePool(poolsSource);
        }
Example #2
0
        internal void initializePool()
        {
            logging.Log.LOG("Initializing connection pools...");
            if (ConnectionPools.getInstance().PoolSource != null)
            {
                logging.Log.LOG("Connection pools already initialized");
                return; // already set up the pools!
            }

            SiteTable sites = new SiteTable(ConfigurationManager.AppSettings[config.AppConfigSettingsConstants.VhaSitesFilePath]);
            IList <AbstractPoolSource> sources     = new List <AbstractPoolSource>();
            ConnectionPoolsSource      poolsSource = new ConnectionPoolsSource();

            poolsSource.CxnSources = new Dictionary <string, ConnectionPoolSource>();
            VistaDao            trash = new VistaDao();
            AbstractCredentials creds = getDownstreamCredentialsFromConfig(getDownstreamUserFromConfig());

            foreach (DataSource source in sites.Sources)
            {
                if (!String.Equals(source.Protocol, "VISTA", StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }
                ConnectionPoolSource newSource = new ConnectionPoolSource()
                {
                    Timeout           = TimeSpan.Parse(ConfigurationManager.AppSettings["PoolConnectionTimeout"]),
                    WaitTime          = TimeSpan.Parse(ConfigurationManager.AppSettings["PoolWaitTimeout"]),
                    MaxPoolSize       = Convert.ToInt32(ConfigurationManager.AppSettings["PoolMaxSize"]),
                    MinPoolSize       = Convert.ToInt32(ConfigurationManager.AppSettings["PoolMinSize"]),
                    PoolExpansionSize = Convert.ToInt32(ConfigurationManager.AppSettings["PoolExpansionSize"]),
                    CxnSource         = source,
                    Credentials       = creds,
                    Permission        = new MenuOption(ConfigurationManager.AppSettings["PoolUserPermission"])
                };
                Int32 recycleCount = 0;
                if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["PoolRecycleCount"]) && Int32.TryParse(ConfigurationManager.AppSettings["PoolRecycleCount"], out recycleCount))
                {
                    newSource.RecycleCount = recycleCount;
                }
                newSource.CxnSource.Protocol = "PVISTA";
                poolsSource.CxnSources.Add(source.SiteId.Id, newSource);
            }

            ConnectionPools pools = (ConnectionPools)AbstractResourcePoolFactory.getResourcePool(poolsSource);

            logging.Log.LOG("Successfully completed connection pools initialization");
        }