示例#1
0
    /// <summary>
    /// Sets base data after user's credential process is done successfully.
    /// </summary>
    private void SetBaseData(ref Lapbase.Business.Login objLogin)
    {
        base.UserPracticeCode = objLogin.UserPracticeCode; // gClass.User_SNo;
        base.Imperial         = objLogin.Imperial;         // gClass.SD_Imperial;
        base.VisitWeeks       = objLogin.VisitWeeks;       // gClass.VisitWeeksFlag;
        base.OrganizationCode = objLogin.OrganizationCode; //Int32.TryParse(gClass.OrganizationCode, out intTemp) ? intTemp : 0;
        base.Direction        = objLogin.PageDirection;
        base.SuperBill        = objLogin.SuperBill;
        base.EMR              = objLogin.EMR;
        base.Export           = objLogin.Export;
        base.BSRExport        = objLogin.BSRExport;
        base.PermissionLevel  = objLogin.PermissionLevel;
        base.SurgeonID        = objLogin.SurgeonID;
        base.DataClamp        = objLogin.DataClamp;
        base.PracticeBoldCode = objLogin.PracticeBoldCode;
        System.Configuration.ConfigurationManager.AppSettings["PracticeCEOCode"] = objLogin.PracticeBoldCode;
        //base.DefaultSort = objLogin.DefaultSort;

        SaveUserApplicationData();

        Response.SetCookie(new HttpCookie("UserPracticeCode", objLogin.UserPracticeCode.ToString()));
        //Response.SetCookie(new HttpCookie("Group_Code", gClass.Group_Code.ToString()));
        Response.SetCookie(new HttpCookie("Logon_UserName", objLogin.UserFullName));
        Response.SetCookie(new HttpCookie("Imperial", objLogin.Imperial.ToString()));
        Response.SetCookie(new HttpCookie("VisitWeeksFlag", objLogin.VisitWeeks.ToString()));
        Response.SetCookie(new HttpCookie("OrganizationCode", "263" + objLogin.OrganizationCode.ToString() + "865"));
        Response.SetCookie(new HttpCookie("SubmitData", objLogin.SubmitData.ToString()));
        Response.SetCookie(new HttpCookie("AutoSave", objLogin.AutoSave.ToString()));
        Response.SetCookie(new HttpCookie("Feature", objLogin.ShowLog.ToString() + "**" + objLogin.ShowRegistry.ToString() + "**" + objLogin.ShowDownloadExcelGraph.ToString() + "**" + objLogin.Export.ToString() + "**" + objLogin.BSRExport.ToString() + "**"));
        Response.SetCookie(new HttpCookie("SuperBill", objLogin.SuperBill.ToString()));
        Response.SetCookie(new HttpCookie("EMR", objLogin.EMR.ToString()));
        Response.SetCookie(new HttpCookie("PermissionLevel", objLogin.PermissionLevel.ToString().ToLower()));
        Response.SetCookie(new HttpCookie("SurgeonID", objLogin.SurgeonID.ToString()));
        Response.SetCookie(new HttpCookie("DataClamp", objLogin.DataClamp.ToString()));
        //Response.SetCookie(new HttpCookie("DefaultSort", objLogin.DefaultSort.ToString().ToLower()));
        //Response.SetCookie(new HttpCookie("PracticeBoldCode", objLogin.PracticeBoldCode.ToString()));

        //HttpCookie aCookie = Request.Cookies["DefaultSort"];
        //aCookie.Expires = DateTime.Now.AddDays(-1);
        //Response.Cookies.Add(aCookie);
    }
示例#2
0
    /*
     * this function is an asp.net ajax function and called when user clicks the LOGIN button,
     * this function checks
     * 1) user credential data (user name and password)
     * 2) if the user is a permitted user for the current organization, checks that this is the first login of the user or not,
     * 3) if this is the first login, the application asks user to confirm and change his/her password (by loading new page and changing the title of button to update login
     * 4) if user is not a valid user, the proper message is loaded
     * 5) if user enters wrong credential for 5 times, his/her account is suspented
     * 6) if user is a valid user of the current organization, the application browses the patient lists page (this task is done at the client-side "login.js"
     */
    /** /
     * protected void btnLogonServer_OnClick(object sender, EventArgs e)
     * {
     *  string strScript = String.Empty, strReturn = String.Empty;
     *
     *  SetLanguageInfo(lblCultureInfo.Text);
     *  if (btnLogonServer.Text.ToUpper().Equals("LOGIN"))
     *  {
     *      try
     *      {
     *          if (CheckUserData(ref strReturn))
     *          {
     *              if (IsNewUser())
     *              {
     *                  DivErrorMessageScriptBuilder(ref strScript, "none", "");
     *                  strScript += "document.getElementById('divLogin').style.display = 'none';";
     *                  strScript += "document.getElementById('divChangePassword').style.display = 'block';";
     *                  btnLogonServer.Text = "Update password";
     *              }
     *              else if (gClass.ValidDays <= Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ValidDays"]))
     *              {
     *                  DivErrorMessageScriptBuilder(ref strScript, "none", "");
     *                  strScript += "document.location.assign('Forms/PatientsVisits/PatientsVisitsForm.aspx');";
     *              }
     *              else
     *              {
     *                  DivErrorMessageScriptBuilder(ref strScript, "block", "Your password has expired after 90, please enter a new one...");
     *                  strScript += "document.getElementById('divLogin').style.display = 'none';";
     *                  strScript += "document.getElementById('divChangePassword').style.display = 'block';";
     *                  btnLogonServer.Text = "Update password";
     *              }
     *          }
     *          else
     *          {
     *              DivErrorMessageScriptBuilder(ref strScript, "block", strReturn);
     *              ControlUnsucessfulLogin();
     *          }
     *      }
     *      catch (Exception err)
     *      {
     *          DivErrorMessageScriptBuilder(ref strScript, "block", "Sorry, please contact System Administrator...");
     *          gClass.AddErrorLogData(String.Empty, Request.Url.Host, String.Empty, "Login Form", "btnLogonServer_OnClick function", err.ToString());
     *      }
     *  }
     *  else // Update Password
     *  {
     *      Boolean flag = (txtNewUserPW.Text.Trim().Length == 0) || (txtNewUserPW_Confirm.Text.Trim().Length == 0);
     *
     *      if (flag)
     *          DivErrorMessageScriptBuilder(ref strScript, "block", "Please enter new password fields...");
     *      else if (!txtNewUserPW.Text.Trim().Equals(txtNewUserPW_Confirm.Text.Trim()))
     *          DivErrorMessageScriptBuilder(ref strScript, "block", "The password was not correctly confirmed. Please ensure that the password and confirmation match exactly....");
     *      else
     *          try
     *          {
     *              if (!CheckLast5Password())
     *              {
     *                  UpdatePasswordHistory();
     *                  DivErrorMessageScriptBuilder(ref strScript, "none", "");
     *                  strScript += "document.location.assign('Forms/PatientsVisits/PatientsVisitsForm.aspx');";
     *              }
     *              else
     *                  DivErrorMessageScriptBuilder(ref strScript, "block", "The new password is duplicate with your 5 previous passwords...");
     *          }
     *          catch (Exception err)
     *          {
     *              DivErrorMessageScriptBuilder(ref strScript, "block", "Error in updating new password, please contact System Administrator...");
     *              gClass.AddErrorLogData(String.Empty, Request.Url.Host, String.Empty, "Login Form", "Update new password function", err.ToString());
     *          }
     *  }
     *  ScriptManager.RegisterStartupScript(btnLogonServer, btnLogonServer.GetType(), "key", strScript, true);
     * }
     * /**/
    #endregion

    protected void btnLogonServer_OnClick(object sender, EventArgs e)
    {
        string strScript = String.Empty, strReturn = String.Empty;

        Lapbase.Business.Login objLogin = new Lapbase.Business.Login();
        objLogin.UserID           = txtUserID.Text;
        objLogin.Password         = this.UserPassword;
        objLogin.OrganizationName = base.DomainURL;
        objLogin.LoginPage        = true;

        SetLanguageInfo(lblCultureInfo.Text);
        if (objLogin.CheckUserCredential())
        {
            if (btnLogonServer.Text.ToUpper().Equals("LOGIN"))
            {
                this.UserPassword = txtUserPW.Text;
                strReturn         = objLogin.MessageContent;
                SetBaseData(ref objLogin);
                if (objLogin.NewUser)
                {
                    DivErrorMessageScriptBuilder(ref strScript, "none", "");
                    strScript          += "document.getElementById('divLogin').style.display = 'none';";
                    strScript          += "document.getElementById('divChangePassword').style.display = 'block';";
                    btnLogonServer.Text = "Update password";
                }
                else if (objLogin.ValidDays <= Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ValidDays"]))
                {
                    DivErrorMessageScriptBuilder(ref strScript, "none", "");
                    strScript += "document.location.assign('Forms/PatientsVisits/PatientsVisitsForm.aspx');";
                }
                else
                {
                    DivErrorMessageScriptBuilder(ref strScript, "block", "Your password has expired after 90, please enter a new one...");
                    strScript          += "document.getElementById('divLogin').style.display = 'none';";
                    strScript          += "document.getElementById('divChangePassword').style.display = 'block';";
                    btnLogonServer.Text = "Update password";
                }
            }
            else
            {
                Boolean flag = (txtNewUserPW.Text.Trim().Length == 0) || (txtNewUserPW_Confirm.Text.Trim().Length == 0);

                if (flag)
                {
                    DivErrorMessageScriptBuilder(ref strScript, "block", "Please enter new password fields...");
                }
                else if (!txtNewUserPW.Text.Trim().Equals(txtNewUserPW_Confirm.Text.Trim()))
                {
                    DivErrorMessageScriptBuilder(ref strScript, "block", "The password was not correctly confirmed. Please ensure that the password and confirmation match exactly....");
                }
                else
                {
                    try
                    {
                        if (!objLogin.CheckUserPasswordHistory(txtNewUserPW.Text.Trim()))
                        {
                            objLogin.UpdatePasswordHistory(txtNewUserPW.Text.Trim());
                            DivErrorMessageScriptBuilder(ref strScript, "none", "");
                            strScript += "document.location.assign('Forms/PatientsVisits/PatientsVisitsForm.aspx');";
                        }
                        else
                        {
                            DivErrorMessageScriptBuilder(ref strScript, "block", "The new password is duplicate with your 5 previous passwords...");
                        }
                    }
                    catch (Exception err)
                    {
                        DivErrorMessageScriptBuilder(ref strScript, "block", "Error in updating new password, please contact System Administrator...");
                        gClass.AddErrorLogData(String.Empty, Request.Url.Host, String.Empty, "Login Form", "Update new password function", err.ToString());
                    }
                }
            }
        }
        else
        {
            strReturn = objLogin.MessageContent;
            DivErrorMessageScriptBuilder(ref strScript, "block", strReturn);
            ControlUnsucessfulLogin();
        }

        /** /
         * if (btnLogonServer.Text.ToUpper().Equals("LOGIN"))
         * {
         *  try
         *  {
         *      if (objLogin.CheckUserCredential( ))
         *      {
         *          this.UserPassword = txtUserPW.Text;
         *          strReturn = objLogin.MessageContent;
         *          SetBaseData(ref objLogin);
         *          if (objLogin.NewUser)
         *          {
         *              DivErrorMessageScriptBuilder(ref strScript, "none", "");
         *              strScript += "document.getElementById('divLogin').style.display = 'none';";
         *              strScript += "document.getElementById('divChangePassword').style.display = 'block';";
         *              btnLogonServer.Text = "Update password";
         *          }
         *          else if (objLogin.ValidDays <= Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ValidDays"]))
         *          {
         *              DivErrorMessageScriptBuilder(ref strScript, "none", "");
         *              strScript += "document.location.assign('Forms/PatientsVisits/PatientsVisitsForm.aspx');";
         *          }
         *          else
         *          {
         *              DivErrorMessageScriptBuilder(ref strScript, "block", "Your password has expired after 90, please enter a new one...");
         *              strScript += "document.getElementById('divLogin').style.display = 'none';";
         *              strScript += "document.getElementById('divChangePassword').style.display = 'block';";
         *              btnLogonServer.Text = "Update password";
         *          }
         *      }
         *      else
         *      {
         *          strReturn = objLogin.MessageContent;
         *          DivErrorMessageScriptBuilder(ref strScript, "block", strReturn);
         *          ControlUnsucessfulLogin();
         *      }
         *  }
         *  catch (Exception err)
         *  {
         *      DivErrorMessageScriptBuilder(ref strScript, "block", "Sorry, please contact System Administrator...");
         *      gClass.AddErrorLogData(String.Empty, Request.Url.Host, String.Empty, "Login Form", "btnLogonServer_OnClick function", err.ToString());
         *  }
         * }
         * else // Update Password
         * {
         *  Boolean flag = (txtNewUserPW.Text.Trim().Length == 0) || (txtNewUserPW_Confirm.Text.Trim().Length == 0);
         *
         *  if (flag)
         *      DivErrorMessageScriptBuilder(ref strScript, "block", "Please enter new password fields...");
         *  else if (!txtNewUserPW.Text.Trim().Equals(txtNewUserPW_Confirm.Text.Trim()))
         *      DivErrorMessageScriptBuilder(ref strScript, "block", "The password was not correctly confirmed. Please ensure that the password and confirmation match exactly....");
         *  else
         *      try
         *      {
         *          if (!objLogin.CheckUserPasswordHistory(txtNewUserPW.Text.Trim()))
         *          {
         *              objLogin.UpdatePasswordHistory();
         *              DivErrorMessageScriptBuilder(ref strScript, "none", "");
         *              strScript += "document.location.assign('Forms/PatientsVisits/PatientsVisitsForm.aspx');";
         *          }
         *          else
         *              DivErrorMessageScriptBuilder(ref strScript, "block", "The new password is duplicate with your 5 previous passwords...");
         *      }
         *      catch (Exception err)
         *      {
         *          DivErrorMessageScriptBuilder(ref strScript, "block", "Error in updating new password, please contant System Administrator...");
         *          gClass.AddErrorLogData(String.Empty, Request.Url.Host, String.Empty, "Login Form", "Update new password function", err.ToString());
         *      }
         * }
         * /**/
        ScriptManager.RegisterStartupScript(btnLogonServer, btnLogonServer.GetType(), "key", strScript, true);
    }