protected void ButtonApprove_Click(object sender, EventArgs e) { int count = 0; new Streamline.UserBusinessServices.MedicationLogin(); DataSet dsTemp = null; try { if (LabelErrorMessage.Text == "Your account is disabled.Please contact system administrator.") { Response.Redirect("MedicationLogin.aspx"); } if (HiddenFieldFirstChance.Value == "") { HiddenFieldFirstChance.Value = "0"; } if (HiddenFieldSecurityAnswer.Value.Trim().ToLower() == TextBoxAnswer.Text.Trim().ToLower()) { ImageError.Style.Add("display", "none"); ImageError.Style.Add("display", "none"); LabelErrorMessage.Style.Add("display", "none"); TextBoxAnswer.Focus(); LabelErrorMessage.Text = ""; objUserPreferences = new Streamline.UserBusinessServices.UserPrefernces(); count = objUserPreferences.ApprovePrescription(((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).UserId, ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).LastPrescriptionReviewTime, HiddenFieldRDLCurrentDateTime.Value); ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).LastPrescriptionReviewTime = HiddenFieldRDLCurrentDateTime.Value; ScriptManager.RegisterStartupScript(LabelErrorMessage, LabelErrorMessage.GetType(), ClientID.ToString(), "redirectToStartPage();", true); //return count; } else { HiddenFieldFirstChance.Value = Convert.ToString(Convert.ToInt32(HiddenFieldFirstChance.Value) + 1); if (Convert.ToInt32(HiddenFieldFirstChance.Value) >= 2) { if (HiddenFieldSecondChance.Value == "") { HiddenFieldSecondChance.Value = "0"; } HiddenFieldSecondChance.Value = Convert.ToString(Convert.ToInt32(HiddenFieldSecondChance.Value) + 1); if (HiddenFieldSecondChance.Value == "1") { dsTemp = (DataSet)Session["DataSetSecurityQustion"]; Random random = new Random(); if (dsTemp != null) { int num = random.Next(0, dsTemp.Tables[0].Rows.Count); if (dsTemp.Tables[0].Rows.Count > 0) { LabelSecurityQuestion.Text = dsTemp.Tables["StaffSecurityQuestion"].Rows[num]["CodeName"].ToString(); HiddenFieldSecurityAnswer.Value = dsTemp.Tables["StaffSecurityQuestion"].Rows[num]["SecurityAnswer"].ToString(); } } } if (Convert.ToInt32(HiddenFieldSecondChance.Value) > 2) { objMedicationLogin = new Streamline.UserBusinessServices.MedicationLogin(); objMedicationLogin.chkCountLogin(((StreamlineIdentity)(Context.User.Identity)).UserCode); ImageError.Style.Add("display", "block"); ImageError.Style.Add("display", "block"); LabelErrorMessage.Style.Add("display", "block"); TextBoxAnswer.Focus(); LabelErrorMessage.Text = "Your account is disabled.Please contact system administrator."; return; } } ImageError.Style.Add("display", "block"); ImageError.Style.Add("display", "block"); LabelErrorMessage.Style.Add("display", "block"); TextBoxAnswer.Focus(); LabelErrorMessage.Text = "The answers provided do not match the answers on record."; } } catch (Exception ex) { throw; } }
protected void ButtonLogon_Click(object sender, EventArgs e) { objMedicationLogin = new Streamline.UserBusinessServices.MedicationLogin(); //Optimization Added by Sony DataSet ds = null; DataSet userAuthenticationType = null; string authType = string.Empty; string enableADAuthentication = string.Empty; bool isValidUser = false; try { if (TextBoxUsername.Text.Trim() == string.Empty || TextBoxPassword.Text.Trim() == string.Empty) { this.LabelError.Text = "Please enter Username/Password"; return; } try { userAuthenticationType = objMedicationLogin.GetUserAuthenticationType(TextBoxUsername.Text.Trim()); if (userAuthenticationType.Tables["Authentication"].Rows.Count > 0) { authType = userAuthenticationType.Tables["Authentication"].Rows[0]["AuthenticationType"].ToString(); } if (userAuthenticationType.Tables["EnableActiveDirectory"] != null) { enableADAuthentication = userAuthenticationType.Tables["EnableActiveDirectory"].Rows[0]["EnableADAuthentication"].ToString(); } if (enableADAuthentication.ToUpperInvariant().Equals("Y") && authType.ToUpperInvariant().Equals("A")) { isValidUser = objMedicationLogin.ADAuthenticateUser(TextBoxUsername.Text.Trim(), TextBoxPassword.Text.Trim(), userAuthenticationType.Tables["Authentication"].Rows[0]["Domain"].ToString() ); if (isValidUser) { var secureADPassword = new SecureString(); ds = objMedicationLogin.GetAuthenticatedStaffInfo(Convert.ToInt32(userAuthenticationType.Tables["Authentication"].Rows[0]["StaffId"]), TextBoxUsername.Text.Trim()); TextBoxPassword.Text.ToCharArray().ToList().ForEach(secureADPassword.AppendChar); Session["ADPassword"] = secureADPassword; } } else { ds = objMedicationLogin.chkServerLogin(TextBoxUsername.Text.Trim(), TextBoxPassword.Text.Trim()); } if (HiddenFieldUseName.Value.Trim().ToLower() != TextBoxUsername.Text.Trim().ToLower()) { HiddenFieldLoginCount.Value = "0"; HiddenFieldUseName.Value = TextBoxUsername.Text; } HiddenFieldLoginCount.Value = Convert.ToString(Convert.ToInt32(HiddenFieldLoginCount.Value) + 1); hiddenOldPassword.Value = TextBoxPassword.Text.Trim(); } catch (Exception ex) { this.LabelError.Text = "Invalid Username/Password"; TextBoxPassword.Text = ""; throw ex; } //Added in ref to Task#2595 if (Convert.ToInt32(HiddenFieldLoginCount.Value) > 5) { objMedicationLogin.chkCountLogin(TextBoxUsername.Text.Trim()); this.LabelError.Text = "Your account is disabled.Please contact system administrator."; TextBoxPassword.Focus(); HiddenFieldLoginCount.Value = ""; return; } if (ds.Tables[0].Rows.Count <= 0) { this.LabelError.Text = "Invalid Username/Password"; TextBoxPassword.Text = ""; return; } //if (ds.Tables[0].Rows.Count > 0) // { // Response.Redirect("ValidatePage.aspx?ClientId=0&StaffId=" + ds.Tables[0].Rows[0]["StaffID"].ToString()); // } else { //Added by Loveena in ref to Task#3269-2.6 User Management: When Staff Created or Updated Set AccessSmartCare flag. if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0][0].ToString() == "Not an authorized user") { this.LabelError.Text = "Not an authorized user"; } else { int _logStatus = Convert.ToInt32((ds.Tables[0].Rows[0][5]).ToString()); // Password Expire Functionality if (_logStatus == 1 || _logStatus == 2) { ScriptManager.RegisterStartupScript(LabelError, LabelError.GetType(), "key", "javascript:OpenChangePassword('" + TextBoxPassword.Text + "','" + TextBoxUsername.Text + "');", true); if (hiddenCancelled.Value == "0") { ScriptManager.RegisterClientScriptBlock(LabelError, LabelError.GetType(), "key", "javascript:alert('Password changed successfully')", true); TextBoxPassword.Text = hiddenOldPassword.Value; } if (hiddenCancelled.Value == "1") { ScriptManager.RegisterClientScriptBlock(LabelError, LabelError.GetType(), "key", "alert('Password changed failed')", true); return; } } else { //Added in ref to Task#2595 //Comented by Pradeep for testing needs to be uncoment later //if (ds.Tables[0].Rows[0]["QuestionsAnswered"] != System.DBNull.Value) // { // this.LabelError.Text = ds.Tables[0].Rows[0]["QuestionsAnswered"].ToString(); // TextBoxPassword.Focus(); // } //else // { //Commented in ref to Task#2700 Response.Redirect("ValidatePage.aspx?ClientId=0&StaffId=" + ds.Tables[0].Rows[0]["StaffID"].ToString(), false); //} //Added in ref to Task#2595 //if (ds.Tables[0].Rows[0]["QuestionsAnswered"] != System.DBNull.Value) //{ // //Modified by Loveena in ref to Task#2700 // //this.LabelError.Text = ds.Tables[0].Rows[0]["QuestionsAnswered"].ToString(); // //TextBoxPassword.Focus(); // Response.Redirect("ValidatePage.aspx?ClientId=0&StaffId=" + ds.Tables[0].Rows[0]["StaffID"].ToString() + "&QuestionsAnswered=" + ds.Tables[0].Rows[0]["QuestionsAnswered"].ToString()); //} //else //{ // Response.Redirect("ValidatePage.aspx?ClientId=0&StaffId=" + ds.Tables[0].Rows[0]["StaffID"].ToString() + "&QuestionsAnswered="); //} } } } } } catch (Exception ex) { if (ex.Data["CustomExceptionInformation"] == null) { ex.Data["CustomExceptionInformation"] = "###Source Function Name - MedicationLogin--Page_Load(), ParameterCount -0 ###"; } else { ex.Data["CustomExceptionInformation"] = ""; } if (ex.Data["DatasetInfo"] == null) { ex.Data["DatasetInfo"] = null; } Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this); } }