/// <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(); }
/// <summary> /// Notifies the observers of the end of the sequence. /// </summary> public virtual void OnCompleted() { // We should consider this operation completed only if all "parent" operations completes if (Observed.All(o => o.Completed)) { Completed = true; Observers.PropagateOnCompleted(); } }
/// <summary> /// Notifies the observers of the end of the sequence. /// </summary> public virtual void OnCompleted() { // We should consider this operation completed only if all "parent" operations completes if (Observed.All(o => o.Completed)) { Completed = true; Observers.PropagateOnCompleted(); } LogProvider.GetLogger(GetType()).Debug("Operation " + DisplayName + " completed"); }
/// <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(); }