protected void DeleteEvent_Click(object sender, EventArgs e) { CSS RequestDirector = new CSS(); string EventID = ((Button)sender).ID; EventID = EventID.Replace("EventDelete", ""); Event selectedEvent = new Event(); selectedEvent.EventID = Convert.ToInt32(EventID); //Delete event data bool confirmation; List <Question> qs = new List <Question>(); qs = RequestDirector.GetQuestions(selectedEvent.EventID); foreach (Question q in qs) { confirmation = RequestDirector.DeleteQuestion(q); } confirmation = RequestDirector.DeleteEventData(selectedEvent); //Delete event confirmation = RequestDirector.DeleteEvent(selectedEvent); //refresh to remove from list Response.Redirect("Events.aspx"); }
protected void UpdateBtn_Click(object sender, EventArgs e) { CSS RequestDirector = new CSS(); Event currentEvent = new Event(); currentEvent.EventID = ((Event)Session["Event"]).EventID; bool success; currentEvent = RequestDirector.GetEvent(currentEvent); currentEvent.Performer = tbPerformer.Text; currentEvent.Description = tbDesc.Text; currentEvent.Location = tbLocation.Text; currentEvent.OpenMsg = tbOpen.Text; currentEvent.CloseMsg = tbClose.Text; currentEvent.Date = DateTime.Today; string crit = ""; if (allCritLB.Items.Count > 0) { foreach (ListItem i in allCritLB.Items) { crit += (i.Text + '|'); } crit.TrimEnd('|'); } else { crit = "Overall Quality"; } currentEvent.VotingCrit = crit; success = RequestDirector.UpdateEventInfo(currentEvent); if (success) { List <Question> questions = new List <Question>(); questions = RequestDirector.GetQuestions(currentEvent.EventID); foreach (Question q in questions) { RequestDirector.DeleteQuestion(q); } Question qu; foreach (ListItem li in allQsLB.Items) { qu = new Question(); qu.EventID = currentEvent.EventID; qu.QuestionText = li.Text; RequestDirector.AddQuestion(qu); } } }
protected void RepeatBtn_Click(object sender, EventArgs e) { CSS RequestDirector = new CSS(); Event currentEvent = new Event(); currentEvent.EventID = ((Event)Session["Event"]).EventID; currentEvent = RequestDirector.GetEvent(currentEvent); currentEvent.CustomQuestions = RequestDirector.GetQuestions(currentEvent.EventID); Event repeatEvent = new Event(); //default value for event start and end times DateTime defaultTime = Convert.ToDateTime("1800-01-01 12:00:00 PM"); //get facilitator info and event info input CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; repeatEvent.EventKey = "AAAA"; repeatEvent.FacilitatorID = Convert.ToInt32(cp.Identity.Name); repeatEvent.Performer = currentEvent.Performer; repeatEvent.Location = currentEvent.Location; repeatEvent.Description = currentEvent.Description; repeatEvent.Date = DateTime.Today; repeatEvent.OpenMsg = currentEvent.OpenMsg; repeatEvent.CloseMsg = currentEvent.CloseMsg; repeatEvent.VotingCrit = currentEvent.VotingCrit; //attept event creation Event newEvent = RequestDirector.CreateEvent(repeatEvent); //if successful, add event to session and redirect to view event if (newEvent.EventID != -1) { Question q; foreach (Question que in currentEvent.CustomQuestions) { q = new Question(); q.EventID = newEvent.EventID; q.QuestionText = que.QuestionText; RequestDirector.AddQuestion(q); } Session["Event"] = newEvent; Response.Redirect("ViewEvent.aspx"); } }
protected void DeleteBtn_Click(object sender, EventArgs e) { CSS RequestDirector = new CSS(); CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; bool confirmation; Facilitator activeFac = new Facilitator(); activeFac.FacilitatorID = Convert.ToInt32(cp.Identity.Name); //delete event data List <Event> events = RequestDirector.GetFacilitatorEvents(activeFac.FacilitatorID); List <Question> eventQs; foreach (Event ev in events) { eventQs = new List <Question>(); eventQs = RequestDirector.GetQuestions(ev.EventID); foreach (Question q in eventQs) { confirmation = RequestDirector.DeleteQuestion(q); } confirmation = RequestDirector.DeleteEventData(ev); confirmation = RequestDirector.DeleteEvent(ev); } //delete account confirmation = RequestDirector.DeleteFacilitator(activeFac); //sign out FormsAuthentication.SignOut(); Response.Redirect("Default.aspx", true); }
//export event data to .csv for external use protected void Export_Click(object sender, EventArgs e) { //Initialize instances of all neccessary classes and director CSS Director = new CSS(); Event theEvent = new Event(); Facilitator Facilitator = new Facilitator(); //List<Evaluation> Evaluations = new List<Evaluation>(); StringBuilder csvcontent = new StringBuilder(); DateTime addEval; DateTime defaultTime = Convert.ToDateTime("1800-01-01 12:00:00 PM"); //Set the Event.ID of our empty event, and use said event to pull event information from DB theEvent.EventID = ((Event)Session["Event"]).EventID; theEvent = Director.GetEvent(theEvent); theEvent.Evaluators = Director.GetEvaluatorsForEvent(theEvent.EventID); foreach (Evaluator eva in theEvent.Evaluators) { eva.EvaluatorEvaluations.RemoveAll(x => x.Rating == 999); } List <Question> questions = new List <Question>(); questions = Director.GetQuestions(theEvent.EventID); List <Question> answers = new List <Question>(); Question que; foreach (Question q in questions) { foreach (Evaluator ev in theEvent.Evaluators) { que = new Question(); que.QID = q.QID; que.EvaluatorID = ev.EvaluatorID; que = Director.GetResponse(que); ev.Responses.Add(que); } } Facilitator = Director.GetFacilitator(1); //Creates the first section of data in the CSV, regarding the Facilitators info. Data is formatted in two lines, the first line being the data description, the second line being the respective data. csvcontent.AppendLine("Event Creator,Organization"); csvcontent.AppendLine(Facilitator.FirstName + " " + Facilitator.LastName + "," + Facilitator.Organization); csvcontent.AppendLine("\n"); //Creates the second line of data in the CSV, regarding the Events info. Formatted as above. csvcontent.AppendLine("Event,Performer,Location,Date of Event,Start Time,End Time"); csvcontent.AppendLine(theEvent.Description + "," + theEvent.Performer + "," + theEvent.Location + "," + theEvent.Date.ToShortDateString() + "," + theEvent.EventStart.ToLongTimeString() + "," + theEvent.EventEnd.ToLongTimeString()); csvcontent.AppendLine("\n"); //get start and end times for table. Convert to local time DateTime eventStart = theEvent.EventStart.ToLocalTime(); DateTime eventEnd = theEvent.EventEnd.ToLocalTime(); double secsBetweenPoints = 0.5; //iterate every 0.5 second //display timestamp for every 0.5 s List <string> timestamps = new List <string>(); for (DateTime i = eventStart; i <= eventEnd; i = i.AddSeconds(secsBetweenPoints)) { timestamps.Add(String.Format("{0}", (i - eventStart).ToString(@"hh\:mm\:ss\:fff"))); } string tsLine = "ID #,Name,"; foreach (Question q in questions) { tsLine += q.QuestionText + ","; } tsLine += "Voting Criteria,Time of First Rating, Time of Last Rating, TimeStamp (HH:MM:SS.mmm):,"; for (int k = 0; k < timestamps.Count; k++) { if (k == timestamps.Count - 1) { tsLine += timestamps[k]; } else { tsLine += (timestamps[k] + ","); } } csvcontent.AppendLine(tsLine); //Add all evaluator evaluations Evaluator _evaluator = new Evaluator(); Evaluation _evaluation = new Evaluation(); int evalCount = 0; string insert; foreach (Evaluator eval in theEvent.Evaluators) { insert = eval.EvaluatorID.ToString() + "," + eval.Name + ","; //add q answers foreach (Question r in eval.Responses) { insert += r.ResponseText + ","; } insert += eval.Criteria + ","; if (eval.EvaluatorEvaluations.Count > 0) { insert += (eval.EvaluatorEvaluations.First().TimeStamp.ToLocalTime() - theEvent.EventStart).ToString() + ","; insert += (eval.EvaluatorEvaluations.Last().TimeStamp.ToLocalTime() - theEvent.EventStart).ToString() + ","; } else { insert += "--:--:--,--:--:--,,"; } for (DateTime i = eventStart; i <= eventEnd; i = i.AddSeconds(secsBetweenPoints)) { if (eval.EvaluatorEvaluations.Count > 0) { if (eval.EvaluatorEvaluations[0].TimeStamp.ToLocalTime() <= i) { evalCount = 0; while (evalCount < eval.EvaluatorEvaluations.Count - 1) { //get the last evaluation before time i if (eval.EvaluatorEvaluations[evalCount].TimeStamp.ToLocalTime() <= i) { //ev = e.EvaluatorEvaluations[evalCount]; evalCount++; } else { break; } } //get time from the start of the event //double timestamp = (i - eventStart).TotalMilliseconds; insert += eval.EvaluatorEvaluations[evalCount].Rating.ToString() + " ,"; } else { insert += " ,"; } } } csvcontent.AppendLine(insert); } //Clear the response and re package it as a downloadable CSV file Response.Clear(); Response.ContentType = "text/csv"; Response.AddHeader("Content-Disposition", "attachment;filename=EventData.csv"); Response.Write(csvcontent.ToString()); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page); scriptManager.RegisterPostBackControl(this.Export); DateTime defaultTime = Convert.ToDateTime("1800-01-01 12:00:00 PM"); if (!IsPostBack) { CSS Director = new CSS(); //for comparing default values of event start and end times. //Get evaluation data for chosen event Event theEvent = new Event(); theEvent.EventID = ((Event)Session["Event"]).EventID; theEvent = Director.GetEvent(theEvent); theEvent.CustomQuestions = Director.GetQuestions(theEvent.EventID); if (theEvent.EventKey == "AAAA") { upTable.Visible = false; PanelButtons.Visible = false; PanelPreLabel.Visible = true; PanelPostLabel.Visible = false; tbEventID.Text = "Generate Key"; tbPerformer.ReadOnly = false; tbDesc.ReadOnly = false; tbLocation.ReadOnly = false; tbOpen.ReadOnly = false; tbClose.ReadOnly = false; allCritLB.Enabled = true; allQsLB.Enabled = true; newQTB.Visible = true; critTxt.Visible = true; AddCritBTN.Enabled = true; AddCritBTN.Visible = true; RemoveCritBRN.Enabled = true; RemoveCritBRN.Visible = true; AddQBTN.Enabled = true; AddQBTN.Visible = true; RemoveQBTN.Enabled = true; RemoveQBTN.Visible = true; TimerForTableRefresh.Enabled = false; PanelCharts.Visible = false; } else { if (theEvent.EventKey == "ZZZZ") { tbEventID.Text = "Key Expired"; } else { tbEventID.Text = theEvent.EventKey; } upTable.Visible = true; PanelButtons.Visible = true; PanelPreLabel.Visible = false; PanelPostLabel.Visible = true; tbPerformer.ReadOnly = true; tbDesc.ReadOnly = true; tbLocation.ReadOnly = true; tbOpen.ReadOnly = true; tbClose.ReadOnly = true; allCritLB.Enabled = false; allQsLB.Enabled = false; newQTB.Visible = false; critTxt.Visible = false; AddCritBTN.Enabled = false; AddCritBTN.Visible = false; RemoveCritBRN.Enabled = false; RemoveCritBRN.Visible = false; AddQBTN.Enabled = false; AddQBTN.Visible = false; RemoveQBTN.Enabled = false; RemoveQBTN.Visible = false; GenKeyBtn.Enabled = false; GenKeyBtn.Visible = false; UpdateBtn.Enabled = false; UpdateBtn.Visible = false; } tbPerformer.Text = theEvent.Performer; tbLocation.Text = theEvent.Location; tbDate.Text = theEvent.Date.ToLongDateString(); tbDesc.Text = theEvent.Description; tbOpen.Text = theEvent.OpenMsg; tbClose.Text = theEvent.CloseMsg; foreach (Question q in theEvent.CustomQuestions) { allQsLB.Items.Add(new ListItem(q.QuestionText, q.QuestionText)); } string[] crits = theEvent.VotingCrit.Split('|'); DropDownListCrit.Items.Add(new ListItem("All Evaluations", "All Evaluations")); foreach (string s in crits) { if (s.Length > 0) { allCritLB.Items.Add(new ListItem(s, s)); DropDownListCrit.Items.Add(new ListItem(s, s)); } } //if the event has ended disable start/end buttons and generate charts and table if (theEvent.EventEnd != defaultTime) { tbStart.Text = theEvent.EventStart.ToLocalTime().ToLongTimeString(); tbEnd.Text = theEvent.EventEnd.ToLocalTime().ToLongTimeString(); ButtonStart.Enabled = false; ButtonEnd.Enabled = false; Export.Enabled = true; TimerForTableRefresh.Enabled = false; RepeatBtn.Enabled = true; BuildTable(); PanelCharts.Visible = true; string chartCrit; string chartMath; if (Session["criteria"] == null) { chartCrit = "All Evaluations"; } else { chartCrit = Session["criteria"].ToString(); DropDownListCrit.SelectedValue = chartCrit; } if (Session["math"] == null) { chartMath = "Mean"; } else { chartMath = Session["math"].ToString(); DropDownListMath.SelectedValue = chartMath; } BuildCharts(chartCrit, chartMath); } else { TimerForTableRefresh.Enabled = true; //if event has not begun if (theEvent.EventStart == defaultTime) { tbStart.Text = "--:--:--"; tbEnd.Text = "--:--:--"; ButtonStart.Enabled = true; ButtonEnd.Enabled = false; Export.Enabled = false; RepeatBtn.Enabled = false; //TimerForTableRefresh.Enabled = true; } //if event is still active else { tbStart.Text = theEvent.EventStart.ToLocalTime().ToLongTimeString(); tbEnd.Text = "--:--:--"; ButtonStart.Enabled = false; //TimerForTableRefresh.Enabled = true; Export.Enabled = false; ButtonEnd.Enabled = true; RepeatBtn.Enabled = false; } } } else { //BuildTable(); //BuildCharts(); } }
protected void Page_Load(object sender, EventArgs e) { //if (!IsPostBack) //{ CSS RequestDirector = new CSS(); DateTime defaultTime = Convert.ToDateTime("1800-01-01 12:00:00 PM"); Event ActiveEvent = new Event(); ActiveEvent.EventID = ((Event)Session["Event"]).EventID; ActiveEvent = RequestDirector.GetEvent(ActiveEvent); ActiveEvent.CustomQuestions = RequestDirector.GetQuestions(ActiveEvent.EventID); tbLocation.Text = ActiveEvent.Location; tbDescription.Text = ActiveEvent.Description; tbPerformer.Text = ActiveEvent.Performer; if (ActiveEvent.OpenMsg.Length > 0) { PanelOpenMsg.Visible = true; TBOpenMsg.Text = ActiveEvent.OpenMsg; } if (ActiveEvent.VotingCrit.Length > 0) { PanelCrit.Visible = true; string[] crits = ActiveEvent.VotingCrit.Split('|'); ListItem li; foreach (string s in crits) { if (s.Length > 0) { li = new ListItem(s, s); DDLCrit.Items.Add(li); } } } if (ActiveEvent.CustomQuestions.Count > 0) { PanelQuestions.Visible = true; Label tbq; TextBox tba; foreach (Question q in ActiveEvent.CustomQuestions) { tbq = new Label(); tbq.Text = q.QuestionText; tbq.Font.Bold = true; PanelQuestions.Controls.Add(tbq); tba = new TextBox(); tba.ID = string.Format("tb{0}", q.QID); tba.CssClass = "form-control"; PanelQuestions.Controls.Add(tba); } } }
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; } }