Ejemplo n.º 1
0
            public T Get <T>(SqlDBCredentials credentials, SoftwareVersion version = null)
            {
                T retVal = default(T);
                CredentialLookup lkp;

                if (_credentialLookup.TryGetValue(typeof(T), out lkp))
                {
                    if (version == null)
                    {
                        version = new SoftwareVersion();
                    }

                    String key = credentials.ToParsableString() + ";DBVER=" + version.ToString();
                    if (lkp.ContainsKey(key))
                    {
                        retVal = (T)lkp[key];
                    }
                }
                return(retVal);
            }
Ejemplo n.º 2
0
            public Object GetByType(Type t, SqlDBCredentials credentials, SoftwareVersion version = null)
            {
                Object           retVal = null;
                CredentialLookup lkp;

                if (_credentialLookup.TryGetValue(t, out lkp))
                {
                    if (version == null)
                    {
                        version = new SoftwareVersion();
                    }

                    String key = credentials.ToParsableString() + ";DBVER=" + version.ToString();
                    if (lkp.ContainsKey(key))
                    {
                        retVal = lkp[key];
                    }
                }
                return(retVal);
            }
Ejemplo n.º 3
0
        public static DBResult GetDatabaseVersion(SqlDBCredentials credentials, out SoftwareVersion version, out InternalDatabaseType databaseType)
        {
            DBResult retVal = new DBResult(DBResult.Result.Success);

            try
            {
                _databaseVersionLock.Lock();
                version      = null;
                databaseType = InternalDatabaseType.Unknown;
                String indexKey = credentials.ToParsableString();
                if (!_databaseVersionLookup.TryGetValue(indexKey, out version))
                {
                    ISqlDataSource     ds = SqlConnectionPool.Instance(credentials).GetDataSource();
                    DatabaseDataReader reader;

                    QueryString sql = ds.FormatTrusted("SELECT * FROM I.seq where name in ('{0}', '{1}')", KEY_DB_TYPE, KEY_SCHEMA_VER);
                    retVal = ds.Query(sql, out reader);
                    if (retVal.ResultCode == DBResult.Result.Success && reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            String key = DBUtil.GetString(reader[COL_KEY]);
                            if (key == KEY_SCHEMA_VER)
                            {
                                version = DBUtil.GetSoftwareVersion(reader[COL_VALUE]);
                            }
                            else if (key == KEY_DB_TYPE)
                            {
                                databaseType = (InternalDatabaseType)DBUtil.GetInt32(reader[COL_VALUE]);
                            }
                        }
                        _databaseVersionLookup.Add(indexKey, version);
                    }
                }
            }
            finally
            {
                _databaseVersionLock.Unlock();
            }
            return(retVal);
        }
Ejemplo n.º 4
0
            public T Set <T>(SqlDBCredentials credentials, SoftwareVersion version, T obj)
            {
                CredentialLookup lkp;

                if (!_credentialLookup.TryGetValue(typeof(T), out lkp))
                {
                    lkp = new CredentialLookup();
                    _credentialLookup.Add(typeof(T), lkp);
                }
                String key = credentials.ToParsableString() + ";DBVER=" + version.ToString();

                if (lkp.ContainsKey(key))
                {
                    lkp[key] = obj;
                }
                else
                {
                    lkp.Add(key, obj);
                }
                return(obj);
            }