Beispiel #1
0
        /// <summary>
        /// Handles the Click event of the btnEnter control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks></remarks>
        protected void btnEnter_Click(object sender, EventArgs e)
        {
            if (IsValidInfo())
            {
                ////start building recaptch api call
                //var sb = new StringBuilder();
                //sb.Append("https://www.google.com/recaptcha/api/siteverify?secret=");

                ////our secret key
                //var secretKey = "6LfCPbsUAAAAALvGNtSqXRZwX1dp0xUZhd0AIbUT";
                //sb.Append(secretKey);

                ////response from recaptch control
                //sb.Append("&");
                //sb.Append("response=");
                //var reCaptchaResponse = Request["g-recaptcha-response"];
                //sb.Append(reCaptchaResponse);

                ////client ip address
                ////---- This Ip address part is optional. If you donot want to send IP address you can
                ////---- Skip(Remove below 4 lines)
                //sb.Append("&");
                //sb.Append("remoteip=");
                ////var clientIpAddress = GetUserIp();
                ////sb.Append(clientIpAddress);

                ////make the api call and determine validity
                //using (var client = new WebClient())
                //{
                //    var uri = sb.ToString();
                //    var json = client.DownloadString(uri);
                //    var serializer = new DataContractJsonSerializer(typeof(RecaptchaApiResponse));
                //    var ms = new MemoryStream(Encoding.Unicode.GetBytes(json));
                //    var result = serializer.ReadObject(ms) as RecaptchaApiResponse;


                //    //--- Check if we are able to call api or not.
                //    if (result == null)
                //    {
                //        lblMessage.Text = "Captcha was unable to make the api call";
                //    }
                //    else // If Yes
                //    {
                //        //api call contains errors
                //        if (result.ErrorCodes != null)
                //        {
                //            if (result.ErrorCodes.Count > 0)
                //            {
                //                foreach (var error in result.ErrorCodes)
                //                {
                //                    lblMessage.Text = "reCAPTCHA Error: " + error;
                //                }
                //            }
                //        }
                //        else //api does not contain errors
                //        {
                //            if (!result.Success) //captcha was unsuccessful for some reason
                //            {
                //                lblMessage.Text = "Captcha did not pass, please try again.";
                //            }
                //            else //---- If successfully verified. Do your rest of logic.
                //            {
                //                lblMessage.Text = "Captcha cleared ";
                //            }
                //        }

                //    }

                //}



                Session["CardHolderId"] = "";
                lblMessage.Text         = "";
                DivMessage.Attributes.CssStyle.Add("display", "none");
                //viewUserLoginError.Text = "";
                bool              ChkActiveUser = false;
                bool              UserStatus    = false;
                DateTime          InvalidLoginDate;
                DateTime          TodayDate;
                TimeSpan          Diffrence;
                int               DurationforActive = 24;
                CardHolderManager am          = new CardHolderManager();
                CardManager       cardManager = new CardManager();
                string            PublicIP    = Request.UserHostAddress;

                if (!cardManager.CheckOracleConnection())
                {
                    LblErrorMessage.Text = Constants.DbConnectionNotAvailable;
                    DivERROR.Attributes.CssStyle.Add("display", "block");
                    return;
                }

                //commented by abhijeet on 23/01/2019
                //CardHolder_MstDTO user = am.FindUser(txtCheckUsername.Text.Trim(), PublicIP);
                CardHolder_MstDTO user = am.FindActiveUser(txtCheckUsername.Text.Trim());
                if (user != null)
                {
                    UserStatus = cardManager.AuthenticateUserStatus(user.creditcard_acc_number.Decrypt());

                    if (UserStatus == true)
                    {
                        InvalidLoginDate = Convert.ToDateTime(user.InvalidLastLoginDt);
                        TodayDate        = System.DateTime.Now;
                        Diffrence        = TodayDate - InvalidLoginDate;

                        int      pendingtime = 24 - Convert.ToInt32(Diffrence.TotalHours);
                        string[] parts       = Convert.ToString(pendingtime).Split('.');
                        DurationforActive = int.Parse(parts[0]);

                        if (Diffrence.TotalHours >= 24)
                        {
                            ChkActiveUser = am.SetCardHolderActive(user.CardHolder_Id);
                        }

                        if (ChkActiveUser == true)
                        {
                            if (user.IsPermanentDisable == true)
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "showalert",
                                                                    "alert('" + Constants.BlockedAccount + "');", true);
                                ClearControls();
                            }
                            else
                            {
                                //mvCheckUser.ActiveViewIndex = 1;
                                //lblPersonalMessage.Text = user.Personal_Msg;
                                //txtUsername.Text = user.User_nm;
                                Session["CardHolderId"] = user.CardHolder_Id;
                                txtCheckUsername.Text   = "";
                                txtCaptchaFirst.Text    = "";
                                Response.Redirect("~/LoginNext.aspx");  //Redirect to next login here
                            }
                        }

                        else
                        {
                            if (user.IsPermanentDisable == true && user.IsActive == false)
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "showalert",
                                                                    "alert('" + Constants.BlockedAccount + "');", true);
                                ClearControls();
                            }
                            else if (user.IsPermanentDisable == true)
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "showalert",
                                                                    "alert('" + Constants.BlockedAccount + "');", true);
                                ClearControls();
                            }
                            else if (user.IsActive == false)
                            {
                                if (DurationforActive == 0)
                                {
                                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert",
                                                                        "alert('" + Constants.InactiveAccountAfter +
                                                                        "sometime');", true);
                                }
                                else
                                {
                                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert",
                                                                        "alert('" + Constants.InactiveAccountAfter +
                                                                        DurationforActive + "hrs');", true);
                                }
                                ClearControls();
                            }
                            else
                            {
                                //mvCheckUser.ActiveViewIndex = 1;
                                //lblPersonalMessage.Text = user.Personal_Msg;
                                //txtUsername.Text = user.User_nm;
                                //Session["CardHolderId"] = user.CardHolder_Id;
                                //txtUsername.Attributes.Add("readonly", "readonly");

                                Session["CardHolderId"] = user.CardHolder_Id;
                                txtCheckUsername.Text   = "";
                                txtCaptchaFirst.Text    = "";
                                Response.Redirect("~/LoginNext.aspx");

                                //Page.ClientScript.RegisterStartupScript(this.GetType(), "VKeyboard", "init()", true);
                            }
                        }
                        // CreateRequest();
                    }
                    else
                    {
                        lblMessage.Text = Constants.AccNotInNormalState;
                        DivMessage.Attributes.CssStyle.Add("display", "block");
                    }
                }
                else
                {
                    lblMessage.Text = Constants.UnameNtExist;
                    DivMessage.Attributes.CssStyle.Add("display", "block");
                }
            }
        }