/**********************************************************************************/

        public void updateEventOpt(List <oadrDistributeEventTypeOadrEvent> evts, OptTypeType optType, string requestID, int responseCode, string responseDescription)
        {
            Thread thread = new Thread(delegate()
            {
                try
                {
                    CreatedEvent createdEvent;

                    lock (m_ven)
                    {
                        createdEvent = m_ven.createdEvent(requestID, evts, optType, responseCode, responseDescription);
                    }

                    m_callbacks.processCreatedEvent(createdEvent, m_processEvents.ActiveEvents, requestID);
                }
                catch (Exception ex)
                {
                    m_callbacks.processException(ex);
                }
            });

            thread.Start();
        }
示例#2
0
        /**********************************************************/

        public void processEvents(oadrDistributeEventType distributeEvent, string requestID, eOptType optType, VEN2b ven)
        {
            List <string> eventIDs = new List <string>();     // track list of valid events from distributeEvent object

            // will use to match against our list of active events

            // validate the VTN id
            if (distributeEvent.vtnID != ven.VTNID)
            {
                // the VTN ID was invalid; remove all events and send an error message
                checkForRemovedEvents(eventIDs);

                m_callbacks.logSystemMessage("Invalid VTN ID: " + distributeEvent.vtnID, UserControls.Log.WebLogView.eWebLogMessageStatus.WARNING);

                CreatedEvent createdEvent = ven.createdEvent(requestID, 452, "Invalid ID");

                m_callbacks.processCreatedEvent(createdEvent, m_idToEvent, requestID);

                return;
            }

            // the VTN didn't send any events; clear all events we have stored
            if (distributeEvent.oadrEvent == null)
            {
                checkForRemovedEvents(eventIDs);
                m_callbacks.processCreatedEvent(null, m_idToEvent, requestID);
                return;
            }

            OptTypeType oadrOptType = (optType == eOptType.OptIn ? OptTypeType.optIn : OptTypeType.optOut);

            // send a createdEvent with an opt type of the incoming optType for all new events
            // that aren't canceled or completed.  optIn/out of cancelled and completed events as appropriate
            CreatedEventHelper createdEventHelper = new CreatedEventHelper();

            foreach (oadrDistributeEventTypeOadrEvent evt in distributeEvent.oadrEvent)
            {
                string eventID = evt.eiEvent.eventDescriptor.eventID;

                // validate that the event is for this VEN and MarketContext
                if (!eventValid(evt, ven, requestID, createdEventHelper))
                {
                    continue;
                }

                eventIDs.Add(eventID);

                if (!m_idToEvent.ContainsKey(eventID))
                {
                    processNewEvent(requestID, oadrOptType, createdEventHelper, evt);
                }
                else
                {
                    processExistingEvent(requestID, createdEventHelper, evt);
                }

                OadrEventWrapper eventWrapper = m_idToEvent[eventID];

                if (eventWrapper.RandomizedMinutes != 0)
                {
                    m_callbacks.logSystemMessage(string.Format("Event start time delayed due to start after parameter: event ID={0}, start after={1}, randomized minutes={2}",
                                                               eventWrapper.OadrEvent.eiEvent.eventDescriptor.eventID, eventWrapper.OadrEvent.eiEvent.eiActivePeriod.properties.tolerance.tolerate.startafter,
                                                               eventWrapper.RandomizedMinutes), UserControls.Log.WebLogView.eWebLogMessageStatus.INFO);
                }
            }

            // events in m_idToEvent but not in the incoming distributeEvent message must be
            // implicitly canceled
            checkForRemovedEvents(eventIDs);

            if (createdEventHelper.EventResponses.Count > 0)
            {
                CreatedEvent createdEvent = ven.createdEvent(createdEventHelper);

                m_callbacks.processCreatedEvent(createdEvent, m_idToEvent, requestID);
            }
            else
            {
                // still need to call this function to ensure the UI is updated with any event status changes
                m_callbacks.processCreatedEvent(null, m_idToEvent, requestID);
            }
        }