Exemplo n.º 1
0
 public void LogEvent(object caller, RFEvent e)
 {/*
   * if (!(e is RFCatalogUpdateEvent) && !(e is RFIntervalEvent))
   * {
   *     LogInSystemLog(caller, "EVENT", e);
   * }*/
 }
Exemplo n.º 2
0
 public void RaiseEvent(object raisedBy, RFEvent e, string processingKey)
 {
     _items.Add(new RFWorkQueueItem
     {
         Item          = e,
         ProcessingKey = processingKey
     });
 }
Exemplo n.º 3
0
 public override List <RFInstruction> React(RFEvent e)
 {
     if (e is RFServiceEvent se && se.ServiceName.Equals(ServiceName, System.StringComparison.OrdinalIgnoreCase))
     {
         return(Service.Command(se.ServiceCommand.ToLower(), se.ServiceParams));
     }
     return(null);
 }
Exemplo n.º 4
0
        public List <RFInstruction> React(RFEvent e)
        {
            var instructions = new List <RFInstruction>();
            var i            = _triggerFunc(e);

            if (i != null)
            {
                instructions.Add(i);
            }
            return(instructions);
        }
Exemplo n.º 5
0
 public void RaiseEvent(object raisedBy, RFEvent e, string processingKey)
 {
     try
     {
         lock (_eventQueue) // Send is not thread-safe, would need to use thread-local instances
         {
             _eventQueue.Send(new RFWorkQueueItem {
                 Item = e, ProcessingKey = processingKey
             });
         }
         RFStatic.Log.Debug(typeof(RFEventSinkMSMQ), "Sent event {0} to MSMQ", e);
     }
     catch (MessageQueueException)
     {
         if (!RFStatic.IsShutdown)
         {
             throw;
         }
     }
 }
Exemplo n.º 6
0
        public void React(RFEvent e, IRFProcessingContext processingContext)
        {
            var allInstructions = new BlockingCollection <RFInstruction>();

            if (e is RFIntervalEvent ie) // silently store intervals in database?
            {
                processingContext.SaveEntry(new RFDocument
                {
                    Content = ie.Interval,
                    Key     = _config.IntervalDocumentKey(),
                    Type    = typeof(RFInterval).FullName
                }, false, true);
            }
            Parallel.ForEach(_reactors, reactor =>
            {
                try
                {
                    var instructions = reactor.React(e);
                    if (instructions != null)
                    {
                        foreach (var instruction in instructions)
                        {
                            allInstructions.Add(instruction);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Exception(this, ex, "Reactor {0} threw an exception processing event {1}", reactor, e);
                }
            });

            foreach (var instruction in allInstructions)
            {
                processingContext.QueueInstruction(this, instruction);
            }
        }
Exemplo n.º 7
0
 public abstract List <RFInstruction> React(RFEvent e);
Exemplo n.º 8
0
 public override List <RFInstruction> React(RFEvent e)
 {
     return(Trigger.React(e));
 }
Exemplo n.º 9
0
 public void RaiseEvent(object raisedBy, RFEvent evt)
 {
     _events.RaiseEvent(raisedBy, evt, ProcessingKey);
 }
Exemplo n.º 10
0
        public override List <RFInstruction> React(RFEvent e)
        {
            var cu = e as RFCatalogUpdateEvent;

            if (cu != null && cu.Key != null && cu.Key.GraphInstance != null && cu.Key.MatchesRoot(_key))
            {
                var key            = cu.Key;
                var updateDate     = key.GraphInstance.ValueDate.Value;
                var processingDate = _dateFunc(key.GraphInstance); // this can be a forward date in case of a range input, but usually 1:1 with key's date
                var instructions   = new List <RFInstruction>();
                if (_dateBehaviour != RFDateBehaviour.Previous)
                {
                    instructions.Add(new RFGraphProcessInstruction(cu.Key.GraphInstance.WithDate(processingDate), _processName));
                }

                // for exact inputs there's no need to queue any forward instructions
                if (_dateBehaviour != RFDateBehaviour.Exact)
                {
                    var maxDate = RFDate.NullDate;

                    // use key's original updatedate rather than derived processingdate for the instruction
                    var laterInstances = _context.GetKeyInstances(key).Where(k => k.Key.Name == key.GraphInstance.Name && k.Key.ValueDate.HasValue)
                                         .Where(d => d.Key.ValueDate.Value > updateDate);
                    if (laterInstances.Any())
                    {
                        maxDate = laterInstances.Min(i => i.Key.ValueDate.Value); // next instance date
                        if (_dateBehaviour == RFDateBehaviour.Latest || _dateBehaviour == RFDateBehaviour.Range)
                        {
                            maxDate = maxDate.OffsetDays(-1); // exclude next instance date (for Previous - it will run)
                        }
                    }
                    else // there are no future instances... so how far do we go?
                    {
                        maxDate = _maxDateFunc(updateDate);
                    }

                    if (maxDate < updateDate)
                    {
                        maxDate = updateDate; // don't do anything
                    }

                    var maxInstanceDate        = _maxDateFunc(_context.Today);
                    var nextDate               = key.GraphInstance.ValueDate.Value.OffsetDays(1);
                    var forwardProcessingDates = new SortedSet <RFDate>(); // eliminate dupes
                    foreach (var forwardUpdateDate in RFDate.Range(nextDate, maxDate, d => true))
                    {
                        var forwardProcessingDate = _dateFunc(key.GraphInstance.WithDate(forwardUpdateDate));
                        if (forwardProcessingDate != processingDate && forwardProcessingDate <= maxInstanceDate)
                        {
                            forwardProcessingDates.Add(forwardProcessingDate);
                        }
                    }

                    if (forwardProcessingDates.Any())
                    {
                        instructions.AddRange(forwardProcessingDates.Select(d => new RFGraphProcessInstruction(key.GraphInstance.WithDate(d), _processName)));

                        _context.SystemLog.Debug(this, "Queuing {0} forward instructions for key {1} from {2} to {3}", forwardProcessingDates.Count, key.FriendlyString(), nextDate, maxDate);
                    }
                }
                return(instructions);
            }
            else
            {
                return(null);
            }
        }