private IrbisConnection GetConnection() { string connectionString = CM.AppSettings["connectionString"]; IrbisConnection result = new IrbisConnection(connectionString); if (_slowBox.CheckBox.Checked) { SlowSocket slow = new SlowSocket ( result, result.Socket ) { Delay = 1000 }; result.SetSocket(slow); } if (_brokenBox.CheckBox.Checked) { BrokenSocket broken = new BrokenSocket ( result, result.Socket ) { Probability = 0.5 }; result.SetSocket(broken); } if (_busyBox.CheckBox.Checked) { _busyStripe.SubscribeTo(result); } if (_retryBox.CheckBox.Checked) { RetryManager manager = result.SetupRetryForm(); manager.ExceptionOccurs += ExceptionOccurs; manager.Resolved += ExceptionResolved; result.Disposing += ConnectionDisposing; } return(result); }
private IrbisConnection GetConnection() { IrbisConnection result = IrbisConnectionUtility.GetClientFromConfig(); SlowSocket socket = new SlowSocket(result, result.Socket) { Delay = 1000 }; result.SetSocket(socket); result.Busy.StateChanged += Busy_StateChanged; result.Disposing += Connection_Disposing; return(result); }
/// <summary> /// Apply settings to the <see cref="IrbisConnection" />. /// </summary> public void ApplyToConnection ( [NotNull] IrbisConnection connection ) { Sure.NotNull(connection, nameof(connection)); connection.Host = _Select(Host, connection.Host); connection.Port = _Select(Port, connection.Port); connection.Username = _Select(Username, connection.Username); connection.Password = _Select(Password, connection.Password); connection.Database = _Select(Database, connection.Database); connection.Workstation = (IrbisWorkstation)_Select ( (int)Workstation, (int)connection.Workstation ); if (!string.IsNullOrEmpty(EngineTypeName)) { connection.SetEngine(EngineTypeName); } if (!string.IsNullOrEmpty(SocketTypeName)) { ClientSocketUtility.CreateSocket ( connection, SocketTypeName ); } if (!string.IsNullOrEmpty(NetworkLogging)) { connection.SetNetworkLogging(NetworkLogging); } if (!string.IsNullOrEmpty(FactoryTypeName)) { connection.SetCommandFactory(FactoryTypeName); } if (!string.IsNullOrEmpty(Smart)) { SmartClientSocket smartSocket = new SmartClientSocket(connection); connection.SetSocket(smartSocket); } if (!string.IsNullOrEmpty(Slow)) { SlowSocket slowSocket = new SlowSocket ( connection, connection.Socket ); int delay; if (NumericUtility.TryParseInt32(Slow, out delay) && delay > 0) { slowSocket.Delay = delay; } connection.SetSocket(slowSocket); } if (!string.IsNullOrEmpty(Broken)) { BrokenSocket brokenSocket = new BrokenSocket ( connection, connection.Socket ); double probability; if (NumericUtility.TryParseDouble(Broken, out probability) && probability > 0.0 && probability < 1.0) { brokenSocket.Probability = probability; } connection.SetSocket(brokenSocket); } if (RetryLimit != 0) { connection.SetRetry(RetryLimit, null); } if (!string.IsNullOrEmpty(UserData)) { connection.UserData = UserData; } connection._connected = Connected; }