public static void updateReviewedStatus(bool isReviewed, int CWID) { try { using (var db = new HearMyNameEntities()) { StudentRecording originalRecord = db.StudentRecordings.Find(CWID); originalRecord.isReviewed = isReviewed; db.SaveChanges(); } } catch (Exception ex) { } }
protected void LoadData() { if (isNSO) { btnUpdate.Value = "Save and Log Out"; } int numericCWID = Int32.Parse(CWID); hdrMainHeader.InnerText = Name; using (var db = new HearMyNameEntities()) { if (db.StudentRecordings.FirstOrDefault(A => A.StudentCWID == numericCWID) != null) //this is an update { StudentRecording previousRecord = db.StudentRecordings.First(A => A.StudentCWID == numericCWID); if (!IsPostBack) { txtPreferredName.Value = previousRecord.StudentPreferredName.Replace("(student)", ""); txtPhoneticName.Value = previousRecord.Pronounciation; if (audioPlayer.Src == null || audioPlayer.Src.Contains("Default")) { audioPlayer.Attributes["src"] = $"~/userfiles/converted/{CWID}.mp3?noCache={new Random().Next(0, 1000).ToString()}"; //the NoCache parameter just makes it so that the name looks different to the browser so it doesn't cache it. } else { playButton.Disabled = true; } } recordingID = previousRecord.ID; hdnRecordingID.Value = recordingID.ToString(); } else //This is a recording for a student has never done this before { txtPreferredName.Value = Name; playButton.Disabled = true; hdnRecordingID.Value = "0"; } } }
private string getStudentNameFromCWID(string cwid) { ICasPrincipal p = HttpContext.Current.User as ICasPrincipal; string fullName = string.Empty; StudentInformation info = new StudentInformation(); using (var db = new HearMyNameEntities()) { info = db.StudentInformations.FirstOrDefault(A => A.EMPLID.Equals(cwid.ToString().Trim())); } if (info == null) { fullName = (p == null ? "Daniil Gedgafov" : p.Assertion.Attributes["displayName"][0]); } else { fullName = info.FIRST_NAME + ' ' + info.MIDDLE_NAME + ' ' + info.LAST_NAME; } return(fullName); }
protected void Page_Load(object sender, EventArgs e) { int cwid = CasAuthentication.CurrentPrincipal == null ? 100 : Int32.Parse(CasAuthentication.CurrentPrincipal.Assertion.Attributes["employeeID"][0]); if (Helpers.HearMyNameHelper.isUserAnAdmin(cwid)) { using (var db = new HearMyNameEntities()) { foreach (LatestRecordingStatus r in db.LatestRecordingStatuses) { TableRow newRow = new TableRow(); TableCell CWIDcell = new TableCell(); TableCell systemNameCell = new TableCell(); TableCell preferredNameCell = new TableCell(); TableCell phoneticCell = new TableCell(); TableCell playCell = new TableCell(); TableCell reviewCell = new TableCell(); CWIDcell.Text = r.StudentCWID.ToString(); systemNameCell.Text = r.StudentName.Replace("(student)", ""); preferredNameCell.Text = r.StudentPreferredName.Replace("(student)", ""); phoneticCell.Text = r.Pronounciation; //Audio Play Cell var play = new HtmlGenericControl("audio"); play.ID = r.StudentCWID + "Audio"; play.ClientIDMode = System.Web.UI.ClientIDMode.Static; play.Attributes.Add("class", "AudioControl"); play.Attributes.Add("hidden", "true"); play.Attributes.Add("src", $"{ResolveUrl("~/userfiles/converted/")}{r.StudentCWID}.mp3?noCache={new Random().Next(0, 1000).ToString()}"); HtmlButton playButton = new HtmlButton(); var span = new HtmlGenericControl("i"); span.Attributes["class"] = "fa fa-fw fa-headphones"; playButton.Controls.Add(span); playButton.Attributes.Add("class", "secondary-btn"); playButton.Attributes.Add("type", "button"); playButton.Attributes.Add("style", "width: 100%; min-width: 5em"); playButton.ClientIDMode = System.Web.UI.ClientIDMode.Static; playButton.ID = r.StudentCWID + "PlayButton"; playButton.InnerText = "Play Back"; playButton.Attributes.Add("onClick", "play('" + r.StudentCWID + "');"); playCell.Controls.Add(play); playCell.Controls.Add(playButton); //Review Cell: reviewCell.CssClass = "text-center"; CheckBox chkIsReviewed = new CheckBox(); chkIsReviewed.Checked = r.isReviewed ?? false; chkIsReviewed.ID = "chk" + r.ID; chkIsReviewed.CssClass = "largerCheckbox"; chkIsReviewed.ClientIDMode = ClientIDMode.Static; chkIsReviewed.Attributes["onClick"] = "updateCheckedStatus(" + r.ID + ")"; reviewCell.Controls.Add(chkIsReviewed); newRow.Controls.Add(CWIDcell); newRow.Controls.Add(systemNameCell); newRow.Controls.Add(preferredNameCell); newRow.Controls.Add(phoneticCell); newRow.Controls.Add(playCell); newRow.Controls.Add(reviewCell); newRow.TableSection = TableRowSection.TableBody; recordingsList.Controls.Add(newRow); } } } else //the current user is not an admin and shouldn't be messing with the review console. { Server.Transfer("../HearNames.aspx"); } }
//copy the recording from the project directory to the file server (Waxmyrtle) and delete the current project directory copy. //save/update db record for the student. protected static string updateDatabase(int recordingID, string email, string pronounciation, string studentSystemName, string NTID, string preferredName, string currentUserID) { int numericCWID = Int32.Parse(currentUserID); try { using (var db = new HearMyNameEntities()) { string newRecodingID = string.Empty; if (recordingID > 0) //a record exists, this is an UPdate { StudentRecording originalRecord = db.StudentRecordings.Find(recordingID); originalRecord.StudentPreferredName = preferredName; originalRecord.Pronounciation = pronounciation; AppEvent newAppEvent = new AppEvent { RecordingID = recordingID, ActionPerformed = "Updated recording", NewStatus = "NotApproved", PerformedBy = 1, PerformedOn = DateTime.Now }; db.AppEvents.Add(newAppEvent); } else //this is a new record, inserrrrt! { StudentRecording newRecord = new StudentRecording { StudentCWID = int.Parse(currentUserID), StudentNTID = NTID, StudentName = studentSystemName, StudentPreferredName = string.IsNullOrEmpty(preferredName) ? " " : preferredName, Pronounciation = string.IsNullOrEmpty(pronounciation) ? " " : pronounciation, StudentEmail = email, CreatedBy = currentUserID, CreatedOn = DateTime.Now }; AppEvent newAppEvent = new AppEvent { ActionPerformed = "Created a new recording", NewStatus = "NotApproved", PerformedBy = 1, PerformedOn = DateTime.Now }; newRecord.AppEvents = new List <AppEvent>(); newRecord.AppEvents.Add(newAppEvent); db.StudentRecordings.Add(newRecord); } db.SaveChanges(); StudentRecording previousRecord = db.StudentRecordings.First(A => A.StudentCWID == numericCWID); return(previousRecord.ID.ToString()); } } catch (Exception exe) { LogHelper.LogError(exe.ToString()); return(string.Empty); } }
private void loadData(string bulkSearch) { string possibleBulkSearch = string.Empty; if (!string.IsNullOrEmpty(Request.QueryString["BulkSearch"])) { possibleBulkSearch = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(HttpUtility.UrlDecode(Request.QueryString["BulkSearch"]))); groupSearchTextBox.InnerText = possibleBulkSearch; } List <string> bulkSearchQuery = groupSearchTextBox.InnerText.Trim().Split(',').Select(p => p.Trim()).ToList(); using (var db = new HearMyNameEntities()) { List <LatestRecordingStatus> searchSet; if (string.IsNullOrEmpty(possibleBulkSearch) && string.IsNullOrEmpty(bulkSearch)) { searchSet = db.LatestRecordingStatuses.ToList(); } else { searchSet = (from LatestRecordingStatus in db.LatestRecordingStatuses where bulkSearchQuery.Contains(LatestRecordingStatus.StudentCWID.ToString()) select LatestRecordingStatus).ToList(); } foreach (LatestRecordingStatus r in searchSet) { TableRow newRow = new TableRow(); TableCell CWIDcell = new TableCell(); TableCell systemNameCell = new TableCell(); TableCell preferredNameCell = new TableCell(); TableCell phoneticCell = new TableCell(); TableCell playCell = new TableCell(); CWIDcell.Text = r.StudentCWID.ToString(); systemNameCell.Text = r.StudentName.Replace("(student)", ""); preferredNameCell.Text = r.StudentPreferredName.Replace("(student)", ""); phoneticCell.Text = r.Pronounciation; //Audio Play Cell var play = new HtmlGenericControl("audio"); play.ID = r.StudentCWID + "Audio"; play.ClientIDMode = System.Web.UI.ClientIDMode.Static; play.Attributes.Add("class", "AudioControl"); play.Attributes.Add("hidden", "true"); play.Attributes.Add("src", $"{ResolveUrl("~/userfiles/converted/")}{r.StudentCWID}.mp3?noCache={new Random().Next(0, 1000).ToString()}"); HtmlButton playButton = new HtmlButton(); var span = new HtmlGenericControl("i"); span.Attributes["class"] = "fa fa-fw fa-headphones"; playButton.Controls.Add(span); playButton.Attributes.Add("class", "secondary-btn"); playButton.Attributes.Add("type", "button"); playButton.Attributes.Add("style", "width: 100%; min-width: 5em"); playButton.ClientIDMode = System.Web.UI.ClientIDMode.Static; playButton.ID = r.StudentCWID + "PlayButton"; playButton.InnerText = "Play Back"; playButton.Attributes.Add("onClick", "play('" + r.StudentCWID + "');"); playCell.Controls.Add(play); playCell.Controls.Add(playButton); newRow.Controls.Add(CWIDcell); newRow.Controls.Add(systemNameCell); newRow.Controls.Add(preferredNameCell); newRow.Controls.Add(phoneticCell); newRow.Controls.Add(playCell); newRow.TableSection = TableRowSection.TableBody; recordingsList.Controls.Add(newRow); } } }