private bool Start( string connectionString, out string server, out DbConnectionPoolIdentity identity, out string user, out string database, ref string queueService, string appDomainKey, SqlDependencyPerAppDomainDispatcher dispatcher, out bool errorOccurred, out bool appDomainStart, bool useDefaults) { IntPtr hscp; Bid.NotificationsScopeEnter(out hscp, "<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, queue: '%ls', appDomainKey: '%ls', perAppDomainDispatcher ID: '%d'", ObjectID, queueService, appDomainKey, dispatcher.ObjectID); try { Debug.Assert(this == _staticInstance, "Instance method called on non _staticInstance instance!"); server = null; // Reset out params. identity = null; user = null; database = null; errorOccurred = false; appDomainStart = false; lock (_sqlDependencyPerAppDomainDispatchers) { if (!_sqlDependencyPerAppDomainDispatchers.ContainsKey(appDomainKey)) { _sqlDependencyPerAppDomainDispatchers[appDomainKey] = dispatcher; } } SqlConnectionStringBuilder connectionStringBuilder = null; SqlConnectionContainerHashHelper hashHelper = GetHashHelper( connectionString, out connectionStringBuilder, out identity, out user, queueService); #if DEBUG SqlConnectionString connectionStringOptions = new SqlConnectionString(connectionStringBuilder.ConnectionString); Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> Modified connection string: '%ls'\n", connectionStringOptions.UsersConnectionStringForTrace()); #endif bool started = false; SqlConnectionContainer container = null; lock (_connectionContainers) { if (!_connectionContainers.ContainsKey(hashHelper)) { Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, hashtable miss, creating new container.\n", ObjectID); container = new SqlConnectionContainer(hashHelper, appDomainKey, useDefaults); _connectionContainers.Add(hashHelper, container); started = true; appDomainStart = true; } else { container = _connectionContainers[hashHelper]; Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, hashtable hit, container: %d\n", ObjectID, container.ObjectID); if (container.InErrorState) { Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, container: %d is in error state!\n", ObjectID, container.ObjectID); errorOccurred = true; // Set outparam errorOccurred true so we invalidate on Start(). } else { container.IncrementStartCount(appDomainKey, out appDomainStart); } } } if (useDefaults && !errorOccurred) { // Return server, database, and queue for use by SqlDependency. server = container.Server; database = container.Database; queueService = container.Queue; Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, default service: '%ls', server: '%ls', database: '%ls'\n", ObjectID, queueService, server, database); } Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, started: %d\n", ObjectID, started); return started; } finally { Bid.ScopeLeave(ref hscp); } }
internal bool Start(string connectionString, string queue, string appDomainKey, SqlDependencyPerAppDomainDispatcher dispatcher) { Debug.Assert(this == _staticInstance, "Instance method called on non _staticInstance instance!"); string dummyValue1 = null; bool dummyValue2 = false; DbConnectionPoolIdentity dummyValue3 = null; return Start( connectionString, out dummyValue1, out dummyValue3, out dummyValue1, out dummyValue1, ref queue, appDomainKey, dispatcher, out dummyValue2, out dummyValue2, false); }
// ------------- // Start methods // ------------- internal bool StartWithDefault( string connectionString, out string server, out DbConnectionPoolIdentity identity, out string user, out string database, ref string service, string appDomainKey, SqlDependencyPerAppDomainDispatcher dispatcher, out bool errorOccurred, out bool appDomainStart) { Debug.Assert(this == _staticInstance, "Instance method called on non _staticInstance instance!"); return Start( connectionString, out server, out identity, out user, out database, ref service, appDomainKey, dispatcher, out errorOccurred, out appDomainStart, true); }
internal bool StartWithDefault(string connectionString, out string server, out DbConnectionPoolIdentity identity, out string user, out string database, ref string service, string appDomainKey, SqlDependencyPerAppDomainDispatcher dispatcher, out bool errorOccurred, out bool appDomainStart) { return this.Start(connectionString, out server, out identity, out user, out database, ref service, appDomainKey, dispatcher, out errorOccurred, out appDomainStart, true); }
private bool Start(string connectionString, out string server, out DbConnectionPoolIdentity identity, out string user, out string database, ref string queueService, string appDomainKey, SqlDependencyPerAppDomainDispatcher dispatcher, out bool errorOccurred, out bool appDomainStart, bool useDefaults) { bool flag2; IntPtr ptr; Bid.NotificationsScopeEnter(out ptr, "<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, queue: '%ls', appDomainKey: '%ls', perAppDomainDispatcher ID: '%d'", this.ObjectID, queueService, appDomainKey, dispatcher.ObjectID); try { server = null; identity = null; user = null; database = null; errorOccurred = false; appDomainStart = false; lock (this._sqlDependencyPerAppDomainDispatchers) { if (!this._sqlDependencyPerAppDomainDispatchers.ContainsKey(appDomainKey)) { this._sqlDependencyPerAppDomainDispatchers[appDomainKey] = dispatcher; } } SqlConnectionStringBuilder connectionStringBuilder = null; SqlConnectionContainerHashHelper key = GetHashHelper(connectionString, out connectionStringBuilder, out identity, out user, queueService); bool flag = false; SqlConnectionContainer container = null; lock (this._connectionContainers) { if (!this._connectionContainers.ContainsKey(key)) { Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, hashtable miss, creating new container.\n", this.ObjectID); container = new SqlConnectionContainer(key, appDomainKey, useDefaults); this._connectionContainers.Add(key, container); flag = true; appDomainStart = true; } else { container = this._connectionContainers[key]; Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, hashtable hit, container: %d\n", this.ObjectID, container.ObjectID); if (container.InErrorState) { Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, container: %d is in error state!\n", this.ObjectID, container.ObjectID); errorOccurred = true; } else { container.IncrementStartCount(appDomainKey, out appDomainStart); } } } if (useDefaults && !errorOccurred) { server = container.Server; database = container.Database; queueService = container.Queue; Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, default service: '%ls', server: '%ls', database: '%ls'\n", this.ObjectID, queueService, server, database); } Bid.NotificationsTrace("<sc.SqlDependencyProcessDispatcher.Start|DEP> %d#, started: %d\n", this.ObjectID, flag); flag2 = flag; } finally { Bid.ScopeLeave(ref ptr); } return flag2; }
internal bool Start(string connectionString, string queue, string appDomainKey, SqlDependencyPerAppDomainDispatcher dispatcher) { string server = null; bool errorOccurred = false; DbConnectionPoolIdentity identity = null; return this.Start(connectionString, out server, out identity, out server, out server, ref queue, appDomainKey, dispatcher, out errorOccurred, out errorOccurred, false); }