public void Add(Dictionary <string, DataSource> sources) { if (myCxns == null) { myCxns = new Dictionary <string, AbstractConnection>(); } foreach (KeyValuePair <string, DataSource> kvp in sources) { if (fExcludeSite200 && kvp.Key == "200") { continue; } AbstractDaoFactory f = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(kvp.Value.Protocol)); AbstractConnection c = f.getConnection(kvp.Value); c.DataSource = kvp.Value; if (!myCxns.ContainsKey(kvp.Key)) { myCxns.Add(kvp.Key, c); if (myCxns.Count == 1) { baseSiteId = kvp.Value.SiteId.Id; } } } }
/// <summary> /// This function is the heart of the connection pool dictionary. It connects to a site /// and attaches the event handlers by executing a standard gettimestamp request /// so the connection can immediately begin processing queued query threads /// </summary> /// <param name="site">Site to which to connect</param> /// <param name="addToCxnCollection">Should the site be added to the pools connection collection?</param> /// <returns></returns> AbstractConnection connectWithReturn(Site site, bool addToCxnCollection) { //Site[] sites = _poolSites.ToArray(); Site currentSite = site; DataSource src = currentSite.Sources[0]; AbstractDaoFactory factory = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(src.Protocol)); AbstractConnection c = factory.getConnection(src); //c.ConnectionId = new Guid(); c.Account = _account; c.Account = new VistaAccount(c); c.Account.AuthenticationMethod = _account.AuthenticationMethod; c.Account.Permissions = new Dictionary <string, AbstractPermission>(); AbstractPermission cprs = new MenuOption("OR CPRS GUI CHART"); cprs.IsPrimary = true; c.Account.Permissions.Add(cprs.Name, cprs); // this needs to be up here so we can reference it if an error occurs QueryThread qt = new QueryThread("", new VistaToolsDao(null), "getTimestamp", new object[] { }); EventHandler eh = new EventHandler(QueryThreadChanged); try { User user = (User)c.authorizedConnect(_credentials, cprs, src); c.IsAvailable = true; // initiliaze this connection's eventhandler by making a standard timestamp request qt.setConnection(c); qt.Changed += eh; _currentActiveConnections++; qt.execute(); if (!(qt.Result is string)) { throw new ConnectionException("Connection does not appear to be active"); } if (addToCxnCollection) { addConnection(currentSite.Id, c); } return(c); } catch (Exception) { qt.Changed -= eh; c.IsAvailable = false; _currentActiveConnections--; try { c.disconnect(); } catch (Exception) { } } return(null); }
public static AbstractConnection authorizedConnect(string theUser, bool isBse) { string securityPhrase = (isBse ? "" : "NON-BSE"); MockApp theApp = getTheApp(theUser, securityPhrase); DataSource src = getSrc(theApp.SiteTable, theApp.LoginSitecode); AbstractDaoFactory f = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(src.Protocol)); AbstractConnection cxn = f.getConnection(src); AbstractCredentials credentials = getVisitCredentials(theApp); AbstractPermission permission = new MenuOption(theApp.User.PermissionString); theApp.User = (User)cxn.authorizedConnect(credentials, permission, null); return(cxn); }
public void Add(DataSource source, string authenticationMethod) { if (fExcludeSite200 && source.SiteId.Id == "200") { return; } AbstractDaoFactory f = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(source.Protocol)); AbstractConnection c = f.getConnection(source); c.DataSource = source; c.Account.AuthenticationMethod = authenticationMethod; if (myCxns == null) { myCxns = new Dictionary <string, AbstractConnection>(1); } if (!myCxns.ContainsKey(source.SiteId.Id)) { myCxns.Add(source.SiteId.Id, c); if (myCxns.Count == 1) { baseSiteId = source.SiteId.Id; } } }
public override object getDao(string daoName, AbstractConnection c) { AbstractDaoFactory f = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(c.DataSource.Protocol)); return(f.getDaoByName(daoName, c)); }
public Object getDao(String daoName) { AbstractDaoFactory df = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(_dataSource.Protocol)); return(df.getDaoByName(daoName, this)); }