Ejemplo n.º 1
0
        public EventManager.EventResult onMessage(Event e)
        {
            EventManager.EventResult ret = EventManager.EventResult.IGNORED;

            List <Behavior> interestedBehaviors;

            if (myMessageInterestMap.TryGetValue(e.name, out interestedBehaviors) == true)
            {
                foreach (Behavior b in interestedBehaviors)
                {
                    ret = b.onEvent(e);
                }
            }

            return(ret);
        }
Ejemplo n.º 2
0
        public EventManager.EventResult messageHandler(Event e)
        {
            EventManager.EventResult ret = EventManager.EventResult.IGNORED;

            foreach (Entity ent in myMessageInterestMap[e.name])
            {
                EventManager.EventResult res;
                res = ent.onMessage(e);
                if (res == EventManager.EventResult.EATEN)
                {
                    return(res);
                }

                if (res == EventManager.EventResult.HANDLED)
                {
                    ret = res;
                }
            }

            return(ret);
        }
Ejemplo n.º 3
0
        public EventManager.EventResult dispatchEvent(Event e)
        {
            EventManager.EventResult ret = EventManager.EventResult.IGNORED;
            foreach (EventListener el in myEventListeners)
            {
                EventManager.EventResult res = el(e);
                if (res == EventManager.EventResult.EATEN)
                {
                    return(res);
                }
                if (res == EventManager.EventResult.HANDLED)
                {
                    ret = res;
                }
            }

            //give the children a chance to handle it
            if (myChildren.Count > 0)
            {
                int id = e.id.myIds[myDepth];
                if (myChildren.ContainsKey(id))
                {
                    EventManager.EventResult res = myChildren[id].dispatchEvent(e);
                    if (res == EventManager.EventResult.EATEN)
                    {
                        return(res);
                    }
                    if (res == EventManager.EventResult.HANDLED)
                    {
                        ret = res;
                    }
                }
            }

            return(ret);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Matt Lapka
        /// Created: 2015/03/26
        /// Sends event information to BLL and validates data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmitEvent_Click(object sender, EventArgs e)
        {
            bool stop       = false;
            int  errorCount = 0;

            //validate!
            if (!txtEventName.Text.ValidateAlphaNumeric(1))
            {
                txtEventName.ToolTip     = "You must enter a valid event name!";
                txtEventName.BorderColor = Color.Red;
                stop = true;
                errorCount++;
            }
            if (comboEventTypeList.SelectedIndex < 1)
            {
                comboEventTypeList.ToolTip     = "You must select an event type!";
                comboEventTypeList.BorderColor = Color.Red;
                stop = true;
                errorCount++;
            }
            if (String.IsNullOrEmpty(txtDescription.Text))
            {
                txtDescription.ToolTip     = "Please enter a brief description";
                txtDescription.BorderColor = Color.Red;
                stop = true;
                errorCount++;
            }
            if (radOnSite.SelectedIndex < 0)
            {
                radOnSite.ToolTip     = "Please select if this will be an on site event.";
                radOnSite.BorderColor = Color.Red;
                stop = true;
                errorCount++;
            }
            if (radTransportation.SelectedIndex < 0)
            {
                radTransportation.ToolTip     = "Please indicate whether or not you will provide transportation to the event.";
                radTransportation.BorderColor = Color.Red;
                stop = true;
                //only add error count if this questions is visible
                if (radTransportation.Visible)
                {
                    errorCount++;
                }
            }
            if (stop)
            {
                showError("You have " + errorCount + " errors that need to be fixed.");
                return;
            }
            else
            {
                //reset border colors
                txtEventName.BorderColor       = Color.Black;
                txtDescription.BorderColor     = Color.Black;
                comboEventTypeList.BorderColor = Color.Black;
                radTransportation.BorderColor  = Color.Black;
                radOnSite.BorderColor          = Color.Black;

                try
                {
                    //create new Event
                    Event currentEvent = new Event();

                    currentEvent.EventItemName = txtEventName.Text;
                    currentEvent.Description   = txtDescription.Text;
                    int typeID = 0;
                    //we know that the selected value (event type id) is an int so no need to validate
                    int.TryParse(comboEventTypeList.SelectedValue, out typeID);
                    currentEvent.EventTypeID = typeID;
                    bool onsite;
                    bool transportation;
                    bool.TryParse(radOnSite.SelectedValue, out onsite);
                    bool.TryParse(radTransportation.SelectedValue, out transportation);
                    currentEvent.OnSite         = onsite;
                    currentEvent.Transportation = transportation;

                    EventManager.EventResult result = _myEventManager.AddNewEvent(currentEvent);
                    if (result == EventManager.EventResult.Success)
                    {
                        lblMessage.Text = "Event Successfully Added!";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "showit", "showMessage()", true);
                    }
                    clearForm();
                }
                catch (Exception ex)
                {
                    showError(ex.Message);
                }
            }
        }