protected void AddNewStaff(object sender, EventArgs e) { var environmentParametersViewModel = new EnvironmentParametersFactory(AppSettings.ConnectionStringName).GetEnvironmentParameters(); var staffManagement = new StaffManagement(environmentParametersViewModel); var doesUserExist = staffManagement.DoesUserExist(loginID.Text); staffManagement.Dispose(); if (doesUserExist) { var radalertscript = "<script language='javascript'>function f(){radalert('" + string.Format("Cannot Add User, this user already exists. User: {0}", loginID.Text) + "', 300, 300, 'Duplicate User Detected'); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>"; Page.ClientScript.RegisterStartupScript(GetType(), "radalert", radalertscript); return; } var staffIdentificationTable = new dtGeneric_String_String(); var schoolIdTable = new dtGeneric_Int(); var userTypeIdTable = new dtGeneric_String(); string restrictionsValue = string.Empty ; staffIdentificationTable.Rows.Add("FirstName", firstName.Text); staffIdentificationTable.Rows.Add("MiddleName", middleName.Text); staffIdentificationTable.Rows.Add("LastName", lastName.Text); staffIdentificationTable.Rows.Add("Email", email.Text); staffIdentificationTable.Rows.Add("LoginID", loginID.Text); switch (DataIntegrity.ConvertToInt(restrictionsDropdown.SelectedIndex)) // using index is not best way to accomplish this... but easy to fix in the future if we need to reorder dropdown { case (int)Restrictions.None: staffIdentificationTable.Rows.Add("IsLockedOut", "false"); staffIdentificationTable.Rows.Add("IsApproved", "true"); staffIdentificationTable.Rows.Add("Restrictions", "None"); restrictionsValue = "None"; break; case (int)Restrictions.Revoked: staffIdentificationTable.Rows.Add("IsLockedOut", "false"); staffIdentificationTable.Rows.Add("IsApproved", "false"); staffIdentificationTable.Rows.Add("Restrictions", "None"); restrictionsValue = "None"; break; case (int)Restrictions.LockedOut: staffIdentificationTable.Rows.Add("IsLockedOut", "true"); staffIdentificationTable.Rows.Add("IsApproved", "true"); staffIdentificationTable.Rows.Add("Restrictions", "None"); restrictionsValue = "None"; break; case (int)Restrictions.ChangePassword: staffIdentificationTable.Rows.Add("IsLockedOut", "false"); staffIdentificationTable.Rows.Add("IsApproved", "true"); staffIdentificationTable.Rows.Add("Restrictions", ThinkgateUser.ChangePasswordRestrictionValue); restrictionsValue = ThinkgateUser.ChangePasswordRestrictionValue.ToString(CultureInfo.InvariantCulture); break; } foreach (RadComboBoxItem item in schoolDropdown.Items) { var itemCheckbox = (CheckBox)item.FindControl("schoolCheckbox"); var itemLabel = (Label)item.FindControl("schoolLabel"); if (itemCheckbox != null && itemCheckbox.Checked && itemLabel.Text != @"All" && itemLabel.Text.ToLower().IndexOf("<img", StringComparison.Ordinal) == -1) { schoolIdTable.Add(DataIntegrity.ConvertToInt(item.Value)); } } StringBuilder userSyncRoles = new StringBuilder(); foreach (RadComboBoxItem item in userTypeDropdown.Items) { var itemCheckbox = (CheckBox)item.FindControl("userTypeCheckbox"); var itemLabel = (Label)item.FindControl("userTypeLabel"); if (itemCheckbox != null && itemCheckbox.Checked && itemLabel.Text != @"All" && itemLabel.Text.ToLower().IndexOf("<img", StringComparison.Ordinal) == -1) { userTypeIdTable.Add(item.Text); userSyncRoles.Append(itemLabel.Text); } } /* Create the user record */ /* Validate Results - if error, give message and go back to user */ SqlParameterCollection parms = new SqlCommand().Parameters; parms.AddWithValue("ApplicationName", AppSettings.ApplicationName); parms.AddWithValue("UserName", loginID.Text); parms.AddWithValue("FirstName", firstName.Text); parms.AddWithValue("MiddleName", middleName.Text); parms.AddWithValue("LastName", lastName.Text); parms.AddWithValue("Password", DistrictParms.LoadDistrictParms().DefaultPasswordEncrypted); parms.AddWithValue("PasswordSalt", DistrictParms.LoadDistrictParms().DefaultPasswordEncryptedSalt); parms.AddWithValue("Email", email.Text); parms.Add(ThinkgateDataAccess.GetParmFromTable(userTypeIdTable.ToSql(), "Roles")); parms.Add(ThinkgateDataAccess.GetParmFromTable(schoolIdTable.ToSql(), "Schools")); parms.AddWithValue("PrimarySchool", DataIntegrity.ConvertToInt(cmbPrimarySchool.SelectedItem.Value)); parms.AddWithValue("PrimaryUser", cmbPrimaryUser.SelectedItem.Text); parms.AddWithValue("TeacherID", string.Empty); parms.AddWithValue("Restrictions", restrictionsValue); var drNewStaffUserPage = ThinkgateDataAccess.FetchDataRow(AppSettings.ConnectionString, Base.Classes.Data.StoredProcedures.ASPNET_TG_SECURITY_USER_CREATE_USER, System.Data.CommandType.StoredProcedure, parms, SessionObject.GlobalInputs); /* * Extract UserPage ID out of recordset and put in hidden field so that when we return to the client side, we * can offer user (through javascript) the opportunity to bring up Staff Object Page with new staff in it. */ if (drNewStaffUserPage != null) { hdnNewStaffIDEncrypted.Value = Standpoint.Core.Classes.Encryption.EncryptString(drNewStaffUserPage["UserPage"].ToString()); KenticoBusiness.AddUserAndRoles(loginID.Text); } //Dan - UserSync - Queue a UserSync Message here! //TODO: Michael Rue - complete user sync functionality //UserSyncHelperFactory.GetMsmqHelper().AddOrUpdateUser(loginID.Text, loginID.Text, null, email.Text, JsonConvert.SerializeObject(userSyncRoles)); ScriptManager.RegisterStartupScript(this, typeof(AddStaff), "AddedStaff", "autoSizeWindow();", true); resultPanel.Visible = true; addPanel.Visible = false; lblResultMessage.Text = @"Staff successfully added!"; }
protected void UpdateStaff(object sender, EventArgs e) { lblResultMessage.Text = string.Empty; var staffIdentificationTable = new dtGeneric_String_String(); var schoolIDTable = new dtGeneric_Int(); var userTypeIDTable = new dtGeneric_String(); string currLoginID = _selectedStaff.LoginID; string newLoginID = loginID.Text; string imageFileName = string.Empty; if (imgPhoto.Src != string.Empty) { imageFileName = Path.GetFileName(imgPhoto.Src); } staffIdentificationTable.Rows.Add("FirstName", firstName.Text); staffIdentificationTable.Rows.Add("MiddleName", middleName.Text); staffIdentificationTable.Rows.Add("LastName", lastName.Text); staffIdentificationTable.Rows.Add("Email", email.Text); staffIdentificationTable.Rows.Add("LoginID", loginID.Text); staffIdentificationTable.Rows.Add("Image_FileName", imageFileName); //staffIdentificationTable.Rows.Add("Restrictions", restrictionsDropdown.Text); switch (DataIntegrity.ConvertToInt(restrictionsDropdown.SelectedIndex)) // using index is not best way to accomplish this... but easy to fix in the future if we need to reorder dropdown { case (int) Restrictions.None: staffIdentificationTable.Rows.Add("IsLockedOut", "false"); staffIdentificationTable.Rows.Add("IsApproved", "true"); staffIdentificationTable.Rows.Add("Restrictions", "None"); break; case (int) Restrictions.Revoked: staffIdentificationTable.Rows.Add("IsLockedOut", "false"); staffIdentificationTable.Rows.Add("IsApproved", "false"); staffIdentificationTable.Rows.Add("Restrictions", "None"); break; case (int) Restrictions.LockedOut: staffIdentificationTable.Rows.Add("IsLockedOut", "true"); staffIdentificationTable.Rows.Add("IsApproved", "true"); staffIdentificationTable.Rows.Add("Restrictions", "None"); break; case (int) Restrictions.ChangePassword: staffIdentificationTable.Rows.Add("IsLockedOut", "false"); staffIdentificationTable.Rows.Add("IsApproved", "true"); staffIdentificationTable.Rows.Add("Restrictions", ThinkgateUser.ChangePasswordRestrictionValue); break; } foreach(RadComboBoxItem item in schoolDropdown.Items) { CheckBox itemCheckbox = (CheckBox)item.FindControl("schoolCheckbox"); Label itemLabel = (Label)item.FindControl("schoolLabel"); if (itemCheckbox != null && itemCheckbox.Checked && itemLabel.Text != "All" && itemLabel.Text.IndexOf("<img") == -1) { schoolIDTable.Add(DataIntegrity.ConvertToInt(item.Value)); } } List<String> userSyncRoles = new List<string>(); foreach (RadComboBoxItem item in userTypeDropdown.Items) { CheckBox itemCheckbox = (CheckBox)item.FindControl("userTypeCheckbox"); Label itemLabel = (Label)item.FindControl("userTypeLabel"); if (itemCheckbox != null && itemCheckbox.Checked && itemLabel.Text != "All" && itemLabel.Text.IndexOf("<img") == -1) { userTypeIDTable.Add(item.Value); userSyncRoles.Add(itemLabel.Text); } } Base.Classes.Staff.UpdateStaff(staffIdentificationTable, schoolIDTable, userTypeIDTable, _selectedStaff.UserID.ToString(), DataIntegrity.ConvertToInt(cmbPrimarySchool.SelectedItem.Value), cmbPrimaryUser.SelectedItem.Text.ToLower()); if (_fromTeacherPage) Base.Classes.Cache.Remove("Teacher_" + GetDecryptedEntityId(X_ID)); Base.Classes.Cache.Remove("Staff_" + GetDecryptedEntityId(X_ID)); //Dan - UserSync - Queue a UserSync Message here! //string usroles = JsonConvert.SerializeObject(userSyncRoles); //TODO: Michael Rue - complete user sync functionality //UserSyncHelperFactory.GetMsmqHelper().AddOrUpdateUser(currLoginID, newLoginID, null, email.Text, usroles); string js = "parent.window.location.reload();"; ScriptManager.RegisterStartupScript(Page, typeof(Page), "StaffIdentificationEditSaveAndClose", js, true); }
/// <summary> /// Save the scores to the respective students to the database. /// </summary> void SaveStudentScores() { dtGeneric_String_String studentScore = new dtGeneric_String_String(); foreach (RepeaterItem rpItem in rptScores.Items.AsParallel()) { string calculatedScore = default(string); if (ScoreType.Equals(Enums.ScoreType.P) || ScoreType.Equals(ScoreType.S)) { calculatedScore = (string.IsNullOrEmpty(((RadNumericTextBox)rpItem.FindControl("radTxtScores")).Text.Trim()) || ScoreType.Equals(ScoreType.S)) ? ((RadNumericTextBox)rpItem.FindControl("radTxtScores")).Text : (Convert.ToDouble(((RadNumericTextBox)rpItem.FindControl("radTxtScores")).Text.Trim()) * .01).ToString(); } else { calculatedScore = ((RadioButtonList)rpItem.FindControl("radScore")).SelectedValue; } studentScore.Add(((HiddenField)rpItem.FindControl("hidStudentID")).Value, calculatedScore); } Student.SaveStudentScore(ClassID, TestID, ScoreType.ToString(), studentScore); }
protected void Page_Load(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); Stopwatch stopwatch = new Stopwatch(); // Begin timing drGeneric_String_String dr1 = new drGeneric_String_String(); stopwatch.Start(); for (var x = 0; x < 100; x++) { //CourseList classCourses = CourseMasterList.GetClassCoursesForUser(SessionObject.LoggedInUser); //DataTable temp = ThinkgateDataAccess.FetchDataTable("E3_WesTempTest", new object[] { classCourses.ToSql() }); //dr1 = ThinkgateDataAccess.wesTest(); } /*foreach (Course c in classCourses) { Console.WriteLine(c.Subject); }*/ stopwatch.Stop(); sb.Append("X: " + dr1[1].Value + "<br/>"); sb.Append("A: " + stopwatch.Elapsed + "<br/>"); drGeneric_String_String dr2 = new drGeneric_String_String(); stopwatch.Reset(); stopwatch.Start(); for (var y = 0; y < 100; y++) { /*DataTable classCoursesX = CourseMasterList2.GetClassCoursesForUser(SessionObject.LoggedInUser); dtGeneric_Int x1 = new dtGeneric_Int(); foreach (DataRow row in classCoursesX.Rows) { x1.Add(DataIntegrity.ConvertToInt(row["ID"])); } DataTable temp4 = ThinkgateDataAccess.FetchDataTable("E3_WesTempTest", new object[] { x1.ToSql() }); */ //dr2 = ThinkgateDataAccess.wesTest2(); } stopwatch.Stop(); sb.Append("X: " + dr2[1].Value + "<br/>"); sb.Append("G: " + stopwatch.Elapsed + "<br/>"); dtGeneric_String_String dt1 = new dtGeneric_String_String(); stopwatch.Reset(); stopwatch.Start(); for (var y = 0; y < 100; y++) { /*DataTable classCoursesX = CourseMasterList2.GetClassCoursesForUser(SessionObject.LoggedInUser); dtGeneric_Int x1 = new dtGeneric_Int(); foreach (DataRow row in classCoursesX.Rows) { x1.Add(DataIntegrity.ConvertToInt(row["ID"])); } DataTable temp4 = ThinkgateDataAccess.FetchDataTable("E3_WesTempTest", new object[] { x1.ToSql() }); */ //dt1 = ThinkgateDataAccess.wesTest3(); } stopwatch.Stop(); sb.Append("X: " + dt1.Rows[1]["Value"].ToString() + "<br/>"); sb.Append("H: " + stopwatch.Elapsed + "<br/>"); resultDiv.InnerHtml = sb.ToString(); }