/// <summary> /// Notifies the observer of a new value in the sequence. It's best to override Dispatch or TreatRow than this method because this method contains pipelining logic. /// </summary> public override void Trigger() { CountTreated++; try { foreach (var elt in _enumeration) { if (elt is Row) { Observers.PropagateOnNext(elt as Row); } else { Observers.PropagateOnNext(Row.FromObject(elt)); } } } catch (Exception ex) { Observers.PropagateOnError(ex); } Completed = true; Observers.PropagateOnCompleted(); }
/// <summary> /// Notifies the observer of a new value in the sequence. It's best to override Dispatch or TreatRow than this method because this method contains pipelining logic. /// </summary> public override void Trigger() { CountTreated++; try { IEnumerator fList = null; if (_strm != null) { using (StreamReader reader = new StreamReader(_strm)) { fList = FluentFile.For(_type).From(reader).GetEnumerator(); } } else if (_strmReader != null) { fList = FluentFile.For(_type).From(_strmReader).GetEnumerator(); } else if (_filename != null) { fList = FluentFile.For(_type).From(_filename).GetEnumerator(); } IterateElements(fList); } catch (Exception ex) { log4net.LogManager.GetLogger(this.GetType()).Error("Operation error", ex); Observers.PropagateOnError(ex); } Completed = true; Observers.PropagateOnCompleted(); }
public override void Trigger() { try { _activator.UseCommand(currentCommand => { if (_activator.Prepare != null) { _activator.Prepare(currentCommand, null); } if (_activator.IsQuery) { OleDbDataAdapter ada = new OleDbDataAdapter(currentCommand); DataTable table = new DataTable(); ada.Fill(table); Observers.PropagateOnNext(table); } else { currentCommand.ExecuteNonQuery(); } }); } catch (Exception ex) { Observers.PropagateOnError(ex); } finally { _activator.Release(); } }
/// <summary> /// Notifies the observer of a new value in the sequence. It's best to override Dispatch or TreatRow than this method because this method contains pipelining logic. /// </summary> public override void Trigger() { try { _activator.UseCommand(currentCommand => { if (_activator.Prepare != null) { _activator.Prepare(currentCommand, null); } log4net.LogManager.GetLogger(this.GetType()).Info(DisplayName + " Execute command " + currentCommand.CommandText); if (_activator.IsQuery) { using (IDataReader reader = currentCommand.ExecuteReader()) { while (reader.Read()) { try { Observers.PropagateOnNext(_activator.CreateRowFromReader(reader)); } catch (Exception ex) { if (_activator.FailOnError) { throw; } log4net.LogManager.GetLogger(this.GetType()).Warn("Non blocking operation error", ex); } } } } else { currentCommand.ExecuteNonQuery(); } }); } catch (Exception ex) { log4net.LogManager.GetLogger(this.GetType()).Error("Operation error", ex); Observers.PropagateOnError(ex); } finally { _activator.Release(); } Completed = true; Observers.PropagateOnCompleted(); }
/// <summary> /// Notifies the observer that an exception has occurred. /// </summary> public virtual void OnError(Exception exception) { Observers.PropagateOnError(exception); }