//update facilitator password protected void UpdatePasswordBtn_Click(object sender, EventArgs e) { CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; CSS requestDirector = new CSS(); //get facilitator info Facilitator activeFac = new Facilitator(); activeFac.FacilitatorID = Convert.ToInt32(cp.Identity.Name); activeFac = requestDirector.GetFacilitator(activeFac.FacilitatorID); //if valid password, update facilitator account with new hash if (activeFac.Password == requestDirector.CreatePasswordHash(oldPasswordtxt.Text, activeFac.Salt)) { activeFac.Password = requestDirector.CreatePasswordHash(Passwordtxt.Text, activeFac.Salt); if (requestDirector.UpdateFacilitator(activeFac)) { Pswdlbl.Text = "Account Password Updated"; } else { Pswdlbl.Text = "Account Password Update Failed"; } } }
//update facilitator account info protected void UpdateBtn_Click(object sender, EventArgs e) { CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; CSS requestDirector = new CSS(); //get facilitator info Facilitator activeFac = new Facilitator(); activeFac.FacilitatorID = Convert.ToInt32(cp.Identity.Name); activeFac = requestDirector.GetFacilitator(activeFac.FacilitatorID); //check if facilitator changed email if (Emailtxt.Text != activeFac.Email) { //if new email, check if email already in use if (requestDirector.GetFacilitatorByEmail(Emailtxt.Text).Email == default(string)) { activeFac.Email = Emailtxt.Text; activeFac.FirstName = FNametxt.Text; activeFac.LastName = LNametxt.Text; activeFac.Title = Titletxt.Text; activeFac.Organization = Orgtxt.Text; activeFac.Location = Loctxt.Text; if (requestDirector.UpdateFacilitator(activeFac)) { Msglbl.Text = "Account Information Updated"; } else { Msglbl.Text = "Account Information Update Failed"; } } else { Msglbl.Text = "That email is used by another account"; } } else { activeFac.Email = Emailtxt.Text; activeFac.FirstName = FNametxt.Text; activeFac.LastName = LNametxt.Text; activeFac.Title = Titletxt.Text; activeFac.Organization = Orgtxt.Text; activeFac.Location = Loctxt.Text; if (requestDirector.UpdateFacilitator(activeFac)) { Msglbl.Text = "Account Information Updated"; } else { Msglbl.Text = "Account Information Update Failed"; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; CSS requester = new CSS(); //get facilitator info Facilitator fac = new Facilitator(); if (HttpContext.Current.User.Identity.IsAuthenticated) { fac = requester.GetFacilitator(Convert.ToInt32(cp.Identity.Name)); //tbEventDate.Text = DateTime.Today.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; CSS requestDirector = new CSS(); //get data for event facilitator Facilitator activeFac = new Facilitator(); activeFac.FacilitatorID = Convert.ToInt32(cp.Identity.Name); activeFac = requestDirector.GetFacilitator(activeFac.FacilitatorID); FNametxt.Text = activeFac.FirstName; LNametxt.Text = activeFac.LastName; Titletxt.Text = activeFac.Title; Orgtxt.Text = activeFac.Organization; Loctxt.Text = activeFac.Location; Emailtxt.Text = activeFac.Email; } }
//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) { CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; CSS Director = new CSS(); Facilitator activeFac = new Facilitator(); activeFac.FacilitatorID = Convert.ToInt32(cp.Identity.Name); activeFac = Director.GetFacilitator(activeFac.FacilitatorID); List <Event> EventList; EventList = Director.GetFacilitatorEvents(activeFac.FacilitatorID); // Displays Rows in the table foreach (Event eve in EventList) { // Display the Row for each event TableRow tRow = new TableRow(); TableCell tCell = new TableCell(); tCell.Text = eve.Date.ToLongDateString(); tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Text = eve.Location; tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Text = eve.Performer; tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Text = eve.Description; tRow.Cells.Add(tCell); tCell = new TableCell(); if (eve.EventStart != defaultTime) { if (eve.EventEnd != defaultTime) { tCell.Text = "Completed"; } else { tCell.Text = "Running"; } } else { tCell.Text = "Waiting to start"; } tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Text = eve.Evaluators.Count.ToString(); tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.CssClass = "btn-group"; Button btn = new Button(); btn.Text = "View Event"; btn.ID = String.Format("EventView{0}", eve.EventID.ToString()); btn.Click += new EventHandler(ViewEvent_Click); btn.CssClass = "btn btn-default"; tCell.Controls.Add(btn); tRow.Cells.Add(tCell); btn = new Button(); btn.Text = "Delete"; btn.ID = String.Format("EventDelete{0}", eve.EventID.ToString()); btn.Click += new EventHandler(DeleteEvent_Click); btn.OnClientClick = "return confirm('Are you sure you want to delete this event and all associated data?');"; btn.CssClass = "btn btn-default"; tCell.Controls.Add(btn); tRow.Cells.Add(tCell); tRow.Cells.Add(tCell); tblEventList.Rows.Add(tRow); } }