Exemplo n.º 1
0
        /// <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();
        }
Exemplo n.º 2
0
 private void IterateElements(IEnumerator fList)
 {
     while (fList.MoveNext())
     {
         Observers.PropagateOnNext(Row.FromObject(fList.Current));
     }
 }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Method called by OnNext to dispatch the new value to the observers of the operation
        /// </summary>
        /// <param name="value">value to dispatch</param>
        protected virtual void Dispatch(Row value)
        {
            var processed = TreatRow(value);

            if (processed != null)
            {
                Observers.PropagateOnNext(processed);
            }
        }
Exemplo n.º 5
0
        /// <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 observers of the end of the sequence.
        /// </summary>
        public override void OnCompleted()
        {
            foreach (var elt in _activator)
            {
                if (matchedRightElt.ContainsKey(elt))
                {
                    continue;
                }

                Row emptyRow = new Row();
                if (_activator.CheckMatch(emptyRow, elt))
                {
                    var res = _activator.ProcessRow(emptyRow, elt);
                    Observers.PropagateOnNext(res);
                }
            }
            base.OnCompleted();
        }