コード例 #1
0
    protected void ButtonDown_Click(object sender, EventArgs e)
    {
        CSS      RequestDirector = new CSS();
        DateTime defaultTime     = Convert.ToDateTime("1800-01-01 12:00:00 PM"); //default date for event start and end times

        //get event info
        Event ActiveEvent = new Event();

        ActiveEvent.EventID = ((Event)Session["Event"]).EventID;
        ActiveEvent         = RequestDirector.GetEvent(ActiveEvent);

        //if event has started and not ended
        if (ActiveEvent.EventStart != defaultTime)
        {
            if (ActiveEvent.EventEnd == defaultTime)
            {
                //limit rating to 1-10
                int Rating = int.Parse(LabelRating.Text);
                Rating = (Rating - 1 < 1) ? Rating = 1 : Rating - 1;

                LabelRating.Text = Rating.ToString();

                //create evaluation and send to DB
                Evaluation eval = new Evaluation(DateTime.Now.ToUniversalTime(), Rating, ((Evaluator)Session["Evaluator"]).EvaluatorID, ((Event)Session["Event"]).EventID);

                bool Success = RequestDirector.AddEvaluation(eval);
            }
            else
            {
                Evaluator eval = new Evaluator();
                eval.EvaluatorID = ((Evaluator)Session["Evaluator"]).EvaluatorID;

                FinishEvent(ActiveEvent, eval);
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('The Event has not yet begun')", true);
        }
    }
コード例 #2
0
    protected void JoinBTN_Click(object sender, EventArgs e)
    {
        //only validate if user has agreed to terms
        if (consentCheck.Checked)
        {
            DateTime defaultTime = Convert.ToDateTime("01-01-1800 12:00:00");

            CSS RequestDirector = new CSS();

            //check all open events to match event Key
            //return Event ID

            //get event info for key input
            Event currentEvent = new Event();
            currentEvent.EventID         = ((Event)Session["Event"]).EventID;
            currentEvent                 = RequestDirector.GetEvent(currentEvent);
            currentEvent.CustomQuestions = RequestDirector.GetQuestions(currentEvent.EventID);

            //check if event key exists
            if (currentEvent.EventKey != default(string))
            {
                //if event end time is not default value, event is over.  Can not join
                if (currentEvent.EventKey != "ZZZZ")
                {
                    //create new evaluator
                    Evaluator activeEvaluator = new Evaluator();

                    //get name if supplied
                    if (tbName.Text == "")
                    {
                        activeEvaluator.Name = "Default";
                    }
                    else
                    {
                        activeEvaluator.Name = tbName.Text;
                    }

                    //get criteria if selected
                    if (DDLCrit.Items.Count > 0)
                    {
                        activeEvaluator.Criteria = DDLCrit.SelectedValue;
                    }
                    else
                    {
                        activeEvaluator.Criteria = "Overall Quality";
                    }

                    activeEvaluator = RequestDirector.CreateEvaluator(activeEvaluator);

                    foreach (Question q in currentEvent.CustomQuestions)
                    {
                        q.EvaluatorID = activeEvaluator.EvaluatorID;

                        string responseTBID = string.Format("tb{0}", q.QID);

                        TextBox tb = (TextBox)(PanelQuestions.FindControl(responseTBID));

                        q.ResponseText = tb.Text;

                        RequestDirector.AddResponse(q);
                    }

                    //redirect to evaluate page if evaluator is created
                    if (activeEvaluator.EvaluatorID != default(int))
                    {
                        //create consent cookie if there isn't one
                        var consentCookie = Request.Cookies["ConsentCookie"];

                        if (consentCookie == null)
                        {
                            HttpCookie newConsent = new HttpCookie("ConsentCookie", "true");

                            //set cookie to expire in 100 days
                            newConsent.Expires = DateTime.UtcNow.AddDays(100);

                            Response.Cookies.Add(newConsent);
                        }

                        //Evaluation eval = new Evaluation(defaultTime, 999, activeEvaluator.EvaluatorID, currentEvent.EventID);
                        Evaluation eval = new Evaluation(DateTime.Now.ToUniversalTime(), 999, activeEvaluator.EvaluatorID, currentEvent.EventID);

                        RequestDirector.AddEvaluation(eval);

                        Session["Event"]     = currentEvent;
                        Session["Evaluator"] = activeEvaluator;
                        Response.Redirect("EvaluateEvent.aspx");
                    }
                    else
                    {
                        //error creating evaluator
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('There was an error joining this event.')", true);
                    }
                }
                else
                {
                }
            }
            else
            {
            }
        }
        else
        {
            consentCheck.ForeColor = System.Drawing.Color.Red;
        }
    }