Пример #1
0
        private static IEnumerable<DomainConnectionInfo> GetDomainConnectionInfo()
        {
            if (storedConnectionInfo == null || DateTime.UtcNow - lastConnectionInfoRefresh > ConnectionListInterval)
            {
                lastConnectionInfoRefresh = DateTime.UtcNow;
                List<DomainConnectionInfo> result = new List<DomainConnectionInfo>();
                string query = "select d.name,d.subdomain,c.connectionstring  from [Domains] as d LEFT JOIN [Connections] as c ON c.Id = d.ConnectionId";
                using (SqlConnection connection = new SqlConnection(AccessConnectionString))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand(query, connection))
                    {

                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            if (dr.HasRows)
                            {
                                while (dr.Read())
                                {
                                    var info = new DomainConnectionInfo { Name = dr.GetString(0), Subdomain = dr.GetString(1), ConnectionString = dr.GetString(2) };
                                    info.ConnectionString += ";Max Pool Size=1000;Min Pool Size=50;Connection Timeout=300";


                                    #if DEBUG
                                    if (DebugDev) 
                                    { 
                                        if (result.Count >= DomainsToLoad) break;
                                        if (DevDomain != null && DevDomain != info.Subdomain) continue;
                                    }
                                    else { if (info.Subdomain != DebugDomain) continue; }
                                    #else
                                    if (result.Count >= DomainsToLoad) break;
                                    #endif

                                    result.Add(info);
                                }
                            }
                        }


                    }
                }

                storedConnectionInfo = result;
                return result;
            }
            else
            {
                return storedConnectionInfo;
            }
        }
Пример #2
0
        private static IEnumerable <DomainConnectionInfo> GetDomainConnectionInfo()
        {
            if (storedConnectionInfo == null || DateTime.UtcNow - lastConnectionInfoRefresh > ConnectionListInterval)
            {
                lastConnectionInfoRefresh = DateTime.UtcNow;
                List <DomainConnectionInfo> result = new List <DomainConnectionInfo>();
                string query = "select d.name,d.subdomain,c.connectionstring  from [Domains] as d LEFT JOIN [Connections] as c ON c.Id = d.ConnectionId";
                using (SqlConnection connection = new SqlConnection(AccessConnectionString))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            if (dr.HasRows)
                            {
                                while (dr.Read())
                                {
                                    var info = new DomainConnectionInfo {
                                        Name = dr.GetString(0), Subdomain = dr.GetString(1), ConnectionString = dr.GetString(2)
                                    };
                                    info.ConnectionString += ";Max Pool Size=1000;Min Pool Size=50;Connection Timeout=300";


                                    #if DEBUG
                                    if (DebugDev)
                                    {
                                        if (result.Count >= DomainsToLoad)
                                        {
                                            break;
                                        }
                                        if (DevDomain != null && DevDomain != info.Subdomain)
                                        {
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        if (info.Subdomain != DebugDomain)
                                        {
                                            continue;
                                        }
                                    }
                                    #else
                                    if (result.Count >= DomainsToLoad)
                                    {
                                        break;
                                    }
                                    #endif

                                    result.Add(info);
                                }
                            }
                        }
                    }
                }

                storedConnectionInfo = result;
                return(result);
            }
            else
            {
                return(storedConnectionInfo);
            }
        }